2
2
#include "git-compat-util.h"
3
3
4
4
#if defined(GIT_WINDOWS_NATIVE )
5
+ #include "lazyload.h"
5
6
6
7
static int cmd_sync (void )
7
8
{
@@ -82,8 +83,7 @@ static int cmd_dropcaches(void)
82
83
{
83
84
HANDLE hProcess = GetCurrentProcess ();
84
85
HANDLE hToken ;
85
- HMODULE ntdll ;
86
- DWORD (WINAPI * NtSetSystemInformation )(INT , PVOID , ULONG );
86
+ DECLARE_PROC_ADDR (ntdll .dll , DWORD , NtSetSystemInformation , INT , PVOID , ULONG );
87
87
SYSTEM_MEMORY_LIST_COMMAND command ;
88
88
int status ;
89
89
@@ -95,14 +95,8 @@ static int cmd_dropcaches(void)
95
95
96
96
CloseHandle (hToken );
97
97
98
- ntdll = LoadLibrary ("ntdll.dll" );
99
- if (!ntdll )
100
- return error ("Can't load ntdll.dll, wrong Windows version?" );
101
-
102
- NtSetSystemInformation =
103
- (DWORD (WINAPI * )(INT , PVOID , ULONG ))GetProcAddress (ntdll , "NtSetSystemInformation" );
104
- if (!NtSetSystemInformation )
105
- return error ("Can't get function addresses, wrong Windows version?" );
98
+ if (!INIT_PROC_ADDR (NtSetSystemInformation ))
99
+ return error ("Could not find NtSetSystemInformation() function" );
106
100
107
101
command = MemoryPurgeStandbyList ;
108
102
status = NtSetSystemInformation (
@@ -115,8 +109,6 @@ static int cmd_dropcaches(void)
115
109
else if (status != STATUS_SUCCESS )
116
110
error ("Unable to execute the memory list command %d" , status );
117
111
118
- FreeLibrary (ntdll );
119
-
120
112
return status ;
121
113
}
122
114
0 commit comments