Commit 2602df14 authored by Alexandre Julliard's avatar Alexandre Julliard

ntdll: Implement the SectionBasicInformation class of NtQuerySection.

parent 1ddc6360
......@@ -52,6 +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 *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);
......@@ -241,8 +242,21 @@ static NTSTATUS map_image_section( const IMAGE_NT_HEADERS *nt_header )
file = CreateFileA(dll_name, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0);
ok(file != INVALID_HANDLE_VALUE, "CreateFile error %d\n", GetLastError());
status = pNtCreateSection(&map, STANDARD_RIGHTS_REQUIRED | SECTION_MAP_READ, NULL, &size,
PAGE_READONLY, SEC_IMAGE, file );
status = pNtCreateSection(&map, STANDARD_RIGHTS_REQUIRED | SECTION_MAP_READ | SECTION_QUERY,
NULL, &size, PAGE_READONLY, SEC_IMAGE, file );
if (!status)
{
SECTION_BASIC_INFORMATION info;
ULONG 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.Attributes == (SEC_IMAGE | SEC_FILE), "NtQuerySection wrong attr %x\n", info.Attributes );
ok( info.BaseAddress == NULL, "NtQuerySection wrong base %p\n", info.BaseAddress );
todo_wine
ok( info.Size.QuadPart == size.QuadPart, "NtQuerySection wrong size %x%08x / %x%08x\n",
info.Size.u.HighPart, info.Size.u.LowPart, size.u.HighPart, size.u.LowPart );
}
if (map) CloseHandle( map );
CloseHandle( file );
DeleteFileA( dll_name );
......@@ -2777,6 +2791,7 @@ START_TEST(loader)
ntdll = GetModuleHandleA("ntdll.dll");
pNtCreateSection = (void *)GetProcAddress(ntdll, "NtCreateSection");
pNtQuerySection = (void *)GetProcAddress(ntdll, "NtQuerySection");
pNtMapViewOfSection = (void *)GetProcAddress(ntdll, "NtMapViewOfSection");
pNtUnmapViewOfSection = (void *)GetProcAddress(ntdll, "NtUnmapViewOfSection");
pNtTerminateProcess = (void *)GetProcAddress(ntdll, "NtTerminateProcess");
......
......@@ -646,25 +646,6 @@ NTSTATUS WINAPI NtPrivilegeCheck(
}
/*
* Section
*/
/******************************************************************************
* NtQuerySection [NTDLL.@]
*/
NTSTATUS WINAPI NtQuerySection(
IN HANDLE SectionHandle,
IN SECTION_INFORMATION_CLASS SectionInformationClass,
OUT PVOID SectionInformation,
IN ULONG Length,
OUT PULONG ResultLength)
{
FIXME("(%p,%d,%p,0x%08x,%p) stub!\n",
SectionHandle,SectionInformationClass,SectionInformation,Length,ResultLength);
return 0;
}
/*
* ports
*/
......
......@@ -269,7 +269,7 @@
@ stdcall NtQueryPerformanceCounter(ptr ptr)
# @ stub NtQueryPortInformationProcess
# @ stub NtQueryQuotaInformationFile
@ stdcall NtQuerySection (long long long long long)
@ stdcall NtQuerySection(long long ptr long ptr)
@ stdcall NtQuerySecurityObject (long long long long long)
@ stdcall NtQuerySemaphore (long long ptr long ptr)
@ stdcall NtQuerySymbolicLinkObject(long ptr ptr)
......@@ -1194,7 +1194,7 @@
@ stdcall ZwQueryPerformanceCounter(ptr ptr) NtQueryPerformanceCounter
# @ stub ZwQueryPortInformationProcess
# @ stub ZwQueryQuotaInformationFile
@ stdcall ZwQuerySection (long long long long long) NtQuerySection
@ stdcall ZwQuerySection(long long ptr long ptr) NtQuerySection
@ stdcall ZwQuerySecurityObject (long long long long long) NtQuerySecurityObject
@ stdcall ZwQuerySemaphore(long long ptr long ptr) NtQuerySemaphore
@ stdcall ZwQuerySymbolicLinkObject(long ptr ptr) NtQuerySymbolicLinkObject
......
......@@ -2761,6 +2761,41 @@ NTSTATUS WINAPI NtUnmapViewOfSection( HANDLE process, PVOID addr )
}
/******************************************************************************
* NtQuerySection (NTDLL.@)
* ZwQuerySection (NTDLL.@)
*/
NTSTATUS WINAPI NtQuerySection( HANDLE handle, SECTION_INFORMATION_CLASS class, void *ptr,
ULONG size, ULONG *ret_size )
{
NTSTATUS status;
SECTION_BASIC_INFORMATION *basic_info = ptr;
if (class != SectionBasicInformation)
{
FIXME( "class %u not implemented\n", class );
return STATUS_NOT_IMPLEMENTED;
}
if (size < sizeof(*basic_info)) return STATUS_INFO_LENGTH_MISMATCH;
SERVER_START_REQ( get_mapping_info )
{
req->handle = wine_server_obj_handle( handle );
req->access = SECTION_QUERY;
if (!(status = wine_server_call( req )))
{
basic_info->Attributes = reply->flags;
basic_info->BaseAddress = NULL;
basic_info->Size.QuadPart = reply->size;
if (ret_size) *ret_size = sizeof(*basic_info);
}
}
SERVER_END_REQ;
return status;
}
/***********************************************************************
* NtFlushVirtualMemory (NTDLL.@)
* ZwFlushVirtualMemory (NTDLL.@)
......
......@@ -704,6 +704,12 @@ DECL_HANDLER(get_mapping_info)
reply->header_size = mapping->header_size;
reply->base = mapping->base;
if (!(req->access & (SECTION_MAP_READ | SECTION_MAP_WRITE))) /* query only */
{
release_object( mapping );
return;
}
if ((mapping->flags & SEC_IMAGE) && mapping->cpu != current->process->cpu)
{
set_error( STATUS_INVALID_IMAGE_FORMAT );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment