| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <map> | 5 #include <map> |
| 6 | 6 |
| 7 #include "sandbox/win/src/policy_broker.h" | 7 #include "sandbox/win/src/policy_broker.h" |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/win/pe_image.h" | 10 #include "base/win/pe_image.h" |
| 11 #include "base/win/windows_version.h" | 11 #include "base/win/windows_version.h" |
| 12 #include "sandbox/win/src/interception.h" | 12 #include "sandbox/win/src/interception.h" |
| 13 #include "sandbox/win/src/interceptors.h" | 13 #include "sandbox/win/src/interceptors.h" |
| 14 #include "sandbox/win/src/policy_target.h" | 14 #include "sandbox/win/src/policy_target.h" |
| 15 #include "sandbox/win/src/process_thread_interception.h" | 15 #include "sandbox/win/src/process_thread_interception.h" |
| 16 #include "sandbox/win/src/sandbox.h" | 16 #include "sandbox/win/src/sandbox.h" |
| 17 #include "sandbox/win/src/sandbox_nt_types.h" | 17 #include "sandbox/win/src/sandbox_nt_types.h" |
| 18 #include "sandbox/win/src/sandbox_types.h" | 18 #include "sandbox/win/src/sandbox_types.h" |
| 19 #include "sandbox/win/src/sandbox_utils.h" | |
| 20 #include "sandbox/win/src/target_process.h" | 19 #include "sandbox/win/src/target_process.h" |
| 21 | 20 |
| 22 // This code executes on the broker side, as a callback from the policy on the | 21 // This code executes on the broker side, as a callback from the policy on the |
| 23 // target side (the child). | 22 // target side (the child). |
| 24 | 23 |
| 25 namespace sandbox { | 24 namespace sandbox { |
| 26 | 25 |
| 27 // This is the list of all imported symbols from ntdll.dll. | 26 // This is the list of all imported symbols from ntdll.dll. |
| 28 SANDBOX_INTERCEPT NtExports g_nt; | 27 SANDBOX_INTERCEPT NtExports g_nt; |
| 29 | 28 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 40 return false | 39 return false |
| 41 | 40 |
| 42 bool SetupNtdllImports(TargetProcess *child) { | 41 bool SetupNtdllImports(TargetProcess *child) { |
| 43 HMODULE ntdll = ::GetModuleHandle(kNtdllName); | 42 HMODULE ntdll = ::GetModuleHandle(kNtdllName); |
| 44 base::win::PEImage ntdll_image(ntdll); | 43 base::win::PEImage ntdll_image(ntdll); |
| 45 | 44 |
| 46 // Bypass purify's interception. | 45 // Bypass purify's interception. |
| 47 wchar_t* loader_get = reinterpret_cast<wchar_t*>( | 46 wchar_t* loader_get = reinterpret_cast<wchar_t*>( |
| 48 ntdll_image.GetProcAddress("LdrGetDllHandle")); | 47 ntdll_image.GetProcAddress("LdrGetDllHandle")); |
| 49 if (loader_get) { | 48 if (loader_get) { |
| 50 GetModuleHandleHelper(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | | 49 GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | |
| 51 GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, | 50 GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, |
| 52 loader_get, &ntdll); | 51 loader_get, &ntdll); |
| 53 } | 52 } |
| 54 | 53 |
| 55 INIT_GLOBAL_NT(AllocateVirtualMemory); | 54 INIT_GLOBAL_NT(AllocateVirtualMemory); |
| 56 INIT_GLOBAL_NT(Close); | 55 INIT_GLOBAL_NT(Close); |
| 57 INIT_GLOBAL_NT(DuplicateObject); | 56 INIT_GLOBAL_NT(DuplicateObject); |
| 58 INIT_GLOBAL_NT(FreeVirtualMemory); | 57 INIT_GLOBAL_NT(FreeVirtualMemory); |
| 59 INIT_GLOBAL_NT(MapViewOfSection); | 58 INIT_GLOBAL_NT(MapViewOfSection); |
| 60 INIT_GLOBAL_NT(ProtectVirtualMemory); | 59 INIT_GLOBAL_NT(ProtectVirtualMemory); |
| 61 INIT_GLOBAL_NT(QueryInformationProcess); | 60 INIT_GLOBAL_NT(QueryInformationProcess); |
| 62 INIT_GLOBAL_NT(QueryObject); | 61 INIT_GLOBAL_NT(QueryObject); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 return false; | 106 return false; |
| 108 | 107 |
| 109 return INTERCEPT_NT(manager, NtOpenThreadTokenEx, OPEN_THREAD_TOKEN_EX_ID, | 108 return INTERCEPT_NT(manager, NtOpenThreadTokenEx, OPEN_THREAD_TOKEN_EX_ID, |
| 110 24); | 109 24); |
| 111 } | 110 } |
| 112 | 111 |
| 113 return true; | 112 return true; |
| 114 } | 113 } |
| 115 | 114 |
| 116 } // namespace sandbox | 115 } // namespace sandbox |
| OLD | NEW |