#include "pch.h" #include #include #include "loader.h" #include "resource.h" #include "cab.h" // Constants typedef enum _MIGWIZLOC { MWL_EXISTING, MWL_UNPACKED } MIGWIZLOC; // Globals HWND g_hWndParent = NULL; HINSTANCE g_hInstParent = NULL; static LPSTR g_lpCmdLine = NULL; VOID HandleError( ERRORCODE ecValue, LPARAM lpszExtra ) { if (ecValue != E_OK) { SendMessage( g_hWndParent, WM_USER_THREAD_ERROR, (WPARAM)ecValue, lpszExtra ); } } BOOL pIsIE4Installed ( VOID ) { LONG hResult; HKEY ieKey = NULL; DWORD valueType = REG_SZ; DWORD valueSize = 0; PTSTR valueData = NULL; PTSTR numPtr = NULL; PTSTR dotPtr = NULL; INT major = 0; INT minor = 0; TCHAR saved; BOOL result = FALSE; hResult = RegOpenKeyEx (HKEY_LOCAL_MACHINE, TEXT("Software\\Microsoft\\Internet Explorer"), 0, KEY_QUERY_VALUE, &ieKey); if ((hResult == ERROR_SUCCESS) && ieKey ) { hResult = RegQueryValueEx (ieKey, TEXT("Version"), NULL, &valueType, NULL, &valueSize); if ((hResult == ERROR_SUCCESS) || (hResult == ERROR_MORE_DATA)) { valueData = (PTSTR)HeapAlloc (GetProcessHeap (), 0, valueSize * 2); if (valueData) { hResult = RegQueryValueEx (ieKey, TEXT("Version"), NULL, &valueType, (PBYTE)valueData, &valueSize); if ((hResult == ERROR_SUCCESS) && (valueType == REG_SZ)) { // let's see if it the version is the correct one numPtr = valueData; dotPtr = _tcschr (numPtr, TEXT('.')); if (dotPtr) { saved = *dotPtr; *dotPtr = 0; major = atoi (numPtr); *dotPtr = saved; } else { major = atoi (numPtr); } if (dotPtr) { numPtr = _tcsinc (dotPtr); dotPtr = _tcschr (numPtr, TEXT('.')); if (dotPtr) { saved = *dotPtr; *dotPtr = 0; minor = atoi (numPtr); *dotPtr = saved; } else { minor = atoi (numPtr); } } if ((major >= 5) || ((major == 4) && (minor >= 71)) ) { result = TRUE; } } HeapFree (GetProcessHeap (), 0, valueData); valueData = NULL; } } } if (ieKey) { RegCloseKey (ieKey); ieKey = NULL; } return result; } ERRORCODE CheckSystemRequirements( VOID ) { ERRORCODE dwRetval = E_OK; DWORD dwArraySize; DWORD x; HMODULE hDll; PSTR lpszDllListA[] = REQUIRED_DLLSA; PWSTR lpszDllListW[] = REQUIRED_DLLSW; DWORD dwVersion; // // Check OS version. Disallow Win32s and NT < 4.00 // dwVersion = GetVersion(); if((dwVersion & 0xff) < 4) { HandleError( E_OLD_OS_VERSION, 0 ); return E_OLD_OS_VERSION; } // let's check to see if IE4 is installed on this machine if (!pIsIE4Installed ()) { HandleError( E_OLD_OS_VERSION, 0 ); return E_OLD_OS_VERSION; } // check if required DLLS exist if (g_VersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) { // WinNT dwArraySize = sizeof(lpszDllListW) / sizeof(PWSTR); for (x=0; xhWnd; g_hInstParent = ((LPTHREADSTARTUPINFO)lpParameter)->hInstance; g_lpCmdLine = ((LPTHREADSTARTUPINFO)lpParameter)->lpCmdLine; ecResult = CheckSystemRequirements(); if (ecResult == E_OK) { // Don't worry if this StartMigwiz fails. It's not an error yet if (StartMigwiz( MWL_EXISTING ) != E_OK) { ecResult = Unpack(); if (ecResult == E_OK) { ecResult = StartMigwiz( MWL_UNPACKED ); CleanupTempFiles(); } HandleError( ecResult, 0 ); } } UtilFree(); SendMessage( g_hWndParent, WM_USER_THREAD_COMPLETE, (WPARAM)NULL, (LPARAM)ecResult ); ExitThread( ecResult ); }