DetectVMware(int *Version)
{
int magic, ver;
-
+
magic = 0;
ver = 0;
-
+
/* Try using a VMware I/O port. If not running in VMware this'll throw an
exception! */
__asm__ __volatile__("inl %%dx, %%eax"
*Version = ver;
return TRUE;
}
-
+
return FALSE;
}
{
WCHAR FileName[MAX_PATH + 1];
HANDLE FileHandle;
-
+
FileName[0] = L'\0';
wcscat(FileName, Path);
wcscat(FileName, File);
FileHandle = CreateFile(FileName, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
-
+
if(FileHandle == INVALID_HANDLE_VALUE)
{
return FALSE;
CloseHandle(FileHandle);
return FALSE;
}
-
+
CloseHandle(FileHandle);
return TRUE;
}
WCHAR DestFileName[MAX_PATH + 1];
HANDLE SourceFileHandle, DestFileHandle;
DWORD DataRead, DataWritten;
-
+
SourceFileName[0] = L'\0';
DestFileName[0] = L'\0';
wcscat(SourceFileName, SrcPath);
wcscat(SourceFileName, File);
wcscat(DestFileName, Destination);
wcscat(DestFileName, File);
-
+
SourceFileHandle = CreateFile(SourceFileName, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if(SourceFileHandle == INVALID_HANDLE_VALUE)
{
CloseHandle(SourceFileHandle);
return FALSE;
}
-
+
while(ReadFile(SourceFileHandle, Buffer, sizeof(Buffer), &DataRead, NULL) && DataRead > 0)
{
if(!WriteFile(DestFileHandle, Buffer, DataRead, &DataWritten, NULL) ||
return FALSE;
}
}
-
+
CloseHandle(SourceFileHandle);
CloseHandle(DestFileHandle);
return TRUE;
{
static WCHAR Drive[4] = L"X:\\";
WCHAR Current;
-
+
*Drv = L'\0';
for(Current = 'C'; Current <= 'Z'; Current++)
{
SetCurrentDirectory(DestinationPath);
continue;
}
-
+
if(FileExists(SrcPath, vmx_fb) &&
FileExists(SrcPath, vmx_mode) &&
FileExists(SrcPath, vmx_svga))
}
#endif
}
-
+
return FALSE;
}
{
HKEY hReg;
DWORD Type, Size;
-
- if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,
- L"SYSTEM\\CurrentControlSet\\Hardware Profiles\\Current\\System\\CurrentControlSet\\Services\\vmx_svga\\Device0",
+
+ if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,
+ L"SYSTEM\\CurrentControlSet\\Hardware Profiles\\Current\\System\\CurrentControlSet\\Services\\vmx_svga\\Device0",
0, KEY_QUERY_VALUE, &hReg) != ERROR_SUCCESS)
{
return FALSE;
RegCloseKey(hReg);
return FALSE;
}
-
+
if(RegQueryValueEx(hReg, L"DefaultSettings.XResolution", 0, &Type, (BYTE*)ResX, &Size) != ERROR_SUCCESS ||
Type != REG_DWORD)
{
RegCloseKey(hReg);
return FALSE;
}
-
+
if(RegQueryValueEx(hReg, L"DefaultSettings.YResolution", 0, &Type, (BYTE*)ResY, &Size) != ERROR_SUCCESS ||
Type != REG_DWORD)
{
RegCloseKey(hReg);
return FALSE;
}
-
+
RegCloseKey(hReg);
return TRUE;
}
{
HKEY hReg;
DWORD Type, Size, Value;
-
- if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,
- L"SYSTEM\\CurrentControlSet\\Services\\vmx_svga",
+
+ if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,
+ L"SYSTEM\\CurrentControlSet\\Services\\vmx_svga",
0, KEY_QUERY_VALUE, &hReg) != ERROR_SUCCESS)
{
return FALSE;
RegCloseKey(hReg);
return FALSE;
}
-
+
RegCloseKey(hReg);
return (Value == 1);
}
SaveResolutionSettings(DWORD ResX, DWORD ResY, DWORD ColDepth)
{
HKEY hReg;
-
- if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,
- L"SYSTEM\\CurrentControlSet\\Hardware Profiles\\Current\\System\\CurrentControlSet\\Services\\vmx_svga\\Device0",
+
+ if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,
+ L"SYSTEM\\CurrentControlSet\\Hardware Profiles\\Current\\System\\CurrentControlSet\\Services\\vmx_svga\\Device0",
0, KEY_QUERY_VALUE, &hReg) != ERROR_SUCCESS)
{
return FALSE;
RegCloseKey(hReg);
return FALSE;
}
-
+
if(RegSetValueEx(hReg, L"DefaultSettings.XResolution", 0, REG_DWORD, (BYTE*)&ResX, sizeof(DWORD)) != ERROR_SUCCESS)
{
RegCloseKey(hReg);
return FALSE;
}
-
+
if(RegSetValueEx(hReg, L"DefaultSettings.YResolution", 0, REG_DWORD, (BYTE*)&ResY, sizeof(DWORD)) != ERROR_SUCCESS)
{
RegCloseKey(hReg);
return FALSE;
}
-
+
RegCloseKey(hReg);
return TRUE;
}
{
DWORD Value;
HKEY hReg;
-
+
Value = (Enable ? 1 : 4);
-
+
if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, Key, 0, KEY_SET_VALUE, &hReg) != ERROR_SUCCESS)
{
return FALSE;
RegCloseKey(hReg);
return FALSE;
}
-
+
RegCloseKey(hReg);
return TRUE;
}
{
return FALSE;
}
-
+
return TRUE;
}
HWND hwndControl;
/* Center the wizard window */
- hwndControl = GetParent(hwndDlg);
+ hwndControl = GetParent(hwndDlg);
CenterWindow (hwndControl);
LPNMHDR pnmh = (LPNMHDR)lParam;
HANDLE hThread;
BOOL DriveAvailable;
int DrivesTested = 0;
-
+
if(AbortInstall != 0) goto done;
PostMessage(hInstallationNotifyWnd, WM_INSTSTATUSUPDATE, IDS_SEARCHINGFORCDROM, 0);
-
+
while(AbortInstall == 0)
{
Sleep(500);
if(AbortInstall != 0) goto done;
PostMessage(hInstallationNotifyWnd, WM_INSTSTATUSUPDATE, IDS_COPYINGFILES, 0);
-
+
if(AbortInstall != 0) goto done;
if(!InstallFile(DestinationPath, vmx_fb))
{
PostMessage(hInstallationNotifyWnd, WM_INSTABORT, IDS_FAILEDTOCOPYFILES, 0);
goto cleanup;
}
-
+
Sleep(250);
-
+
if(AbortInstall != 0) goto done;
if(!InstallFile(DestinationPath, vmx_mode))
{
PostMessage(hInstallationNotifyWnd, WM_INSTABORT, IDS_FAILEDTOCOPYFILES, 0);
goto cleanup;
}
-
+
Sleep(250);
-
+
if(AbortInstall != 0) goto done;
if(!InstallFile(DestinationDriversPath, vmx_svga))
{
PostMessage(hInstallationNotifyWnd, WM_INSTABORT, IDS_FAILEDTOCOPYFILES, 0);
goto cleanup;
}
-
+
Sleep(250);
if(AbortInstall != 0) goto done;
SendMessage(hInstallationNotifyWnd, WM_INSTABORT, 0, 0);
break;
}
-
+
cleanup:
hThread = (HANDLE)InterlockedExchange((LONG*)&hInstallationThread, 0);
if(hThread != NULL)
{
int i;
WCHAR Text[256];
-
+
for(i = From; i <= To; i++)
{
if(LoadString(hAppInstance, i, Text, 255) > 0)
{
DWORD ResX = 0, ResY = 0, ColDepth = 0;
int cbSel;
-
+
FillComboBox(hwndDlg, IDC_COLORQUALITY, 10001, 10003);
if(LoadResolutionSettings(&ResX, &ResY, &ColDepth))
{
HWND hwndControl;
/* Center the wizard window */
- hwndControl = GetParent(hwndDlg);
+ hwndControl = GetParent(hwndDlg);
CenterWindow (hwndControl);
LPNMHDR pnmh = (LPNMHDR)lParam;
break;
}
}
-
+
switch(SendDlgItemMessage(hwndDlg, IDC_COLORQUALITY, CB_GETCURSEL, 0, 0))
{
case 0:
cd = 32;
break;
}
-
+
SaveResolutionSettings(rx, ry, cd);
break;
}
{
static ULONG SelPage[4] = {IDD_CONFIG, IDD_SELECTDRIVER, IDD_SELECTDRIVER, IDD_CHOOSEACTION};
int i;
-
+
for(i = IDC_CONFIGSETTINGS; i <= IDC_UNINSTALL; i++)
{
if(SendDlgItemMessage(hwndDlg, i, BM_GETCHECK, 0, 0) == BST_CHECKED)
break;
}
}
-
+
UninstallDriver = (i == IDC_UNINSTALL);
-
+
SetWindowLong(hwndDlg, DWL_MSGRESULT, SelPage[i - IDC_CONFIGSETTINGS]);
return TRUE;
}
HPROPSHEETPAGE ahpsp[8];
PROPSHEETPAGE psp;
WCHAR Caption[1024];
-
+
LoadString(hAppInstance, IDS_WIZARD_NAME, Caption, sizeof(Caption) / sizeof(TCHAR));
/* Create the Welcome page */
psp.pszHeaderSubTitle = MAKEINTRESOURCE(IDD_SELECTDRIVERSUBTITLE);
psp.pfnDlgProc = PageSelectDriverProc;
psp.pszTemplate = MAKEINTRESOURCE(IDD_SELECTDRIVER);
- ahpsp[6] = CreatePropertySheetPage(&psp);
+ ahpsp[6] = CreatePropertySheetPage(&psp);
/* Create the DOUNINSTALL page */
psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
psp.pszHeaderSubTitle = MAKEINTRESOURCE(IDD_DOUNINSTALLSUBTITLE);
psp.pfnDlgProc = PageDoUninstallProc;
psp.pszTemplate = MAKEINTRESOURCE(IDD_DOUNINSTALL);
- ahpsp[7] = CreatePropertySheetPage(&psp);
+ ahpsp[7] = CreatePropertySheetPage(&psp);
/* Create the property sheet */
psh.dwSize = sizeof(PROPSHEETHEADER);
return (LONG)(PropertySheet(&psh) != -1);
}
-int WINAPI
+int WINAPI
WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpszCmdLine,
int nCmdShow)
{
-
+
LPTOP_LEVEL_EXCEPTION_FILTER OldHandler;
int Version;
WCHAR *lc;
-
+
hAppInstance = hInstance;
/* Setup our exception "handler" ;-) */
/* restore the exception handler */
SetUnhandledExceptionFilter(OldHandler);
-
+
lc = DestinationPath;
lc += GetSystemDirectory(DestinationPath, MAX_PATH) - 1;
if(lc >= DestinationPath && *lc != L'\\')
DestinationDriversPath[0] = L'\0';
wcscat(DestinationDriversPath, DestinationPath);
wcscat(DestinationDriversPath, L"drivers\\");
-
+
SetCurrentDirectory(DestinationPath);
-
+
DriverFilesFound = FileExists(DestinationPath, vmx_fb) &&
FileExists(DestinationPath, vmx_mode) &&
FileExists(DestinationDriversPath, vmx_svga);
-
+
StartVMwConfigWizard = DriverFilesFound && IsVmwSVGAEnabled();
-
+
/* Show the wizard */
CreateWizard();
-
+
return 2;
}