| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/filesystem_interception.h" | 5 #include "sandbox/win/src/filesystem_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 22 matching lines...) Expand all Loading... |
| 39 do { | 41 do { |
| 40 if (!ValidParameter(file, sizeof(HANDLE), WRITE)) | 42 if (!ValidParameter(file, sizeof(HANDLE), WRITE)) |
| 41 break; | 43 break; |
| 42 if (!ValidParameter(io_status, sizeof(IO_STATUS_BLOCK), WRITE)) | 44 if (!ValidParameter(io_status, sizeof(IO_STATUS_BLOCK), WRITE)) |
| 43 break; | 45 break; |
| 44 | 46 |
| 45 void* memory = GetGlobalIPCMemory(); | 47 void* memory = GetGlobalIPCMemory(); |
| 46 if (NULL == memory) | 48 if (NULL == memory) |
| 47 break; | 49 break; |
| 48 | 50 |
| 49 uint32 attributes = 0; | 51 uint32_t attributes = 0; |
| 50 NTSTATUS ret = AllocAndCopyName(object_attributes, &name, &attributes, | 52 NTSTATUS ret = AllocAndCopyName(object_attributes, &name, &attributes, |
| 51 NULL); | 53 NULL); |
| 52 if (!NT_SUCCESS(ret) || NULL == name) | 54 if (!NT_SUCCESS(ret) || NULL == name) |
| 53 break; | 55 break; |
| 54 | 56 |
| 55 uint32 desired_access_uint32 = desired_access; | 57 uint32_t desired_access_uint32 = desired_access; |
| 56 uint32 options_uint32 = options; | 58 uint32_t options_uint32 = options; |
| 57 uint32 disposition_uint32 = disposition; | 59 uint32_t disposition_uint32 = disposition; |
| 58 uint32 broker = FALSE; | 60 uint32_t broker = FALSE; |
| 59 CountedParameterSet<OpenFile> params; | 61 CountedParameterSet<OpenFile> params; |
| 60 params[OpenFile::NAME] = ParamPickerMake(name); | 62 params[OpenFile::NAME] = ParamPickerMake(name); |
| 61 params[OpenFile::ACCESS] = ParamPickerMake(desired_access_uint32); | 63 params[OpenFile::ACCESS] = ParamPickerMake(desired_access_uint32); |
| 62 params[OpenFile::DISPOSITION] = ParamPickerMake(disposition_uint32); | 64 params[OpenFile::DISPOSITION] = ParamPickerMake(disposition_uint32); |
| 63 params[OpenFile::OPTIONS] = ParamPickerMake(options_uint32); | 65 params[OpenFile::OPTIONS] = ParamPickerMake(options_uint32); |
| 64 params[OpenFile::BROKER] = ParamPickerMake(broker); | 66 params[OpenFile::BROKER] = ParamPickerMake(broker); |
| 65 | 67 |
| 66 if (!QueryBroker(IPC_NTCREATEFILE_TAG, params.GetBase())) | 68 if (!QueryBroker(IPC_NTCREATEFILE_TAG, params.GetBase())) |
| 67 break; | 69 break; |
| 68 | 70 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 do { | 117 do { |
| 116 if (!ValidParameter(file, sizeof(HANDLE), WRITE)) | 118 if (!ValidParameter(file, sizeof(HANDLE), WRITE)) |
| 117 break; | 119 break; |
| 118 if (!ValidParameter(io_status, sizeof(IO_STATUS_BLOCK), WRITE)) | 120 if (!ValidParameter(io_status, sizeof(IO_STATUS_BLOCK), WRITE)) |
| 119 break; | 121 break; |
| 120 | 122 |
| 121 void* memory = GetGlobalIPCMemory(); | 123 void* memory = GetGlobalIPCMemory(); |
| 122 if (NULL == memory) | 124 if (NULL == memory) |
| 123 break; | 125 break; |
| 124 | 126 |
| 125 uint32 attributes; | 127 uint32_t attributes; |
| 126 NTSTATUS ret = AllocAndCopyName(object_attributes, &name, &attributes, | 128 NTSTATUS ret = AllocAndCopyName(object_attributes, &name, &attributes, |
| 127 NULL); | 129 NULL); |
| 128 if (!NT_SUCCESS(ret) || NULL == name) | 130 if (!NT_SUCCESS(ret) || NULL == name) |
| 129 break; | 131 break; |
| 130 | 132 |
| 131 uint32 desired_access_uint32 = desired_access; | 133 uint32_t desired_access_uint32 = desired_access; |
| 132 uint32 options_uint32 = options; | 134 uint32_t options_uint32 = options; |
| 133 uint32 disposition_uint32 = FILE_OPEN; | 135 uint32_t disposition_uint32 = FILE_OPEN; |
| 134 uint32 broker = FALSE; | 136 uint32_t broker = FALSE; |
| 135 CountedParameterSet<OpenFile> params; | 137 CountedParameterSet<OpenFile> params; |
| 136 params[OpenFile::NAME] = ParamPickerMake(name); | 138 params[OpenFile::NAME] = ParamPickerMake(name); |
| 137 params[OpenFile::ACCESS] = ParamPickerMake(desired_access_uint32); | 139 params[OpenFile::ACCESS] = ParamPickerMake(desired_access_uint32); |
| 138 params[OpenFile::DISPOSITION] = ParamPickerMake(disposition_uint32); | 140 params[OpenFile::DISPOSITION] = ParamPickerMake(disposition_uint32); |
| 139 params[OpenFile::OPTIONS] = ParamPickerMake(options_uint32); | 141 params[OpenFile::OPTIONS] = ParamPickerMake(options_uint32); |
| 140 params[OpenFile::BROKER] = ParamPickerMake(broker); | 142 params[OpenFile::BROKER] = ParamPickerMake(broker); |
| 141 | 143 |
| 142 if (!QueryBroker(IPC_NTOPENFILE_TAG, params.GetBase())) | 144 if (!QueryBroker(IPC_NTOPENFILE_TAG, params.GetBase())) |
| 143 break; | 145 break; |
| 144 | 146 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 | 187 |
| 186 wchar_t* name = NULL; | 188 wchar_t* name = NULL; |
| 187 do { | 189 do { |
| 188 if (!ValidParameter(file_attributes, sizeof(FILE_BASIC_INFORMATION), WRITE)) | 190 if (!ValidParameter(file_attributes, sizeof(FILE_BASIC_INFORMATION), WRITE)) |
| 189 break; | 191 break; |
| 190 | 192 |
| 191 void* memory = GetGlobalIPCMemory(); | 193 void* memory = GetGlobalIPCMemory(); |
| 192 if (NULL == memory) | 194 if (NULL == memory) |
| 193 break; | 195 break; |
| 194 | 196 |
| 195 uint32 attributes = 0; | 197 uint32_t attributes = 0; |
| 196 NTSTATUS ret = AllocAndCopyName(object_attributes, &name, &attributes, | 198 NTSTATUS ret = AllocAndCopyName(object_attributes, &name, &attributes, |
| 197 NULL); | 199 NULL); |
| 198 if (!NT_SUCCESS(ret) || NULL == name) | 200 if (!NT_SUCCESS(ret) || NULL == name) |
| 199 break; | 201 break; |
| 200 | 202 |
| 201 InOutCountedBuffer file_info(file_attributes, | 203 InOutCountedBuffer file_info(file_attributes, |
| 202 sizeof(FILE_BASIC_INFORMATION)); | 204 sizeof(FILE_BASIC_INFORMATION)); |
| 203 | 205 |
| 204 uint32 broker = FALSE; | 206 uint32_t broker = FALSE; |
| 205 CountedParameterSet<FileName> params; | 207 CountedParameterSet<FileName> params; |
| 206 params[FileName::NAME] = ParamPickerMake(name); | 208 params[FileName::NAME] = ParamPickerMake(name); |
| 207 params[FileName::BROKER] = ParamPickerMake(broker); | 209 params[FileName::BROKER] = ParamPickerMake(broker); |
| 208 | 210 |
| 209 if (!QueryBroker(IPC_NTQUERYATTRIBUTESFILE_TAG, params.GetBase())) | 211 if (!QueryBroker(IPC_NTQUERYATTRIBUTESFILE_TAG, params.GetBase())) |
| 210 break; | 212 break; |
| 211 | 213 |
| 212 SharedMemIPCClient ipc(memory); | 214 SharedMemIPCClient ipc(memory); |
| 213 CrossCallReturn answer = {0}; | 215 CrossCallReturn answer = {0}; |
| 214 ResultCode code = CrossCall(ipc, IPC_NTQUERYATTRIBUTESFILE_TAG, name, | 216 ResultCode code = CrossCall(ipc, IPC_NTQUERYATTRIBUTESFILE_TAG, name, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 244 wchar_t* name = NULL; | 246 wchar_t* name = NULL; |
| 245 do { | 247 do { |
| 246 if (!ValidParameter(file_attributes, sizeof(FILE_NETWORK_OPEN_INFORMATION), | 248 if (!ValidParameter(file_attributes, sizeof(FILE_NETWORK_OPEN_INFORMATION), |
| 247 WRITE)) | 249 WRITE)) |
| 248 break; | 250 break; |
| 249 | 251 |
| 250 void* memory = GetGlobalIPCMemory(); | 252 void* memory = GetGlobalIPCMemory(); |
| 251 if (NULL == memory) | 253 if (NULL == memory) |
| 252 break; | 254 break; |
| 253 | 255 |
| 254 uint32 attributes = 0; | 256 uint32_t attributes = 0; |
| 255 NTSTATUS ret = AllocAndCopyName(object_attributes, &name, &attributes, | 257 NTSTATUS ret = AllocAndCopyName(object_attributes, &name, &attributes, |
| 256 NULL); | 258 NULL); |
| 257 if (!NT_SUCCESS(ret) || NULL == name) | 259 if (!NT_SUCCESS(ret) || NULL == name) |
| 258 break; | 260 break; |
| 259 | 261 |
| 260 InOutCountedBuffer file_info(file_attributes, | 262 InOutCountedBuffer file_info(file_attributes, |
| 261 sizeof(FILE_NETWORK_OPEN_INFORMATION)); | 263 sizeof(FILE_NETWORK_OPEN_INFORMATION)); |
| 262 | 264 |
| 263 uint32 broker = FALSE; | 265 uint32_t broker = FALSE; |
| 264 CountedParameterSet<FileName> params; | 266 CountedParameterSet<FileName> params; |
| 265 params[FileName::NAME] = ParamPickerMake(name); | 267 params[FileName::NAME] = ParamPickerMake(name); |
| 266 params[FileName::BROKER] = ParamPickerMake(broker); | 268 params[FileName::BROKER] = ParamPickerMake(broker); |
| 267 | 269 |
| 268 if (!QueryBroker(IPC_NTQUERYFULLATTRIBUTESFILE_TAG, params.GetBase())) | 270 if (!QueryBroker(IPC_NTQUERYFULLATTRIBUTESFILE_TAG, params.GetBase())) |
| 269 break; | 271 break; |
| 270 | 272 |
| 271 SharedMemIPCClient ipc(memory); | 273 SharedMemIPCClient ipc(memory); |
| 272 CrossCallReturn answer = {0}; | 274 CrossCallReturn answer = {0}; |
| 273 ResultCode code = CrossCall(ipc, IPC_NTQUERYFULLATTRIBUTESFILE_TAG, name, | 275 ResultCode code = CrossCall(ipc, IPC_NTQUERYFULLATTRIBUTESFILE_TAG, name, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 object_name.Length = object_name.MaximumLength = | 328 object_name.Length = object_name.MaximumLength = |
| 327 static_cast<USHORT>(file_rename_info->FileNameLength); | 329 static_cast<USHORT>(file_rename_info->FileNameLength); |
| 328 } __except(EXCEPTION_EXECUTE_HANDLER) { | 330 } __except(EXCEPTION_EXECUTE_HANDLER) { |
| 329 break; | 331 break; |
| 330 } | 332 } |
| 331 | 333 |
| 332 NTSTATUS ret = AllocAndCopyName(&object_attributes, &name, NULL, NULL); | 334 NTSTATUS ret = AllocAndCopyName(&object_attributes, &name, NULL, NULL); |
| 333 if (!NT_SUCCESS(ret) || !name) | 335 if (!NT_SUCCESS(ret) || !name) |
| 334 break; | 336 break; |
| 335 | 337 |
| 336 uint32 broker = FALSE; | 338 uint32_t broker = FALSE; |
| 337 CountedParameterSet<FileName> params; | 339 CountedParameterSet<FileName> params; |
| 338 params[FileName::NAME] = ParamPickerMake(name); | 340 params[FileName::NAME] = ParamPickerMake(name); |
| 339 params[FileName::BROKER] = ParamPickerMake(broker); | 341 params[FileName::BROKER] = ParamPickerMake(broker); |
| 340 | 342 |
| 341 if (!QueryBroker(IPC_NTSETINFO_RENAME_TAG, params.GetBase())) | 343 if (!QueryBroker(IPC_NTSETINFO_RENAME_TAG, params.GetBase())) |
| 342 break; | 344 break; |
| 343 | 345 |
| 344 InOutCountedBuffer io_status_buffer(io_status, sizeof(IO_STATUS_BLOCK)); | 346 InOutCountedBuffer io_status_buffer(io_status, sizeof(IO_STATUS_BLOCK)); |
| 345 // This is actually not an InOut buffer, only In, but using InOut facility | 347 // This is actually not an InOut buffer, only In, but using InOut facility |
| 346 // really helps to simplify the code. | 348 // really helps to simplify the code. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 358 status = answer.nt_status; | 360 status = answer.nt_status; |
| 359 } while (false); | 361 } while (false); |
| 360 | 362 |
| 361 if (name) | 363 if (name) |
| 362 operator delete(name, NT_ALLOC); | 364 operator delete(name, NT_ALLOC); |
| 363 | 365 |
| 364 return status; | 366 return status; |
| 365 } | 367 } |
| 366 | 368 |
| 367 } // namespace sandbox | 369 } // namespace sandbox |
| OLD | NEW |