Skip to content

Commit

Permalink
sandbox: Fix some nt_internals.h function prototypes for Win64
Browse files Browse the repository at this point in the history
NtQuerySection should use ULONG instead of SIZE_T as it is dealing with PE section sizes.

NtQueryVirtualMemory should use SIZE_T instead of ULONG as it is dealing with memory sizes.

DynamoRIO, another project that consumes these native APIs, uses the prototypes introduced by this change.

R=robertshield@chromium.org,rvargas@chromium.org
BUG=458690

Review URL: https://codereview.chromium.org/921353002

Cr-Commit-Position: refs/heads/master@{#317177}
  • Loading branch information
rnk authored and Commit bot committed Feb 20, 2015
1 parent 638a47d commit 4ede4e1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions chrome_elf/blacklist/blacklist_interceptions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ base::string16 GetBackingModuleFilePath(PVOID address) {
DCHECK_NT(g_nt_query_virtual_memory_func);

// We'll start with something close to max_path characters for the name.
ULONG buffer_bytes = MAX_PATH * 2;
SIZE_T buffer_bytes = MAX_PATH * 2;
std::vector<BYTE> buffer_data(buffer_bytes);

for (;;) {
Expand All @@ -61,7 +61,7 @@ base::string16 GetBackingModuleFilePath(PVOID address) {
if (!section_name)
break;

ULONG returned_bytes;
SIZE_T returned_bytes;
NTSTATUS ret = g_nt_query_virtual_memory_func(
NtCurrentProcess, address, MemorySectionName, section_name,
buffer_bytes, &returned_bytes);
Expand Down Expand Up @@ -95,7 +95,7 @@ bool IsModuleValidImageSection(HANDLE section,
return false;

SECTION_BASIC_INFORMATION basic_info;
SIZE_T bytes_returned;
ULONG bytes_returned;
NTSTATUS ret = g_nt_query_section_func(section, SectionBasicInformation,
&basic_info, sizeof(basic_info),
&bytes_returned);
Expand Down
8 changes: 4 additions & 4 deletions sandbox/win/src/nt_internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,8 @@ typedef NTSTATUS (WINAPI *NtQuerySectionFunction)(
IN HANDLE SectionHandle,
IN SECTION_INFORMATION_CLASS SectionInformationClass,
OUT PVOID SectionInformation,
IN SIZE_T SectionInformationLength,
OUT PSIZE_T ReturnLength OPTIONAL);
IN ULONG SectionInformationLength,
OUT PULONG ReturnLength OPTIONAL);

// -----------------------------------------------------------------------
// Process and Thread
Expand Down Expand Up @@ -450,8 +450,8 @@ typedef NTSTATUS (WINAPI *NtQueryVirtualMemoryFunction)(
IN PVOID BaseAddress,
IN MEMORY_INFORMATION_CLASS MemoryInformationClass,
OUT PVOID MemoryInformation,
IN ULONG MemoryInformationLength,
OUT PULONG ReturnLength OPTIONAL);
IN SIZE_T MemoryInformationLength,
OUT PSIZE_T ReturnLength OPTIONAL);

typedef NTSTATUS (WINAPI *NtProtectVirtualMemoryFunction)(
IN HANDLE ProcessHandle,
Expand Down
6 changes: 3 additions & 3 deletions sandbox/win/src/sandbox_nt_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ bool IsValidImageSection(HANDLE section, PVOID *base, PLARGE_INTEGER offset,
return false;

SECTION_BASIC_INFORMATION basic_info;
SIZE_T bytes_returned;
ULONG bytes_returned;
ret = g_nt.QuerySection(query_section, SectionBasicInformation, &basic_info,
sizeof(basic_info), &bytes_returned);

Expand Down Expand Up @@ -469,7 +469,7 @@ UNICODE_STRING* GetImageInfoFromModule(HMODULE module, uint32* flags) {

UNICODE_STRING* GetBackingFilePath(PVOID address) {
// We'll start with something close to max_path charactes for the name.
ULONG buffer_bytes = MAX_PATH * 2;
SIZE_T buffer_bytes = MAX_PATH * 2;

for (;;) {
MEMORY_SECTION_NAME* section_name = reinterpret_cast<MEMORY_SECTION_NAME*>(
Expand All @@ -478,7 +478,7 @@ UNICODE_STRING* GetBackingFilePath(PVOID address) {
if (!section_name)
return NULL;

ULONG returned_bytes;
SIZE_T returned_bytes;
NTSTATUS ret = g_nt.QueryVirtualMemory(NtCurrentProcess, address,
MemorySectionName, section_name,
buffer_bytes, &returned_bytes);
Expand Down

0 comments on commit 4ede4e1

Please sign in to comment.