wine-staging/patches/ntdll-NtQuerySection/0001-ntdll-Implement-NtQuerySection-class-SectionBasicInf.patch
2014-10-03 18:25:08 +02:00

122 lines
3.7 KiB
Diff

From bf3f5ae559f93ec5c0598574aa1838464a2ad701 Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Fri, 3 Oct 2014 18:03:58 +0200
Subject: ntdll: Implement NtQuerySection class SectionBasicInformation.
---
dlls/ntdll/nt.c | 19 -------------------
dlls/ntdll/virtual.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++
include/winternl.h | 2 +-
3 files changed, 54 insertions(+), 20 deletions(-)
diff --git a/dlls/ntdll/nt.c b/dlls/ntdll/nt.c
index 73d9383..f0433db 100644
--- a/dlls/ntdll/nt.c
+++ b/dlls/ntdll/nt.c
@@ -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
*/
diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c
index 4819d2d..94b4827 100644
--- a/dlls/ntdll/virtual.c
+++ b/dlls/ntdll/virtual.c
@@ -2465,6 +2465,59 @@ NTSTATUS WINAPI NtOpenSection( HANDLE *handle, ACCESS_MASK access, const OBJECT_
/***********************************************************************
+ * NtQuerySection (NTDLL.@)
+ */
+NTSTATUS WINAPI NtQuerySection(HANDLE handle, SECTION_INFORMATION_CLASS info_class,
+ PVOID buffer, ULONG len, PULONG ret_len)
+{
+ SECTION_BASIC_INFORMATION *info;
+ HANDLE dup_mapping, shared_file;
+ unsigned protect;
+ LARGE_INTEGER size;
+ void *base;
+ NTSTATUS res;
+
+ if (info_class != SectionBasicInformation)
+ {
+ FIXME("%p,info_class=%d,%p,%d,%p) Unknown information class\n",
+ handle, info_class, buffer, len, ret_len);
+ return STATUS_INVALID_INFO_CLASS;
+ }
+
+ if (len < sizeof(SECTION_BASIC_INFORMATION))
+ return STATUS_INFO_LENGTH_MISMATCH;
+
+ SERVER_START_REQ( get_mapping_info )
+ {
+ req->handle = wine_server_obj_handle( handle );
+ req->access = SECTION_QUERY;
+ res = wine_server_call( req );
+ protect = reply->protect;
+ base = wine_server_get_ptr( reply->base );
+ size.QuadPart = reply->size;
+ dup_mapping = wine_server_ptr_handle( reply->mapping );
+ shared_file = wine_server_ptr_handle( reply->shared_file );
+ if ((ULONG_PTR)base != reply->base) base = NULL;
+ }
+ SERVER_END_REQ;
+ if (res) return res;
+
+ info = buffer;
+ info->BaseAddress = base;
+ info->Size = size;
+ info->Attributes = (protect & VPROT_COMMITTED) ? SEC_COMMIT : SEC_RESERVE;
+ if (protect & VPROT_NOCACHE) info->Attributes |= SEC_NOCACHE;
+ if (protect & VPROT_IMAGE) info->Attributes |= SEC_IMAGE;
+ /* FIXME: SEC_FILE */
+ if (ret_len) *ret_len = sizeof(*info);
+
+ if (dup_mapping) NtClose( dup_mapping );
+ if (shared_file) NtClose( shared_file );
+ return STATUS_SUCCESS;
+}
+
+
+/***********************************************************************
* NtMapViewOfSection (NTDLL.@)
* ZwMapViewOfSection (NTDLL.@)
*/
diff --git a/include/winternl.h b/include/winternl.h
index 95951e2..ee08187 100644
--- a/include/winternl.h
+++ b/include/winternl.h
@@ -1791,7 +1791,7 @@ typedef enum _SECTION_INFORMATION_CLASS
} SECTION_INFORMATION_CLASS;
typedef struct _SECTION_BASIC_INFORMATION {
- ULONG BaseAddress;
+ PVOID BaseAddress;
ULONG Attributes;
LARGE_INTEGER Size;
} SECTION_BASIC_INFORMATION, *PSECTION_BASIC_INFORMATION;
--
2.1.1