ReactOS 0.4.17-dev-357-ga8f14ff
globmemstatus.c
Go to the documentation of this file.
1/*
2 * PROJECT: appshim_apitest
3 * LICENSE: MIT (https://spdx.org/licenses/MIT)
4 * PURPOSE: Tests for GlobalMemoryStatus2GB shim
5 * COPYRIGHT: Copyright 2026 Mark Jansen <mark.jansen@reactos.org>
6 */
7
8#include <ntstatus.h>
9#define WIN32_NO_STATUS
10#include <windows.h>
11#include "wine/test.h"
12
13#include "appshim_apitest.h"
14
17
19
20
23{
24 memset(lpBuffer, 0, sizeof(MEMORYSTATUS));
25}
26
29{
30 memset(lpBuffer, 0xff, sizeof(MEMORYSTATUS));
31}
32
33static void
35{
37
38 ok_str(hook->LibraryName, "KERNEL32.DLL");
39 hook->OriginalFunction = my_GlobalMemoryStatus_Low;
40 proc = hook->ReplacementFunction;
41
42
43 MEMORYSTATUS ms;
44 memset(&ms, 0x33, sizeof(ms));
45 proc(&ms);
46
47 ok_hex(ms.dwLength, 0);
48 ok_hex(ms.dwMemoryLoad, 0);
49 ok_hex(ms.dwTotalPhys, 0);
50 ok_hex(ms.dwAvailPhys, 0);
55
56
57 hook->OriginalFunction = my_GlobalMemoryStatus_High;
58
59 memset(&ms, 0x33, sizeof(ms));
60 proc(&ms);
61 ok_hex(ms.dwLength, 0xffffffff); // not touched
62 ok_hex(ms.dwMemoryLoad, 0xffffffff); // not touched
63 ok_hex(ms.dwTotalPhys, 0x3fffffff);
64 ok_hex(ms.dwAvailPhys, 0x3fffffff);
65 ok_hex(ms.dwTotalPageFile, 0x7fffffff);
66 ok_hex(ms.dwAvailPageFile, 0x3fffffff);
67 ok_hex(ms.dwTotalVirtual, 0xffffffff); // not touched
68 ok_hex(ms.dwAvailVirtual, 0xffffffff); // not touched
69}
70
71
72START_TEST(globalmemorystatus)
73{
74 DWORD num_shims = 0, n;
76
77 if (!LoadShimDLL(L"aclayers.dll", &g_hShimDll, &pGetHookAPIs))
78 return;
79
80 hook = pGetHookAPIs("", L"GlobalMemoryStatus2GB", &num_shims);
81
82 ok(hook != NULL, "Expected hook to be a valid pointer\n");
83 ok(num_shims == 1, "Expected num_shims to be 1, was: %u\n", num_shims);
84
85 if (!hook || !num_shims)
86 return;
87
88 for (n = 0; n < num_shims; ++n)
89 {
90 if (!_stricmp(hook[n].FunctionName, "GlobalMemoryStatus"))
92 }
93}
@ hook
Definition: SystemMenu.c:35
#define VOID
Definition: acefi.h:82
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK void *Context ACPI_BUFFER *RetBuffer UINT16 ACPI_RESOURCE **ResourcePtr ACPI_GENERIC_ADDRESS *Reg UINT32 *ReturnValue UINT8 UINT8 *Slp_TypB ACPI_PHYSICAL_ADDRESS PhysicalAddress64 UINT32 UINT32 *TimeElapsed UINT32 ACPI_STATUS const char UINT32 ACPI_STATUS const char UINT32 const char * FunctionName
Definition: acpixf.h:1279
PHOOKAPI(WINAPI * tGETHOOKAPIS)(LPCSTR szCommandLine, LPCWSTR wszShimName, PDWORD pdwHookCount)
BOOL LoadShimDLL(PCWSTR ShimDll, HMODULE *module, tGETHOOKAPIS *ppGetHookAPIs)
Definition: versionlie.c:307
#define ok_hex(expression, result)
Definition: atltest.h:94
#define ok_str(x, y)
Definition: atltest.h:127
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
#define _stricmp
Definition: cat.c:22
#define NULL
Definition: types.h:112
#define L(x)
Definition: resources.c:13
unsigned long DWORD
Definition: ntddk_ex.h:95
GLdouble n
Definition: glext.h:7729
VOID NTAPI my_GlobalMemoryStatus_Low(LPMEMORYSTATUS lpBuffer)
Definition: globmemstatus.c:22
VOID NTAPI my_GlobalMemoryStatus_High(LPMEMORYSTATUS lpBuffer)
Definition: globmemstatus.c:28
static HMODULE g_hShimDll
Definition: globmemstatus.c:15
VOID(NTAPI * GLOBALMEMORYSTATUSPROC)(LPMEMORYSTATUS lpBuffer)
Definition: globmemstatus.c:18
static tGETHOOKAPIS pGetHookAPIs
Definition: globmemstatus.c:16
static void test_GlobalMemoryStatus(void)
Definition: heap.c:3874
_Out_ LPWSTR lpBuffer
Definition: netsh.h:68
static HANDLE proc()
Definition: pdb.c:32
#define memset(x, y, z)
Definition: compat.h:39
SIZE_T dwTotalPhys
Definition: winbase.h:921
DWORD dwLength
Definition: winbase.h:919
DWORD dwMemoryLoad
Definition: winbase.h:920
SIZE_T dwAvailPageFile
Definition: winbase.h:924
SIZE_T dwAvailVirtual
Definition: winbase.h:926
SIZE_T dwAvailPhys
Definition: winbase.h:922
SIZE_T dwTotalPageFile
Definition: winbase.h:923
SIZE_T dwTotalVirtual
Definition: winbase.h:925
#define NTAPI
Definition: typedefs.h:36