| 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 "chrome_elf/blacklist/blacklist.h" | 5 #include "chrome_elf/blacklist/blacklist.h" |
| 6 | 6 |
| 7 #include <assert.h> | 7 #include <assert.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 #if defined(_WIN64) | 96 #if defined(_WIN64) |
| 97 // Allocate storage for the pointer to the old NtMapViewOfSectionFunction. | 97 // Allocate storage for the pointer to the old NtMapViewOfSectionFunction. |
| 98 #pragma section(".oldntmap", write, read) | 98 #pragma section(".oldntmap", write, read) |
| 99 __declspec(allocate(".oldntmap")) | 99 __declspec(allocate(".oldntmap")) |
| 100 NtMapViewOfSectionFunction g_nt_map_view_of_section_func = NULL; | 100 NtMapViewOfSectionFunction g_nt_map_view_of_section_func = NULL; |
| 101 #endif | 101 #endif |
| 102 | 102 |
| 103 bool LeaveSetupBeacon() { | 103 bool LeaveSetupBeacon() { |
| 104 HANDLE key_handle = INVALID_HANDLE_VALUE; | 104 HANDLE key_handle = INVALID_HANDLE_VALUE; |
| 105 | 105 |
| 106 if (!nt::CreateRegKey(nt::HKCU, kRegistryBeaconPath, | 106 if (!nt::CreateRegKey(nt::HKCU, |
| 107 install_static::GetRegistryPath() |
| 108 .append(kRegistryBeaconKeyName) |
| 109 .c_str(), |
| 107 KEY_QUERY_VALUE | KEY_SET_VALUE, &key_handle)) | 110 KEY_QUERY_VALUE | KEY_SET_VALUE, &key_handle)) |
| 108 return false; | 111 return false; |
| 109 | 112 |
| 110 DWORD blacklist_state = BLACKLIST_STATE_MAX; | 113 DWORD blacklist_state = BLACKLIST_STATE_MAX; |
| 111 if (!nt::QueryRegValueDWORD(key_handle, kBeaconState, &blacklist_state) || | 114 if (!nt::QueryRegValueDWORD(key_handle, kBeaconState, &blacklist_state) || |
| 112 blacklist_state == BLACKLIST_DISABLED) { | 115 blacklist_state == BLACKLIST_DISABLED) { |
| 113 nt::CloseRegKey(key_handle); | 116 nt::CloseRegKey(key_handle); |
| 114 return false; | 117 return false; |
| 115 } | 118 } |
| 116 | 119 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 145 } | 148 } |
| 146 } | 149 } |
| 147 | 150 |
| 148 nt::CloseRegKey(key_handle); | 151 nt::CloseRegKey(key_handle); |
| 149 return success; | 152 return success; |
| 150 } | 153 } |
| 151 | 154 |
| 152 bool ResetBeacon() { | 155 bool ResetBeacon() { |
| 153 HANDLE key_handle = INVALID_HANDLE_VALUE; | 156 HANDLE key_handle = INVALID_HANDLE_VALUE; |
| 154 | 157 |
| 155 if (!nt::CreateRegKey(nt::HKCU, kRegistryBeaconPath, | 158 if (!nt::CreateRegKey(nt::HKCU, |
| 159 install_static::GetRegistryPath() |
| 160 .append(kRegistryBeaconKeyName) |
| 161 .c_str(), |
| 156 KEY_QUERY_VALUE | KEY_SET_VALUE, &key_handle)) | 162 KEY_QUERY_VALUE | KEY_SET_VALUE, &key_handle)) |
| 157 return false; | 163 return false; |
| 158 | 164 |
| 159 DWORD blacklist_state = BLACKLIST_STATE_MAX; | 165 DWORD blacklist_state = BLACKLIST_STATE_MAX; |
| 160 if (!nt::QueryRegValueDWORD(key_handle, kBeaconState, &blacklist_state)) { | 166 if (!nt::QueryRegValueDWORD(key_handle, kBeaconState, &blacklist_state)) { |
| 161 nt::CloseRegKey(key_handle); | 167 nt::CloseRegKey(key_handle); |
| 162 return false; | 168 return false; |
| 163 } | 169 } |
| 164 | 170 |
| 165 // Reaching this point with the setup running state means the setup did not | 171 // Reaching this point with the setup running state means the setup did not |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 | 350 |
| 345 // Mark the thunk storage as executable and prevent any future writes to it. | 351 // Mark the thunk storage as executable and prevent any future writes to it. |
| 346 page_executable = page_executable && | 352 page_executable = page_executable && |
| 347 VirtualProtect(&g_thunk_storage, sizeof(g_thunk_storage), | 353 VirtualProtect(&g_thunk_storage, sizeof(g_thunk_storage), |
| 348 PAGE_EXECUTE_READ, &old_protect); | 354 PAGE_EXECUTE_READ, &old_protect); |
| 349 | 355 |
| 350 return NT_SUCCESS(ret) && page_executable; | 356 return NT_SUCCESS(ret) && page_executable; |
| 351 } | 357 } |
| 352 | 358 |
| 353 } // namespace blacklist | 359 } // namespace blacklist |
| OLD | NEW |