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