1 : // Copyright 2015 Google Inc. All Rights Reserved.
2 : //
3 : // Licensed under the Apache License, Version 2.0 (the "License");
4 : // you may not use this file except in compliance with the License.
5 : // You may obtain a copy of the License at
6 : //
7 : // http://www.apache.org/licenses/LICENSE-2.0
8 : //
9 : // Unless required by applicable law or agreed to in writing, software
10 : // distributed under the License is distributed on an "AS IS" BASIS,
11 : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 : // See the License for the specific language governing permissions and
13 : // limitations under the License.
14 : //
15 : // Declares the data structures that will be injected into images transformed
16 : // by hot patching transformations. These data structures contain the necessary
17 : // metadata that is required to perform the hot patching of blocks at runtime.
18 :
19 : #ifndef SYZYGY_BLOCK_GRAPH_HOT_PATCHING_METADATA_H_
20 : #define SYZYGY_BLOCK_GRAPH_HOT_PATCHING_METADATA_H_
21 :
22 : #include <vector>
23 :
24 : #include "base/basictypes.h"
25 :
26 m : namespace block_graph {
27 :
28 : // Ensure there are no padding bytes because these structs are going to be
29 : // written to the .syzyhp stream directly.
30 : #pragma pack(push, 1)
31 :
32 : // This data structure describes a single Block in the HotPatchingMetadata.
33 m : struct HotPatchingBlockMetadata {
34 : // The RVA of the start of the block.
35 m : uint32 relative_address;
36 :
37 : // The size of the code in the block data.
38 m : uint16 code_size;
39 :
40 : // The size of the block data.
41 m : uint16 block_size;
42 m : };
43 :
44 : // This struct contains the data that will be injected into images transformed
45 : // by hot patching transformations, it contains the necessary metadata that is
46 : // required to perform the hot patching of blocks at runtime.
47 m : struct HotPatchingMetadataHeader {
48 : // Version information.
49 m : uint32 version;
50 :
51 : // Number of HotPatchingBlockMetadata structures to follow.
52 m : uint32 number_of_blocks;
53 m : };
54 :
55 : #pragma pack(pop)
56 :
57 : // The current version of the HotPatchingMetadata structure. This needs to
58 : // be incremented if any time a non-backwards compatible change is made to the
59 : // serialization format.
60 m : const uint32 kHotPatchingMetadataVersion = 1U;
61 :
62 m : } // namespace block_graph
63 :
64 : #endif // SYZYGY_BLOCK_GRAPH_HOT_PATCHING_METADATA_H_
|