Chromium Code Reviews

Side by Side Diff: base/win/pe_image.h

Issue 664803003: Update from chromium a8e7c94b1b79a0948d05a1fcfff53391d22ce37a (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« no previous file with comments | « base/process/kill_posix.cc ('k') | build/android/buildbot/OWNERS » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This file was adapted from GreenBorder's Code. 5 // This file was adapted from GreenBorder's Code.
6 // To understand what this class is about (for other than well known functions 6 // To understand what this class is about (for other than well known functions
7 // as GetProcAddress), a good starting point is "An In-Depth Look into the 7 // as GetProcAddress), a good starting point is "An In-Depth Look into the
8 // Win32 Portable Executable File Format" by Matt Pietrek: 8 // Win32 Portable Executable File Format" by Matt Pietrek:
9 // http://msdn.microsoft.com/msdnmag/issues/02/02/PE/default.aspx 9 // http://msdn.microsoft.com/msdnmag/issues/02/02/PE/default.aspx
10 10
11 #ifndef BASE_WIN_PE_IMAGE_H_ 11 #ifndef BASE_WIN_PE_IMAGE_H_
12 #define BASE_WIN_PE_IMAGE_H_ 12 #define BASE_WIN_PE_IMAGE_H_
13 13
14 #include <windows.h> 14 #include <windows.h>
15 15
16 #if defined(_WIN32_WINNT_WIN8) 16 #if defined(_WIN32_WINNT_WIN8)
17 // The Windows 8 SDK defines FACILITY_VISUALCPP in winerror.h. 17 // The Windows 8 SDK defines FACILITY_VISUALCPP in winerror.h.
18 #undef FACILITY_VISUALCPP 18 #undef FACILITY_VISUALCPP
19 #endif 19 #endif
20 #include <DelayIMP.h> 20 #include <DelayIMP.h>
21 21
22 namespace base { 22 namespace base {
23 namespace win { 23 namespace win {
24 24
25 // This class is a wrapper for the Portable Executable File Format (PE). 25 // This class is a wrapper for the Portable Executable File Format (PE).
26 // It's main purpose is to provide an easy way to work with imports and exports 26 // Its main purpose is to provide an easy way to work with imports and exports
27 // from a file, mapped in memory as image. 27 // from a file, mapped in memory as image.
28 class PEImage { 28 class PEImage {
29 public: 29 public:
30 // Callback to enumerate sections. 30 // Callback to enumerate sections.
31 // cookie is the value passed to the enumerate method. 31 // cookie is the value passed to the enumerate method.
32 // Returns true to continue the enumeration. 32 // Returns true to continue the enumeration.
33 typedef bool (*EnumSectionsFunction)(const PEImage &image, 33 typedef bool (*EnumSectionsFunction)(const PEImage &image,
34 PIMAGE_SECTION_HEADER header, 34 PIMAGE_SECTION_HEADER header,
35 PVOID section_start, DWORD section_size, 35 PVOID section_start, DWORD section_size,
36 PVOID cookie); 36 PVOID cookie);
(...skipping 40 matching lines...)
77 // cookie is the value passed to the enumerate method. 77 // cookie is the value passed to the enumerate method.
78 // Returns true to continue the enumeration. 78 // Returns true to continue the enumeration.
79 typedef bool (*EnumRelocsFunction)(const PEImage &image, WORD type, 79 typedef bool (*EnumRelocsFunction)(const PEImage &image, WORD type,
80 PVOID address, PVOID cookie); 80 PVOID address, PVOID cookie);
81 81
82 explicit PEImage(HMODULE module) : module_(module) {} 82 explicit PEImage(HMODULE module) : module_(module) {}
83 explicit PEImage(const void* module) { 83 explicit PEImage(const void* module) {
84 module_ = reinterpret_cast<HMODULE>(const_cast<void*>(module)); 84 module_ = reinterpret_cast<HMODULE>(const_cast<void*>(module));
85 } 85 }
86 86
87 virtual ~PEImage() {}
88
87 // Gets the HMODULE for this object. 89 // Gets the HMODULE for this object.
88 HMODULE module() const; 90 HMODULE module() const;
89 91
90 // Sets this object's HMODULE. 92 // Sets this object's HMODULE.
91 void set_module(HMODULE module); 93 void set_module(HMODULE module);
92 94
93 // Checks if this symbol is actually an ordinal. 95 // Checks if this symbol is actually an ordinal.
94 static bool IsOrdinal(LPCSTR name); 96 static bool IsOrdinal(LPCSTR name);
95 97
96 // Converts a named symbol to the corresponding ordinal. 98 // Converts a named symbol to the corresponding ordinal.
(...skipping 162 matching lines...)
259 261
260 inline PIMAGE_EXPORT_DIRECTORY PEImage::GetExportDirectory() const { 262 inline PIMAGE_EXPORT_DIRECTORY PEImage::GetExportDirectory() const {
261 return reinterpret_cast<PIMAGE_EXPORT_DIRECTORY>( 263 return reinterpret_cast<PIMAGE_EXPORT_DIRECTORY>(
262 GetImageDirectoryEntryAddr(IMAGE_DIRECTORY_ENTRY_EXPORT)); 264 GetImageDirectoryEntryAddr(IMAGE_DIRECTORY_ENTRY_EXPORT));
263 } 265 }
264 266
265 } // namespace win 267 } // namespace win
266 } // namespace base 268 } // namespace base
267 269
268 #endif // BASE_WIN_PE_IMAGE_H_ 270 #endif // BASE_WIN_PE_IMAGE_H_
OLDNEW
« no previous file with comments | « base/process/kill_posix.cc ('k') | build/android/buildbot/OWNERS » ('j') | no next file with comments »

Powered by Google App Engine