From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@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 cbce448d3e9..c51dbd6bc73 100644 --- a/dlls/kernelbase/kernelbase.spec +++ b/dlls/kernelbase/kernelbase.spec @@ -1250,7 +1250,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 412d80f5cfd..19b1d0a3a1a 100644 --- a/dlls/kernelbase/memory.c +++ b/dlls/kernelbase/memory.c @@ -1411,6 +1411,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 277f981982d..fe2d7db15b0 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