OLD | NEW |
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 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 } while (false); | 462 } while (false); |
463 } __except(EXCEPTION_EXECUTE_HANDLER) { | 463 } __except(EXCEPTION_EXECUTE_HANDLER) { |
464 } | 464 } |
465 | 465 |
466 return out_name; | 466 return out_name; |
467 #pragma warning(pop) | 467 #pragma warning(pop) |
468 } | 468 } |
469 | 469 |
470 UNICODE_STRING* GetBackingFilePath(PVOID address) { | 470 UNICODE_STRING* GetBackingFilePath(PVOID address) { |
471 // We'll start with something close to max_path charactes for the name. | 471 // We'll start with something close to max_path charactes for the name. |
472 ULONG buffer_bytes = MAX_PATH * 2; | 472 SIZE_T buffer_bytes = MAX_PATH * 2; |
473 | 473 |
474 for (;;) { | 474 for (;;) { |
475 MEMORY_SECTION_NAME* section_name = reinterpret_cast<MEMORY_SECTION_NAME*>( | 475 MEMORY_SECTION_NAME* section_name = reinterpret_cast<MEMORY_SECTION_NAME*>( |
476 new(NT_ALLOC) char[buffer_bytes]); | 476 new(NT_ALLOC) char[buffer_bytes]); |
477 | 477 |
478 if (!section_name) | 478 if (!section_name) |
479 return NULL; | 479 return NULL; |
480 | 480 |
481 ULONG returned_bytes; | 481 SIZE_T returned_bytes; |
482 NTSTATUS ret = g_nt.QueryVirtualMemory(NtCurrentProcess, address, | 482 NTSTATUS ret = g_nt.QueryVirtualMemory(NtCurrentProcess, address, |
483 MemorySectionName, section_name, | 483 MemorySectionName, section_name, |
484 buffer_bytes, &returned_bytes); | 484 buffer_bytes, &returned_bytes); |
485 | 485 |
486 if (STATUS_BUFFER_OVERFLOW == ret) { | 486 if (STATUS_BUFFER_OVERFLOW == ret) { |
487 // Retry the call with the given buffer size. | 487 // Retry the call with the given buffer size. |
488 operator delete(section_name, NT_ALLOC); | 488 operator delete(section_name, NT_ALLOC); |
489 section_name = NULL; | 489 section_name = NULL; |
490 buffer_bytes = returned_bytes; | 490 buffer_bytes = returned_bytes; |
491 continue; | 491 continue; |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
670 UNREFERENCED_PARAMETER(type); | 670 UNREFERENCED_PARAMETER(type); |
671 return buffer; | 671 return buffer; |
672 } | 672 } |
673 | 673 |
674 void __cdecl operator delete(void* memory, void* buffer, | 674 void __cdecl operator delete(void* memory, void* buffer, |
675 sandbox::AllocationType type) { | 675 sandbox::AllocationType type) { |
676 UNREFERENCED_PARAMETER(memory); | 676 UNREFERENCED_PARAMETER(memory); |
677 UNREFERENCED_PARAMETER(buffer); | 677 UNREFERENCED_PARAMETER(buffer); |
678 UNREFERENCED_PARAMETER(type); | 678 UNREFERENCED_PARAMETER(type); |
679 } | 679 } |
OLD | NEW |