Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(275)

Side by Side Diff: sandbox/win/src/filesystem_interception.cc

Issue 1539423002: Revert of Switch to standard integer types in sandbox/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sandbox/win/src/filesystem_dispatcher.cc ('k') | sandbox/win/src/filesystem_policy.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 22 matching lines...) Expand all
41 do { 39 do {
42 if (!ValidParameter(file, sizeof(HANDLE), WRITE)) 40 if (!ValidParameter(file, sizeof(HANDLE), WRITE))
43 break; 41 break;
44 if (!ValidParameter(io_status, sizeof(IO_STATUS_BLOCK), WRITE)) 42 if (!ValidParameter(io_status, sizeof(IO_STATUS_BLOCK), WRITE))
45 break; 43 break;
46 44
47 void* memory = GetGlobalIPCMemory(); 45 void* memory = GetGlobalIPCMemory();
48 if (NULL == memory) 46 if (NULL == memory)
49 break; 47 break;
50 48
51 uint32_t attributes = 0; 49 uint32 attributes = 0;
52 NTSTATUS ret = AllocAndCopyName(object_attributes, &name, &attributes, 50 NTSTATUS ret = AllocAndCopyName(object_attributes, &name, &attributes,
53 NULL); 51 NULL);
54 if (!NT_SUCCESS(ret) || NULL == name) 52 if (!NT_SUCCESS(ret) || NULL == name)
55 break; 53 break;
56 54
57 uint32_t desired_access_uint32 = desired_access; 55 uint32 desired_access_uint32 = desired_access;
58 uint32_t options_uint32 = options; 56 uint32 options_uint32 = options;
59 uint32_t disposition_uint32 = disposition; 57 uint32 disposition_uint32 = disposition;
60 uint32_t broker = FALSE; 58 uint32 broker = FALSE;
61 CountedParameterSet<OpenFile> params; 59 CountedParameterSet<OpenFile> params;
62 params[OpenFile::NAME] = ParamPickerMake(name); 60 params[OpenFile::NAME] = ParamPickerMake(name);
63 params[OpenFile::ACCESS] = ParamPickerMake(desired_access_uint32); 61 params[OpenFile::ACCESS] = ParamPickerMake(desired_access_uint32);
64 params[OpenFile::DISPOSITION] = ParamPickerMake(disposition_uint32); 62 params[OpenFile::DISPOSITION] = ParamPickerMake(disposition_uint32);
65 params[OpenFile::OPTIONS] = ParamPickerMake(options_uint32); 63 params[OpenFile::OPTIONS] = ParamPickerMake(options_uint32);
66 params[OpenFile::BROKER] = ParamPickerMake(broker); 64 params[OpenFile::BROKER] = ParamPickerMake(broker);
67 65
68 if (!QueryBroker(IPC_NTCREATEFILE_TAG, params.GetBase())) 66 if (!QueryBroker(IPC_NTCREATEFILE_TAG, params.GetBase()))
69 break; 67 break;
70 68
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 do { 115 do {
118 if (!ValidParameter(file, sizeof(HANDLE), WRITE)) 116 if (!ValidParameter(file, sizeof(HANDLE), WRITE))
119 break; 117 break;
120 if (!ValidParameter(io_status, sizeof(IO_STATUS_BLOCK), WRITE)) 118 if (!ValidParameter(io_status, sizeof(IO_STATUS_BLOCK), WRITE))
121 break; 119 break;
122 120
123 void* memory = GetGlobalIPCMemory(); 121 void* memory = GetGlobalIPCMemory();
124 if (NULL == memory) 122 if (NULL == memory)
125 break; 123 break;
126 124
127 uint32_t attributes; 125 uint32 attributes;
128 NTSTATUS ret = AllocAndCopyName(object_attributes, &name, &attributes, 126 NTSTATUS ret = AllocAndCopyName(object_attributes, &name, &attributes,
129 NULL); 127 NULL);
130 if (!NT_SUCCESS(ret) || NULL == name) 128 if (!NT_SUCCESS(ret) || NULL == name)
131 break; 129 break;
132 130
133 uint32_t desired_access_uint32 = desired_access; 131 uint32 desired_access_uint32 = desired_access;
134 uint32_t options_uint32 = options; 132 uint32 options_uint32 = options;
135 uint32_t disposition_uint32 = FILE_OPEN; 133 uint32 disposition_uint32 = FILE_OPEN;
136 uint32_t broker = FALSE; 134 uint32 broker = FALSE;
137 CountedParameterSet<OpenFile> params; 135 CountedParameterSet<OpenFile> params;
138 params[OpenFile::NAME] = ParamPickerMake(name); 136 params[OpenFile::NAME] = ParamPickerMake(name);
139 params[OpenFile::ACCESS] = ParamPickerMake(desired_access_uint32); 137 params[OpenFile::ACCESS] = ParamPickerMake(desired_access_uint32);
140 params[OpenFile::DISPOSITION] = ParamPickerMake(disposition_uint32); 138 params[OpenFile::DISPOSITION] = ParamPickerMake(disposition_uint32);
141 params[OpenFile::OPTIONS] = ParamPickerMake(options_uint32); 139 params[OpenFile::OPTIONS] = ParamPickerMake(options_uint32);
142 params[OpenFile::BROKER] = ParamPickerMake(broker); 140 params[OpenFile::BROKER] = ParamPickerMake(broker);
143 141
144 if (!QueryBroker(IPC_NTOPENFILE_TAG, params.GetBase())) 142 if (!QueryBroker(IPC_NTOPENFILE_TAG, params.GetBase()))
145 break; 143 break;
146 144
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 185
188 wchar_t* name = NULL; 186 wchar_t* name = NULL;
189 do { 187 do {
190 if (!ValidParameter(file_attributes, sizeof(FILE_BASIC_INFORMATION), WRITE)) 188 if (!ValidParameter(file_attributes, sizeof(FILE_BASIC_INFORMATION), WRITE))
191 break; 189 break;
192 190
193 void* memory = GetGlobalIPCMemory(); 191 void* memory = GetGlobalIPCMemory();
194 if (NULL == memory) 192 if (NULL == memory)
195 break; 193 break;
196 194
197 uint32_t attributes = 0; 195 uint32 attributes = 0;
198 NTSTATUS ret = AllocAndCopyName(object_attributes, &name, &attributes, 196 NTSTATUS ret = AllocAndCopyName(object_attributes, &name, &attributes,
199 NULL); 197 NULL);
200 if (!NT_SUCCESS(ret) || NULL == name) 198 if (!NT_SUCCESS(ret) || NULL == name)
201 break; 199 break;
202 200
203 InOutCountedBuffer file_info(file_attributes, 201 InOutCountedBuffer file_info(file_attributes,
204 sizeof(FILE_BASIC_INFORMATION)); 202 sizeof(FILE_BASIC_INFORMATION));
205 203
206 uint32_t broker = FALSE; 204 uint32 broker = FALSE;
207 CountedParameterSet<FileName> params; 205 CountedParameterSet<FileName> params;
208 params[FileName::NAME] = ParamPickerMake(name); 206 params[FileName::NAME] = ParamPickerMake(name);
209 params[FileName::BROKER] = ParamPickerMake(broker); 207 params[FileName::BROKER] = ParamPickerMake(broker);
210 208
211 if (!QueryBroker(IPC_NTQUERYATTRIBUTESFILE_TAG, params.GetBase())) 209 if (!QueryBroker(IPC_NTQUERYATTRIBUTESFILE_TAG, params.GetBase()))
212 break; 210 break;
213 211
214 SharedMemIPCClient ipc(memory); 212 SharedMemIPCClient ipc(memory);
215 CrossCallReturn answer = {0}; 213 CrossCallReturn answer = {0};
216 ResultCode code = CrossCall(ipc, IPC_NTQUERYATTRIBUTESFILE_TAG, name, 214 ResultCode code = CrossCall(ipc, IPC_NTQUERYATTRIBUTESFILE_TAG, name,
(...skipping 29 matching lines...) Expand all
246 wchar_t* name = NULL; 244 wchar_t* name = NULL;
247 do { 245 do {
248 if (!ValidParameter(file_attributes, sizeof(FILE_NETWORK_OPEN_INFORMATION), 246 if (!ValidParameter(file_attributes, sizeof(FILE_NETWORK_OPEN_INFORMATION),
249 WRITE)) 247 WRITE))
250 break; 248 break;
251 249
252 void* memory = GetGlobalIPCMemory(); 250 void* memory = GetGlobalIPCMemory();
253 if (NULL == memory) 251 if (NULL == memory)
254 break; 252 break;
255 253
256 uint32_t attributes = 0; 254 uint32 attributes = 0;
257 NTSTATUS ret = AllocAndCopyName(object_attributes, &name, &attributes, 255 NTSTATUS ret = AllocAndCopyName(object_attributes, &name, &attributes,
258 NULL); 256 NULL);
259 if (!NT_SUCCESS(ret) || NULL == name) 257 if (!NT_SUCCESS(ret) || NULL == name)
260 break; 258 break;
261 259
262 InOutCountedBuffer file_info(file_attributes, 260 InOutCountedBuffer file_info(file_attributes,
263 sizeof(FILE_NETWORK_OPEN_INFORMATION)); 261 sizeof(FILE_NETWORK_OPEN_INFORMATION));
264 262
265 uint32_t broker = FALSE; 263 uint32 broker = FALSE;
266 CountedParameterSet<FileName> params; 264 CountedParameterSet<FileName> params;
267 params[FileName::NAME] = ParamPickerMake(name); 265 params[FileName::NAME] = ParamPickerMake(name);
268 params[FileName::BROKER] = ParamPickerMake(broker); 266 params[FileName::BROKER] = ParamPickerMake(broker);
269 267
270 if (!QueryBroker(IPC_NTQUERYFULLATTRIBUTESFILE_TAG, params.GetBase())) 268 if (!QueryBroker(IPC_NTQUERYFULLATTRIBUTESFILE_TAG, params.GetBase()))
271 break; 269 break;
272 270
273 SharedMemIPCClient ipc(memory); 271 SharedMemIPCClient ipc(memory);
274 CrossCallReturn answer = {0}; 272 CrossCallReturn answer = {0};
275 ResultCode code = CrossCall(ipc, IPC_NTQUERYFULLATTRIBUTESFILE_TAG, name, 273 ResultCode code = CrossCall(ipc, IPC_NTQUERYFULLATTRIBUTESFILE_TAG, name,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 object_name.Length = object_name.MaximumLength = 326 object_name.Length = object_name.MaximumLength =
329 static_cast<USHORT>(file_rename_info->FileNameLength); 327 static_cast<USHORT>(file_rename_info->FileNameLength);
330 } __except(EXCEPTION_EXECUTE_HANDLER) { 328 } __except(EXCEPTION_EXECUTE_HANDLER) {
331 break; 329 break;
332 } 330 }
333 331
334 NTSTATUS ret = AllocAndCopyName(&object_attributes, &name, NULL, NULL); 332 NTSTATUS ret = AllocAndCopyName(&object_attributes, &name, NULL, NULL);
335 if (!NT_SUCCESS(ret) || !name) 333 if (!NT_SUCCESS(ret) || !name)
336 break; 334 break;
337 335
338 uint32_t broker = FALSE; 336 uint32 broker = FALSE;
339 CountedParameterSet<FileName> params; 337 CountedParameterSet<FileName> params;
340 params[FileName::NAME] = ParamPickerMake(name); 338 params[FileName::NAME] = ParamPickerMake(name);
341 params[FileName::BROKER] = ParamPickerMake(broker); 339 params[FileName::BROKER] = ParamPickerMake(broker);
342 340
343 if (!QueryBroker(IPC_NTSETINFO_RENAME_TAG, params.GetBase())) 341 if (!QueryBroker(IPC_NTSETINFO_RENAME_TAG, params.GetBase()))
344 break; 342 break;
345 343
346 InOutCountedBuffer io_status_buffer(io_status, sizeof(IO_STATUS_BLOCK)); 344 InOutCountedBuffer io_status_buffer(io_status, sizeof(IO_STATUS_BLOCK));
347 // This is actually not an InOut buffer, only In, but using InOut facility 345 // This is actually not an InOut buffer, only In, but using InOut facility
348 // really helps to simplify the code. 346 // really helps to simplify the code.
(...skipping 11 matching lines...) Expand all
360 status = answer.nt_status; 358 status = answer.nt_status;
361 } while (false); 359 } while (false);
362 360
363 if (name) 361 if (name)
364 operator delete(name, NT_ALLOC); 362 operator delete(name, NT_ALLOC);
365 363
366 return status; 364 return status;
367 } 365 }
368 366
369 } // namespace sandbox 367 } // namespace sandbox
OLDNEW
« no previous file with comments | « sandbox/win/src/filesystem_dispatcher.cc ('k') | sandbox/win/src/filesystem_policy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698