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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
235 public: | 235 public: |
236 explicit PEImageAsData(HMODULE hModule) : PEImage(hModule) {} | 236 explicit PEImageAsData(HMODULE hModule) : PEImage(hModule) {} |
237 | 237 |
238 virtual PVOID RVAToAddr(DWORD rva) const; | 238 virtual PVOID RVAToAddr(DWORD rva) const; |
239 }; | 239 }; |
240 | 240 |
241 inline bool PEImage::IsOrdinal(LPCSTR name) { | 241 inline bool PEImage::IsOrdinal(LPCSTR name) { |
242 #pragma warning(push) | 242 #pragma warning(push) |
243 #pragma warning(disable: 4311) | 243 #pragma warning(disable: 4311) |
244 // This cast generates a warning because it is 32 bit specific. | 244 // This cast generates a warning because it is 32 bit specific. |
245 return reinterpret_cast<DWORD>(name) <= 0xFFFF; | 245 return reinterpret_cast<DWORD>(name) <= 0xFFFF; |
grt (UTC plus 2)
2015/01/27 20:55:56
should this be
return reinterpret_cast<uintptr_
Will Harris
2015/01/27 21:36:04
my understanding was that 0x80000001 was an ordina
scottmg
2015/01/27 21:42:04
Done.
| |
246 #pragma warning(pop) | 246 #pragma warning(pop) |
247 } | 247 } |
248 | 248 |
249 inline WORD PEImage::ToOrdinal(LPCSTR name) { | 249 inline WORD PEImage::ToOrdinal(LPCSTR name) { |
250 return reinterpret_cast<WORD>(name); | 250 return static_cast<WORD>(reinterpret_cast<intptr_t>(name)); |
251 } | 251 } |
252 | 252 |
253 inline HMODULE PEImage::module() const { | 253 inline HMODULE PEImage::module() const { |
254 return module_; | 254 return module_; |
255 } | 255 } |
256 | 256 |
257 inline PIMAGE_IMPORT_DESCRIPTOR PEImage::GetFirstImportChunk() const { | 257 inline PIMAGE_IMPORT_DESCRIPTOR PEImage::GetFirstImportChunk() const { |
258 return reinterpret_cast<PIMAGE_IMPORT_DESCRIPTOR>( | 258 return reinterpret_cast<PIMAGE_IMPORT_DESCRIPTOR>( |
259 GetImageDirectoryEntryAddr(IMAGE_DIRECTORY_ENTRY_IMPORT)); | 259 GetImageDirectoryEntryAddr(IMAGE_DIRECTORY_ENTRY_IMPORT)); |
260 } | 260 } |
261 | 261 |
262 inline PIMAGE_EXPORT_DIRECTORY PEImage::GetExportDirectory() const { | 262 inline PIMAGE_EXPORT_DIRECTORY PEImage::GetExportDirectory() const { |
263 return reinterpret_cast<PIMAGE_EXPORT_DIRECTORY>( | 263 return reinterpret_cast<PIMAGE_EXPORT_DIRECTORY>( |
264 GetImageDirectoryEntryAddr(IMAGE_DIRECTORY_ENTRY_EXPORT)); | 264 GetImageDirectoryEntryAddr(IMAGE_DIRECTORY_ENTRY_EXPORT)); |
265 } | 265 } |
266 | 266 |
267 } // namespace win | 267 } // namespace win |
268 } // namespace base | 268 } // namespace base |
269 | 269 |
270 #endif // BASE_WIN_PE_IMAGE_H_ | 270 #endif // BASE_WIN_PE_IMAGE_H_ |
OLD | NEW |