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> |
11 | 11 |
12 #include "chrome/install_static/install_util.h" | 12 #include "chrome/install_static/install_util.h" |
13 #include "chrome_elf/blacklist/blacklist_interceptions.h" | 13 #include "chrome_elf/blacklist/blacklist_interceptions.h" |
14 #include "chrome_elf/chrome_elf_constants.h" | 14 #include "chrome_elf/chrome_elf_constants.h" |
15 #include "chrome_elf/hook_util/thunk_getter.h" | 15 #include "chrome_elf/hook_util/hook_util.h" |
16 #include "chrome_elf/nt_registry/nt_registry.h" | 16 #include "chrome_elf/nt_registry/nt_registry.h" |
17 #include "sandbox/win/src/interception_internal.h" | 17 #include "sandbox/win/src/interception_internal.h" |
18 #include "sandbox/win/src/internal_types.h" | 18 #include "sandbox/win/src/internal_types.h" |
19 #include "sandbox/win/src/service_resolver.h" | 19 #include "sandbox/win/src/service_resolver.h" |
20 | 20 |
21 // http://blogs.msdn.com/oldnewthing/archive/2004/10/25/247180.aspx | 21 // http://blogs.msdn.com/oldnewthing/archive/2004/10/25/247180.aspx |
22 extern "C" IMAGE_DOS_HEADER __ImageBase; | 22 extern "C" IMAGE_DOS_HEADER __ImageBase; |
23 | 23 |
24 namespace blacklist { | 24 namespace blacklist { |
25 | 25 |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 // Check to see if the blacklist beacon is still set to running (indicating a | 284 // Check to see if the blacklist beacon is still set to running (indicating a |
285 // failure) or disabled, and abort if so. | 285 // failure) or disabled, and abort if so. |
286 if (!force && !LeaveSetupBeacon()) | 286 if (!force && !LeaveSetupBeacon()) |
287 return false; | 287 return false; |
288 | 288 |
289 // It is possible for other dlls to have already patched code by now and | 289 // It is possible for other dlls to have already patched code by now and |
290 // attempting to patch their code might result in crashes. | 290 // attempting to patch their code might result in crashes. |
291 const bool kRelaxed = false; | 291 const bool kRelaxed = false; |
292 | 292 |
293 // Create a thunk via the appropriate ServiceResolver instance. | 293 // Create a thunk via the appropriate ServiceResolver instance. |
294 sandbox::ServiceResolverThunk* thunk = GetThunk(kRelaxed); | 294 sandbox::ServiceResolverThunk* thunk = elf_hook::HookSystemService(kRelaxed); |
295 | 295 |
296 // Don't try blacklisting on unsupported OS versions. | 296 // Don't try blacklisting on unsupported OS versions. |
297 if (!thunk) | 297 if (!thunk) |
298 return false; | 298 return false; |
299 | 299 |
300 BYTE* thunk_storage = reinterpret_cast<BYTE*>(&g_thunk_storage); | 300 BYTE* thunk_storage = reinterpret_cast<BYTE*>(&g_thunk_storage); |
301 | 301 |
302 // Mark the thunk storage as readable and writeable, since we | 302 // Mark the thunk storage as readable and writeable, since we |
303 // ready to write to it. | 303 // ready to write to it. |
304 DWORD old_protect = 0; | 304 DWORD old_protect = 0; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 | 344 |
345 // Mark the thunk storage as executable and prevent any future writes to it. | 345 // Mark the thunk storage as executable and prevent any future writes to it. |
346 page_executable = page_executable && | 346 page_executable = page_executable && |
347 VirtualProtect(&g_thunk_storage, sizeof(g_thunk_storage), | 347 VirtualProtect(&g_thunk_storage, sizeof(g_thunk_storage), |
348 PAGE_EXECUTE_READ, &old_protect); | 348 PAGE_EXECUTE_READ, &old_protect); |
349 | 349 |
350 return NT_SUCCESS(ret) && page_executable; | 350 return NT_SUCCESS(ret) && page_executable; |
351 } | 351 } |
352 | 352 |
353 } // namespace blacklist | 353 } // namespace blacklist |
OLD | NEW |