From 096784ea5114cb5bf99151cc047d69951035d152 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Sun, 7 Feb 2021 18:54:54 -0600 Subject: Require Vista (Server 2008) SP2 or newer. #6318 --- src/engine/condition.cpp | 8 ++------ src/engine/engine.cpp | 10 +++------ src/engine/engine.vcxproj | 4 ++-- src/engine/msuengine.cpp | 6 +----- src/engine/packages.config | 2 +- src/engine/pipe.cpp | 5 +---- src/engine/precomp.h | 1 + src/engine/registration.cpp | 11 ---------- src/engine/variable.cpp | 33 ++++-------------------------- src/stub/packages.config | 2 +- src/stub/stub.vcxproj | 4 ++-- src/test/BurnUnitTest/BurnUnitTest.vcxproj | 4 ++-- src/test/BurnUnitTest/packages.config | 2 +- 13 files changed, 21 insertions(+), 71 deletions(-) diff --git a/src/engine/condition.cpp b/src/engine/condition.cpp index 06591567..316224db 100644 --- a/src/engine/condition.cpp +++ b/src/engine/condition.cpp @@ -187,13 +187,9 @@ extern "C" HRESULT ConditionGlobalCheck( HRESULT hr = S_OK; BOOL fSuccess = TRUE; HRESULT hrError = HRESULT_FROM_WIN32(ERROR_OLD_WIN_VERSION); - OS_VERSION osv = OS_VERSION_UNKNOWN; - DWORD dwServicePack = 0; - OsGetVersion(&osv, &dwServicePack); - - // Always error on Windows 2000 or lower - if (OS_VERSION_WIN2000 >= osv) + // Only run on Windows Vista SP2 or newer, or Windows Server 2008 SP2 or newer. + if (!::IsWindowsVistaSP2OrGreater()) { fSuccess = FALSE; } diff --git a/src/engine/engine.cpp b/src/engine/engine.cpp index 7e6e2922..458386d4 100644 --- a/src/engine/engine.cpp +++ b/src/engine/engine.cpp @@ -95,7 +95,7 @@ extern "C" HRESULT EngineRun( BOOL fWiuInitialized = FALSE; BOOL fXmlInitialized = FALSE; SYSTEM_INFO si = { }; - OSVERSIONINFOEXW ovix = { }; + RTL_OSVERSIONINFOEXW ovix = { }; LPWSTR sczExePath = NULL; BOOL fRunNormal = FALSE; BOOL fRestart = FALSE; @@ -150,12 +150,8 @@ extern "C" HRESULT EngineRun( ExitOnFailure(hr, "Failed to initialize XML util."); fXmlInitialized = TRUE; - ovix.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXW); - #pragma warning(suppress: 4996) - if (!::GetVersionExW((LPOSVERSIONINFOW)&ovix)) - { - ExitWithLastError(hr, "Failed to get OS info."); - } + hr = OsRtlGetVersion(&ovix); + ExitOnFailure(hr, "Failed to get OS info."); #if defined(_M_ARM64) LPCSTR szBurnPlatform = "ARM64"; diff --git a/src/engine/engine.vcxproj b/src/engine/engine.vcxproj index cb179a23..bc724a40 100644 --- a/src/engine/engine.vcxproj +++ b/src/engine/engine.vcxproj @@ -1,7 +1,7 @@ - + Debug @@ -167,7 +167,7 @@ rc.exe -fo "$(OutDir)engine.res" "$(IntDir)engine.messages.rc" This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + \ No newline at end of file diff --git a/src/engine/msuengine.cpp b/src/engine/msuengine.cpp index b7a503ad..499e1da6 100644 --- a/src/engine/msuengine.cpp +++ b/src/engine/msuengine.cpp @@ -90,14 +90,10 @@ extern "C" HRESULT MsuEnginePlanCalculatePackage( BOOTSTRAPPER_ACTION_STATE execute = BOOTSTRAPPER_ACTION_STATE_NONE; BOOTSTRAPPER_ACTION_STATE rollback = BOOTSTRAPPER_ACTION_STATE_NONE; BOOL fBARequestedCache = FALSE; - BOOL fAllowUninstall = FALSE; - OS_VERSION osVersion = OS_VERSION_UNKNOWN; - DWORD dwServicePack = 0; // We can only uninstall MSU packages if they have a KB and we are on Win7 or newer. - OsGetVersion(&osVersion, &dwServicePack); - fAllowUninstall = (pPackage->Msu.sczKB && *pPackage->Msu.sczKB) && OS_VERSION_WIN7 <= osVersion; + fAllowUninstall = pPackage->Msu.sczKB && *pPackage->Msu.sczKB && ::IsWindows7OrGreater(); // execute action switch (pPackage->currentState) diff --git a/src/engine/packages.config b/src/engine/packages.config index f074ae43..102b8bee 100644 --- a/src/engine/packages.config +++ b/src/engine/packages.config @@ -1,5 +1,5 @@  - + \ No newline at end of file diff --git a/src/engine/pipe.cpp b/src/engine/pipe.cpp index eb3eb863..67eeae87 100644 --- a/src/engine/pipe.cpp +++ b/src/engine/pipe.cpp @@ -391,16 +391,13 @@ extern "C" HRESULT PipeLaunchChildProcess( HRESULT hr = S_OK; DWORD dwCurrentProcessId = ::GetCurrentProcessId(); LPWSTR sczParameters = NULL; - OS_VERSION osVersion = OS_VERSION_UNKNOWN; - DWORD dwServicePack = 0; LPCWSTR wzVerb = NULL; HANDLE hProcess = NULL; hr = StrAllocFormatted(&sczParameters, L"-q -%ls %ls %ls %u", BURN_COMMANDLINE_SWITCH_ELEVATED, pConnection->sczName, pConnection->sczSecret, dwCurrentProcessId); ExitOnFailure(hr, "Failed to allocate parameters for elevated process."); - OsGetVersion(&osVersion, &dwServicePack); - wzVerb = (OS_VERSION_VISTA > osVersion) || !fElevate ? L"open" : L"runas"; + wzVerb = !fElevate ? L"open" : L"runas"; // Since ShellExecuteEx doesn't support passing inherited handles, don't bother with CoreAppendFileHandleSelfToCommandLine. // We could fallback to using ::DuplicateHandle to inject the file handle later if necessary. diff --git a/src/engine/precomp.h b/src/engine/precomp.h index 53fa949a..1b3e9bdc 100644 --- a/src/engine/precomp.h +++ b/src/engine/precomp.h @@ -18,6 +18,7 @@ #include #include #include +#include #include #include diff --git a/src/engine/registration.cpp b/src/engine/registration.cpp index d3732e74..a2ed2a0d 100644 --- a/src/engine/registration.cpp +++ b/src/engine/registration.cpp @@ -1178,20 +1178,9 @@ static HRESULT UpdateResumeMode( HKEY hkRun = NULL; LPWSTR sczResumeCommandLine = NULL; LPCWSTR sczResumeKey = REGISTRY_RUN_ONCE_KEY; - OS_VERSION osv = OS_VERSION_UNKNOWN; - DWORD dwServicePack = 0; LogId(REPORT_STANDARD, MSG_SESSION_UPDATE, pRegistration->sczRegistrationKey, LoggingResumeModeToString(resumeMode), LoggingBoolToString(fRestartInitiated), LoggingBoolToString(pRegistration->fDisableResume)); - // On Windows XP and Server 2003, write the resume information to the Run key - // instead of RunOnce. That avoids the problem that driver installation might - // trigger RunOnce commands to be executed before the reboot. - OsGetVersion(&osv, &dwServicePack); - if (osv < OS_VERSION_VISTA) - { - sczResumeKey = REGISTRY_RUN_KEY; - } - // write resume information if (hkRegistration) { diff --git a/src/engine/variable.cpp b/src/engine/variable.cpp index 51dbdff4..fed23151 100644 --- a/src/engine/variable.cpp +++ b/src/engine/variable.cpp @@ -1638,33 +1638,17 @@ LExit: return hr; } -extern "C" typedef NTSTATUS (NTAPI *RTL_GET_VERSION)(_Out_ PRTL_OSVERSIONINFOEXW lpVersionInformation); - static HRESULT InitializeVariableVersionNT( __in DWORD_PTR dwpData, __inout BURN_VARIANT* pValue ) { HRESULT hr = S_OK; - HMODULE ntdll = NULL; - RTL_GET_VERSION rtlGetVersion = NULL; RTL_OSVERSIONINFOEXW ovix = { }; BURN_VARIANT value = { }; VERUTIL_VERSION* pVersion = NULL; - if (!::GetModuleHandleExW(0, L"ntdll", &ntdll)) - { - ExitWithLastError(hr, "Failed to locate NTDLL."); - } - - rtlGetVersion = reinterpret_cast(::GetProcAddress(ntdll, "RtlGetVersion")); - if (NULL == rtlGetVersion) - { - ExitWithLastError(hr, "Failed to locate RtlGetVersion."); - } - - ovix.dwOSVersionInfoSize = sizeof(RTL_OSVERSIONINFOEXW); - hr = static_cast(rtlGetVersion(&ovix)); + hr = OsRtlGetVersion(&ovix); ExitOnFailure(hr, "Failed to get OS info."); switch ((OS_INFO_VARIABLE)dwpData) @@ -1712,11 +1696,6 @@ static HRESULT InitializeVariableVersionNT( ExitOnFailure(hr, "Failed to set variant value."); LExit: - if (NULL != ntdll) - { - FreeLibrary(ntdll); - } - ReleaseVerutilVersion(pVersion); return hr; @@ -1728,15 +1707,11 @@ static HRESULT InitializeVariableOsInfo( ) { HRESULT hr = S_OK; - OSVERSIONINFOEXW ovix = { }; + RTL_OSVERSIONINFOEXW ovix = { }; BURN_VARIANT value = { }; - ovix.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXW); - #pragma warning(suppress: 4996) - if (!::GetVersionExW((LPOSVERSIONINFOW)&ovix)) - { - ExitWithLastError(hr, "Failed to get OS info."); - } + hr = OsRtlGetVersion(&ovix); + ExitOnFailure(hr, "Failed to get OS info."); switch ((OS_INFO_VARIABLE)dwpData) { diff --git a/src/stub/packages.config b/src/stub/packages.config index 7681e32c..3b161457 100644 --- a/src/stub/packages.config +++ b/src/stub/packages.config @@ -4,5 +4,5 @@ - + \ No newline at end of file diff --git a/src/stub/stub.vcxproj b/src/stub/stub.vcxproj index 1b76d866..f4d34d1d 100644 --- a/src/stub/stub.vcxproj +++ b/src/stub/stub.vcxproj @@ -5,7 +5,7 @@ - + @@ -117,6 +117,6 @@ - + \ No newline at end of file diff --git a/src/test/BurnUnitTest/BurnUnitTest.vcxproj b/src/test/BurnUnitTest/BurnUnitTest.vcxproj index a843eddd..62e58942 100644 --- a/src/test/BurnUnitTest/BurnUnitTest.vcxproj +++ b/src/test/BurnUnitTest/BurnUnitTest.vcxproj @@ -4,7 +4,7 @@ - + Debug @@ -95,6 +95,6 @@ - + \ No newline at end of file diff --git a/src/test/BurnUnitTest/packages.config b/src/test/BurnUnitTest/packages.config index f9d0f75a..e3e97259 100644 --- a/src/test/BurnUnitTest/packages.config +++ b/src/test/BurnUnitTest/packages.config @@ -10,5 +10,5 @@ - + \ No newline at end of file -- cgit v1.2.3-55-g6feb