[PATCH 2/2] kernelbase: Add QueryVirtualMemoryInformation().
Nikolay Sivov
wine at gitlab.winehq.org
Tue Jun 28 10:15:20 CDT 2022
From: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
dlls/kernelbase/kernelbase.spec | 2 +-
dlls/kernelbase/memory.c | 17 +++++++++++++
include/memoryapi.h | 45 +++++++++++++++++++++++++++++++++
include/winbase.h | 1 +
4 files changed, 64 insertions(+), 1 deletion(-)
create mode 100644 include/memoryapi.h
diff --git a/dlls/kernelbase/kernelbase.spec b/dlls/kernelbase/kernelbase.spec
index 1296757b29a..07664646983 100644
--- a/dlls/kernelbase/kernelbase.spec
+++ b/dlls/kernelbase/kernelbase.spec
@@ -1248,7 +1248,7 @@
@ stdcall QueryThreadpoolStackInformation(ptr ptr)
@ stdcall QueryUnbiasedInterruptTime(ptr) ntdll.RtlQueryUnbiasedInterruptTime
# @ stub QueryUnbiasedInterruptTimePrecise
-# @ stub QueryVirtualMemoryInformation
+@ stdcall QueryVirtualMemoryInformation(long ptr long ptr long ptr)
@ stdcall QueryWorkingSet(long ptr long)
@ stdcall QueryWorkingSetEx(long ptr long)
@ stdcall QueueUserAPC(ptr long long)
diff --git a/dlls/kernelbase/memory.c b/dlls/kernelbase/memory.c
index e24a6f9aad0..09ab8fdc895 100644
--- a/dlls/kernelbase/memory.c
+++ b/dlls/kernelbase/memory.c
@@ -1390,6 +1390,23 @@ LPVOID WINAPI DECLSPEC_HOTPATCH VirtualAllocExNuma( HANDLE process, void *addr,
}
+/***********************************************************************
+ * QueryVirtualMemoryInformation (kernelbase.@)
+ */
+BOOL WINAPI DECLSPEC_HOTPATCH QueryVirtualMemoryInformation( HANDLE process, const void *addr,
+ WIN32_MEMORY_INFORMATION_CLASS info_class, void *info, SIZE_T size, SIZE_T *ret_size)
+{
+ switch (info_class)
+ {
+ case MemoryRegionInfo:
+ return set_ntstatus( NtQueryVirtualMemory( process, addr, MemoryRegionInformation, info, size, ret_size ));
+ default:
+ FIXME("Unsupported info class %u.\n", info_class);
+ return FALSE;
+ }
+}
+
+
/***********************************************************************
* CPU functions
***********************************************************************/
diff --git a/include/memoryapi.h b/include/memoryapi.h
new file mode 100644
index 00000000000..8743e67927c
--- /dev/null
+++ b/include/memoryapi.h
@@ -0,0 +1,45 @@
+/*
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+typedef enum WIN32_MEMORY_INFORMATION_CLASS
+{
+ MemoryRegionInfo
+} WIN32_MEMORY_INFORMATION_CLASS;
+
+typedef struct WIN32_MEMORY_REGION_INFORMATION
+{
+ PVOID AllocationBase;
+ ULONG AllocationProtect;
+ union
+ {
+ ULONG Flags;
+ struct
+ {
+ ULONG Private : 1;
+ ULONG MappedDataFile : 1;
+ ULONG MappedImage : 1;
+ ULONG MappedPageFile : 1;
+ ULONG MappedPhysical : 1;
+ ULONG DirectMapped : 1;
+ ULONG Reserved : 26;
+ } DUMMYSTRUCTNAME;
+ } DUMMYUNIONNAME;
+ SIZE_T RegionSize;
+ SIZE_T CommitSize;
+} WIN32_MEMORY_REGION_INFORMATION;
+
+BOOL WINAPI QueryVirtualMemoryInformation(HANDLE process,const void *addr,
+ WIN32_MEMORY_INFORMATION_CLASS info_class, void *info, SIZE_T size, SIZE_T *ret_size);
diff --git a/include/winbase.h b/include/winbase.h
index bf191153ddc..1c83a5350d4 100644
--- a/include/winbase.h
+++ b/include/winbase.h
@@ -43,6 +43,7 @@ extern "C" {
#include <processthreadsapi.h>
#include <synchapi.h>
#include <threadpoolapiset.h>
+#include <memoryapi.h>
/* Windows Exit Procedure flag values */
#define WEP_FREE_DLL 0
--
GitLab
https://gitlab.winehq.org/wine/wine/-/merge_requests/333
More information about the wine-devel
mailing list