diff --git a/dlls/kernel/kernel32.spec b/dlls/kernel/kernel32.spec index 468be203fd6..5937756063d 100644 --- a/dlls/kernel/kernel32.spec +++ b/dlls/kernel/kernel32.spec @@ -533,7 +533,7 @@ @ stdcall GlobalHandle(ptr) GlobalHandle @ stdcall GlobalLock(long) GlobalLock @ stdcall GlobalMemoryStatus(ptr) GlobalMemoryStatus -@ stub GlobalMemoryStatusEx +@ stdcall GlobalMemoryStatusEx(ptr) GlobalMemoryStatusEx @ stdcall GlobalReAlloc(long long long) GlobalReAlloc @ stdcall GlobalSize(long) GlobalSize @ stdcall GlobalUnWire(long) GlobalUnWire diff --git a/include/winbase.h b/include/winbase.h index ecf66bc2a7e..fce2e8ad31f 100644 --- a/include/winbase.h +++ b/include/winbase.h @@ -460,6 +460,18 @@ typedef struct tagMEMORYSTATUS SIZE_T dwAvailVirtual; } MEMORYSTATUS, *LPMEMORYSTATUS; +typedef struct tagMEMORYSTATUSEX { + DWORD dwLength; + DWORD dwMemoryLoad; + DWORDLONG ullTotalPhys; + DWORDLONG ullAvailPhys; + DWORDLONG ullTotalPageFile; + DWORDLONG ullAvailPageFile; + DWORDLONG ullTotalVirtual; + DWORDLONG ullAvailVirtual; + DWORDLONG ullAvailExtendedVirtual; +} MEMORYSTATUSEX, *LPMEMORYSTATUSEX; + typedef struct _SYSTEMTIME{ WORD wYear; diff --git a/memory/global.c b/memory/global.c index afcd5b77bce..8f94c292113 100644 --- a/memory/global.c +++ b/memory/global.c @@ -1558,6 +1558,9 @@ SIZE_T WINAPI GlobalCompact( DWORD minfree ) /*********************************************************************** * GlobalMemoryStatus (KERNEL32.@) + * Provides information about the status of the memory, so apps can tell + * roughly how much they are able to allocate + * * RETURNS * None */ @@ -1692,6 +1695,38 @@ VOID WINAPI GlobalMemoryStatus( lpmem->dwAvailVirtual); } +/*********************************************************************** + * GlobalMemoryStatusEx (KERNEL32.@) + * A version of GlobalMemoryStatus that can deal with memory over 4GB + * + * RETURNS + * None + */ +BOOL WINAPI GlobalMemoryStatusEx( LPMEMORYSTATUSEX lpBuffer ) { + MEMORYSTATUS memstatus; + + /* Because GlobalMemoryStatusEx is identical to GlobalMemoryStatus save + for one extra field in the struct, and the lack of a bug, we simply + call GlobalMemoryStatus and copy the values across. */ + FIXME("we should emulate the 4GB bug here, as per MSDN\n"); + GlobalMemoryStatus(&memstatus); + lpBuffer->dwMemoryLoad = memstatus.dwMemoryLoad; + lpBuffer->ullTotalPhys = memstatus.dwTotalPhys; + lpBuffer->ullAvailPhys = memstatus.dwAvailPhys; + lpBuffer->ullTotalPageFile = memstatus.dwTotalPageFile; + lpBuffer->ullAvailPageFile = memstatus.dwAvailPageFile; + lpBuffer->ullTotalVirtual = memstatus.dwTotalVirtual; + lpBuffer->ullAvailVirtual = memstatus.dwAvailVirtual; + /* MSDN says about AvailExtendedVirtual: Size of unreserved and uncommitted + memory in the extended portion of the virtual address space of the calling + process, in bytes. + + However, I don't know what this means, so set it to zero :( + */ + lpBuffer->ullAvailExtendedVirtual = 0; + return 1; +} + /*********************************************************************** * A20Proc (KERNEL.165) * A20_Proc (SYSTEM.20)