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 :
25 m : namespace block_graph {
26 :
27 : // Ensure there are no padding bytes because these structs are going to be
28 : // written to the .syzyhp stream directly.
29 : #pragma pack(push, 1)
30 :
31 : // This data structure describes a single Block in the HotPatchingMetadata.
32 m : struct HotPatchingBlockMetadata {
33 : // The RVA of the start of the block.
34 m : uint32_t relative_address;
35 :
36 : // The size of the code in the block data.
37 m : uint16_t code_size;
38 :
39 : // The size of the block data.
40 m : uint16_t block_size;
41 m : };
42 :
43 : // This struct contains the data that will be injected into images transformed
44 : // by hot patching transformations, it contains the necessary metadata that is
45 : // required to perform the hot patching of blocks at runtime.
46 m : struct HotPatchingMetadataHeader {
47 : // Version information.
48 m : uint32_t version;
49 :
50 : // Number of HotPatchingBlockMetadata structures to follow.
51 m : uint32_t number_of_blocks;
52 m : };
53 :
54 : #pragma pack(pop)
55 :
56 : // The current version of the HotPatchingMetadata structure. This needs to
57 : // be incremented if any time a non-backwards compatible change is made to the
58 : // serialization format.
59 m : const uint32_t kHotPatchingMetadataVersion = 1U;
60 :
61 m : } // namespace block_graph
62 :
63 : #endif // SYZYGY_BLOCK_GRAPH_HOT_PATCHING_METADATA_H_
|