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

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

Issue 1296223005: Continuing changes for lpc proxy Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 months 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/sandbox_nt_util.h ('k') | sandbox/win/src/sandbox_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) 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 "sandbox/win/src/sandbox_nt_util.h" 5 #include "sandbox/win/src/sandbox_nt_util.h"
6 6
7 #include "base/win/pe_image.h" 7 #include "base/win/pe_image.h"
8 #include "sandbox/win/src/sandbox_factory.h" 8 #include "sandbox/win/src/sandbox_factory.h"
9 #include "sandbox/win/src/target_services.h" 9 #include "sandbox/win/src/target_services.h"
10 10
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 NTSTATUS ret = STATUS_UNSUCCESSFUL; 299 NTSTATUS ret = STATUS_UNSUCCESSFUL;
300 __try { 300 __try {
301 do { 301 do {
302 if (in_object->RootDirectory != static_cast<HANDLE>(0) && !root) 302 if (in_object->RootDirectory != static_cast<HANDLE>(0) && !root)
303 break; 303 break;
304 if (NULL == in_object->ObjectName) 304 if (NULL == in_object->ObjectName)
305 break; 305 break;
306 if (NULL == in_object->ObjectName->Buffer) 306 if (NULL == in_object->ObjectName->Buffer)
307 break; 307 break;
308 308
309 size_t size = in_object->ObjectName->Length + sizeof(wchar_t); 309 ret = AllocAndCopyUnicodeString(in_object->ObjectName, out_name);
310 *out_name = new(NT_ALLOC) wchar_t[size/sizeof(wchar_t)];
311 if (NULL == *out_name)
312 break;
313
314 ret = CopyData(*out_name, in_object->ObjectName->Buffer,
315 size - sizeof(wchar_t));
316 if (!NT_SUCCESS(ret)) 310 if (!NT_SUCCESS(ret))
317 break; 311 break;
318 312
319 (*out_name)[size / sizeof(wchar_t) - 1] = L'\0';
320
321 if (attributes) 313 if (attributes)
322 *attributes = in_object->Attributes; 314 *attributes = in_object->Attributes;
323 315
324 if (root) 316 if (root)
325 *root = in_object->RootDirectory; 317 *root = in_object->RootDirectory;
326 ret = STATUS_SUCCESS; 318 ret = STATUS_SUCCESS;
327 } while (false); 319 } while (false);
328 } __except(EXCEPTION_EXECUTE_HANDLER) { 320 } __except(EXCEPTION_EXECUTE_HANDLER) {
329 ret = GetExceptionCode(); 321 ret = GetExceptionCode();
330 } 322 }
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 602
611 if (file_info->FileName[0] != kPathPrefix[0] || 603 if (file_info->FileName[0] != kPathPrefix[0] ||
612 file_info->FileName[1] != kPathPrefix[1] || 604 file_info->FileName[1] != kPathPrefix[1] ||
613 file_info->FileName[2] != kPathPrefix[2] || 605 file_info->FileName[2] != kPathPrefix[2] ||
614 file_info->FileName[3] != kPathPrefix[3]) 606 file_info->FileName[3] != kPathPrefix[3])
615 return false; 607 return false;
616 608
617 return true; 609 return true;
618 } 610 }
619 611
612 NTSTATUS AllocAndCopyUnicodeString(const UNICODE_STRING* in_string,
613 wchar_t** out_string) {
614 if (!in_string)
615 return STATUS_INVALID_PARAMETER;
616
617 size_t size = in_string->Length + sizeof(wchar_t);
618 *out_string = new(NT_ALLOC) wchar_t[size/sizeof(wchar_t)];
619 if (NULL == *out_string)
620 return STATUS_UNSUCCESSFUL;
621
622 NTSTATUS ret = CopyData(*out_string, in_string->Buffer,
623 size - sizeof(wchar_t));
624 if (!NT_SUCCESS(ret))
625 return ret;
626
627 (*out_string)[size / sizeof(wchar_t) - 1] = L'\0';
628 return STATUS_SUCCESS;
629 }
630
620 } // namespace sandbox 631 } // namespace sandbox
621 632
622 void* operator new(size_t size, sandbox::AllocationType type, 633 void* operator new(size_t size, sandbox::AllocationType type,
623 void* near_to) { 634 void* near_to) {
624 using namespace sandbox; 635 using namespace sandbox;
625 636
626 void* result = NULL; 637 void* result = NULL;
627 if (NT_ALLOC == type) { 638 if (NT_ALLOC == type) {
628 if (InitHeap()) { 639 if (InitHeap()) {
629 // Use default flags for the allocation. 640 // Use default flags for the allocation.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 UNREFERENCED_PARAMETER(type); 681 UNREFERENCED_PARAMETER(type);
671 return buffer; 682 return buffer;
672 } 683 }
673 684
674 void __cdecl operator delete(void* memory, void* buffer, 685 void __cdecl operator delete(void* memory, void* buffer,
675 sandbox::AllocationType type) { 686 sandbox::AllocationType type) {
676 UNREFERENCED_PARAMETER(memory); 687 UNREFERENCED_PARAMETER(memory);
677 UNREFERENCED_PARAMETER(buffer); 688 UNREFERENCED_PARAMETER(buffer);
678 UNREFERENCED_PARAMETER(type); 689 UNREFERENCED_PARAMETER(type);
679 } 690 }
OLDNEW
« no previous file with comments | « sandbox/win/src/sandbox_nt_util.h ('k') | sandbox/win/src/sandbox_policy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698