diff --git a/build-scripts/build_windows_installer.bat b/build-scripts/build_windows_installer.bat index 44f30ef..6659e01 100644 --- a/build-scripts/build_windows_installer.bat +++ b/build-scripts/build_windows_installer.bat @@ -39,12 +39,41 @@ if %FIND_VS_WHERE% NEQ 0 ( :VS2017PlusCheck +if defined VS170COMNTOOLS ( + set TOOL_CHAIN_TAG=VS2022 +) if defined VS160COMNTOOLS ( set TOOL_CHAIN_TAG=VS2019 ) if defined VS150COMNTOOLS ( set TOOL_CHAIN_TAG=VS2017 ) + +set CHECK_VS2022=0 +if not defined TOOL_CHAIN_TAG ( + set CHECK_VS2022=1 +) else ( + if /I "%TOOL_CHAIN_TAG%"=="VS2022" ( + set CHECK_VS2022=1 + ) +) +if %CHECK_VS2022% NEQ 0 ( + for /f "usebackq tokens=1* delims=: " %%i in (`"%VS_WHERE%" -version [17.0^,18.0^)`) do ( + if /i "%%i"=="installationPath" set INSTALL_PATH=%%j + ) +) +if %CHECK_VS2022% NEQ 0 ( + if defined INSTALL_PATH ( + echo. + echo Prebuild: Set the VS2022 environment. + echo. + if not defined VS160COMNTOOLS ( + call "%INSTALL_PATH%\VC\Auxiliary\Build\vcvars32.bat" + ) + set TOOL_CHAIN_TAG=VS2022 + ) +) + set CHECK_VS2019=0 if not defined TOOL_CHAIN_TAG ( set CHECK_VS2019=1 @@ -155,11 +184,7 @@ if errorlevel 1 ( set SCRIPT_ERROR=1 goto End ) -copy /B /Y ..\edkrepo_installer\Release\SetupLauncher.exe ..\dist\self_extract -if errorlevel 1 ( - set SCRIPT_ERROR=1 - goto End -) + copy /B /Y ..\edkrepo_installer\EdkRepoInstaller\bin\Release\EdkRepoInstaller.exe ..\dist\self_extract if errorlevel 1 ( set SCRIPT_ERROR=1 diff --git a/edkrepo_installer/SelfExtract/config.txt b/edkrepo_installer/SelfExtract/config.txt index 989e61f..55dd926 100644 --- a/edkrepo_installer/SelfExtract/config.txt +++ b/edkrepo_installer/SelfExtract/config.txt @@ -1,4 +1,4 @@ ;!@Install@!UTF-8! Title="EdkRepo Installer" -RunProgram="SetupLauncher.exe" +RunProgram="EdkRepoInstaller.exe" ;!@InstallEnd@! diff --git a/edkrepo_installer/SetupLauncher/DetectDotNet.cpp b/edkrepo_installer/SetupLauncher/DetectDotNet.cpp deleted file mode 100644 index 7f2c7d5..0000000 --- a/edkrepo_installer/SetupLauncher/DetectDotNet.cpp +++ /dev/null @@ -1,1099 +0,0 @@ -// -// Code is from: -// https://blogs.msdn.microsoft.com/astebner/2009/06/16/sample-code-to-detect-net-framework-install-state-and-service-pack-level/ -// Author has indicated that there is no license required to use this code. -// - -#include -#include -#include -#include -#include - -// In case the machine this is compiled on does not have the most recent platform SDK -// with these values defined, define them here -#ifndef SM_TABLETPC - #define SM_TABLETPC 86 -#endif - -#ifndef SM_MEDIACENTER - #define SM_MEDIACENTER 87 -#endif - -#define CountOf(x) sizeof(x)/sizeof(*x) - -// Constants that represent registry key names and value names -// to use for detection -const TCHAR *g_szNetfx10RegKeyName = _T("Software\\Microsoft\\.NETFramework\\Policy\\v1.0"); -const TCHAR *g_szNetfx10RegKeyValue = _T("3705"); -const TCHAR *g_szNetfx10SPxMSIRegKeyName = _T("Software\\Microsoft\\Active Setup\\Installed Components\\{78705f0d-e8db-4b2d-8193-982bdda15ecd}"); -const TCHAR *g_szNetfx10SPxOCMRegKeyName = _T("Software\\Microsoft\\Active Setup\\Installed Components\\{FDC11A6F-17D1-48f9-9EA3-9051954BAA24}"); -const TCHAR *g_szNetfx11RegKeyName = _T("Software\\Microsoft\\NET Framework Setup\\NDP\\v1.1.4322"); -const TCHAR *g_szNetfx20RegKeyName = _T("Software\\Microsoft\\NET Framework Setup\\NDP\\v2.0.50727"); -const TCHAR *g_szNetfx30RegKeyName = _T("Software\\Microsoft\\NET Framework Setup\\NDP\\v3.0\\Setup"); -const TCHAR *g_szNetfx30SpRegKeyName = _T("Software\\Microsoft\\NET Framework Setup\\NDP\\v3.0"); -const TCHAR *g_szNetfx30RegValueName = _T("InstallSuccess"); -const TCHAR *g_szNetfx35RegKeyName = _T("Software\\Microsoft\\NET Framework Setup\\NDP\\v3.5"); -const TCHAR *g_szNetfx40ClientRegKeyName = _T("Software\\Microsoft\\NET Framework Setup\\NDP\\v4\\Client"); -const TCHAR *g_szNetfx40FullRegKeyName = _T("Software\\Microsoft\\NET Framework Setup\\NDP\\v4\\Full"); -const TCHAR *g_szNetfx40SPxRegValueName = _T("Servicing"); -const TCHAR *g_szNetfx45RegKeyName = _T("Software\\Microsoft\\NET Framework Setup\\NDP\\v4\\Full"); -const TCHAR *g_szNetfx45RegValueName = _T("Release"); -const TCHAR *g_szNetfxStandardRegValueName = _T("Install"); -const TCHAR *g_szNetfxStandardSPxRegValueName = _T("SP"); -const TCHAR *g_szNetfxStandardVersionRegValueName = _T("Version"); - -// Version information for final release of .NET Framework 3.0 -const int g_iNetfx30VersionMajor = 3; -const int g_iNetfx30VersionMinor = 0; -const int g_iNetfx30VersionBuild = 4506; -const int g_iNetfx30VersionRevision = 26; - -// Version information for final release of .NET Framework 3.5 -const int g_iNetfx35VersionMajor = 3; -const int g_iNetfx35VersionMinor = 5; -const int g_iNetfx35VersionBuild = 21022; -const int g_iNetfx35VersionRevision = 8; - -// Version information for final release of .NET Framework 4 -const int g_iNetfx40VersionMajor = 4; -const int g_iNetfx40VersionMinor = 0; -const int g_iNetfx40VersionBuild = 30319; -const int g_iNetfx40VersionRevision = 0; - -// Version information for final release of .NET Framework 4.5 -const int g_dwNetfx45ReleaseVersion = 378389; - -// Version information for final release of .NET Framework 4.5.1 -const int g_dwNetfx451ReleaseVersion = 378675; - -// Version information for final release of .NET Framework 4.5.2 -const int g_dwNetfx452ReleaseVersion = 379893; - -// Version information for final release of .NET Framework 4.6 -const int g_dwNetfx46ReleaseVersion = 393295; - -// Version information for final release of .NET Framework 4.6.1 -const int g_dwNetfx461ReleaseVersion = 394254; - -// Version information for final release of .NET Framework 4.6.2 -const int g_dwNetfx462ReleaseVersion = 394802; - -// Constants for known .NET Framework versions used with the GetRequestedRuntimeInfo API -const TCHAR *g_szNetfx10VersionString = _T("v1.0.3705"); -const TCHAR *g_szNetfx11VersionString = _T("v1.1.4322"); -const TCHAR *g_szNetfx20VersionString = _T("v2.0.50727"); -const TCHAR *g_szNetfx40VersionString = _T("v4.0.30319"); - -// Function prototypes -bool CheckNetfxBuildNumber(const TCHAR*, const TCHAR*, const int, const int, const int, const int); -bool CheckNetfxVersionUsingMscoree(const TCHAR*); -int GetNetfx10SPLevel(); -int GetNetfxSPLevel(const TCHAR*, const TCHAR*); -DWORD GetProcessorArchitectureFlag(); -bool IsCurrentOSTabletMedCenter(); -bool IsNetfx10Installed(); -bool IsNetfx11Installed(); -bool IsNetfx20Installed(); -bool IsNetfx30Installed(); -bool IsNetfx35Installed(); -bool IsNetfx40ClientInstalled(); -bool IsNetfx40FullInstalled(); -bool IsNetfx45Installed(); -bool IsNetfx451Installed(); -bool IsNetfx452Installed(); -bool IsNetfx46Installed(); -bool IsNetfx461Installed(); -bool IsNetfx462Installed(); -bool RegistryGetValue(HKEY, const TCHAR*, const TCHAR*, DWORD, LPBYTE, DWORD); - - -/****************************************************************** -Function Name: CheckNetfxVersionUsingMscoree -Description: Uses the logic described in the sample code at - http://msdn2.microsoft.com/library/ydh6b3yb.aspx - to load mscoree.dll and call its APIs to determine - whether or not a specific version of the .NET - Framework is installed on the system -Inputs: pszNetfxVersionToCheck - version to look for -Results: true if the requested version is installed - false otherwise -******************************************************************/ -bool CheckNetfxVersionUsingMscoree(const TCHAR *pszNetfxVersionToCheck) -{ - bool bFoundRequestedNetfxVersion = false; - HRESULT hr = S_OK; - - // Check input parameter - if (NULL == pszNetfxVersionToCheck) - return false; - - HMODULE hmodMscoree = LoadLibraryEx(_T("mscoree.dll"), NULL, LOAD_LIBRARY_SEARCH_SYSTEM32); - if (NULL != hmodMscoree) - { - typedef HRESULT (STDAPICALLTYPE *GETCORVERSION)(LPWSTR szBuffer, DWORD cchBuffer, DWORD* dwLength); - GETCORVERSION pfnGETCORVERSION = (GETCORVERSION)GetProcAddress(hmodMscoree, "GetCORVersion"); - - // Some OSs shipped with a placeholder copy of mscoree.dll. The existence of mscoree.dll - // therefore does NOT mean that a version of the .NET Framework is installed. - // If this copy of mscoree.dll does not have an exported function named GetCORVersion - // then we know it is a placeholder DLL. - if (NULL == pfnGETCORVERSION) - goto Finish; - - typedef HRESULT (STDAPICALLTYPE *CORBINDTORUNTIME)(LPCWSTR pwszVersion, LPCWSTR pwszBuildFlavor, REFCLSID rclsid, REFIID riid, LPVOID FAR *ppv); - CORBINDTORUNTIME pfnCORBINDTORUNTIME = (CORBINDTORUNTIME)GetProcAddress(hmodMscoree, "CorBindToRuntime"); - - typedef HRESULT (STDAPICALLTYPE *GETREQUESTEDRUNTIMEINFO)(LPCWSTR pExe, LPCWSTR pwszVersion, LPCWSTR pConfigurationFile, DWORD startupFlags, DWORD runtimeInfoFlags, LPWSTR pDirectory, DWORD dwDirectory, DWORD *dwDirectoryLength, LPWSTR pVersion, DWORD cchBuffer, DWORD* dwlength); - GETREQUESTEDRUNTIMEINFO pfnGETREQUESTEDRUNTIMEINFO = (GETREQUESTEDRUNTIMEINFO)GetProcAddress(hmodMscoree, "GetRequestedRuntimeInfo"); - - if (NULL != pfnCORBINDTORUNTIME) - { - TCHAR szRetrievedVersion[50]; - DWORD dwLength = CountOf(szRetrievedVersion); - - if (NULL == pfnGETREQUESTEDRUNTIMEINFO) - { - // Having CorBindToRuntimeHost but not having GetRequestedRuntimeInfo means that - // this machine contains no higher than .NET Framework 1.0, but the only way to - // 100% guarantee that the .NET Framework 1.0 is installed is to call a function - // to exercise its functionality - if (0 == _tcscmp(pszNetfxVersionToCheck, g_szNetfx10VersionString)) - { - hr = pfnGETCORVERSION(szRetrievedVersion, dwLength, &dwLength); - - if (SUCCEEDED(hr)) - { - if (0 == _tcscmp(szRetrievedVersion, g_szNetfx10VersionString)) - bFoundRequestedNetfxVersion = true; - } - - goto Finish; - } - } - - // Set error mode to prevent the .NET Framework from displaying - // unfriendly error dialogs - UINT uOldErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS); - - TCHAR szDirectory[MAX_PATH]; - DWORD dwDirectoryLength = 0; - DWORD dwRuntimeInfoFlags = RUNTIME_INFO_DONT_RETURN_DIRECTORY | GetProcessorArchitectureFlag(); - - // Check for the requested .NET Framework version - hr = pfnGETREQUESTEDRUNTIMEINFO(NULL, pszNetfxVersionToCheck, NULL, STARTUP_LOADER_OPTIMIZATION_MULTI_DOMAIN_HOST, NULL, szDirectory, CountOf(szDirectory), &dwDirectoryLength, szRetrievedVersion, CountOf(szRetrievedVersion), &dwLength); - - if (SUCCEEDED(hr)) - bFoundRequestedNetfxVersion = true; - - // Restore the previous error mode - SetErrorMode(uOldErrorMode); - } - } - -Finish: - if (hmodMscoree) - { - FreeLibrary(hmodMscoree); - } - - return bFoundRequestedNetfxVersion; -} - - -/****************************************************************** -Function Name: GetNetfx10SPLevel -Description: Uses the detection method recommended at - http://blogs.msdn.com/astebner/archive/2004/09/14/229802.aspx - to determine what service pack for the - .NET Framework 1.0 is installed on the machine -Inputs: NONE -Results: integer representing SP level for .NET Framework 1.0 -******************************************************************/ -int GetNetfx10SPLevel() -{ - TCHAR szRegValue[MAX_PATH]; - TCHAR *pszSPLevel = NULL; - int iRetValue = -1; - bool bRegistryRetVal = false; - - // Need to detect what OS we are running on so we know what - // registry key to use to look up the SP level - if (IsCurrentOSTabletMedCenter()) - bRegistryRetVal = RegistryGetValue(HKEY_LOCAL_MACHINE, g_szNetfx10SPxOCMRegKeyName, g_szNetfxStandardVersionRegValueName, NULL, (LPBYTE)szRegValue, MAX_PATH); - else - bRegistryRetVal = RegistryGetValue(HKEY_LOCAL_MACHINE, g_szNetfx10SPxMSIRegKeyName, g_szNetfxStandardVersionRegValueName, NULL, (LPBYTE)szRegValue, MAX_PATH); - - if (bRegistryRetVal) - { - // This registry value should be of the format - // #,#,#####,# where the last # is the SP level - // Try to parse off the last # here - pszSPLevel = _tcsrchr(szRegValue, _T(',')); - if (NULL != pszSPLevel) - { - // Increment the pointer to skip the comma - pszSPLevel++; - - // Convert the remaining value to an integer - iRetValue = _tstoi(pszSPLevel); - } - } - - return iRetValue; -} - - -/****************************************************************** -Function Name: GetNetfxSPLevel -Description: Determine what service pack is installed for a - version of the .NET Framework using registry - based detection methods documented in the - .NET Framework deployment guides. -Inputs: pszNetfxRegKeyName - registry key name to use for detection - pszNetfxRegValueName - registry value to use for detection -Results: integer representing SP level for .NET Framework -******************************************************************/ -int GetNetfxSPLevel(const TCHAR *pszNetfxRegKeyName, const TCHAR *pszNetfxRegValueName) -{ - DWORD dwRegValue=0; - - if (RegistryGetValue(HKEY_LOCAL_MACHINE, pszNetfxRegKeyName, pszNetfxRegValueName, NULL, (LPBYTE)&dwRegValue, sizeof(DWORD))) - { - return (int)dwRegValue; - } - - // We can only get here if the .NET Framework is not - // installed or there was some kind of error retrieving - // the data from the registry - return -1; -} - - -/****************************************************************** -Function Name: GetProcessorArchitectureFlag -Description: Determine the processor architecture of the - system (x86, x64, ia64) -Inputs: NONE -Results: DWORD processor architecture flag -******************************************************************/ -DWORD GetProcessorArchitectureFlag() -{ - HMODULE hmodKernel32 = NULL; - typedef void (WINAPI *PFnGetNativeSystemInfo) (LPSYSTEM_INFO); - PFnGetNativeSystemInfo pfnGetNativeSystemInfo; - - SYSTEM_INFO sSystemInfo; - memset(&sSystemInfo, 0, sizeof(sSystemInfo)); - - bool bRetrievedSystemInfo = false; - - // Attempt to load kernel32.dll - hmodKernel32 = LoadLibrary(_T("Kernel32.dll")); - if (NULL != hmodKernel32) - { - // If the DLL loaded correctly, get the proc address for GetNativeSystemInfo - pfnGetNativeSystemInfo = (PFnGetNativeSystemInfo) GetProcAddress(hmodKernel32, "GetNativeSystemInfo"); - if (NULL != pfnGetNativeSystemInfo) - { - // Call GetNativeSystemInfo if it exists - (*pfnGetNativeSystemInfo)(&sSystemInfo); - bRetrievedSystemInfo = true; - } - FreeLibrary(hmodKernel32); - } - - if (!bRetrievedSystemInfo) - { - // Fallback to calling GetSystemInfo if the above failed - GetSystemInfo(&sSystemInfo); - bRetrievedSystemInfo = true; - } - - if (bRetrievedSystemInfo) - { - switch (sSystemInfo.wProcessorArchitecture) - { - case PROCESSOR_ARCHITECTURE_INTEL: - return RUNTIME_INFO_REQUEST_X86; - case PROCESSOR_ARCHITECTURE_IA64: - return RUNTIME_INFO_REQUEST_IA64; - case PROCESSOR_ARCHITECTURE_AMD64: - return RUNTIME_INFO_REQUEST_AMD64; - default: - return 0; - } - } - - return 0; -} - - -/****************************************************************** -Function Name: CheckNetfxBuildNumber -Description: Retrieves the .NET Framework build number from - the registry and validates that it is not a pre-release - version number -Inputs: NONE -Results: true if the build number in the registry is greater - than or equal to the passed in version; false otherwise -******************************************************************/ -bool CheckNetfxBuildNumber(const TCHAR *pszNetfxRegKeyName, const TCHAR *pszNetfxRegKeyValue, const int iRequestedVersionMajor, const int iRequestedVersionMinor, const int iRequestedVersionBuild, const int iRequestedVersionRevision) -{ - TCHAR szRegValue[MAX_PATH]; - TCHAR *pszToken = NULL; - TCHAR *pszNextToken = NULL; - int iVersionPartCounter = 0; - int iRegistryVersionMajor = 0; - int iRegistryVersionMinor = 0; - int iRegistryVersionBuild = 0; - int iRegistryVersionRevision = 0; - bool bRegistryRetVal = false; - - // Attempt to retrieve the build number registry value - bRegistryRetVal = RegistryGetValue(HKEY_LOCAL_MACHINE, pszNetfxRegKeyName, pszNetfxRegKeyValue, NULL, (LPBYTE)szRegValue, MAX_PATH); - - if (bRegistryRetVal) - { - // This registry value should be of the format - // #.#.#####.##. Try to parse the 4 parts of - // the version here - pszToken = _tcstok_s(szRegValue, _T("."), &pszNextToken); - while (NULL != pszToken) - { - iVersionPartCounter++; - - switch (iVersionPartCounter) - { - case 1: - // Convert the major version value to an integer - iRegistryVersionMajor = _tstoi(pszToken); - break; - case 2: - // Convert the minor version value to an integer - iRegistryVersionMinor = _tstoi(pszToken); - break; - case 3: - // Convert the build number value to an integer - iRegistryVersionBuild = _tstoi(pszToken); - break; - case 4: - // Convert the revision number value to an integer - iRegistryVersionRevision = _tstoi(pszToken); - break; - default: - break; - - } - - // Get the next part of the version number - pszToken = _tcstok_s(NULL, _T("."), &pszNextToken); - } - } - - // Compare the version number retrieved from the registry with - // the version number of the final release of the .NET Framework - // that we are checking - if (iRegistryVersionMajor > iRequestedVersionMajor) - { - return true; - } - else if (iRegistryVersionMajor == iRequestedVersionMajor) - { - if (iRegistryVersionMinor > iRequestedVersionMinor) - { - return true; - } - else if (iRegistryVersionMinor == iRequestedVersionMinor) - { - if (iRegistryVersionBuild > iRequestedVersionBuild) - { - return true; - } - else if (iRegistryVersionBuild == iRequestedVersionBuild) - { - if (iRegistryVersionRevision >= iRequestedVersionRevision) - { - return true; - } - } - } - } - - // If we get here, the version in the registry must be less than the - // version of the final release of the .NET Framework we are checking, - // so return false - return false; -} - - -/****************************************************************** -Function Name: IsCurrentOSTabletMedCenter -Description: Determine if the current OS is a Windows XP - Tablet PC Edition or Windows XP Media Center - Edition system -Inputs: NONE -Results: true if the OS is Tablet PC or Media Center - false otherwise -******************************************************************/ -bool IsCurrentOSTabletMedCenter() -{ - // Use GetSystemMetrics to detect if we are on a Tablet PC or Media Center OS - return ( (GetSystemMetrics(SM_TABLETPC) != 0) || (GetSystemMetrics(SM_MEDIACENTER) != 0) ); -} - - -/****************************************************************** -Function Name: IsNetfx10Installed -Description: Uses the detection method recommended at - http://msdn.microsoft.com/library/ms994349.aspx - to determine whether the .NET Framework 1.0 is - installed on the machine -Inputs: NONE -Results: true if the .NET Framework 1.0 is installed - false otherwise -******************************************************************/ -bool IsNetfx10Installed() -{ - TCHAR szRegValue[MAX_PATH]; - return (RegistryGetValue(HKEY_LOCAL_MACHINE, g_szNetfx10RegKeyName, g_szNetfx10RegKeyValue, NULL, (LPBYTE)szRegValue, MAX_PATH)); -} - - -/****************************************************************** -Function Name: IsNetfx11Installed -Description: Uses the detection method recommended at - http://msdn.microsoft.com/library/ms994339.aspx - to determine whether the .NET Framework 1.1 is - installed on the machine -Inputs: NONE -Results: true if the .NET Framework 1.1 is installed - false otherwise -******************************************************************/ -bool IsNetfx11Installed() -{ - bool bRetValue = false; - DWORD dwRegValue=0; - - if (RegistryGetValue(HKEY_LOCAL_MACHINE, g_szNetfx11RegKeyName, g_szNetfxStandardRegValueName, NULL, (LPBYTE)&dwRegValue, sizeof(DWORD))) - { - if (1 == dwRegValue) - bRetValue = true; - } - - return bRetValue; -} - - -/****************************************************************** -Function Name: IsNetfx20Installed -Description: Uses the detection method recommended at - http://msdn2.microsoft.com/library/aa480243.aspx - to determine whether the .NET Framework 2.0 is - installed on the machine -Inputs: NONE -Results: true if the .NET Framework 2.0 is installed - false otherwise -******************************************************************/ -bool IsNetfx20Installed() -{ - bool bRetValue = false; - DWORD dwRegValue=0; - - if (RegistryGetValue(HKEY_LOCAL_MACHINE, g_szNetfx20RegKeyName, g_szNetfxStandardRegValueName, NULL, (LPBYTE)&dwRegValue, sizeof(DWORD))) - { - if (1 == dwRegValue) - bRetValue = true; - } - - return bRetValue; -} - - -/****************************************************************** -Function Name: IsNetfx30Installed -Description: Uses the detection method recommended at - http://msdn.microsoft.com/library/aa964979.aspx - to determine whether the .NET Framework 3.0 is - installed on the machine -Inputs: NONE -Results: true if the .NET Framework 3.0 is installed - false otherwise -******************************************************************/ -bool IsNetfx30Installed() -{ - bool bRetValue = false; - DWORD dwRegValue=0; - - // Check that the InstallSuccess registry value exists and equals 1 - if (RegistryGetValue(HKEY_LOCAL_MACHINE, g_szNetfx30RegKeyName, g_szNetfx30RegValueName, NULL, (LPBYTE)&dwRegValue, sizeof(DWORD))) - { - if (1 == dwRegValue) - bRetValue = true; - } - - // A system with a pre-release version of the .NET Framework 3.0 can - // have the InstallSuccess value. As an added verification, check the - // version number listed in the registry - return (bRetValue && CheckNetfxBuildNumber(g_szNetfx30RegKeyName, g_szNetfxStandardVersionRegValueName, g_iNetfx30VersionMajor, g_iNetfx30VersionMinor, g_iNetfx30VersionBuild, g_iNetfx30VersionRevision)); -} - - -/****************************************************************** -Function Name: IsNetfx35Installed -Description: Uses the detection method recommended at - http://msdn.microsoft.com/library/cc160716.aspx - to determine whether the .NET Framework 3.5 is - installed on the machine -Inputs: NONE -Results: true if the .NET Framework 3.5 is installed - false otherwise -******************************************************************/ -bool IsNetfx35Installed() -{ - bool bRetValue = false; - DWORD dwRegValue=0; - - // Check that the Install registry value exists and equals 1 - if (RegistryGetValue(HKEY_LOCAL_MACHINE, g_szNetfx35RegKeyName, g_szNetfxStandardRegValueName, NULL, (LPBYTE)&dwRegValue, sizeof(DWORD))) - { - if (1 == dwRegValue) - bRetValue = true; - } - - // A system with a pre-release version of the .NET Framework 3.5 can - // have the Install value. As an added verification, check the - // version number listed in the registry - return (bRetValue && CheckNetfxBuildNumber(g_szNetfx35RegKeyName, g_szNetfxStandardVersionRegValueName, g_iNetfx35VersionMajor, g_iNetfx35VersionMinor, g_iNetfx35VersionBuild, g_iNetfx35VersionRevision)); -} - - -/****************************************************************** -Function Name: IsNetfx40ClientInstalled -Description: Uses the detection method recommended at - http://msdn.microsoft.com/library/ee942965(v=VS.100).aspx - to determine whether the .NET Framework 4 Client is - installed on the machine -Inputs: NONE -Results: true if the .NET Framework 4 Client is installed - false otherwise -******************************************************************/ -bool IsNetfx40ClientInstalled() -{ - bool bRetValue = false; - DWORD dwRegValue=0; - - if (RegistryGetValue(HKEY_LOCAL_MACHINE, g_szNetfx40ClientRegKeyName, g_szNetfxStandardRegValueName, NULL, (LPBYTE)&dwRegValue, sizeof(DWORD))) - { - if (1 == dwRegValue) - bRetValue = true; - } - - // A system with a pre-release version of the .NET Framework 4 can - // have the Install value. As an added verification, check the - // version number listed in the registry - return (bRetValue && CheckNetfxBuildNumber(g_szNetfx40ClientRegKeyName, g_szNetfxStandardVersionRegValueName, g_iNetfx40VersionMajor, g_iNetfx40VersionMinor, g_iNetfx40VersionBuild, g_iNetfx40VersionRevision)); -} - - -/****************************************************************** -Function Name: IsNetfx40FullInstalled -Description: Uses the detection method recommended at - http://msdn.microsoft.com/library/ee942965(v=VS.100).aspx - to determine whether the .NET Framework 4 Full is - installed on the machine -Inputs: NONE -Results: true if the .NET Framework 4 Full is installed - false otherwise -******************************************************************/ -bool IsNetfx40FullInstalled() -{ - bool bRetValue = false; - DWORD dwRegValue=0; - - if (RegistryGetValue(HKEY_LOCAL_MACHINE, g_szNetfx40FullRegKeyName, g_szNetfxStandardRegValueName, NULL, (LPBYTE)&dwRegValue, sizeof(DWORD))) - { - if (1 == dwRegValue) - bRetValue = true; - } - - // A system with a pre-release version of the .NET Framework 4 can - // have the Install value. As an added verification, check the - // version number listed in the registry - return (bRetValue && CheckNetfxBuildNumber(g_szNetfx40FullRegKeyName, g_szNetfxStandardVersionRegValueName, g_iNetfx40VersionMajor, g_iNetfx40VersionMinor, g_iNetfx40VersionBuild, g_iNetfx40VersionRevision)); -} - - -/****************************************************************** -Function Name: IsNetfx45Installed -Description: Uses the detection method recommended at - http://msdn.microsoft.com/en-us/library/ee942965(v=vs.110).aspx - to determine whether the .NET Framework 4.5 is - installed on the machine -Inputs: NONE -Results: true if the .NET Framework 4.5 is installed - false otherwise -******************************************************************/ -bool IsNetfx45Installed() -{ - bool bRetValue = false; - DWORD dwRegValue=0; - - if (RegistryGetValue(HKEY_LOCAL_MACHINE, g_szNetfx45RegKeyName, g_szNetfx45RegValueName, NULL, (LPBYTE)&dwRegValue, sizeof(DWORD))) - { - if (g_dwNetfx45ReleaseVersion <= dwRegValue) - bRetValue = true; - } - - return bRetValue; -} - - -/****************************************************************** -Function Name: IsNetfx451Installed -Description: Uses the detection method recommended at - http://msdn.microsoft.com/en-us/library/ee942965(v=vs.110).aspx - to determine whether the .NET Framework 4.5.1 is - installed on the machine -Inputs: NONE -Results: true if the .NET Framework 4.5.1 is installed - false otherwise -******************************************************************/ -bool IsNetfx451Installed() -{ - bool bRetValue = false; - DWORD dwRegValue=0; - - if (RegistryGetValue(HKEY_LOCAL_MACHINE, g_szNetfx45RegKeyName, g_szNetfx45RegValueName, NULL, (LPBYTE)&dwRegValue, sizeof(DWORD))) - { - if (g_dwNetfx451ReleaseVersion <= dwRegValue) - bRetValue = true; - } - - return bRetValue; -} - - -/****************************************************************** -Function Name: IsNetfx452Installed -Description: Uses the detection method recommended at - http://msdn.microsoft.com/en-us/library/ee942965(v=vs.110).aspx - to determine whether the .NET Framework 4.5.2 is - installed on the machine -Inputs: NONE -Results: true if the .NET Framework 4.5.2 is installed - false otherwise -******************************************************************/ -bool IsNetfx452Installed() -{ - bool bRetValue = false; - DWORD dwRegValue=0; - - if (RegistryGetValue(HKEY_LOCAL_MACHINE, g_szNetfx45RegKeyName, g_szNetfx45RegValueName, NULL, (LPBYTE)&dwRegValue, sizeof(DWORD))) - { - if (g_dwNetfx452ReleaseVersion <= dwRegValue) - bRetValue = true; - } - - return bRetValue; -} - - -/****************************************************************** -Function Name: IsNetfx46Installed -Description: Uses the detection method recommended at - http://msdn.microsoft.com/en-us/library/ee942965(v=vs.110).aspx - to determine whether the .NET Framework 4.6 is - installed on the machine -Inputs: NONE -Results: true if the .NET Framework 4.6 is installed - false otherwise -******************************************************************/ -bool IsNetfx46Installed() -{ - bool bRetValue = false; - DWORD dwRegValue=0; - - if (RegistryGetValue(HKEY_LOCAL_MACHINE, g_szNetfx45RegKeyName, g_szNetfx45RegValueName, NULL, (LPBYTE)&dwRegValue, sizeof(DWORD))) - { - if (g_dwNetfx46ReleaseVersion <= dwRegValue) - bRetValue = true; - } - - return bRetValue; -} - - -/****************************************************************** -Function Name: IsNetfx461Installed -Description: Uses the detection method recommended at - http://msdn.microsoft.com/en-us/library/ee942965(v=vs.110).aspx - to determine whether the .NET Framework 4.6.1 is - installed on the machine -Inputs: NONE -Results: true if the .NET Framework 4.6.1 is installed - false otherwise -******************************************************************/ -bool IsNetfx461Installed() -{ - bool bRetValue = false; - DWORD dwRegValue=0; - - if (RegistryGetValue(HKEY_LOCAL_MACHINE, g_szNetfx45RegKeyName, g_szNetfx45RegValueName, NULL, (LPBYTE)&dwRegValue, sizeof(DWORD))) - { - if (g_dwNetfx461ReleaseVersion <= dwRegValue) - bRetValue = true; - } - - return bRetValue; -} - - -/****************************************************************** -Function Name: IsNetfx462Installed -Description: Uses the detection method recommended at - http://msdn.microsoft.com/en-us/library/ee942965(v=vs.110).aspx - to determine whether the .NET Framework 4.6.2 is - installed on the machine -Inputs: NONE -Results: true if the .NET Framework 4.6.2 is installed - false otherwise -******************************************************************/ -bool IsNetfx462Installed() -{ - bool bRetValue = false; - DWORD dwRegValue=0; - - if (RegistryGetValue(HKEY_LOCAL_MACHINE, g_szNetfx45RegKeyName, g_szNetfx45RegValueName, NULL, (LPBYTE)&dwRegValue, sizeof(DWORD))) - { - if (g_dwNetfx462ReleaseVersion <= dwRegValue) - bRetValue = true; - } - - return bRetValue; -} - - -/****************************************************************** -Function Name: RegistryGetValue -Description: Get the value of a reg key -Inputs: HKEY hk - The hk of the key to retrieve - TCHAR *pszKey - Name of the key to retrieve - TCHAR *pszValue - The value that will be retrieved - DWORD dwType - The type of the value that will be retrieved - LPBYTE data - A buffer to save the retrieved data - DWORD dwSize - The size of the data retrieved -Results: true if successful, false otherwise -******************************************************************/ -bool RegistryGetValue(HKEY hk, const TCHAR * pszKey, const TCHAR * pszValue, DWORD dwType, LPBYTE data, DWORD dwSize) -{ - HKEY hkOpened; - - // Try to open the key - if (RegOpenKeyEx(hk, pszKey, 0, KEY_READ, &hkOpened) != ERROR_SUCCESS) - { - return false; - } - - // If the key was opened, try to retrieve the value - if (RegQueryValueEx(hkOpened, pszValue, 0, &dwType, (LPBYTE)data, &dwSize) != ERROR_SUCCESS) - { - RegCloseKey(hkOpened); - return false; - } - - // Clean up - RegCloseKey(hkOpened); - - return true; -} - -/* -int APIENTRY _tWinMain(HINSTANCE hInstance, - HINSTANCE hPrevInstance, - LPTSTR lpCmdLine, - int nCmdShow) -{ - int iNetfx10SPLevel = -1; - int iNetfx11SPLevel = -1; - int iNetfx20SPLevel = -1; - int iNetfx30SPLevel = -1; - int iNetfx35SPLevel = -1; - int iNetfx40ClientSPLevel = -1; - int iNetfx40FullSPLevel = -1; - int iNetfx45SPLevel = -1; - int iNetfx451SPLevel = -1; - int iNetfx452SPLevel = -1; - int iNetfx46SPLevel = -1; - int iNetfx461SPLevel = -1; - int iNetfx462SPLevel = -1; - TCHAR szMessage[MAX_PATH]; - TCHAR szOutputString[MAX_PATH*20]; - - // Determine whether or not the .NET Framework - // 1.0, 1.1, 2.0, 3.0, 3.5, 4, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, or 4.6.2 are installed - bool bNetfx10Installed = (IsNetfx10Installed() && CheckNetfxVersionUsingMscoree(g_szNetfx10VersionString)); - bool bNetfx11Installed = (IsNetfx11Installed() && CheckNetfxVersionUsingMscoree(g_szNetfx11VersionString)); - bool bNetfx20Installed = (IsNetfx20Installed() && CheckNetfxVersionUsingMscoree(g_szNetfx20VersionString)); - - // The .NET Framework 3.0 is an add-in that installs - // on top of the .NET Framework 2.0. For this version - // check, validate that both 2.0 and 3.0 are installed. - bool bNetfx30Installed = (IsNetfx20Installed() && IsNetfx30Installed() && CheckNetfxVersionUsingMscoree(g_szNetfx20VersionString)); - - // The .NET Framework 3.5 is an add-in that installs - // on top of the .NET Framework 2.0 and 3.0. For this version - // check, validate that 2.0, 3.0 and 3.5 are installed. - bool bNetfx35Installed = (IsNetfx20Installed() && IsNetfx30Installed() && IsNetfx35Installed() && CheckNetfxVersionUsingMscoree(g_szNetfx20VersionString)); - - bool bNetfx40ClientInstalled = (IsNetfx40ClientInstalled() && CheckNetfxVersionUsingMscoree(g_szNetfx40VersionString)); - bool bNetfx40FullInstalled = (IsNetfx40FullInstalled() && CheckNetfxVersionUsingMscoree(g_szNetfx40VersionString)); - - // The .NET Framework 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, and 4.6.2 are in-place replacements for the .NET Framework 4. - // They use the same runtime version as the .NET Framework 4. - bool bNetfx45Installed = (IsNetfx45Installed() && CheckNetfxVersionUsingMscoree(g_szNetfx40VersionString)); - bool bNetfx451Installed = (IsNetfx451Installed() && CheckNetfxVersionUsingMscoree(g_szNetfx40VersionString)); - bool bNetfx452Installed = (IsNetfx452Installed() && CheckNetfxVersionUsingMscoree(g_szNetfx40VersionString)); - bool bNetfx46Installed = (IsNetfx46Installed() && CheckNetfxVersionUsingMscoree(g_szNetfx40VersionString)); - bool bNetfx461Installed = (IsNetfx461Installed() && CheckNetfxVersionUsingMscoree(g_szNetfx40VersionString)); - bool bNetfx462Installed = (IsNetfx462Installed() && CheckNetfxVersionUsingMscoree(g_szNetfx40VersionString)); - - // If .NET Framework 1.0 is installed, get the - // service pack level - if (bNetfx10Installed) - { - iNetfx10SPLevel = GetNetfx10SPLevel(); - - if (iNetfx10SPLevel > 0) - _stprintf_s(szMessage, MAX_PATH, _T(".NET Framework 1.0 service pack %i is installed."), iNetfx10SPLevel); - else - _stprintf_s(szMessage, MAX_PATH, _T(".NET Framework 1.0 is installed with no service packs.")); - - _tcscpy_s(szOutputString, szMessage); - } - else - { - _tcscpy_s(szOutputString, _T(".NET Framework 1.0 is not installed.")); - } - - // If .NET Framework 1.1 is installed, get the - // service pack level - if (bNetfx11Installed) - { - iNetfx11SPLevel = GetNetfxSPLevel(g_szNetfx11RegKeyName, g_szNetfxStandardSPxRegValueName); - - if (iNetfx11SPLevel > 0) - _stprintf_s(szMessage, MAX_PATH, _T("\n\n.NET Framework 1.1 service pack %i is installed."), iNetfx11SPLevel); - else - _stprintf_s(szMessage, MAX_PATH, _T("\n\n.NET Framework 1.1 is installed with no service packs.")); - - _tcscat_s(szOutputString, szMessage); - } - else - { - _tcscat_s(szOutputString, _T("\n\n.NET Framework 1.1 is not installed.")); - } - - // If .NET Framework 2.0 is installed, get the - // service pack level - if (bNetfx20Installed) - { - iNetfx20SPLevel = GetNetfxSPLevel(g_szNetfx20RegKeyName, g_szNetfxStandardSPxRegValueName); - - if (iNetfx20SPLevel > 0) - _stprintf_s(szMessage, MAX_PATH, _T("\n\n.NET Framework 2.0 service pack %i is installed."), iNetfx20SPLevel); - else - _stprintf_s(szMessage, MAX_PATH, _T("\n\n.NET Framework 2.0 is installed with no service packs.")); - - _tcscat_s(szOutputString, szMessage); - } - else - { - _tcscat_s(szOutputString, _T("\n\n.NET Framework 2.0 is not installed.")); - } - - // If .NET Framework 3.0 is installed, get the - // service pack level - if (bNetfx30Installed) - { - iNetfx30SPLevel = GetNetfxSPLevel(g_szNetfx30SpRegKeyName, g_szNetfxStandardSPxRegValueName); - - if (iNetfx30SPLevel > 0) - _stprintf_s(szMessage, MAX_PATH, _T("\n\n.NET Framework 3.0 service pack %i is installed."), iNetfx30SPLevel); - else - _stprintf_s(szMessage, MAX_PATH, _T("\n\n.NET Framework 3.0 is installed with no service packs.")); - - _tcscat_s(szOutputString, szMessage); - } - else - { - _tcscat_s(szOutputString, _T("\n\n.NET Framework 3.0 is not installed.")); - } - - // If .NET Framework 3.5 is installed, get the - // service pack level - if (bNetfx35Installed) - { - iNetfx35SPLevel = GetNetfxSPLevel(g_szNetfx35RegKeyName, g_szNetfxStandardSPxRegValueName); - - if (iNetfx35SPLevel > 0) - _stprintf_s(szMessage, MAX_PATH, _T("\n\n.NET Framework 3.5 service pack %i is installed."), iNetfx35SPLevel); - else - _stprintf_s(szMessage, MAX_PATH, _T("\n\n.NET Framework 3.5 is installed with no service packs.")); - - _tcscat_s(szOutputString, szMessage); - } - else - { - _tcscat_s(szOutputString, _T("\n\n.NET Framework 3.5 is not installed.")); - } - - // If .NET Framework 4 Client is installed, get the - // service pack level - if (bNetfx40ClientInstalled) - { - iNetfx40ClientSPLevel = GetNetfxSPLevel(g_szNetfx40ClientRegKeyName, g_szNetfx40SPxRegValueName); - - if (iNetfx40ClientSPLevel > 0) - _stprintf_s(szMessage, MAX_PATH, _T("\n\n.NET Framework 4 client service pack %i is installed."), iNetfx40ClientSPLevel); - else - _stprintf_s(szMessage, MAX_PATH, _T("\n\n.NET Framework 4 client is installed with no service packs.")); - - _tcscat_s(szOutputString, szMessage); - } - else - { - _tcscat_s(szOutputString, _T("\n\n.NET Framework 4 client is not installed.")); - } - - // If .NET Framework 4 Full is installed, get the - // service pack level - if (bNetfx40FullInstalled) - { - iNetfx40FullSPLevel = GetNetfxSPLevel(g_szNetfx40FullRegKeyName, g_szNetfx40SPxRegValueName); - - if (iNetfx40FullSPLevel > 0) - _stprintf_s(szMessage, MAX_PATH, _T("\n\n.NET Framework 4 full service pack %i is installed."), iNetfx40FullSPLevel); - else - _stprintf_s(szMessage, MAX_PATH, _T("\n\n.NET Framework 4 full is installed with no service packs.")); - - _tcscat_s(szOutputString, szMessage); - } - else - { - _tcscat_s(szOutputString, _T("\n\n.NET Framework 4 full is not installed.")); - } - - // If .NET Framework 4.5 is installed, get the - // service pack level - if (bNetfx45Installed) - { - iNetfx45SPLevel = GetNetfxSPLevel(g_szNetfx45RegKeyName, g_szNetfx40SPxRegValueName); - - if (iNetfx45SPLevel > 0) - _stprintf_s(szMessage, MAX_PATH, _T("\n\n.NET Framework 4.5 service pack %i is installed."), iNetfx45SPLevel); - else - _stprintf_s(szMessage, MAX_PATH, _T("\n\n.NET Framework 4.5 is installed with no service packs.")); - - _tcscat_s(szOutputString, szMessage); - } - else - { - _tcscat_s(szOutputString, _T("\n\n.NET Framework 4.5 is not installed.")); - } - - // If .NET Framework 4.5.1 is installed, get the - // service pack level - if (bNetfx451Installed) - { - iNetfx451SPLevel = GetNetfxSPLevel(g_szNetfx45RegKeyName, g_szNetfx40SPxRegValueName); - - if (iNetfx451SPLevel > 0) - _stprintf_s(szMessage, MAX_PATH, _T("\n\n.NET Framework 4.5.1 service pack %i is installed."), iNetfx451SPLevel); - else - _stprintf_s(szMessage, MAX_PATH, _T("\n\n.NET Framework 4.5.1 is installed with no service packs.")); - - _tcscat_s(szOutputString, szMessage); - } - else - { - _tcscat_s(szOutputString, _T("\n\n.NET Framework 4.5.1 is not installed.")); - } - - // If .NET Framework 4.5.2 is installed, get the - // service pack level - if (bNetfx452Installed) - { - iNetfx452SPLevel = GetNetfxSPLevel(g_szNetfx45RegKeyName, g_szNetfx40SPxRegValueName); - - if (iNetfx452SPLevel > 0) - _stprintf_s(szMessage, MAX_PATH, _T("\n\n.NET Framework 4.5.2 service pack %i is installed."), iNetfx452SPLevel); - else - _stprintf_s(szMessage, MAX_PATH, _T("\n\n.NET Framework 4.5.2 is installed with no service packs.")); - - _tcscat_s(szOutputString, szMessage); - } - else - { - _tcscat_s(szOutputString, _T("\n\n.NET Framework 4.5.2 is not installed.")); - } - - // If .NET Framework 4.6 is installed, get the - // service pack level - if (bNetfx46Installed) - { - iNetfx46SPLevel = GetNetfxSPLevel(g_szNetfx45RegKeyName, g_szNetfx40SPxRegValueName); - - if (iNetfx46SPLevel > 0) - _stprintf_s(szMessage, MAX_PATH, _T("\n\n.NET Framework 4.6 service pack %i is installed."), iNetfx46SPLevel); - else - _stprintf_s(szMessage, MAX_PATH, _T("\n\n.NET Framework 4.6 is installed with no service packs.")); - - _tcscat_s(szOutputString, szMessage); - } - else - { - _tcscat_s(szOutputString, _T("\n\n.NET Framework 4.6 is not installed.")); - } - - // If .NET Framework 4.6.1 is installed, get the - // service pack level - if (bNetfx461Installed) - { - iNetfx461SPLevel = GetNetfxSPLevel(g_szNetfx45RegKeyName, g_szNetfx40SPxRegValueName); - - if (iNetfx461SPLevel > 0) - _stprintf_s(szMessage, MAX_PATH, _T("\n\n.NET Framework 4.6.1 service pack %i is installed."), iNetfx461SPLevel); - else - _stprintf_s(szMessage, MAX_PATH, _T("\n\n.NET Framework 4.6.1 is installed with no service packs.")); - - _tcscat_s(szOutputString, szMessage); - } - else - { - _tcscat_s(szOutputString, _T("\n\n.NET Framework 4.6.1 is not installed.")); - } - - // If .NET Framework 4.6.2 is installed, get the - // service pack level - if (bNetfx462Installed) - { - iNetfx462SPLevel = GetNetfxSPLevel(g_szNetfx45RegKeyName, g_szNetfx40SPxRegValueName); - - if (iNetfx462SPLevel > 0) - _stprintf_s(szMessage, MAX_PATH, _T("\n\n.NET Framework 4.6.2 service pack %i is installed."), iNetfx462SPLevel); - else - _stprintf_s(szMessage, MAX_PATH, _T("\n\n.NET Framework 4.6.2 is installed with no service packs.")); - - _tcscat_s(szOutputString, szMessage); - } - else - { - _tcscat_s(szOutputString, _T("\n\n.NET Framework 4.6.2 is not installed.")); - } - - MessageBox(NULL, szOutputString, _T(".NET Framework Install Info"), MB_OK | MB_ICONINFORMATION); - - return 0; -} -*/ diff --git a/edkrepo_installer/SetupLauncher/Manifest.xml b/edkrepo_installer/SetupLauncher/Manifest.xml deleted file mode 100644 index cd90f7a..0000000 --- a/edkrepo_installer/SetupLauncher/Manifest.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Per Monitor - - - diff --git a/edkrepo_installer/SetupLauncher/SetupIcon.ico b/edkrepo_installer/SetupLauncher/SetupIcon.ico deleted file mode 100644 index 250f3cd..0000000 Binary files a/edkrepo_installer/SetupLauncher/SetupIcon.ico and /dev/null differ diff --git a/edkrepo_installer/SetupLauncher/SetupLauncher.cpp b/edkrepo_installer/SetupLauncher/SetupLauncher.cpp deleted file mode 100644 index 63b2fde..0000000 --- a/edkrepo_installer/SetupLauncher/SetupLauncher.cpp +++ /dev/null @@ -1,557 +0,0 @@ -/** @file - SetupLauncher.cpp - -@copyright - Copyright 2016 - 2023 Intel Corporation. All rights reserved.
- SPDX-License-Identifier: BSD-2-Clause-Patent - -@par Specification Reference: - -**/ - -#include -#include -#include -#include - -#define BUFFER_SIZE 2000 -TCHAR DotNetInstallerFileName[] = _T("NDP452-KB2901954-Web.exe"); -TCHAR EdkRepoInstallerFileName[] = _T("EdkRepoInstaller.exe"); -extern const TCHAR *g_szNetfx40VersionString; -BOOLEAN g_SilentMode = FALSE; -bool IsNetfx452Installed(); -bool CheckNetfxVersionUsingMscoree(const TCHAR*); - -void -DisplayErrorMessage ( - LPTSTR ErrorMessage - ) -{ - DWORD StringLength; - DWORD nNumberOfCharsWritten; - HANDLE StdOut; - LPTSTR NewLine = _T("\r\n"); - - if (g_SilentMode) { - StdOut = GetStdHandle(STD_OUTPUT_HANDLE); - if (StdOut != NULL) { -#if TCHAR == WCHAR - StringLength = wcslen(ErrorMessage); -#else - StringLength = strlen(ErrorMessage); -#endif - nNumberOfCharsWritten = 0; - WriteConsole( - StdOut, - ErrorMessage, - StringLength, - &nNumberOfCharsWritten, - NULL - ); - nNumberOfCharsWritten = 0; - WriteConsole( - StdOut, - NewLine, - sizeof(NewLine) / sizeof(TCHAR), - &nNumberOfCharsWritten, - NULL - ); - } - } else { - MessageBox(NULL, ErrorMessage, _T("Fatal Error"), MB_OK | MB_ICONERROR); - } -} - -void -DisplayWin32Error ( - LPTSTR FunctionName, - DWORD Error - ) -{ - TCHAR Buffer[BUFFER_SIZE]; - LPTSTR Message; - - Message = NULL; - - FormatMessage ( - FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - Error, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPTSTR)&Message, - 0, - NULL - ); - - if(Message != NULL) { - _sntprintf_s ( - Buffer, - BUFFER_SIZE, - _TRUNCATE, - _T ("%s failed with error: %s"), - FunctionName, - Message - ); - LocalFree(Message); - DisplayErrorMessage(Buffer); - } else { - _sntprintf_s ( - Buffer, - BUFFER_SIZE, - _TRUNCATE, - _T ("%s failed with error code: 0x%X"), - FunctionName, - Error - ); - DisplayErrorMessage(Buffer); - } -} - -void -DisplayLastWin32Error ( - LPTSTR FunctionName - ) -{ - DisplayWin32Error (FunctionName, GetLastError()); -} - -LPTSTR -GetModulePath ( - HMODULE Module - ) -{ - LPTSTR ExePath; - SIZE_T ExePathCapacity; - DWORD ExePathSize; - - ExePathCapacity = MAX_PATH + 1; - ExePathSize = ExePathCapacity; - ExePath = NULL; - while (ExePathSize >= ExePathCapacity) { - if (ExePath != NULL) { - ExePathCapacity = (15 * ExePathCapacity) / 10; //Slightly less than the Golden Ratio - HeapFree (GetProcessHeap (), 0, ExePath); - if (ExePathCapacity >= 0x6400000) { // Any file path should be <100MB - return NULL; - } - } - ExePath = (TCHAR *) HeapAlloc ( - GetProcessHeap(), - HEAP_ZERO_MEMORY, - sizeof (TCHAR) * ExePathCapacity - ); - if (ExePath == NULL) { - return NULL; - } - ExePathSize = GetModuleFileName (Module, ExePath, ExePathCapacity); - if (ExePathSize == 0) { - DisplayLastWin32Error(TEXT("GetModuleFileName")); - HeapFree(GetProcessHeap(), 0, ExePath); - return NULL; - } - } - return ExePath; -} - -BOOLEAN -GetDirectoryName ( - IN OUT LPTSTR Path - ) -{ - LPTSTR LastBackslash; - DWORD FileAttributes; - - LastBackslash = _tcsrchr (Path, '\\'); - if (LastBackslash != 0) { - *LastBackslash = '\0'; - } - FileAttributes = GetFileAttributes (Path); - if (FileAttributes == INVALID_FILE_ATTRIBUTES) { - return FALSE; - } - if ((FileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) { - LastBackslash = _tcsrchr (Path, '\\'); - if (LastBackslash != 0) { - *LastBackslash = '\0'; - } - FileAttributes = GetFileAttributes (Path); - if (FileAttributes == INVALID_FILE_ATTRIBUTES) { - return FALSE; - } - if ((FileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) { - return FALSE; - } - } - return TRUE; -} - -LPWSTR -CombinePaths ( - IN CONST LPWSTR Path1, - IN CONST LPWSTR Path2 - ) -{ - LPWSTR CombinedPath; - SIZE_T CombinedPathSize; - - CombinedPathSize = wcslen (Path1) + wcslen (Path2) + 2; - CombinedPath = (LPTSTR)HeapAlloc ( - GetProcessHeap (), - HEAP_ZERO_MEMORY, - sizeof (WCHAR) * - (CombinedPathSize) - ); - if (CombinedPath == NULL) { - return NULL; - } - wcscat_s (CombinedPath, CombinedPathSize, Path1); - if (CombinedPath[_tcsclen (CombinedPath) - 1] != '\\') { - wcscat_s (CombinedPath, CombinedPathSize, TEXT("\\")); - } - wcscat_s (CombinedPath, CombinedPathSize, Path2); - return CombinedPath; -} - -BOOLEAN -FileExists ( - IN LPTSTR FilePath - ) -{ - WIN32_FIND_DATA FileData; - HANDLE Handle; - - Handle = FindFirstFile (FilePath, &FileData); - if (Handle == INVALID_HANDLE_VALUE) { - return FALSE; - } else { - FindClose (Handle); - return TRUE; - } -} - -BOOLEAN -IsFile ( - IN LPTSTR FilePath - ) -{ - DWORD FileAttributes; - - FileAttributes = GetFileAttributes (FilePath); - if (FileAttributes == INVALID_FILE_ATTRIBUTES) { - return FALSE; - } - if ((FileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) { - return TRUE; - } - return FALSE; -} - -BOOLEAN -RunProgram ( - LPWSTR ProgramPath, - LPCWSTR Parameters, - OUT DWORD *ExitCode - ) -{ - SHELLEXECUTEINFO ExecuteInfo; - - - memset (&ExecuteInfo, 0, sizeof (SHELLEXECUTEINFO)); - ExecuteInfo.cbSize = sizeof (SHELLEXECUTEINFO); - ExecuteInfo.fMask = SEE_MASK_NOCLOSEPROCESS; - ExecuteInfo.hwnd = NULL; - ExecuteInfo.lpVerb = L"runas"; - ExecuteInfo.lpFile = ProgramPath; - ExecuteInfo.lpParameters = Parameters; - ExecuteInfo.nShow = SW_NORMAL; - if (!ShellExecuteExW (&ExecuteInfo)) { - DisplayLastWin32Error (TEXT ("ShellExecuteEx")); - return FALSE; - } - WaitForSingleObject (ExecuteInfo.hProcess, INFINITE); - if (!GetExitCodeProcess (ExecuteInfo.hProcess, ExitCode)) { - DisplayLastWin32Error (TEXT ("GetExitCodeProcess")); - CloseHandle (ExecuteInfo.hProcess); - return FALSE; - } - CloseHandle (ExecuteInfo.hProcess); - return TRUE; -} - -BOOLEAN -RebootSystem ( - VOID - ) -{ - HANDLE Token; - TOKEN_PRIVILEGES TokenPrivileges; - BOOL Status; - DWORD ErrorCode; - - // - // Get the process token - // - if (!OpenProcessToken (GetCurrentProcess (), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &Token)) { - return FALSE; - } - // - // Get the LUID for the shutdown privilege - // - if (!LookupPrivilegeValue (NULL, SE_SHUTDOWN_NAME, &TokenPrivileges.Privileges[0].Luid)) { - return FALSE; - } - TokenPrivileges.PrivilegeCount = 1; - TokenPrivileges.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; - // - // Request the shutdown privilege for this process - // - Status = AdjustTokenPrivileges (Token, FALSE, &TokenPrivileges, 0, (PTOKEN_PRIVILEGES) NULL, 0); - ErrorCode = GetLastError (); - if (!Status || ErrorCode != ERROR_SUCCESS) { - DisplayLastWin32Error (TEXT ("AdjustTokenPrivileges")); - return FALSE; - } - // - // Shut down the system - // - if (!ExitWindowsEx ( - EWX_REBOOT, - SHTDN_REASON_MAJOR_APPLICATION | SHTDN_REASON_MINOR_INSTALLATION | SHTDN_REASON_FLAG_PLANNED - )) { - DisplayLastWin32Error (TEXT ("ExitWindowsEx")); - return FALSE; - } - return TRUE; -} - -BOOLEAN -RunDotNetInstaller ( - BOOLEAN PassiveMode - ) -{ - LPTSTR FilePath; - LPTSTR InstallerPath; - LPWSTR Parameters; - DWORD ExitCode; - BOOLEAN Status; - int MessageBoxId; - - FilePath = GetModulePath (NULL); - if (FilePath == NULL) { - MessageBox (NULL, _T ("Failed to get path, out of memory"), _T("Fatal Error"), MB_OK | MB_ICONERROR); - return FALSE; - } - if (!GetDirectoryName (FilePath)) { - HeapFree (GetProcessHeap (), 0, FilePath); - MessageBox (NULL, _T ("Failed to get directory"), _T("Fatal Error"), MB_OK | MB_ICONERROR); - return FALSE; - } - InstallerPath = CombinePaths (FilePath, DotNetInstallerFileName); - HeapFree (GetProcessHeap (), 0, FilePath); - if (InstallerPath == NULL) { - MessageBox (NULL, _T ("Failed to combine paths"), _T("Fatal Error"), MB_OK | MB_ICONERROR); - return FALSE; - } - if (FileExists (InstallerPath) && IsFile (InstallerPath)) { - if (PassiveMode) { - Parameters = L"/norestart /passive"; - } else { - Parameters = L"/norestart /passive /showrmui"; - } - Status = RunProgram (InstallerPath, Parameters, &ExitCode); - HeapFree (GetProcessHeap (), 0, InstallerPath); - if (Status) { - if (ExitCode == 0) { //Success - return TRUE; - } else if (ExitCode == 1641 || ExitCode == 3010) { //Reboot Required - if (PassiveMode) { - RebootSystem (); - return FALSE; - } else { - MessageBoxId = MessageBox ( - NULL, - _T("Windows must be rebooted before setup can continue, reboot now?"), - _T ("Reboot Required"), - MB_YESNO | MB_ICONQUESTION - ); - if (MessageBoxId == IDYES) { - MessageBox ( - NULL, - _T ("Please run setup again after the system restarts"), - _T ("Reboot Required"), - MB_OK | MB_ICONINFORMATION - ); - if (!RebootSystem ()) { - MessageBox (NULL, _T ("Reboot failed. Please reboot manually."), _T("Fatal Error"), MB_OK | MB_ICONERROR); - } - } else { - MessageBox ( - NULL, - _T ("Unable to continue. Please reboot the computer and run setup again"), - _T ("Reboot Required"), - MB_OK | MB_ICONWARNING - ); - } - } - return FALSE; - } else if (ExitCode == 1602) { //User Canceled - return FALSE; - } else { //Fatal Error - MessageBox ( - NULL, - _T (".NET Framework installation failed. Unable to continue."), - _T("Fatal Error"), - MB_OK | MB_ICONERROR - ); - return FALSE; - } - } - return FALSE; - } else { - MessageBox ( - NULL, - _T ("Unable to install .NET Framework. Installer was not found in the package."), - _T("Fatal Error"), - MB_OK | MB_ICONERROR - ); - return FALSE; - } -} - -BOOLEAN -RunEdkRepoInstaller ( - BOOLEAN PassiveMode - ) -{ - LPTSTR FilePath; - LPTSTR InstallerPath; - LPWSTR Parameters; - DWORD ExitCode; - DWORD nNumberOfCharsWritten; - HANDLE StdOut; - BOOLEAN Status; - - FilePath = GetModulePath (NULL); - if (FilePath == NULL) { - DisplayErrorMessage (_T ("Failed to get path, out of memory")); - return FALSE; - } - if (!GetDirectoryName (FilePath)) { - HeapFree (GetProcessHeap (), 0, FilePath); - DisplayErrorMessage (_T ("Failed to get directory")); - return FALSE; - } - InstallerPath = CombinePaths (FilePath, EdkRepoInstallerFileName); - HeapFree (GetProcessHeap (), 0, FilePath); - if (InstallerPath == NULL) { - DisplayErrorMessage (_T ("Failed to combine paths")); - return FALSE; - } - if (FileExists (InstallerPath) && IsFile (InstallerPath)) { - if (g_SilentMode) { - Parameters = L"/Silent /Passive"; - } else { - if (PassiveMode) { - Parameters = L"/Passive"; - } else { - Parameters = L""; - } - } - Status = RunProgram (InstallerPath, Parameters, &ExitCode); - HeapFree (GetProcessHeap (), 0, InstallerPath); - if (!Status || ExitCode != 0) - { - return FALSE; - } - return TRUE; - } else { - DisplayErrorMessage (_T ("Unable to install EdkRepo. Installer was not found in the package.")); - return FALSE; - } -} - -int -APIENTRY -_tWinMain ( - HINSTANCE hInstance, - HINSTANCE hPrevInstance, - LPTSTR lpCmdLine, - int nCmdShow - ) -{ - LPCWSTR CommandLine; - LPWSTR *Argv; - BOOLEAN PassiveMode; - BOOLEAN SilentMode; - int MessageBoxId; - int Index; - int NumArgs; - bool bNetfx452Installed; - DWORD nNumberOfCharsWritten; - HANDLE StdOut = NULL; - LPTSTR SilentDotNetInstallError = _T(".NET Framework 4.5.2 must be installed to continue setup. Please install .NET and try again."); - - InitCommonControls (); - CommandLine = GetCommandLineW (); - Argv = CommandLineToArgvW (CommandLine, &NumArgs); - PassiveMode = FALSE; - SilentMode = FALSE; - for (Index = 0; Index < NumArgs; Index++) { - if (wcscmp (Argv[Index], _T ("/Passive")) == 0) { - PassiveMode = TRUE; - break; - } - if (wcscmp (Argv[Index], _T ("/passive")) == 0) { - PassiveMode = TRUE; - break; - } - if (wcscmp(Argv[Index], _T("/Silent")) == 0) { - SilentMode = TRUE; - PassiveMode = TRUE; - break; - } - if (wcscmp(Argv[Index], _T("/silent")) == 0) { - SilentMode = TRUE; - PassiveMode = TRUE; - break; - } - } - g_SilentMode = SilentMode; - LocalFree (Argv); - if (SilentMode) { - if (AttachConsole(ATTACH_PARENT_PROCESS)) { - StdOut = GetStdHandle(STD_OUTPUT_HANDLE); - } - } - bNetfx452Installed = (IsNetfx452Installed() && CheckNetfxVersionUsingMscoree(g_szNetfx40VersionString)); - - if (!bNetfx452Installed) { - if (SilentMode) { - nNumberOfCharsWritten = 0; - if (StdOut != NULL) { - WriteConsole(StdOut, SilentDotNetInstallError, sizeof(SilentDotNetInstallError) / sizeof(TCHAR), &nNumberOfCharsWritten, NULL); - } - exit(1); - } - if (!PassiveMode) { - MessageBoxId = MessageBox ( - NULL, - _T(".NET Framework 4.5.2 must be installed to continue setup. The system must be connected to the Internet to do so. Install now?"), - _T ("Setup"), - MB_YESNO | MB_ICONQUESTION - ); - if (MessageBoxId != IDYES) { - exit (1); - } - } - if (!RunDotNetInstaller (PassiveMode)) { - exit (1); - } - } - if (!RunEdkRepoInstaller (PassiveMode)) { - exit (1); - } - exit (0); -} diff --git a/edkrepo_installer/SetupLauncher/SetupLauncher.rc b/edkrepo_installer/SetupLauncher/SetupLauncher.rc deleted file mode 100644 index 1ed84f5..0000000 --- a/edkrepo_installer/SetupLauncher/SetupLauncher.rc +++ /dev/null @@ -1,38 +0,0 @@ -/** @file - SetupLauncher.rc - -@copyright - Copyright 2016 - 2019 Intel Corporation. All rights reserved.
- SPDX-License-Identifier: BSD-2-Clause-Patent - -@par Specification Reference: - -**/ - -1 24 "Manifest.xml" -1 ICON SetupIcon.ico -1 VERSIONINFO -FILEVERSION 1, 0, 0, 0 -PRODUCTVERSION 1, 0, 0, 0 -FILEOS 0x40004 -FILETYPE 0x2 -{ - BLOCK "StringFileInfo" - { - BLOCK "040904B0" - { - VALUE "CompanyName", "TianoCore" - VALUE "FileDescription", "EdkRepo Installer" - VALUE "FileVersion", "1.0.0.0" - VALUE "InternalName", "" - VALUE "LegalCopyright", "Copyright (c) 2019 TianoCore Contributors" - VALUE "OriginalFilename", "SetupLauncher.exe" - VALUE "ProductName", "EdkRepo" - VALUE "ProductVersion", "1.0.0.0" - } - } - BLOCK "VarFileInfo" - { - VALUE "Translation", 0x0409, 0x04B0 - } -} diff --git a/edkrepo_installer/SetupLauncher/SetupLauncher.vcxproj b/edkrepo_installer/SetupLauncher/SetupLauncher.vcxproj deleted file mode 100644 index 1261883..0000000 --- a/edkrepo_installer/SetupLauncher/SetupLauncher.vcxproj +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - Debug - Win32 - - - Release - Win32 - - - - {4B3DE9AA-728E-4FEA-996A-0BE83F44FA29} - Win32Proj - bptoolsinstaller - SetupLauncher - - - - Application - true - v140 - Unicode - - - Application - false - v140 - true - Unicode - - - - - - - - - - - - - true - false - - - false - false - - - - - - Level3 - Disabled - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - true - - - Windows - true - comctl32.lib;%(AdditionalDependencies) - - - false - - - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - MultiThreaded - - - Windows - true - true - true - comctl32.lib;%(AdditionalDependencies) - - - false - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/edkrepo_installer/edkrepo-installer.sln b/edkrepo_installer/edkrepo-installer.sln index 36660c3..2685cf7 100644 --- a/edkrepo_installer/edkrepo-installer.sln +++ b/edkrepo_installer/edkrepo-installer.sln @@ -1,14 +1,12 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.25420.1 +# Visual Studio Version 17 +VisualStudioVersion = 17.9.34728.123 MinimumVisualStudioVersion = 10.0.40219.1 # # Copyright (c) 2016 - 2019, Intel Corporation. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent # -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SetupLauncher", "SetupLauncher\SetupLauncher.vcxproj", "{4B3DE9AA-728E-4FEA-996A-0BE83F44FA29}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{19439C5D-008C-4EEB-836D-D24A98E1970A}" ProjectSection(SolutionItems) = preProject EdkRepoInstallerConfig.xml = EdkRepoInstallerConfig.xml @@ -26,16 +24,6 @@ Global Release|Win32 = Release|Win32 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {4B3DE9AA-728E-4FEA-996A-0BE83F44FA29}.Debug|Any CPU.ActiveCfg = Debug|Win32 - {4B3DE9AA-728E-4FEA-996A-0BE83F44FA29}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 - {4B3DE9AA-728E-4FEA-996A-0BE83F44FA29}.Debug|Mixed Platforms.Build.0 = Debug|Win32 - {4B3DE9AA-728E-4FEA-996A-0BE83F44FA29}.Debug|Win32.ActiveCfg = Debug|Win32 - {4B3DE9AA-728E-4FEA-996A-0BE83F44FA29}.Debug|Win32.Build.0 = Debug|Win32 - {4B3DE9AA-728E-4FEA-996A-0BE83F44FA29}.Release|Any CPU.ActiveCfg = Release|Win32 - {4B3DE9AA-728E-4FEA-996A-0BE83F44FA29}.Release|Mixed Platforms.ActiveCfg = Release|Win32 - {4B3DE9AA-728E-4FEA-996A-0BE83F44FA29}.Release|Mixed Platforms.Build.0 = Release|Win32 - {4B3DE9AA-728E-4FEA-996A-0BE83F44FA29}.Release|Win32.ActiveCfg = Release|Win32 - {4B3DE9AA-728E-4FEA-996A-0BE83F44FA29}.Release|Win32.Build.0 = Release|Win32 {525009EE-799D-4696-8036-710D637410D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {525009EE-799D-4696-8036-710D637410D2}.Debug|Any CPU.Build.0 = Debug|Any CPU {525009EE-799D-4696-8036-710D637410D2}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU