| OLD | NEW |
| 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> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| 11 #include <functional> | 11 #include <functional> |
| 12 #include <map> | 12 #include <map> |
| 13 #include <memory> |
| 13 #include <vector> | 14 #include <vector> |
| 14 | 15 |
| 15 #include "base/files/file_path.h" | 16 #include "base/files/file_path.h" |
| 16 #include "base/files/memory_mapped_file.h" | 17 #include "base/files/memory_mapped_file.h" |
| 17 #include "base/macros.h" | 18 #include "base/macros.h" |
| 18 #include "base/memory/scoped_ptr.h" | |
| 19 #include "base/native_library.h" | 19 #include "base/native_library.h" |
| 20 #include "base/scoped_native_library.h" | 20 #include "base/scoped_native_library.h" |
| 21 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
| 22 #include "base/win/pe_image.h" | 22 #include "base/win/pe_image.h" |
| 23 #include "chrome/browser/safe_browsing/incident_reporting/module_integrity_unitt
est_util_win.h" | 23 #include "chrome/browser/safe_browsing/incident_reporting/module_integrity_unitt
est_util_win.h" |
| 24 #include "chrome/common/safe_browsing/csd.pb.h" | 24 #include "chrome/common/safe_browsing/csd.pb.h" |
| 25 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
| 26 | 26 |
| 27 namespace safe_browsing { | 27 namespace safe_browsing { |
| 28 | 28 |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 if (!modification.has_export_name()) | 150 if (!modification.has_export_name()) |
| 151 export_name.clear(); | 151 export_name.clear(); |
| 152 else | 152 else |
| 153 export_name = modification.export_name(); | 153 export_name = modification.export_name(); |
| 154 (*modification_map)[export_name].push_back(&modification); | 154 (*modification_map)[export_name].push_back(&modification); |
| 155 } | 155 } |
| 156 } | 156 } |
| 157 | 157 |
| 158 base::ScopedNativeLibrary mem_dll_handle_; | 158 base::ScopedNativeLibrary mem_dll_handle_; |
| 159 base::MemoryMappedFile disk_dll_handle_; | 159 base::MemoryMappedFile disk_dll_handle_; |
| 160 scoped_ptr<base::win::PEImageAsData> disk_peimage_ptr_; | 160 std::unique_ptr<base::win::PEImageAsData> disk_peimage_ptr_; |
| 161 scoped_ptr<base::win::PEImage> mem_peimage_ptr_; | 161 std::unique_ptr<base::win::PEImage> mem_peimage_ptr_; |
| 162 }; | 162 }; |
| 163 | 163 |
| 164 // Don't run these tests under AddressSanitizer as it patches the modules on | 164 // Don't run these tests under AddressSanitizer as it patches the modules on |
| 165 // startup, thus interferes with all these test expectations. | 165 // startup, thus interferes with all these test expectations. |
| 166 #if !defined(ADDRESS_SANITIZER) | 166 #if !defined(ADDRESS_SANITIZER) |
| 167 TEST_F(SafeBrowsingModuleVerifierWinTest, VerifyModuleUnmodified) { | 167 TEST_F(SafeBrowsingModuleVerifierWinTest, VerifyModuleUnmodified) { |
| 168 ModuleState state; | 168 ModuleState state; |
| 169 int num_bytes_different = 0; | 169 int num_bytes_different = 0; |
| 170 // Call VerifyModule before the module has been loaded, should fail. | 170 // Call VerifyModule before the module has been loaded, should fail. |
| 171 ASSERT_FALSE(VerifyModule(kTestDllNames[0], &state, &num_bytes_different)); | 171 ASSERT_FALSE(VerifyModule(kTestDllNames[0], &state, &num_bytes_different)); |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 | 393 |
| 394 // One of the two exports now has two modifications. | 394 // One of the two exports now has two modifications. |
| 395 BuildModificationMap(state, &modification_map); | 395 BuildModificationMap(state, &modification_map); |
| 396 ASSERT_EQ(2U, modification_map.size()); | 396 ASSERT_EQ(2U, modification_map.size()); |
| 397 ASSERT_EQ(3U, (modification_map.begin()->second.size() + | 397 ASSERT_EQ(3U, (modification_map.begin()->second.size() + |
| 398 (++modification_map.begin())->second.size())); | 398 (++modification_map.begin())->second.size())); |
| 399 } | 399 } |
| 400 #endif // ADDRESS_SANITIZER | 400 #endif // ADDRESS_SANITIZER |
| 401 | 401 |
| 402 } // namespace safe_browsing | 402 } // namespace safe_browsing |
| OLD | NEW |