Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/environment.h" | 5 #include "base/environment.h" |
| 6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
| 7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
| 8 #include "base/i18n/case_conversion.h" | 8 #include "base/i18n/case_conversion.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/scoped_native_library.h" | 10 #include "base/scoped_native_library.h" |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 27 const wchar_t kDll3Beacon[] = L"{9E056AEC-169E-400c-B2D0-5A07E3ACE2EB}"; | 27 const wchar_t kDll3Beacon[] = L"{9E056AEC-169E-400c-B2D0-5A07E3ACE2EB}"; |
| 28 | 28 |
| 29 extern const wchar_t* kEnvVars[]; | 29 extern const wchar_t* kEnvVars[]; |
| 30 | 30 |
| 31 extern "C" { | 31 extern "C" { |
| 32 // When modifying the blacklist in the test process, use the exported test dll | 32 // When modifying the blacklist in the test process, use the exported test dll |
| 33 // functions on the test blacklist dll, not the ones linked into the test | 33 // functions on the test blacklist dll, not the ones linked into the test |
| 34 // executable itself. | 34 // executable itself. |
| 35 __declspec(dllimport) void TestDll_AddDllsFromRegistryToBlacklist(); | 35 __declspec(dllimport) void TestDll_AddDllsFromRegistryToBlacklist(); |
| 36 __declspec(dllimport) bool TestDll_AddDllToBlacklist(const wchar_t* dll_name); | 36 __declspec(dllimport) bool TestDll_AddDllToBlacklist(const wchar_t* dll_name); |
| 37 __declspec(dllimport) int TestDll_BlacklistSize(); | |
| 38 __declspec(dllimport) void TestDll_BlockedDll(size_t blocked_index); | |
| 39 __declspec(dllimport) int TestDll_GetBlacklistIndex(const wchar_t* dll_name); | |
| 37 __declspec(dllimport) bool TestDll_IsBlacklistInitialized(); | 40 __declspec(dllimport) bool TestDll_IsBlacklistInitialized(); |
| 38 __declspec(dllimport) bool TestDll_RemoveDllFromBlacklist( | 41 __declspec(dllimport) bool TestDll_RemoveDllFromBlacklist( |
| 39 const wchar_t* dll_name); | 42 const wchar_t* dll_name); |
| 40 __declspec(dllimport) bool TestDll_SuccessfullyBlocked( | 43 __declspec(dllimport) bool TestDll_SuccessfullyBlocked( |
| 41 const wchar_t** blocked_dlls, | 44 const wchar_t** blocked_dlls, |
| 42 int* size); | 45 int* size); |
| 43 } | 46 } |
| 44 | 47 |
| 45 namespace { | 48 namespace { |
| 46 | 49 |
| 50 struct TestData { | |
| 51 const wchar_t* dll_name; | |
| 52 const wchar_t* dll_beacon; | |
| 53 } test_data[] = { | |
| 54 {kTestDllName2, kDll2Beacon}, | |
| 55 #if !defined(_WIN64) | |
| 56 // The third test dll is special in that it does not contain an export | |
| 57 // table. This prevents SafeGetImageInfo from extracting the name from there | |
| 58 // AND for some reason NtQueryVirtualMemory with MemorySectionName returns | |
| 59 // STATUS_ACCESS_VIOLATION in 64 bit builds for reasons still unknown. | |
| 60 // http://crbug.com/397137 | |
|
robertshield
2015/03/23 03:59:28
Is this comment still true? (c.f. crbug.com/397137
csharp
2015/03/23 17:17:18
Comment no longer seems to old, removing.
| |
| 61 {kTestDllName3, kDll3Beacon} | |
| 62 #endif | |
| 63 }; | |
| 64 | |
| 47 class BlacklistTest : public testing::Test { | 65 class BlacklistTest : public testing::Test { |
| 48 protected: | 66 protected: |
| 49 BlacklistTest() : override_manager_() { | 67 BlacklistTest() : override_manager_() { |
| 50 override_manager_.OverrideRegistry(HKEY_CURRENT_USER); | 68 override_manager_.OverrideRegistry(HKEY_CURRENT_USER); |
| 51 } | 69 } |
| 52 | 70 |
| 71 void CheckBlacklistedDllsNotLoaded() { | |
| 72 base::FilePath current_dir; | |
| 73 ASSERT_TRUE(PathService::Get(base::DIR_EXE, ¤t_dir)); | |
| 74 | |
| 75 for (int i = 0; i < arraysize(test_data); ++i) { | |
| 76 // Ensure that the dll has not been loaded both by inspecting the handle | |
| 77 // returned by LoadLibrary and by looking for an environment variable that | |
| 78 // is set when the DLL's entry point is called. | |
| 79 base::ScopedNativeLibrary dll_blacklisted( | |
| 80 current_dir.Append(test_data[i].dll_name)); | |
| 81 EXPECT_FALSE(dll_blacklisted.is_valid()); | |
| 82 EXPECT_EQ(0u, ::GetEnvironmentVariable(test_data[i].dll_beacon, NULL, 0)); | |
| 83 dll_blacklisted.Reset(NULL); | |
| 84 | |
| 85 // Ensure that the dll is recorded as blocked. | |
| 86 int array_size = 1 + num_initially_blocked_; | |
| 87 std::vector<const wchar_t*> blocked_dlls(array_size); | |
| 88 TestDll_SuccessfullyBlocked(&blocked_dlls[0], &array_size); | |
| 89 EXPECT_EQ(1 + num_initially_blocked_, array_size); | |
| 90 EXPECT_STREQ(test_data[i].dll_name, blocked_dlls[num_initially_blocked_]); | |
| 91 | |
| 92 // Remove the DLL from the blacklist. Ensure that it loads and that its | |
| 93 // entry point was called. | |
| 94 EXPECT_TRUE(TestDll_RemoveDllFromBlacklist(test_data[i].dll_name)); | |
| 95 base::ScopedNativeLibrary dll(current_dir.Append(test_data[i].dll_name)); | |
| 96 EXPECT_TRUE(dll.is_valid()); | |
| 97 EXPECT_NE(0u, ::GetEnvironmentVariable(test_data[i].dll_beacon, NULL, 0)); | |
| 98 dll.Reset(NULL); | |
| 99 | |
| 100 ::SetEnvironmentVariable(test_data[i].dll_beacon, NULL); | |
| 101 | |
| 102 // Ensure that the dll won't load even if the name has different | |
| 103 // capitalization. | |
| 104 base::string16 uppercase_name = | |
| 105 base::i18n::ToUpper(test_data[i].dll_name); | |
| 106 EXPECT_TRUE(TestDll_AddDllToBlacklist(uppercase_name.c_str())); | |
| 107 base::ScopedNativeLibrary dll_blacklisted_different_case( | |
| 108 current_dir.Append(test_data[i].dll_name)); | |
| 109 EXPECT_FALSE(dll_blacklisted_different_case.is_valid()); | |
| 110 EXPECT_EQ(0u, ::GetEnvironmentVariable(test_data[i].dll_beacon, NULL, 0)); | |
| 111 dll_blacklisted_different_case.Reset(NULL); | |
| 112 | |
| 113 EXPECT_TRUE(TestDll_RemoveDllFromBlacklist(uppercase_name.c_str())); | |
| 114 | |
| 115 // The blocked dll was removed, so the number of blocked dlls should | |
| 116 // return to what it originally was. | |
| 117 int num_blocked_dlls = 0; | |
| 118 TestDll_SuccessfullyBlocked(NULL, &num_blocked_dlls); | |
| 119 EXPECT_EQ(num_initially_blocked_, num_blocked_dlls); | |
| 120 } | |
| 121 } | |
| 122 | |
| 53 scoped_ptr<base::win::RegKey> blacklist_registry_key_; | 123 scoped_ptr<base::win::RegKey> blacklist_registry_key_; |
| 54 registry_util::RegistryOverrideManager override_manager_; | 124 registry_util::RegistryOverrideManager override_manager_; |
| 55 | 125 |
| 126 // The number of dlls initially blocked by the blacklist. | |
| 127 int num_initially_blocked_; | |
|
robertshield
2015/03/23 03:59:28
init to 0 in the constructor's initializer list
csharp
2015/03/23 17:17:17
Done.
| |
| 128 | |
| 56 private: | 129 private: |
| 57 virtual void SetUp() { | 130 virtual void SetUp() { |
| 58 // Force an import from blacklist_test_main_dll. | 131 // Force an import from blacklist_test_main_dll. |
| 59 InitBlacklistTestDll(); | 132 InitBlacklistTestDll(); |
| 60 blacklist_registry_key_.reset( | 133 blacklist_registry_key_.reset( |
| 61 new base::win::RegKey(HKEY_CURRENT_USER, | 134 new base::win::RegKey(HKEY_CURRENT_USER, |
| 62 blacklist::kRegistryBeaconPath, | 135 blacklist::kRegistryBeaconPath, |
| 63 KEY_QUERY_VALUE | KEY_SET_VALUE)); | 136 KEY_QUERY_VALUE | KEY_SET_VALUE)); |
| 137 | |
| 138 // Find out how many dlls were blocked before the test starts. | |
| 139 TestDll_SuccessfullyBlocked(NULL, &num_initially_blocked_); | |
| 64 } | 140 } |
| 65 | 141 |
| 66 virtual void TearDown() { | 142 virtual void TearDown() { |
| 67 TestDll_RemoveDllFromBlacklist(kTestDllName1); | 143 TestDll_RemoveDllFromBlacklist(kTestDllName1); |
| 68 TestDll_RemoveDllFromBlacklist(kTestDllName2); | 144 TestDll_RemoveDllFromBlacklist(kTestDllName2); |
| 69 TestDll_RemoveDllFromBlacklist(kTestDllName3); | 145 TestDll_RemoveDllFromBlacklist(kTestDllName3); |
| 70 } | 146 } |
| 71 }; | 147 }; |
| 72 | 148 |
| 73 struct TestData { | |
| 74 const wchar_t* dll_name; | |
| 75 const wchar_t* dll_beacon; | |
| 76 } test_data[] = { | |
| 77 {kTestDllName2, kDll2Beacon}, | |
| 78 #if !defined(_WIN64) | |
| 79 // The third test dll is special in that it does not contain an export | |
| 80 // table. This prevents SafeGetImageInfo from extracting the name from there | |
| 81 // AND for some reason NtQueryVirtualMemory with MemorySectionName returns | |
| 82 // STATUS_ACCESS_VIOLATION in 64 bit builds for reasons still unknown. | |
| 83 // http://crbug.com/397137 | |
| 84 {kTestDllName3, kDll3Beacon} | |
| 85 #endif | |
| 86 }; | |
| 87 | |
| 88 TEST_F(BlacklistTest, Beacon) { | 149 TEST_F(BlacklistTest, Beacon) { |
| 89 // Ensure that the beacon state starts off 'running' for this version. | 150 // Ensure that the beacon state starts off 'running' for this version. |
| 90 LONG result = blacklist_registry_key_->WriteValue( | 151 LONG result = blacklist_registry_key_->WriteValue( |
| 91 blacklist::kBeaconState, blacklist::BLACKLIST_SETUP_RUNNING); | 152 blacklist::kBeaconState, blacklist::BLACKLIST_SETUP_RUNNING); |
| 92 EXPECT_EQ(ERROR_SUCCESS, result); | 153 EXPECT_EQ(ERROR_SUCCESS, result); |
| 93 | 154 |
| 94 result = blacklist_registry_key_->WriteValue(blacklist::kBeaconVersion, | 155 result = blacklist_registry_key_->WriteValue(blacklist::kBeaconVersion, |
| 95 TEXT(CHROME_VERSION_STRING)); | 156 TEXT(CHROME_VERSION_STRING)); |
| 96 EXPECT_EQ(ERROR_SUCCESS, result); | 157 EXPECT_EQ(ERROR_SUCCESS, result); |
| 97 | 158 |
| 98 // First call should find the beacon and reset it. | 159 // First call should find the beacon and reset it. |
| 99 EXPECT_TRUE(blacklist::ResetBeacon()); | 160 EXPECT_TRUE(blacklist::ResetBeacon()); |
| 100 | 161 |
| 101 // First call should succeed as the beacon is enabled. | 162 // First call should succeed as the beacon is enabled. |
| 102 EXPECT_TRUE(blacklist::LeaveSetupBeacon()); | 163 EXPECT_TRUE(blacklist::LeaveSetupBeacon()); |
| 103 } | 164 } |
| 104 | 165 |
| 105 TEST_F(BlacklistTest, AddAndRemoveModules) { | 166 TEST_F(BlacklistTest, AddAndRemoveModules) { |
| 106 EXPECT_TRUE(blacklist::AddDllToBlacklist(L"foo.dll")); | 167 EXPECT_TRUE(TestDll_AddDllToBlacklist(L"foo.dll")); |
| 107 // Adding the same item twice should be idempotent. | 168 // Adding the same item twice should be idempotent. |
| 108 EXPECT_TRUE(blacklist::AddDllToBlacklist(L"foo.dll")); | 169 EXPECT_TRUE(TestDll_AddDllToBlacklist(L"foo.dll")); |
| 109 EXPECT_TRUE(blacklist::RemoveDllFromBlacklist(L"foo.dll")); | 170 EXPECT_TRUE(TestDll_RemoveDllFromBlacklist(L"foo.dll")); |
| 110 EXPECT_FALSE(blacklist::RemoveDllFromBlacklist(L"foo.dll")); | 171 EXPECT_FALSE(TestDll_RemoveDllFromBlacklist(L"foo.dll")); |
| 111 | 172 |
| 112 // Increase the blacklist size by 1 to include the NULL pointer | 173 // Increase the blacklist size by 1 to include the NULL pointer |
| 113 // that marks the end. | 174 // that marks the end. |
| 114 int empty_spaces = blacklist::kTroublesomeDllsMaxCount - ( | 175 int empty_spaces = |
| 115 blacklist::BlacklistSize() + 1); | 176 blacklist::kTroublesomeDllsMaxCount - (TestDll_BlacklistSize() + 1); |
| 116 std::vector<base::string16> added_dlls; | 177 std::vector<base::string16> added_dlls; |
| 117 added_dlls.reserve(empty_spaces); | 178 added_dlls.reserve(empty_spaces); |
| 118 for (int i = 0; i < empty_spaces; ++i) { | 179 for (int i = 0; i < empty_spaces; ++i) { |
| 119 added_dlls.push_back(base::IntToString16(i) + L".dll"); | 180 added_dlls.push_back(base::IntToString16(i) + L".dll"); |
| 120 EXPECT_TRUE(blacklist::AddDllToBlacklist(added_dlls[i].c_str())) << i; | 181 EXPECT_TRUE(TestDll_AddDllToBlacklist(added_dlls[i].c_str())) << i; |
| 121 } | 182 } |
| 122 EXPECT_FALSE(blacklist::AddDllToBlacklist(L"overflow.dll")); | 183 EXPECT_FALSE(TestDll_AddDllToBlacklist(L"overflow.dll")); |
| 123 for (int i = 0; i < empty_spaces; ++i) { | 184 for (int i = 0; i < empty_spaces; ++i) { |
| 124 EXPECT_TRUE(blacklist::RemoveDllFromBlacklist(added_dlls[i].c_str())) << i; | 185 EXPECT_TRUE(TestDll_RemoveDllFromBlacklist(added_dlls[i].c_str())) << i; |
| 125 } | 186 } |
| 126 EXPECT_FALSE(blacklist::RemoveDllFromBlacklist(added_dlls[0].c_str())); | 187 EXPECT_FALSE(TestDll_RemoveDllFromBlacklist(added_dlls[0].c_str())); |
| 127 EXPECT_FALSE(blacklist::RemoveDllFromBlacklist( | 188 EXPECT_FALSE( |
| 128 added_dlls[empty_spaces - 1].c_str())); | 189 TestDll_RemoveDllFromBlacklist(added_dlls[empty_spaces - 1].c_str())); |
| 129 } | 190 } |
| 130 | 191 |
| 131 TEST_F(BlacklistTest, SuccessfullyBlocked) { | 192 TEST_F(BlacklistTest, SuccessfullyBlocked) { |
| 132 // Ensure that we have at least 5 dlls to blacklist. | 193 // Add 5 news dlls to blacklist. |
| 133 int blacklist_size = blacklist::BlacklistSize(); | 194 const int kDesiredBlacklistSize = 1; |
| 134 const int kDesiredBlacklistSize = 5; | 195 std::vector<base::string16> dlls_to_block; |
| 135 for (int i = blacklist_size; i < kDesiredBlacklistSize; ++i) { | 196 for (int i = 0; i < kDesiredBlacklistSize; ++i) { |
| 136 base::string16 new_dll_name(base::IntToString16(i) + L".dll"); | 197 dlls_to_block.push_back(base::IntToString16(i) + L".dll"); |
| 137 EXPECT_TRUE(blacklist::AddDllToBlacklist(new_dll_name.c_str())); | 198 ASSERT_TRUE(TestDll_AddDllToBlacklist(dlls_to_block[i].c_str())); |
| 138 } | 199 } |
| 139 | 200 |
| 140 // Block 5 dlls, one at a time, starting from the end of the list, and | 201 // Block the dlls, one at a time, and ensure SuccesfullyBlocked correctly |
| 141 // ensuring SuccesfullyBlocked correctly passes the list of blocked dlls. | 202 // passes the list of blocked dlls. |
| 142 for (int i = 0; i < kDesiredBlacklistSize; ++i) { | 203 for (int i = 0; i < kDesiredBlacklistSize; ++i) { |
| 143 blacklist::BlockedDll(i); | 204 TestDll_BlockedDll(TestDll_GetBlacklistIndex(dlls_to_block[i].c_str())); |
| 144 | 205 |
| 145 int size = 0; | 206 int size = 0; |
| 146 blacklist::SuccessfullyBlocked(NULL, &size); | 207 TestDll_SuccessfullyBlocked(NULL, &size); |
| 147 EXPECT_EQ(i + 1, size); | 208 ASSERT_EQ(num_initially_blocked_ + i + 1, size); |
| 148 | 209 |
| 149 std::vector<const wchar_t*> blocked_dlls(size); | 210 std::vector<const wchar_t*> blocked_dlls(size); |
| 150 blacklist::SuccessfullyBlocked(&(blocked_dlls[0]), &size); | 211 TestDll_SuccessfullyBlocked(&(blocked_dlls[0]), &size); |
| 151 EXPECT_EQ(i + 1, size); | 212 ASSERT_EQ(num_initially_blocked_ + i + 1, size); |
| 152 | 213 |
| 153 for (size_t j = 0; j < blocked_dlls.size(); ++j) { | 214 for (int j = 0; j <= i; ++j) { |
| 154 EXPECT_EQ(blocked_dlls[j], blacklist::g_troublesome_dlls[j]); | 215 EXPECT_STREQ(blocked_dlls[num_initially_blocked_ + j], |
| 216 dlls_to_block[j].c_str()); | |
| 155 } | 217 } |
| 156 } | 218 } |
| 219 | |
| 220 // Remove the dlls from the blacklist now that we are done. | |
| 221 for (const auto& dll : dlls_to_block) { | |
| 222 EXPECT_TRUE(TestDll_RemoveDllFromBlacklist(dll.c_str())); | |
| 223 } | |
| 157 } | 224 } |
| 158 | 225 |
| 159 void CheckBlacklistedDllsNotLoaded() { | |
| 160 base::FilePath current_dir; | |
| 161 ASSERT_TRUE(PathService::Get(base::DIR_EXE, ¤t_dir)); | |
| 162 | |
| 163 for (int i = 0; i < arraysize(test_data); ++i) { | |
| 164 // Ensure that the dll has not been loaded both by inspecting the handle | |
| 165 // returned by LoadLibrary and by looking for an environment variable that | |
| 166 // is set when the DLL's entry point is called. | |
| 167 base::ScopedNativeLibrary dll_blacklisted( | |
| 168 current_dir.Append(test_data[i].dll_name)); | |
| 169 EXPECT_FALSE(dll_blacklisted.is_valid()); | |
| 170 EXPECT_EQ(0u, ::GetEnvironmentVariable(test_data[i].dll_beacon, NULL, 0)); | |
| 171 dll_blacklisted.Reset(NULL); | |
| 172 | |
| 173 // Ensure that the dll is recorded as blocked. | |
| 174 int array_size = 1; | |
| 175 const wchar_t* blocked_dll = NULL; | |
| 176 TestDll_SuccessfullyBlocked(&blocked_dll, &array_size); | |
| 177 EXPECT_EQ(1, array_size); | |
| 178 EXPECT_EQ(test_data[i].dll_name, base::string16(blocked_dll)); | |
| 179 | |
| 180 // Remove the DLL from the blacklist. Ensure that it loads and that its | |
| 181 // entry point was called. | |
| 182 EXPECT_TRUE(TestDll_RemoveDllFromBlacklist(test_data[i].dll_name)); | |
| 183 base::ScopedNativeLibrary dll(current_dir.Append(test_data[i].dll_name)); | |
| 184 EXPECT_TRUE(dll.is_valid()); | |
| 185 EXPECT_NE(0u, ::GetEnvironmentVariable(test_data[i].dll_beacon, NULL, 0)); | |
| 186 dll.Reset(NULL); | |
| 187 | |
| 188 ::SetEnvironmentVariable(test_data[i].dll_beacon, NULL); | |
| 189 | |
| 190 // Ensure that the dll won't load even if the name has different | |
| 191 // capitalization. | |
| 192 base::string16 uppercase_name = base::i18n::ToUpper(test_data[i].dll_name); | |
| 193 EXPECT_TRUE(TestDll_AddDllToBlacklist(uppercase_name.c_str())); | |
| 194 base::ScopedNativeLibrary dll_blacklisted_different_case( | |
| 195 current_dir.Append(test_data[i].dll_name)); | |
| 196 EXPECT_FALSE(dll_blacklisted_different_case.is_valid()); | |
| 197 EXPECT_EQ(0u, ::GetEnvironmentVariable(test_data[i].dll_beacon, NULL, 0)); | |
| 198 dll_blacklisted_different_case.Reset(NULL); | |
| 199 | |
| 200 EXPECT_TRUE(TestDll_RemoveDllFromBlacklist(uppercase_name.c_str())); | |
| 201 | |
| 202 // The blocked dll was removed, so we shouldn't get anything returned | |
| 203 // here. | |
| 204 int num_blocked_dlls = 0; | |
| 205 TestDll_SuccessfullyBlocked(NULL, &num_blocked_dlls); | |
| 206 EXPECT_EQ(0, num_blocked_dlls); | |
| 207 } | |
| 208 } | |
| 209 | |
| 210 TEST_F(BlacklistTest, LoadBlacklistedLibrary) { | 226 TEST_F(BlacklistTest, LoadBlacklistedLibrary) { |
| 211 base::FilePath current_dir; | 227 base::FilePath current_dir; |
| 212 ASSERT_TRUE(PathService::Get(base::DIR_EXE, ¤t_dir)); | 228 ASSERT_TRUE(PathService::Get(base::DIR_EXE, ¤t_dir)); |
| 213 | 229 |
| 214 // Ensure that the blacklist is loaded. | 230 // Ensure that the blacklist is loaded. |
| 215 ASSERT_TRUE(TestDll_IsBlacklistInitialized()); | 231 ASSERT_TRUE(TestDll_IsBlacklistInitialized()); |
| 216 | 232 |
| 217 // Test that an un-blacklisted DLL can load correctly. | 233 // Test that an un-blacklisted DLL can load correctly. |
| 218 base::ScopedNativeLibrary dll1(current_dir.Append(kTestDllName1)); | 234 base::ScopedNativeLibrary dll1(current_dir.Append(kTestDllName1)); |
| 219 EXPECT_TRUE(dll1.is_valid()); | 235 EXPECT_TRUE(dll1.is_valid()); |
| 220 dll1.Reset(NULL); | 236 dll1.Reset(NULL); |
| 221 | 237 |
| 222 int num_blocked_dlls = 0; | 238 int num_blocked_dlls = 0; |
| 223 TestDll_SuccessfullyBlocked(NULL, &num_blocked_dlls); | 239 TestDll_SuccessfullyBlocked(NULL, &num_blocked_dlls); |
| 224 EXPECT_EQ(0, num_blocked_dlls); | 240 EXPECT_EQ(num_initially_blocked_, num_blocked_dlls); |
| 225 | 241 |
| 226 // Add all DLLs to the blacklist then check they are blocked. | 242 // Add all DLLs to the blacklist then check they are blocked. |
| 227 for (int i = 0; i < arraysize(test_data); ++i) { | 243 for (int i = 0; i < arraysize(test_data); ++i) { |
| 228 EXPECT_TRUE(TestDll_AddDllToBlacklist(test_data[i].dll_name)); | 244 EXPECT_TRUE(TestDll_AddDllToBlacklist(test_data[i].dll_name)); |
| 229 } | 245 } |
| 230 CheckBlacklistedDllsNotLoaded(); | 246 CheckBlacklistedDllsNotLoaded(); |
| 231 } | 247 } |
| 232 | 248 |
| 233 TEST_F(BlacklistTest, AddDllsFromRegistryToBlacklist) { | 249 TEST_F(BlacklistTest, AddDllsFromRegistryToBlacklist) { |
| 234 // Ensure that the blacklist is loaded. | 250 // Ensure that the blacklist is loaded. |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 327 &blacklist_state); | 343 &blacklist_state); |
| 328 EXPECT_EQ(blacklist_state, blacklist::BLACKLIST_SETUP_RUNNING); | 344 EXPECT_EQ(blacklist_state, blacklist::BLACKLIST_SETUP_RUNNING); |
| 329 | 345 |
| 330 DWORD attempt_count = blacklist::kBeaconMaxAttempts; | 346 DWORD attempt_count = blacklist::kBeaconMaxAttempts; |
| 331 blacklist_registry_key_->ReadValueDW(blacklist::kBeaconAttemptCount, | 347 blacklist_registry_key_->ReadValueDW(blacklist::kBeaconAttemptCount, |
| 332 &attempt_count); | 348 &attempt_count); |
| 333 EXPECT_EQ(static_cast<DWORD>(0), attempt_count); | 349 EXPECT_EQ(static_cast<DWORD>(0), attempt_count); |
| 334 } | 350 } |
| 335 | 351 |
| 336 } // namespace | 352 } // namespace |
| OLD | NEW |