| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "sandbox/win/src/process_thread_interception.h" | 5 #include "sandbox/win/src/process_thread_interception.h" |
| 6 | 6 |
| 7 #include <stdint.h> | |
| 8 | |
| 9 #include "sandbox/win/src/crosscall_client.h" | 7 #include "sandbox/win/src/crosscall_client.h" |
| 10 #include "sandbox/win/src/ipc_tags.h" | 8 #include "sandbox/win/src/ipc_tags.h" |
| 11 #include "sandbox/win/src/policy_params.h" | 9 #include "sandbox/win/src/policy_params.h" |
| 12 #include "sandbox/win/src/policy_target.h" | 10 #include "sandbox/win/src/policy_target.h" |
| 13 #include "sandbox/win/src/sandbox_factory.h" | 11 #include "sandbox/win/src/sandbox_factory.h" |
| 14 #include "sandbox/win/src/sandbox_nt_util.h" | 12 #include "sandbox/win/src/sandbox_nt_util.h" |
| 15 #include "sandbox/win/src/sharedmem_ipc_client.h" | 13 #include "sandbox/win/src/sharedmem_ipc_client.h" |
| 16 #include "sandbox/win/src/target_services.h" | 14 #include "sandbox/win/src/target_services.h" |
| 17 | 15 |
| 18 namespace sandbox { | 16 namespace sandbox { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 29 client_id); | 27 client_id); |
| 30 if (NT_SUCCESS(status)) | 28 if (NT_SUCCESS(status)) |
| 31 return status; | 29 return status; |
| 32 | 30 |
| 33 do { | 31 do { |
| 34 if (!SandboxFactory::GetTargetServices()->GetState()->InitCalled()) | 32 if (!SandboxFactory::GetTargetServices()->GetState()->InitCalled()) |
| 35 break; | 33 break; |
| 36 if (!client_id) | 34 if (!client_id) |
| 37 break; | 35 break; |
| 38 | 36 |
| 39 uint32_t thread_id = 0; | 37 uint32 thread_id = 0; |
| 40 bool should_break = false; | 38 bool should_break = false; |
| 41 __try { | 39 __try { |
| 42 // We support only the calls for the current process | 40 // We support only the calls for the current process |
| 43 if (NULL != client_id->UniqueProcess) | 41 if (NULL != client_id->UniqueProcess) |
| 44 should_break = true; | 42 should_break = true; |
| 45 | 43 |
| 46 // Object attributes should be NULL or empty. | 44 // Object attributes should be NULL or empty. |
| 47 if (!should_break && NULL != object_attributes) { | 45 if (!should_break && NULL != object_attributes) { |
| 48 if (0 != object_attributes->Attributes || | 46 if (0 != object_attributes->Attributes || |
| 49 NULL != object_attributes->ObjectName || | 47 NULL != object_attributes->ObjectName || |
| 50 NULL != object_attributes->RootDirectory || | 48 NULL != object_attributes->RootDirectory || |
| 51 NULL != object_attributes->SecurityDescriptor || | 49 NULL != object_attributes->SecurityDescriptor || |
| 52 NULL != object_attributes->SecurityQualityOfService) { | 50 NULL != object_attributes->SecurityQualityOfService) { |
| 53 should_break = true; | 51 should_break = true; |
| 54 } | 52 } |
| 55 } | 53 } |
| 56 | 54 |
| 57 thread_id = static_cast<uint32_t>( | 55 thread_id = static_cast<uint32>( |
| 58 reinterpret_cast<ULONG_PTR>(client_id->UniqueThread)); | 56 reinterpret_cast<ULONG_PTR>(client_id->UniqueThread)); |
| 59 } __except(EXCEPTION_EXECUTE_HANDLER) { | 57 } __except(EXCEPTION_EXECUTE_HANDLER) { |
| 60 break; | 58 break; |
| 61 } | 59 } |
| 62 | 60 |
| 63 if (should_break) | 61 if (should_break) |
| 64 break; | 62 break; |
| 65 | 63 |
| 66 if (!ValidParameter(thread, sizeof(HANDLE), WRITE)) | 64 if (!ValidParameter(thread, sizeof(HANDLE), WRITE)) |
| 67 break; | 65 break; |
| 68 | 66 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 client_id); | 109 client_id); |
| 112 if (NT_SUCCESS(status)) | 110 if (NT_SUCCESS(status)) |
| 113 return status; | 111 return status; |
| 114 | 112 |
| 115 do { | 113 do { |
| 116 if (!SandboxFactory::GetTargetServices()->GetState()->InitCalled()) | 114 if (!SandboxFactory::GetTargetServices()->GetState()->InitCalled()) |
| 117 break; | 115 break; |
| 118 if (!client_id) | 116 if (!client_id) |
| 119 break; | 117 break; |
| 120 | 118 |
| 121 uint32_t process_id = 0; | 119 uint32 process_id = 0; |
| 122 bool should_break = false; | 120 bool should_break = false; |
| 123 __try { | 121 __try { |
| 124 // Object attributes should be NULL or empty. | 122 // Object attributes should be NULL or empty. |
| 125 if (!should_break && NULL != object_attributes) { | 123 if (!should_break && NULL != object_attributes) { |
| 126 if (0 != object_attributes->Attributes || | 124 if (0 != object_attributes->Attributes || |
| 127 NULL != object_attributes->ObjectName || | 125 NULL != object_attributes->ObjectName || |
| 128 NULL != object_attributes->RootDirectory || | 126 NULL != object_attributes->RootDirectory || |
| 129 NULL != object_attributes->SecurityDescriptor || | 127 NULL != object_attributes->SecurityDescriptor || |
| 130 NULL != object_attributes->SecurityQualityOfService) { | 128 NULL != object_attributes->SecurityQualityOfService) { |
| 131 should_break = true; | 129 should_break = true; |
| 132 } | 130 } |
| 133 } | 131 } |
| 134 | 132 |
| 135 process_id = static_cast<uint32_t>( | 133 process_id = static_cast<uint32>( |
| 136 reinterpret_cast<ULONG_PTR>(client_id->UniqueProcess)); | 134 reinterpret_cast<ULONG_PTR>(client_id->UniqueProcess)); |
| 137 } __except(EXCEPTION_EXECUTE_HANDLER) { | 135 } __except(EXCEPTION_EXECUTE_HANDLER) { |
| 138 break; | 136 break; |
| 139 } | 137 } |
| 140 | 138 |
| 141 if (should_break) | 139 if (should_break) |
| 142 break; | 140 break; |
| 143 | 141 |
| 144 if (!ValidParameter(process, sizeof(HANDLE), WRITE)) | 142 if (!ValidParameter(process, sizeof(HANDLE), WRITE)) |
| 145 break; | 143 break; |
| 146 | 144 |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 return FALSE; | 399 return FALSE; |
| 402 | 400 |
| 403 return TRUE; | 401 return TRUE; |
| 404 } while (false); | 402 } while (false); |
| 405 | 403 |
| 406 ::SetLastError(original_error); | 404 ::SetLastError(original_error); |
| 407 return FALSE; | 405 return FALSE; |
| 408 } | 406 } |
| 409 | 407 |
| 410 } // namespace sandbox | 408 } // namespace sandbox |
| OLD | NEW |