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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « courgette/image_info_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: courgette/types_win_pe.h
diff --git a/courgette/types_win_pe.h b/courgette/types_win_pe.h
new file mode 100644
index 0000000000000000000000000000000000000000..234b79971abbb2a8b1dbf05ea343b02ace54abd7
--- /dev/null
+++ b/courgette/types_win_pe.h
@@ -0,0 +1,69 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef TYPES_WIN_PE_H_
+#define TYPES_WIN_PE_H_
+
+#include "base/basictypes.h"
+
+
+namespace courgette {
+
+// A Relative Virtual Address is the address in the image file after it is
+// loaded into memory relative to the image load address.
+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.
+
+// PE file section header. This struct has the same layout as the
+// IMAGE_SECTION_HEADER structure from WINNT.H
+// http://msdn.microsoft.com/en-us/library/ms680341(VS.85).aspx
+//
+#pragma pack(push, 1) // Supported by MSVC and GCC. Ensures no gaps in packing.
+struct Section {
+ char name[8];
+ uint32 virtual_size;
+ uint32 virtual_address;
+ uint32 size_of_raw_data;
+ uint32 file_offset_of_raw_data;
+ uint32 pointer_to_relocations; // Always zero in an image.
+ uint32 pointer_to_line_numbers; // Always zero in an image.
+ uint16 number_of_relocations; // Always zero in an image.
+ uint16 number_of_line_numbers; // Always zero in an image.
+ uint32 characteristics;
+};
+#pragma pack(pop)
+
+COMPILE_ASSERT(sizeof(Section) == 40, section_is_40_bytes);
+
+// ImageDataDirectory has same layout as IMAGE_DATA_DIRECTORY structure from
+// WINNT.H
+// http://msdn.microsoft.com/en-us/library/ms680305(VS.85).aspx
+//
+class ImageDataDirectory {
+ public:
+ ImageDataDirectory() : address_(0), size_(0) {}
+ RVA address_;
+ uint32 size_;
+};
+
+COMPILE_ASSERT(sizeof(ImageDataDirectory) == 8,
+ image_data_directory_is_8_bytes);
+
+
+////////////////////////////////////////////////////////////////////////////////
+
+// Constants and offsets gleaned from WINNT.H and various articles on the
+// format of Windows PE executables.
+
+// This is FIELD_OFFSET(IMAGE_DOS_HEADER, e_lfanew):
+const size_t kOffsetOfFileAddressOfNewExeHeader = 0x3c;
+
+const uint16 kImageNtOptionalHdr32Magic = 0x10b;
+const uint16 kImageNtOptionalHdr64Magic = 0x20b;
+
+const size_t kSizeOfCoffHeader = 20;
+const size_t kOffsetOfDataDirectoryFromImageOptionalHeader32 = 96;
+const size_t kOffsetOfDataDirectoryFromImageOptionalHeader64 = 112;
+
+} // namespace
+#endif // TYPES_WIN_PE_H_
« 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