diff options
author | 2023-12-06 07:58:49 +1100 | |
---|---|---|
committer | 2023-12-06 07:58:49 +1100 | |
commit | 79bef1e23049fdac25f1fefd132e0b6c7d2cc3a1 (patch) | |
tree | 643e9313fe86f583c4022c338677cbc12b761df7 /3rdparty/lzma/CPP/Windows/MemoryLock.cpp | |
parent | 512ccf0c7c9b4f08e41038b2ed2de220e140385b (diff) |
3rdparty/lzma: Updated to version 23.01.
Diffstat (limited to '3rdparty/lzma/CPP/Windows/MemoryLock.cpp')
-rw-r--r-- | 3rdparty/lzma/CPP/Windows/MemoryLock.cpp | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/3rdparty/lzma/CPP/Windows/MemoryLock.cpp b/3rdparty/lzma/CPP/Windows/MemoryLock.cpp index 24866b1aeb3..0bd7504f1cc 100644 --- a/3rdparty/lzma/CPP/Windows/MemoryLock.cpp +++ b/3rdparty/lzma/CPP/Windows/MemoryLock.cpp @@ -21,7 +21,10 @@ typedef BOOL (WINAPI * Func_LookupPrivilegeValue)(LPCTSTR lpSystemName, LPCTSTR typedef BOOL (WINAPI * Func_AdjustTokenPrivileges)(HANDLE TokenHandle, BOOL DisableAllPrivileges, PTOKEN_PRIVILEGES NewState, DWORD BufferLength, PTOKEN_PRIVILEGES PreviousState, PDWORD ReturnLength); } -#define GET_PROC_ADDR(fff, name) Func_ ## fff my_ ## fff = (Func_ ## fff) (void(*)()) GetProcAddress(hModule, name) + +#define GET_PROC_ADDR(fff, name) \ + const Func_ ## fff my_ ## fff = Z7_GET_PROC_ADDRESS( \ + Func_ ## fff, hModule, name); #endif bool EnablePrivilege(LPCTSTR privilegeName, bool enable) @@ -30,13 +33,19 @@ bool EnablePrivilege(LPCTSTR privilegeName, bool enable) #ifndef _UNICODE - HMODULE hModule = ::LoadLibrary(TEXT("Advapi32.dll")); - if (hModule == NULL) + const HMODULE hModule = ::LoadLibrary(TEXT("advapi32.dll")); + if (!hModule) return false; - GET_PROC_ADDR(OpenProcessToken, "OpenProcessToken"); - GET_PROC_ADDR(LookupPrivilegeValue, "LookupPrivilegeValueA"); - GET_PROC_ADDR(AdjustTokenPrivileges, "AdjustTokenPrivileges"); + GET_PROC_ADDR( + OpenProcessToken, + "OpenProcessToken") + GET_PROC_ADDR( + LookupPrivilegeValue, + "LookupPrivilegeValueA") + GET_PROC_ADDR( + AdjustTokenPrivileges, + "AdjustTokenPrivileges") if (my_OpenProcessToken && my_AdjustTokenPrivileges && @@ -85,10 +94,13 @@ typedef void (WINAPI * Func_RtlGetVersion) (OSVERSIONINFOEXW *); unsigned Get_LargePages_RiskLevel() { OSVERSIONINFOEXW vi; - HMODULE ntdll = ::GetModuleHandleW(L"ntdll.dll"); + const HMODULE ntdll = ::GetModuleHandleW(L"ntdll.dll"); if (!ntdll) return 0; - Func_RtlGetVersion func = (Func_RtlGetVersion)(void *)GetProcAddress(ntdll, "RtlGetVersion"); + const + Func_RtlGetVersion func = Z7_GET_PROC_ADDRESS( + Func_RtlGetVersion, ntdll, + "RtlGetVersion"); if (!func) return 0; func(&vi); |