Alexandre Julliard : ntdll: NtQuerySection takes SIZE_T parameters.
Alexandre Julliard
julliard at winehq.org
Thu Dec 28 15:18:28 CST 2017
Module: wine
Branch: master
Commit: d108ff79d5550051357ec4a8609a56a63a68b9d0
URL: https://source.winehq.org/git/wine.git/?a=commit;h=d108ff79d5550051357ec4a8609a56a63a68b9d0
Author: Alexandre Julliard <julliard at winehq.org>
Date: Thu Dec 28 13:04:20 2017 +0100
ntdll: NtQuerySection takes SIZE_T parameters.
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/kernel32/tests/loader.c | 10 +++++-----
dlls/kernel32/tests/virtual.c | 22 +++++++++++++++-------
dlls/ntdll/virtual.c | 2 +-
include/winternl.h | 2 +-
4 files changed, 22 insertions(+), 14 deletions(-)
diff --git a/dlls/kernel32/tests/loader.c b/dlls/kernel32/tests/loader.c
index 1ee6210..7267fad 100644
--- a/dlls/kernel32/tests/loader.c
+++ b/dlls/kernel32/tests/loader.c
@@ -52,7 +52,7 @@ static DWORD page_size;
static NTSTATUS (WINAPI *pNtCreateSection)(HANDLE *, ACCESS_MASK, const OBJECT_ATTRIBUTES *,
const LARGE_INTEGER *, ULONG, ULONG, HANDLE );
-static NTSTATUS (WINAPI *pNtQuerySection)(HANDLE, SECTION_INFORMATION_CLASS, void *, ULONG, ULONG *);
+static NTSTATUS (WINAPI *pNtQuerySection)(HANDLE, SECTION_INFORMATION_CLASS, void *, SIZE_T, SIZE_T *);
static NTSTATUS (WINAPI *pNtMapViewOfSection)(HANDLE, HANDLE, PVOID *, ULONG, SIZE_T, const LARGE_INTEGER *, SIZE_T *, ULONG, ULONG, ULONG);
static NTSTATUS (WINAPI *pNtUnmapViewOfSection)(HANDLE, PVOID);
static NTSTATUS (WINAPI *pNtQueryInformationProcess)(HANDLE, PROCESSINFOCLASS, PVOID, ULONG, PULONG);
@@ -239,7 +239,7 @@ static BOOL query_image_section( int id, const char *dll_name, const IMAGE_NT_HE
{
SECTION_BASIC_INFORMATION info;
SECTION_IMAGE_INFORMATION image;
- ULONG info_size = 0xdeadbeef;
+ SIZE_T info_size = (SIZE_T)0xdeadbeef << 16;
NTSTATUS status;
HANDLE file, mapping;
ULONG file_size;
@@ -265,7 +265,7 @@ static BOOL query_image_section( int id, const char *dll_name, const IMAGE_NT_HE
}
status = pNtQuerySection( mapping, SectionImageInformation, &image, sizeof(image), &info_size );
ok( !status, "%u: NtQuerySection failed err %x\n", id, status );
- ok( info_size == sizeof(image), "%u: NtQuerySection wrong size %u\n", id, info_size );
+ ok( info_size == sizeof(image), "%u: NtQuerySection wrong size %lu\n", id, info_size );
if (nt_header->OptionalHeader.Magic == (sizeof(void *) > sizeof(int) ? IMAGE_NT_OPTIONAL_HDR64_MAGIC
: IMAGE_NT_OPTIONAL_HDR32_MAGIC))
{
@@ -405,10 +405,10 @@ static NTSTATUS map_image_section( const IMAGE_NT_HEADERS *nt_header, int line )
if (!status)
{
SECTION_BASIC_INFORMATION info;
- ULONG info_size = 0xdeadbeef;
+ SIZE_T info_size = 0xdeadbeef;
NTSTATUS ret = pNtQuerySection( map, SectionBasicInformation, &info, sizeof(info), &info_size );
ok( !ret, "NtQuerySection failed err %x\n", ret );
- ok( info_size == sizeof(info), "NtQuerySection wrong size %u\n", info_size );
+ ok( info_size == sizeof(info), "NtQuerySection wrong size %lu\n", info_size );
ok( info.Attributes == (SEC_IMAGE | SEC_FILE), "NtQuerySection wrong attr %x\n", info.Attributes );
ok( info.BaseAddress == NULL, "NtQuerySection wrong base %p\n", info.BaseAddress );
ok( info.Size.QuadPart == file_size, "NtQuerySection wrong size %x%08x / %08x\n",
diff --git a/dlls/kernel32/tests/virtual.c b/dlls/kernel32/tests/virtual.c
index b1424c6..4a449fd 100644
--- a/dlls/kernel32/tests/virtual.c
+++ b/dlls/kernel32/tests/virtual.c
@@ -46,7 +46,7 @@ static NTSTATUS (WINAPI *pNtCreateSection)(HANDLE *, ACCESS_MASK, const OBJECT_A
const LARGE_INTEGER *, ULONG, ULONG, HANDLE );
static NTSTATUS (WINAPI *pNtMapViewOfSection)(HANDLE, HANDLE, PVOID *, ULONG, SIZE_T, const LARGE_INTEGER *, SIZE_T *, ULONG, ULONG, ULONG);
static DWORD (WINAPI *pNtUnmapViewOfSection)(HANDLE, PVOID);
-static NTSTATUS (WINAPI *pNtQuerySection)(HANDLE, SECTION_INFORMATION_CLASS, void *, ULONG, ULONG *);
+static NTSTATUS (WINAPI *pNtQuerySection)(HANDLE, SECTION_INFORMATION_CLASS, void *, SIZE_T, SIZE_T *);
static PVOID (WINAPI *pRtlAddVectoredExceptionHandler)(ULONG, PVECTORED_EXCEPTION_HANDLER);
static ULONG (WINAPI *pRtlRemoveVectoredExceptionHandler)(PVOID);
static BOOL (WINAPI *pGetProcessDEPPolicy)(HANDLE, LPDWORD, PBOOL);
@@ -502,7 +502,7 @@ static void test_MapViewOfFile(void)
BOOL ret;
SIZE_T size;
NTSTATUS status;
- ULONG info_size;
+ SIZE_T info_size;
LARGE_INTEGER map_size;
SetLastError(0xdeadbeef);
@@ -722,10 +722,11 @@ static void test_MapViewOfFile(void)
CloseHandle( mapping );
mapping = OpenFileMappingA( FILE_MAP_READ | SECTION_QUERY, FALSE, name );
ok( mapping != 0, "OpenFileMapping FILE_MAP_READ error %u\n", GetLastError() );
+ info_size = (SIZE_T)0xdeadbeef << 16;
status = pNtQuerySection( mapping, SectionBasicInformation, §ion_info,
sizeof(section_info), &info_size );
ok( !status, "NtQuerySection failed err %x\n", status );
- ok( info_size == sizeof(section_info), "NtQuerySection wrong size %u\n", info_size );
+ ok( info_size == sizeof(section_info), "NtQuerySection wrong size %lu\n", info_size );
ok( section_info.Attributes == SEC_COMMIT, "NtQuerySection wrong attr %08x\n",
section_info.Attributes );
ok( section_info.BaseAddress == NULL, "NtQuerySection wrong base %p\n", section_info.BaseAddress );
@@ -764,7 +765,7 @@ static void test_MapViewOfFile(void)
status = pNtQuerySection( mapping, SectionBasicInformation, §ion_info,
sizeof(section_info), &info_size );
ok( !status, "NtQuerySection failed err %x\n", status );
- ok( info_size == sizeof(section_info), "NtQuerySection wrong size %u\n", info_size );
+ ok( info_size == sizeof(section_info), "NtQuerySection wrong size %lu\n", info_size );
ok( section_info.Attributes == SEC_COMMIT, "NtQuerySection wrong attr %08x\n",
section_info.Attributes );
ok( section_info.BaseAddress == NULL, "NtQuerySection wrong base %p\n", section_info.BaseAddress );
@@ -1070,7 +1071,7 @@ static void test_MapViewOfFile(void)
status = pNtQuerySection( mapping, SectionBasicInformation, §ion_info,
sizeof(section_info), &info_size );
ok( !status, "NtQuerySection failed err %x\n", status );
- ok( info_size == sizeof(section_info), "NtQuerySection wrong size %u\n", info_size );
+ ok( info_size == sizeof(section_info), "NtQuerySection wrong size %lu\n", info_size );
ok( section_info.Attributes == SEC_FILE, "NtQuerySection wrong attr %08x\n",
section_info.Attributes );
ok( section_info.BaseAddress == NULL, "NtQuerySection wrong base %p\n", section_info.BaseAddress );
@@ -1163,7 +1164,7 @@ static void test_MapViewOfFile(void)
status = pNtQuerySection( mapping, SectionBasicInformation, §ion_info,
sizeof(section_info), &info_size );
ok( !status, "NtQuerySection failed err %x\n", status );
- ok( info_size == sizeof(section_info), "NtQuerySection wrong size %u\n", info_size );
+ ok( info_size == sizeof(section_info), "NtQuerySection wrong size %lu\n", info_size );
ok( section_info.Attributes == SEC_FILE, "NtQuerySection wrong attr %08x\n",
section_info.Attributes );
ok( section_info.BaseAddress == NULL, "NtQuerySection wrong base %p\n", section_info.BaseAddress );
@@ -1178,7 +1179,7 @@ static void test_MapViewOfFile(void)
status = pNtQuerySection( mapping, SectionBasicInformation, §ion_info,
sizeof(section_info), &info_size );
ok( !status, "NtQuerySection failed err %x\n", status );
- ok( info_size == sizeof(section_info), "NtQuerySection wrong size %u\n", info_size );
+ ok( info_size == sizeof(section_info), "NtQuerySection wrong size %lu\n", info_size );
ok( section_info.Attributes == SEC_FILE, "NtQuerySection wrong attr %08x\n",
section_info.Attributes );
ok( section_info.BaseAddress == NULL, "NtQuerySection wrong base %p\n", section_info.BaseAddress );
@@ -1236,6 +1237,13 @@ static void test_MapViewOfFile(void)
ok( status == STATUS_SECTION_NOT_IMAGE, "NtQuerySection failed err %x\n", status );
status = pNtQuerySection( mapping, SectionImageInformation, &image_info, sizeof(image_info)+1, NULL );
ok( status == STATUS_SECTION_NOT_IMAGE, "NtQuerySection failed err %x\n", status );
+ if (sizeof(SIZE_T) > sizeof(int))
+ {
+ status = pNtQuerySection( mapping, SectionImageInformation, &image_info,
+ sizeof(image_info) + ((SIZE_T)0x10000000 << 8), NULL );
+ todo_wine
+ ok( status == STATUS_ACCESS_VIOLATION, "NtQuerySection wrong err %x\n", status );
+ }
CloseHandle(mapping);
SetFilePointer(file, 0, NULL, FILE_BEGIN);
diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c
index 8c4fe3b..d077eb7 100644
--- a/dlls/ntdll/virtual.c
+++ b/dlls/ntdll/virtual.c
@@ -3161,7 +3161,7 @@ NTSTATUS WINAPI NtUnmapViewOfSection( HANDLE process, PVOID addr )
* ZwQuerySection (NTDLL.@)
*/
NTSTATUS WINAPI NtQuerySection( HANDLE handle, SECTION_INFORMATION_CLASS class, void *ptr,
- ULONG size, ULONG *ret_size )
+ SIZE_T size, SIZE_T *ret_size )
{
NTSTATUS status;
pe_image_info_t image_info;
diff --git a/include/winternl.h b/include/winternl.h
index 322d111..21353d8 100644
--- a/include/winternl.h
+++ b/include/winternl.h
@@ -2321,7 +2321,7 @@ NTSYSAPI NTSTATUS WINAPI NtQueryObject(HANDLE, OBJECT_INFORMATION_CLASS, PVOID,
NTSYSAPI NTSTATUS WINAPI NtQueryOpenSubKeys(POBJECT_ATTRIBUTES,PULONG);
NTSYSAPI NTSTATUS WINAPI NtQueryPerformanceCounter(PLARGE_INTEGER, PLARGE_INTEGER);
NTSYSAPI NTSTATUS WINAPI NtQuerySecurityObject(HANDLE,SECURITY_INFORMATION,PSECURITY_DESCRIPTOR,ULONG,PULONG);
-NTSYSAPI NTSTATUS WINAPI NtQuerySection(HANDLE,SECTION_INFORMATION_CLASS,PVOID,ULONG,PULONG);
+NTSYSAPI NTSTATUS WINAPI NtQuerySection(HANDLE,SECTION_INFORMATION_CLASS,PVOID,SIZE_T,SIZE_T*);
NTSYSAPI NTSTATUS WINAPI NtQuerySemaphore(HANDLE,SEMAPHORE_INFORMATION_CLASS,PVOID,ULONG,PULONG);
NTSYSAPI NTSTATUS WINAPI NtQuerySymbolicLinkObject(HANDLE,PUNICODE_STRING,PULONG);
NTSYSAPI NTSTATUS WINAPI NtQuerySystemEnvironmentValue(PUNICODE_STRING,PWCHAR,ULONG,PULONG);
More information about the wine-cvs
mailing list