| OLD | NEW |
| 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 |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 private: | 231 private: |
| 232 HMODULE module_; | 232 HMODULE module_; |
| 233 }; | 233 }; |
| 234 | 234 |
| 235 // This class is an extension to the PEImage class that allows working with PE | 235 // This class is an extension to the PEImage class that allows working with PE |
| 236 // files mapped as data instead of as image file. | 236 // files mapped as data instead of as image file. |
| 237 class PEImageAsData : public PEImage { | 237 class PEImageAsData : public PEImage { |
| 238 public: | 238 public: |
| 239 explicit PEImageAsData(HMODULE hModule) : PEImage(hModule) {} | 239 explicit PEImageAsData(HMODULE hModule) : PEImage(hModule) {} |
| 240 | 240 |
| 241 virtual PVOID RVAToAddr(DWORD rva) const; | 241 PVOID RVAToAddr(DWORD rva) const override; |
| 242 }; | 242 }; |
| 243 | 243 |
| 244 inline bool PEImage::IsOrdinal(LPCSTR name) { | 244 inline bool PEImage::IsOrdinal(LPCSTR name) { |
| 245 return reinterpret_cast<uintptr_t>(name) <= 0xFFFF; | 245 return reinterpret_cast<uintptr_t>(name) <= 0xFFFF; |
| 246 } | 246 } |
| 247 | 247 |
| 248 inline WORD PEImage::ToOrdinal(LPCSTR name) { | 248 inline WORD PEImage::ToOrdinal(LPCSTR name) { |
| 249 return static_cast<WORD>(reinterpret_cast<intptr_t>(name)); | 249 return static_cast<WORD>(reinterpret_cast<intptr_t>(name)); |
| 250 } | 250 } |
| 251 | 251 |
| 252 inline HMODULE PEImage::module() const { | 252 inline HMODULE PEImage::module() const { |
| 253 return module_; | 253 return module_; |
| 254 } | 254 } |
| 255 | 255 |
| 256 inline PIMAGE_IMPORT_DESCRIPTOR PEImage::GetFirstImportChunk() const { | 256 inline PIMAGE_IMPORT_DESCRIPTOR PEImage::GetFirstImportChunk() const { |
| 257 return reinterpret_cast<PIMAGE_IMPORT_DESCRIPTOR>( | 257 return reinterpret_cast<PIMAGE_IMPORT_DESCRIPTOR>( |
| 258 GetImageDirectoryEntryAddr(IMAGE_DIRECTORY_ENTRY_IMPORT)); | 258 GetImageDirectoryEntryAddr(IMAGE_DIRECTORY_ENTRY_IMPORT)); |
| 259 } | 259 } |
| 260 | 260 |
| 261 inline PIMAGE_EXPORT_DIRECTORY PEImage::GetExportDirectory() const { | 261 inline PIMAGE_EXPORT_DIRECTORY PEImage::GetExportDirectory() const { |
| 262 return reinterpret_cast<PIMAGE_EXPORT_DIRECTORY>( | 262 return reinterpret_cast<PIMAGE_EXPORT_DIRECTORY>( |
| 263 GetImageDirectoryEntryAddr(IMAGE_DIRECTORY_ENTRY_EXPORT)); | 263 GetImageDirectoryEntryAddr(IMAGE_DIRECTORY_ENTRY_EXPORT)); |
| 264 } | 264 } |
| 265 | 265 |
| 266 } // namespace win | 266 } // namespace win |
| 267 } // namespace base | 267 } // namespace base |
| 268 | 268 |
| 269 #endif // BASE_WIN_PE_IMAGE_H_ | 269 #endif // BASE_WIN_PE_IMAGE_H_ |
| OLD | NEW |