aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2021-02-07 17:38:13 -0600
committerSean Hall <r.sean.hall@gmail.com>2021-02-07 18:54:33 -0600
commit69567aaa95f41812a49afa7454b69a3d79c5010d (patch)
treebae6f8fc89c7da0020fe1063f86534cb4d8e5c4e
parentc294fb860ed7710c80fc004af6c9ebb09779c70c (diff)
downloadwix-69567aaa95f41812a49afa7454b69a3d79c5010d.tar.gz
wix-69567aaa95f41812a49afa7454b69a3d79c5010d.tar.bz2
wix-69567aaa95f41812a49afa7454b69a3d79c5010d.zip
Add OsRtlGetVersion.
#6318
-rw-r--r--src/dutil/inc/osutil.h3
-rw-r--r--src/dutil/osutil.cpp41
2 files changed, 44 insertions, 0 deletions
diff --git a/src/dutil/inc/osutil.h b/src/dutil/inc/osutil.h
index 01f8d9cf..2cce6f63 100644
--- a/src/dutil/inc/osutil.h
+++ b/src/dutil/inc/osutil.h
@@ -33,6 +33,9 @@ HRESULT DAPI OsIsRunningPrivileged(
33HRESULT DAPI OsIsUacEnabled( 33HRESULT DAPI OsIsUacEnabled(
34 __out BOOL* pfUacEnabled 34 __out BOOL* pfUacEnabled
35 ); 35 );
36HRESULT DAPI OsRtlGetVersion(
37 __inout RTL_OSVERSIONINFOEXW* pOvix
38 );
36 39
37#ifdef __cplusplus 40#ifdef __cplusplus
38} 41}
diff --git a/src/dutil/osutil.cpp b/src/dutil/osutil.cpp
index d1a4dd9a..38b32eb3 100644
--- a/src/dutil/osutil.cpp
+++ b/src/dutil/osutil.cpp
@@ -2,8 +2,11 @@
2 2
3#include "precomp.h" 3#include "precomp.h"
4 4
5typedef NTSTATUS(NTAPI* PFN_RTL_GET_VERSION)(_Out_ PRTL_OSVERSIONINFOEXW lpVersionInformation);
6
5OS_VERSION vOsVersion = OS_VERSION_UNKNOWN; 7OS_VERSION vOsVersion = OS_VERSION_UNKNOWN;
6DWORD vdwOsServicePack = 0; 8DWORD vdwOsServicePack = 0;
9RTL_OSVERSIONINFOEXW vovix = { };
7 10
8/******************************************************************** 11/********************************************************************
9 OsGetVersion 12 OsGetVersion
@@ -186,3 +189,41 @@ LExit:
186 189
187 return hr; 190 return hr;
188} 191}
192
193HRESULT DAPI OsRtlGetVersion(
194 __inout RTL_OSVERSIONINFOEXW* pOvix
195 )
196{
197 HRESULT hr = S_OK;
198 HMODULE hNtdll = NULL;
199 PFN_RTL_GET_VERSION pfnRtlGetVersion = NULL;
200
201 if (vovix.dwOSVersionInfoSize)
202 {
203 ExitFunction();
204 }
205
206 vovix.dwOSVersionInfoSize = sizeof(RTL_OSVERSIONINFOEXW);
207
208 hr = LoadSystemLibrary(L"ntdll.dll", &hNtdll);
209 if (E_MODNOTFOUND == hr)
210 {
211 ExitOnRootFailure(hr = E_NOTIMPL, "Failed to load ntdll.dll");
212 }
213 ExitOnFailure(hr, "Failed to load ntdll.dll.");
214
215 pfnRtlGetVersion = reinterpret_cast<PFN_RTL_GET_VERSION>(::GetProcAddress(hNtdll, "RtlGetVersion"));
216 ExitOnNullWithLastError(pfnRtlGetVersion, hr, "Failed to locate RtlGetVersion.");
217
218 hr = static_cast<HRESULT>(pfnRtlGetVersion(&vovix));
219
220LExit:
221 memcpy(pOvix, &vovix, sizeof(RTL_OSVERSIONINFOEXW));
222
223 if (hNtdll)
224 {
225 ::FreeLibrary(hNtdll);
226 }
227
228 return hr;
229}