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

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

Issue 883873002: Fix truncation warning in PEImage on VS2015 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2015-logging
Patch Set: Created 5 years, 11 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | 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
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698