Merge branch 'bp/test-drop-caches'
Code simplification. * bp/test-drop-caches: test-drop-caches: simplify delay loading of NtSetSystemInformation
This commit is contained in:
commit
fda537adba
@ -2,6 +2,7 @@
|
|||||||
#include "git-compat-util.h"
|
#include "git-compat-util.h"
|
||||||
|
|
||||||
#if defined(GIT_WINDOWS_NATIVE)
|
#if defined(GIT_WINDOWS_NATIVE)
|
||||||
|
#include "lazyload.h"
|
||||||
|
|
||||||
static int cmd_sync(void)
|
static int cmd_sync(void)
|
||||||
{
|
{
|
||||||
@ -82,8 +83,7 @@ static int cmd_dropcaches(void)
|
|||||||
{
|
{
|
||||||
HANDLE hProcess = GetCurrentProcess();
|
HANDLE hProcess = GetCurrentProcess();
|
||||||
HANDLE hToken;
|
HANDLE hToken;
|
||||||
HMODULE ntdll;
|
DECLARE_PROC_ADDR(ntdll.dll, DWORD, NtSetSystemInformation, INT, PVOID, ULONG);
|
||||||
DWORD(WINAPI *NtSetSystemInformation)(INT, PVOID, ULONG);
|
|
||||||
SYSTEM_MEMORY_LIST_COMMAND command;
|
SYSTEM_MEMORY_LIST_COMMAND command;
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
@ -95,14 +95,8 @@ static int cmd_dropcaches(void)
|
|||||||
|
|
||||||
CloseHandle(hToken);
|
CloseHandle(hToken);
|
||||||
|
|
||||||
ntdll = LoadLibrary("ntdll.dll");
|
if (!INIT_PROC_ADDR(NtSetSystemInformation))
|
||||||
if (!ntdll)
|
return error("Could not find NtSetSystemInformation() function");
|
||||||
return error("Can't load ntdll.dll, wrong Windows version?");
|
|
||||||
|
|
||||||
NtSetSystemInformation =
|
|
||||||
(DWORD(WINAPI *)(INT, PVOID, ULONG))GetProcAddress(ntdll, "NtSetSystemInformation");
|
|
||||||
if (!NtSetSystemInformation)
|
|
||||||
return error("Can't get function addresses, wrong Windows version?");
|
|
||||||
|
|
||||||
command = MemoryPurgeStandbyList;
|
command = MemoryPurgeStandbyList;
|
||||||
status = NtSetSystemInformation(
|
status = NtSetSystemInformation(
|
||||||
@ -115,8 +109,6 @@ static int cmd_dropcaches(void)
|
|||||||
else if (status != STATUS_SUCCESS)
|
else if (status != STATUS_SUCCESS)
|
||||||
error("Unable to execute the memory list command %d", status);
|
error("Unable to execute the memory list command %d", status);
|
||||||
|
|
||||||
FreeLibrary(ntdll);
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user