#6318
This commit is contained in:
Sean Hall 2021-02-07 17:38:13 -06:00
Родитель c294fb860e
Коммит 69567aaa95
2 изменённых файлов: 44 добавлений и 0 удалений

Просмотреть файл

@ -33,6 +33,9 @@ HRESULT DAPI OsIsRunningPrivileged(
HRESULT DAPI OsIsUacEnabled( HRESULT DAPI OsIsUacEnabled(
__out BOOL* pfUacEnabled __out BOOL* pfUacEnabled
); );
HRESULT DAPI OsRtlGetVersion(
__inout RTL_OSVERSIONINFOEXW* pOvix
);
#ifdef __cplusplus #ifdef __cplusplus
} }

Просмотреть файл

@ -2,8 +2,11 @@
#include "precomp.h" #include "precomp.h"
typedef NTSTATUS(NTAPI* PFN_RTL_GET_VERSION)(_Out_ PRTL_OSVERSIONINFOEXW lpVersionInformation);
OS_VERSION vOsVersion = OS_VERSION_UNKNOWN; OS_VERSION vOsVersion = OS_VERSION_UNKNOWN;
DWORD vdwOsServicePack = 0; DWORD vdwOsServicePack = 0;
RTL_OSVERSIONINFOEXW vovix = { };
/******************************************************************** /********************************************************************
OsGetVersion OsGetVersion
@ -186,3 +189,41 @@ LExit:
return hr; return hr;
} }
HRESULT DAPI OsRtlGetVersion(
__inout RTL_OSVERSIONINFOEXW* pOvix
)
{
HRESULT hr = S_OK;
HMODULE hNtdll = NULL;
PFN_RTL_GET_VERSION pfnRtlGetVersion = NULL;
if (vovix.dwOSVersionInfoSize)
{
ExitFunction();
}
vovix.dwOSVersionInfoSize = sizeof(RTL_OSVERSIONINFOEXW);
hr = LoadSystemLibrary(L"ntdll.dll", &hNtdll);
if (E_MODNOTFOUND == hr)
{
ExitOnRootFailure(hr = E_NOTIMPL, "Failed to load ntdll.dll");
}
ExitOnFailure(hr, "Failed to load ntdll.dll.");
pfnRtlGetVersion = reinterpret_cast<PFN_RTL_GET_VERSION>(::GetProcAddress(hNtdll, "RtlGetVersion"));
ExitOnNullWithLastError(pfnRtlGetVersion, hr, "Failed to locate RtlGetVersion.");
hr = static_cast<HRESULT>(pfnRtlGetVersion(&vovix));
LExit:
memcpy(pOvix, &vovix, sizeof(RTL_OSVERSIONINFOEXW));
if (hNtdll)
{
::FreeLibrary(hNtdll);
}
return hr;
}