| OLD | NEW |
| 1 // Copyright (c) 2006-2008 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_PE_IMAGE_H_ | 11 #ifndef BASE_WIN_PE_IMAGE_H_ |
| 12 #define BASE_PE_IMAGE_H_ | 12 #define BASE_WIN_PE_IMAGE_H_ |
| 13 #pragma once | 13 #pragma once |
| 14 | 14 |
| 15 #include <windows.h> | 15 #include <windows.h> |
| 16 #include <DelayIMP.h> | 16 #include <DelayIMP.h> |
| 17 | 17 |
| 18 namespace base { |
| 19 namespace win { |
| 20 |
| 18 // This class is a wrapper for the Portable Executable File Format (PE). | 21 // This class is a wrapper for the Portable Executable File Format (PE). |
| 19 // It's main purpose is to provide an easy way to work with imports and exports | 22 // It's main purpose is to provide an easy way to work with imports and exports |
| 20 // from a file, mapped in memory as image. | 23 // from a file, mapped in memory as image. |
| 21 class PEImage { | 24 class PEImage { |
| 22 public: | 25 public: |
| 23 // Callback to enumerate sections. | 26 // Callback to enumerate sections. |
| 24 // cookie is the value passed to the enumerate method. | 27 // cookie is the value passed to the enumerate method. |
| 25 // Returns true to continue the enumeration. | 28 // Returns true to continue the enumeration. |
| 26 typedef bool (*EnumSectionsFunction)(const PEImage &image, | 29 typedef bool (*EnumSectionsFunction)(const PEImage &image, |
| 27 PIMAGE_SECTION_HEADER header, | 30 PIMAGE_SECTION_HEADER header, |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 inline PIMAGE_IMPORT_DESCRIPTOR PEImage::GetFirstImportChunk() const { | 251 inline PIMAGE_IMPORT_DESCRIPTOR PEImage::GetFirstImportChunk() const { |
| 249 return reinterpret_cast<PIMAGE_IMPORT_DESCRIPTOR>( | 252 return reinterpret_cast<PIMAGE_IMPORT_DESCRIPTOR>( |
| 250 GetImageDirectoryEntryAddr(IMAGE_DIRECTORY_ENTRY_IMPORT)); | 253 GetImageDirectoryEntryAddr(IMAGE_DIRECTORY_ENTRY_IMPORT)); |
| 251 } | 254 } |
| 252 | 255 |
| 253 inline PIMAGE_EXPORT_DIRECTORY PEImage::GetExportDirectory() const { | 256 inline PIMAGE_EXPORT_DIRECTORY PEImage::GetExportDirectory() const { |
| 254 return reinterpret_cast<PIMAGE_EXPORT_DIRECTORY>( | 257 return reinterpret_cast<PIMAGE_EXPORT_DIRECTORY>( |
| 255 GetImageDirectoryEntryAddr(IMAGE_DIRECTORY_ENTRY_EXPORT)); | 258 GetImageDirectoryEntryAddr(IMAGE_DIRECTORY_ENTRY_EXPORT)); |
| 256 } | 259 } |
| 257 | 260 |
| 258 #endif // BASE_PE_IMAGE_H_ | 261 } // namespace win |
| 262 } // namespace base |
| 263 |
| 264 #endif // BASE_WIN_PE_IMAGE_H_ |
| OLD | NEW |