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

Side by Side Diff: chrome/browser/safe_browsing/incident_reporting/module_integrity_verifier_win.cc

Issue 1548133002: Switch to standard integer types in chrome/browser/, part 3 of 4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "chrome/browser/safe_browsing/incident_reporting/module_integrity_verif ier_win.h" 5 #include "chrome/browser/safe_browsing/incident_reporting/module_integrity_verif ier_win.h"
6 6
7 #include <stddef.h>
8
7 #include <algorithm> 9 #include <algorithm>
8 #include <string> 10 #include <string>
9 #include <vector> 11 #include <vector>
10 12
11 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
12 #include "base/files/memory_mapped_file.h" 14 #include "base/files/memory_mapped_file.h"
15 #include "base/macros.h"
13 #include "base/metrics/sparse_histogram.h" 16 #include "base/metrics/sparse_histogram.h"
14 #include "base/scoped_native_library.h" 17 #include "base/scoped_native_library.h"
15 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
16 #include "base/win/pe_image.h" 19 #include "base/win/pe_image.h"
17 #include "chrome/common/safe_browsing/csd.pb.h" 20 #include "chrome/common/safe_browsing/csd.pb.h"
18 21
19 namespace safe_browsing { 22 namespace safe_browsing {
20 23
21 namespace { 24 namespace {
22 25
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 WCHAR module_path[MAX_PATH] = {}; 321 WCHAR module_path[MAX_PATH] = {};
319 DWORD length = 322 DWORD length =
320 GetModuleFileName(module_handle, module_path, arraysize(module_path)); 323 GetModuleFileName(module_handle, module_path, arraysize(module_path));
321 if (!length || length == arraysize(module_path)) 324 if (!length || length == arraysize(module_path))
322 return false; 325 return false;
323 326
324 base::MemoryMappedFile mapped_module; 327 base::MemoryMappedFile mapped_module;
325 if (!mapped_module.Initialize(base::FilePath(module_path))) 328 if (!mapped_module.Initialize(base::FilePath(module_path)))
326 return false; 329 return false;
327 ModuleVerificationState state( 330 ModuleVerificationState state(
328 reinterpret_cast<HMODULE>(const_cast<uint8*>(mapped_module.data()))); 331 reinterpret_cast<HMODULE>(const_cast<uint8_t*>(mapped_module.data())));
329 332
330 base::win::PEImage mem_peimage(module_handle); 333 base::win::PEImage mem_peimage(module_handle);
331 if (!mem_peimage.VerifyMagic() || !state.disk_peimage.VerifyMagic()) 334 if (!mem_peimage.VerifyMagic() || !state.disk_peimage.VerifyMagic())
332 return false; 335 return false;
333 336
334 // Get the list of exports and sort them by address for efficient lookups. 337 // Get the list of exports and sort them by address for efficient lookups.
335 mem_peimage.EnumExports(EnumExportsCallback, &state.exports); 338 mem_peimage.EnumExports(EnumExportsCallback, &state.exports);
336 std::sort(state.exports.begin(), state.exports.end()); 339 std::sort(state.exports.begin(), state.exports.end());
337 340
338 // Get the addresses of the code sections then calculate |code_section_delta| 341 // Get the addresses of the code sections then calculate |code_section_delta|
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 // entire module was scanned and understood. 381 // entire module was scanned and understood.
379 if (state.bytes_different) 382 if (state.bytes_different)
380 module_state->set_modified_state(ModuleState::MODULE_STATE_MODIFIED); 383 module_state->set_modified_state(ModuleState::MODULE_STATE_MODIFIED);
381 else if (!state.unknown_reloc_type && scan_complete) 384 else if (!state.unknown_reloc_type && scan_complete)
382 module_state->set_modified_state(ModuleState::MODULE_STATE_UNMODIFIED); 385 module_state->set_modified_state(ModuleState::MODULE_STATE_UNMODIFIED);
383 386
384 return scan_complete; 387 return scan_complete;
385 } 388 }
386 389
387 } // namespace safe_browsing 390 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698