Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(139)

Side by Side Diff: courgette/types_win_pe.h

Issue 8166013: Further refactoring, move ImageInfo into Disassembler/DisassemblerWin32X86. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « courgette/image_info_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef TYPES_WIN_PE_H_
6 #define TYPES_WIN_PE_H_
7
8 #include "base/basictypes.h"
9
10
11 namespace courgette {
12
13 // A Relative Virtual Address is the address in the image file after it is
14 // loaded into memory relative to the image load address.
15 typedef uint32 RVA;
sra1 2011/10/14 23:05:59 This is also typedef-ed in disassembler.h
dgarrett 2011/10/25 23:15:17 Done.
16
17 // PE file section header. This struct has the same layout as the
18 // IMAGE_SECTION_HEADER structure from WINNT.H
19 // http://msdn.microsoft.com/en-us/library/ms680341(VS.85).aspx
20 //
21 #pragma pack(push, 1) // Supported by MSVC and GCC. Ensures no gaps in packing.
22 struct Section {
23 char name[8];
24 uint32 virtual_size;
25 uint32 virtual_address;
26 uint32 size_of_raw_data;
27 uint32 file_offset_of_raw_data;
28 uint32 pointer_to_relocations; // Always zero in an image.
29 uint32 pointer_to_line_numbers; // Always zero in an image.
30 uint16 number_of_relocations; // Always zero in an image.
31 uint16 number_of_line_numbers; // Always zero in an image.
32 uint32 characteristics;
33 };
34 #pragma pack(pop)
35
36 COMPILE_ASSERT(sizeof(Section) == 40, section_is_40_bytes);
37
38 // ImageDataDirectory has same layout as IMAGE_DATA_DIRECTORY structure from
39 // WINNT.H
40 // http://msdn.microsoft.com/en-us/library/ms680305(VS.85).aspx
41 //
42 class ImageDataDirectory {
43 public:
44 ImageDataDirectory() : address_(0), size_(0) {}
45 RVA address_;
46 uint32 size_;
47 };
48
49 COMPILE_ASSERT(sizeof(ImageDataDirectory) == 8,
50 image_data_directory_is_8_bytes);
51
52
53 ////////////////////////////////////////////////////////////////////////////////
54
55 // Constants and offsets gleaned from WINNT.H and various articles on the
56 // format of Windows PE executables.
57
58 // This is FIELD_OFFSET(IMAGE_DOS_HEADER, e_lfanew):
59 const size_t kOffsetOfFileAddressOfNewExeHeader = 0x3c;
60
61 const uint16 kImageNtOptionalHdr32Magic = 0x10b;
62 const uint16 kImageNtOptionalHdr64Magic = 0x20b;
63
64 const size_t kSizeOfCoffHeader = 20;
65 const size_t kOffsetOfDataDirectoryFromImageOptionalHeader32 = 96;
66 const size_t kOffsetOfDataDirectoryFromImageOptionalHeader64 = 112;
67
68 } // namespace
69 #endif // TYPES_WIN_PE_H_
OLDNEW
« no previous file with comments | « courgette/image_info_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698