added tool for easy installation of the VMware SVGA driver

svn path=/trunk/; revision=9047
This commit is contained in:
Thomas Bluemel 2004-04-09 18:27:11 +00:00
parent 7f72303d64
commit 50133e0fad
7 changed files with 1077 additions and 3 deletions

View file

@ -1,4 +1,4 @@
# $Id: Makefile,v 1.214 2004/04/07 18:05:16 gvg Exp $
# $Id: Makefile,v 1.215 2004/04/09 18:27:10 weiden Exp $
#
# Global makefile
#
@ -92,7 +92,7 @@ STORAGE_DRIVERS = atapi cdrom class2 disk scsiport diskdump
# System applications
# autochk cmd format services setup usetup welcome winlogon
SYS_APPS = autochk cmd explorer format services setup taskmgr userinit usetup welcome winlogon regedit
SYS_APPS = autochk cmd explorer format services setup taskmgr userinit usetup welcome vmwinst winlogon regedit
# System services
# rpcss eventlog

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: install.c,v 1.9 2004/03/21 14:37:19 navaraf Exp $
/* $Id: install.c,v 1.10 2004/04/09 18:27:10 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
@ -38,6 +38,7 @@
#include "resource.h"
// #define NO_GUI
#define VMWINST
#if 0
VOID Wizard (VOID);
@ -77,6 +78,28 @@ DebugPrint(char* fmt,...)
#endif
}
#ifdef VMWINST
static BOOL
RunVMWInstall(VOID)
{
PROCESS_INFORMATION ProcInfo;
STARTUPINFO si;
ZeroMemory(&si, sizeof(STARTUPINFO));
si.cb = sizeof(STARTUPINFO);
if(CreateProcessA(NULL, "vmwinst.exe", NULL, NULL, TRUE, NORMAL_PRIORITY_CLASS,
NULL, NULL, &si, &ProcInfo))
{
WaitForSingleObject(ProcInfo.hProcess, INFINITE);
CloseHandle(ProcInfo.hThread);
CloseHandle(ProcInfo.hProcess);
return TRUE;
}
return FALSE;
}
#endif
static VOID
CreateRandomSid (PSID *Sid)
@ -270,6 +293,9 @@ InstallReactOS (HINSTANCE hInstance)
Wizard ();
#endif
#ifdef VMWINST
RunVMWInstall();
#endif
DialogBox(
GetModuleHandle(TEXT("syssetup.dll")),
MAKEINTRESOURCE(IDD_RESTART),

View file

@ -0,0 +1,6 @@
*.o
*.d
*.exe
*.coff
*.sym
*.map

View file

@ -0,0 +1,23 @@
# $Id: Makefile,v 1.1 2004/04/09 18:27:11 weiden Exp $
PATH_TO_TOP = ../../..
TARGET_TYPE = program
TARGET_APPTYPE = windows
TARGET_NAME = vmwinst
TARGET_INSTALLDIR = system32
TARGET_CFLAGS = -Wall -Werror -D__USE_W32API -DUNICODE -D_WIN32_IE=0x0501 -D_WIN32_WINNT=0x0501
TARGET_SDKLIBS = kernel32.a ntdll.a
TARGET_GCCLIBS = msvcrt advapi32 kernel32 comctl32 comdlg32 shell32
TARGET_OBJECTS = $(TARGET_NAME).o
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk

View file

@ -0,0 +1,845 @@
/*
* ReactOS applications
* Copyright (C) 2004 ReactOS Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: vmwinst.c,v 1.1 2004/04/09 18:27:11 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS VMware(r) driver installation utility
* FILE: subsys/system/vmwinst/vmwinst.c
* PROGRAMMERS: Thomas Weidenmueller (w3seek@users.sourceforge.net)
*/
#include <windows.h>
#include <commctrl.h>
#include <stdio.h>
#include <string.h>
#include "vmwinst.h"
HINSTANCE hAppInstance;
BOOL StartVMwConfigWizard, ActivateVBE = FALSE, UninstallDriver = FALSE;
static WCHAR DestinationDriversPath[MAX_PATH+1];
static WCHAR CDDrive = L'\0';
static WCHAR PathToVideoDrivers45[MAX_PATH+1] = L"X:\\program files\\VMware\\VMware Tools\\Drivers\\video\\winnt2k\\";
static WCHAR PathToVideoDrivers40[MAX_PATH+1] = L"X:\\video\\winnt2k\\";
static WCHAR DestinationPath[MAX_PATH+1];
static WCHAR *vmx_fb = L"vmx_fb.dll";
static WCHAR *vmx_mode = L"vmx_mode.dll";
static WCHAR *vmx_svga = L"vmx_svga.sys";
static WCHAR *SrcPath = PathToVideoDrivers45;
/* Helper functions */
LONG WINAPI ExceptionHandler(LPEXCEPTION_POINTERS ExceptionInfo)
{
/* This is rude, but i don't know how to continue execution properly, that's why
we just exit here when we're not running inside of VMware */
ExitProcess(ExceptionInfo->ExceptionRecord->ExceptionCode == STATUS_PRIVILEGED_INSTRUCTION);
return EXCEPTION_CONTINUE_EXECUTION;
}
BOOL
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"
: "=a" (ver), "=b" (magic)
: "0" (0x564d5868), "d" (0x5658), "c" (0xa));
if(magic == 0x564d5868)
{
*Version = ver;
return TRUE;
}
return FALSE;
}
BOOL
ProcessMessage(void)
{
MSG msg;
if(PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
return TRUE;
}
return FALSE;
}
void
ProcessMessages(void)
{
while(ProcessMessage());
}
/* try to open the file */
BOOL
FileExists(WCHAR *Path, WCHAR *File)
{
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;
}
if(GetFileSize(FileHandle, NULL) <= 0)
{
CloseHandle(FileHandle);
return FALSE;
}
CloseHandle(FileHandle);
return TRUE;
}
/* Copy file */
BOOL
InstallFile(WCHAR *Destination, WCHAR *File)
{
static char Buffer[1024];
WCHAR SourceFileName[MAX_PATH + 1];
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)
{
return FALSE;
}
DestFileHandle = CreateFile(DestFileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if(DestFileHandle == INVALID_HANDLE_VALUE)
{
CloseHandle(SourceFileHandle);
return FALSE;
}
while(ReadFile(SourceFileHandle, Buffer, sizeof(Buffer), &DataRead, NULL) && DataRead > 0)
{
if(!WriteFile(DestFileHandle, Buffer, DataRead, &DataWritten, NULL) ||
DataRead != DataWritten)
{
CloseHandle(SourceFileHandle);
CloseHandle(DestFileHandle);
DeleteFile(DestFileName);
return FALSE;
}
}
CloseHandle(SourceFileHandle);
CloseHandle(DestFileHandle);
return TRUE;
}
/* Find the drive with the inserted VMware cd-rom */
BOOL
IsVMwareCDInDrive(WCHAR *Drv)
{
static WCHAR Drive[4] = L"X:\\";
WCHAR Current;
*Drv = L'\0';
for(Current = 'C'; Current <= 'Z'; Current++)
{
Drive[0] = Current;
#if CHECKDRIVETYPE
if(GetDriveType(Drive) == DRIVE_CDROM)
{
#endif
PathToVideoDrivers40[0] = Current;
PathToVideoDrivers45[0] = Current;
if(SetCurrentDirectory(PathToVideoDrivers45))
SrcPath = PathToVideoDrivers45;
else if(SetCurrentDirectory(PathToVideoDrivers40))
SrcPath = PathToVideoDrivers40;
else
{
SetCurrentDirectory(DestinationPath);
continue;
}
if(FileExists(SrcPath, vmx_fb) &&
FileExists(SrcPath, vmx_mode) &&
FileExists(SrcPath, vmx_svga))
{
*Drv = Current;
return TRUE;
}
#if CHECKDRIVETYPE
}
#endif
}
return FALSE;
}
BOOL
LoadResolutionSettings(DWORD *ResX, DWORD *ResY, DWORD *ColDepth)
{
HKEY hReg;
DWORD Type, Size;
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;
}
if(RegQueryValueEx(hReg, L"DefaultSettings.BitsPerPel", 0, &Type, (BYTE*)ColDepth, &Size) != ERROR_SUCCESS ||
Type != REG_DWORD)
{
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;
}
BOOL
IsVmwSVGAEnabled(VOID)
{
HKEY hReg;
DWORD Type, Size, Value;
if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,
L"SYSTEM\\CurrentControlSet\\Services\\vmx_svga",
0, KEY_QUERY_VALUE, &hReg) != ERROR_SUCCESS)
{
return FALSE;
}
if(RegQueryValueEx(hReg, L"Start", 0, &Type, (BYTE*)&Value, &Size) != ERROR_SUCCESS ||
Type != REG_DWORD)
{
RegCloseKey(hReg);
return FALSE;
}
RegCloseKey(hReg);
return (Value == 1);
}
BOOL
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",
0, KEY_QUERY_VALUE, &hReg) != ERROR_SUCCESS)
{
return FALSE;
}
if(RegSetValueEx(hReg, L"DefaultSettings.BitsPerPel", 0, REG_DWORD, (BYTE*)&ColDepth, sizeof(DWORD)) != ERROR_SUCCESS)
{
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;
}
BOOL
EnableDriver(WCHAR *Key, BOOL Enable)
{
DWORD Value;
HKEY hReg;
Value = (Enable ? 1 : 4);
if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, Key, 0, KEY_SET_VALUE, &hReg) != ERROR_SUCCESS)
{
return FALSE;
}
if(RegSetValueEx(hReg, L"Start", 0, REG_DWORD, (BYTE*)&Value, sizeof(DWORD)) != ERROR_SUCCESS)
{
RegCloseKey(hReg);
return FALSE;
}
RegCloseKey(hReg);
return TRUE;
}
/* Activate the vmware driver and deactivate the others */
BOOL
EnableVmwareDriver(BOOL VBE, BOOL VGA, BOOL VMX)
{
if(!EnableDriver(L"SYSTEM\\CurrentControlSet\\Services\\VBE", VBE))
{
return FALSE;
}
if(!EnableDriver(L"SYSTEM\\CurrentControlSet\\Services\\vga", VGA))
{
return FALSE;
}
if(!EnableDriver(L"SYSTEM\\CurrentControlSet\\Services\\vmx_svga", VMX))
{
return FALSE;
}
return TRUE;
}
/* GUI */
void
InitPropSheetPage(PROPSHEETPAGE *psp, WORD idDlg, DLGPROC DlgProc)
{
ZeroMemory(psp, sizeof(PROPSHEETPAGE));
psp->dwSize = sizeof(PROPSHEETPAGE);
psp->dwFlags = PSP_DEFAULT;
psp->hInstance = hAppInstance;
psp->pszTemplate = MAKEINTRESOURCE(idDlg);
psp->pfnDlgProc = DlgProc;
}
/* Property page dialog callback */
int CALLBACK
PageWelcomeProc(
HWND hwndDlg,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
)
{
switch(uMsg)
{
case WM_NOTIFY:
{
LPNMHDR pnmh = (LPNMHDR)lParam;
switch(pnmh->code)
{
case PSN_SETACTIVE:
PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_NEXT);
break;
}
break;
}
}
return FALSE;
}
/* Property page dialog callback */
int CALLBACK
PageInsertDiscProc(
HWND hwndDlg,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
)
{
switch(uMsg)
{
case WM_NOTIFY:
{
LPNMHDR pnmh = (LPNMHDR)lParam;
switch(pnmh->code)
{
case PSN_SETACTIVE:
PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
break;
case PSN_WIZNEXT:
PropSheet_SetWizButtons(GetParent(hwndDlg), 0);
ProcessMessages();
if(!IsVMwareCDInDrive(&CDDrive))
{
WCHAR Msg[1024];
LoadString(hAppInstance, IDS_FAILEDTOLOCATEDRIVERS, Msg, sizeof(Msg) / sizeof(WCHAR));
MessageBox(GetParent(hwndDlg), Msg, NULL, MB_ICONWARNING);
PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
SetWindowLong(hwndDlg, DWL_MSGRESULT, IDD_INSERT_VMWARE_TOOLS);
return TRUE;
}
DestinationDriversPath[0] = L'\0';
wcscat(DestinationDriversPath, DestinationPath);
wcscat(DestinationDriversPath, L"drivers\\");
if(!InstallFile(DestinationPath, vmx_fb) ||
!InstallFile(DestinationPath, vmx_mode) ||
!InstallFile(DestinationDriversPath, vmx_svga))
{
WCHAR Msg[1024];
LoadString(hAppInstance, IDS_FAILEDTOCOPYFILES, Msg, sizeof(Msg) / sizeof(WCHAR));
MessageBox(GetParent(hwndDlg), Msg, NULL, MB_ICONWARNING);
PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
SetWindowLong(hwndDlg, DWL_MSGRESULT, IDD_INSERT_VMWARE_TOOLS);
return TRUE;
}
if(!EnableVmwareDriver(FALSE, FALSE, TRUE))
{
WCHAR Msg[1024];
LoadString(hAppInstance, IDS_FAILEDTOACTIVATEDRIVER, Msg, sizeof(Msg) / sizeof(WCHAR));
MessageBox(GetParent(hwndDlg), Msg, NULL, MB_ICONWARNING);
SetWindowLong(hwndDlg, DWL_MSGRESULT, IDD_INSTALLATION_FAILED);
return TRUE;
}
PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
break;
}
break;
}
}
return FALSE;
}
/* Property page dialog callback */
BOOL CALLBACK
PageInstallFailedProc(
HWND hwndDlg,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
)
{
switch(uMsg)
{
case WM_NOTIFY:
{
LPNMHDR pnmh = (LPNMHDR)lParam;
switch(pnmh->code)
{
case PSN_SETACTIVE:
PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_FINISH);
break;
}
break;
}
}
return FALSE;
}
void
FillComboBox(HWND Dlg, int idComboBox, int From, int To)
{
int i;
WCHAR Text[256];
for(i = From; i <= To; i++)
{
if(LoadString(hAppInstance, i, Text, 255) > 0)
{
SendDlgItemMessage(Dlg, idComboBox, CB_ADDSTRING, 0, (LPARAM)Text);
}
}
}
typedef struct
{
int ControlID;
int ResX;
int ResY;
} MAPCTLRES;
/* Property page dialog callback */
BOOL CALLBACK
PageConfigProc(
HWND hwndDlg,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
)
{
switch(uMsg)
{
case WM_INITDIALOG:
{
DWORD ResX = 0, ResY = 0, ColDepth = 0;
int cbSel;
FillComboBox(hwndDlg, IDC_COLORQUALITY, 10001, 10003);
if(LoadResolutionSettings(&ResX, &ResY, &ColDepth))
{
SendDlgItemMessage(hwndDlg, ResX + ResY, BM_SETCHECK, BST_CHECKED, 0);
switch(ColDepth)
{
case 8:
cbSel = 0;
break;
case 16:
cbSel = 1;
break;
case 32:
cbSel = 2;
break;
default:
cbSel = -1;
break;
}
SendDlgItemMessage(hwndDlg, IDC_COLORQUALITY, CB_SETCURSEL, cbSel, 0);
}
break;
}
case WM_NOTIFY:
{
LPNMHDR pnmh = (LPNMHDR)lParam;
switch(pnmh->code)
{
case PSN_SETACTIVE:
{
PropSheet_SetWizButtons(GetParent(hwndDlg), (StartVMwConfigWizard ? PSWIZB_FINISH | PSWIZB_BACK : PSWIZB_FINISH));
break;
}
case PSN_WIZBACK:
{
if(StartVMwConfigWizard)
{
SetWindowLong(hwndDlg, DWL_MSGRESULT, IDD_CHOOSEACTION);
return TRUE;
}
break;
}
case PSN_WIZFINISH:
{
DWORD rx = 800, ry = 600, cd = 32;
int i;
static MAPCTLRES Resolutions[11] = {
{540, 640, 480},
{1400, 800, 600},
{1792, 1024, 768},
{2016, 1152, 864},
{2240, 1280, 960},
{2304, 1280, 1024},
{2450, 1400, 1050},
{2800, 1600, 1200},
{3136, 1792, 1344},
{3248, 1856, 1392},
{3360, 1920, 1440}
};
for(i = 0; i < 11; i++)
{
if(SendDlgItemMessage(hwndDlg, Resolutions[i].ControlID, BM_GETCHECK, 0, 0) == BST_CHECKED)
{
rx = Resolutions[i].ResX;
ry = Resolutions[i].ResY;
break;
}
}
switch(SendDlgItemMessage(hwndDlg, IDC_COLORQUALITY, CB_GETCURSEL, 0, 0))
{
case 0:
cd = 8;
break;
case 1:
cd = 16;
break;
case 2:
cd = 32;
break;
}
SaveResolutionSettings(rx, ry, cd);
break;
}
}
break;
}
}
return FALSE;
}
/* Property page dialog callback */
BOOL CALLBACK
PageChooseActionProc(
HWND hwndDlg,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
)
{
switch(uMsg)
{
case WM_INITDIALOG:
SendDlgItemMessage(hwndDlg, IDC_CONFIGSETTINGS, BM_SETCHECK, BST_CHECKED, 0);
break;
case WM_NOTIFY:
{
LPNMHDR pnmh = (LPNMHDR)lParam;
switch(pnmh->code)
{
case PSN_SETACTIVE:
PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_NEXT);
break;
case PSN_WIZBACK:
{
SetWindowLong(hwndDlg, DWL_MSGRESULT, IDD_CHOOSEACTION);
return TRUE;
}
case PSN_WIZNEXT:
{
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;
}
}
break;
}
}
return FALSE;
}
/* Property page dialog callback */
BOOL CALLBACK
PageSelectDriverProc(
HWND hwndDlg,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
)
{
switch(uMsg)
{
case WM_INITDIALOG:
SendDlgItemMessage(hwndDlg, IDC_VGA, BM_SETCHECK, BST_CHECKED, 0);
break;
case WM_NOTIFY:
{
LPNMHDR pnmh = (LPNMHDR)lParam;
switch(pnmh->code)
{
case PSN_SETACTIVE:
PropSheet_SetWizButtons(GetParent(hwndDlg), (UninstallDriver ? PSWIZB_NEXT | PSWIZB_BACK : PSWIZB_BACK | PSWIZB_FINISH));
break;
case PSN_WIZBACK:
{
SetWindowLong(hwndDlg, DWL_MSGRESULT, IDD_CHOOSEACTION);
return TRUE;
}
case PSN_WIZNEXT:
{
ActivateVBE = (SendDlgItemMessage(hwndDlg, IDC_VBE, BM_GETCHECK, 0, 0) == BST_CHECKED);
if(UninstallDriver)
{
return FALSE;
}
return TRUE;
}
case PSN_WIZFINISH:
{
if(UninstallDriver)
{
return FALSE;
}
ActivateVBE = (SendDlgItemMessage(hwndDlg, IDC_VBE, BM_GETCHECK, 0, 0) == BST_CHECKED);
if(!EnableVmwareDriver(ActivateVBE,
!ActivateVBE,
FALSE))
{
WCHAR Msg[1024];
LoadString(hAppInstance, (ActivateVBE ? IDS_FAILEDTOSELVBEDRIVER : IDS_FAILEDTOSELVGADRIVER), Msg, sizeof(Msg) / sizeof(WCHAR));
MessageBox(GetParent(hwndDlg), Msg, NULL, MB_ICONWARNING);
SetWindowLong(hwndDlg, DWL_MSGRESULT, IDD_SELECTDRIVER);
return TRUE;
}
break;
}
}
break;
}
}
return FALSE;
}
VOID
ShowUninstNotice(HWND Owner)
{
WCHAR Msg[1024];
LoadString(hAppInstance, IDS_UNINSTNOTICE, Msg, sizeof(Msg) / sizeof(WCHAR));
MessageBox(Owner, Msg, NULL, MB_ICONINFORMATION);
}
BOOL CALLBACK
PageDoUninstallProc(
HWND hwndDlg,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
)
{
switch(uMsg)
{
case WM_NOTIFY:
{
LPNMHDR pnmh = (LPNMHDR)lParam;
switch(pnmh->code)
{
case PSN_SETACTIVE:
PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_FINISH);
break;
case PSN_WIZFINISH:
{
if(UninstallDriver)
{
if(!EnableVmwareDriver(ActivateVBE,
!ActivateVBE,
FALSE))
{
WCHAR Msg[1024];
LoadString(hAppInstance, (ActivateVBE ? IDS_FAILEDTOSELVBEDRIVER : IDS_FAILEDTOSELVGADRIVER), Msg, sizeof(Msg) / sizeof(WCHAR));
MessageBox(GetParent(hwndDlg), Msg, NULL, MB_ICONWARNING);
SetWindowLong(hwndDlg, DWL_MSGRESULT, IDD_SELECTDRIVER);
return TRUE;
}
ShowUninstNotice(GetParent(hwndDlg));
}
return FALSE;
}
}
break;
}
}
return FALSE;
}
static LONG
CreateWizard(VOID)
{
PROPSHEETPAGE psp[7];
PROPSHEETHEADER psh;
WCHAR Caption[1024];
LoadString(hAppInstance, IDS_WIZARD_NAME, Caption, sizeof(Caption) / sizeof(TCHAR));
ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
psh.dwSize = sizeof(PROPSHEETHEADER);
psh.dwFlags = PSH_PROPSHEETPAGE | PSH_WIZARD;
psh.hwndParent = NULL;
psh.hInstance = hAppInstance;
psh.hIcon = 0;
psh.pszCaption = Caption;
psh.nPages = 7;
psh.nStartPage = (StartVMwConfigWizard ? 4 : 0);
psh.ppsp = psp;
InitPropSheetPage(&psp[0], IDD_WELCOMEPAGE, PageWelcomeProc);
InitPropSheetPage(&psp[1], IDD_INSERT_VMWARE_TOOLS, PageInsertDiscProc);
InitPropSheetPage(&psp[2], IDD_CONFIG, PageConfigProc);
InitPropSheetPage(&psp[3], IDD_INSTALLATION_FAILED, PageInstallFailedProc);
InitPropSheetPage(&psp[4], IDD_CHOOSEACTION, PageChooseActionProc);
InitPropSheetPage(&psp[5], IDD_SELECTDRIVER, PageSelectDriverProc);
InitPropSheetPage(&psp[6], IDD_DOUNINSTALL, PageDoUninstallProc);
return (LONG)(PropertySheet(&psh) != -1);
}
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" ;-) */
OldHandler = SetUnhandledExceptionFilter(ExceptionHandler);
if(!DetectVMware(&Version))
{
ExitProcess(1);
return 1;
}
/* restore the exception handler */
SetUnhandledExceptionFilter(OldHandler);
lc = DestinationPath;
lc += GetSystemDirectory(DestinationPath, MAX_PATH) - 1;
if(lc >= DestinationPath && *lc != L'\\')
{
wcscat(DestinationPath, L"\\");
}
SetCurrentDirectory(DestinationPath);
StartVMwConfigWizard = IsVmwSVGAEnabled();
/* Show the wizard */
CreateWizard();
return 2;
}

View file

@ -0,0 +1,41 @@
#ifndef __VMWINST_H
#define __VMWINST_H
#ifndef PSCB_BUTTONPRESSED
#define PSCB_BUTTONPRESSED (3)
#endif
/* metrics */
#define PROPSHEETWIDTH 250
#define PROPSHEETHEIGHT 120
#define PROPSHEETPADDING 6
#define SYSTEM_COLUMN (18 * PROPSHEETPADDING)
#define LABELLINE(x) (((PROPSHEETPADDING + 2) * x) + (x + 2))
#define ICONSIZE 16
/* Resource IDs */
#define IDS_WIZARD_NAME 100
#define IDS_FAILEDTOLOCATEDRIVERS 101
#define IDS_FAILEDTOCOPYFILES 102
#define IDS_FAILEDTOACTIVATEDRIVER 103
#define IDS_FAILEDTOSELVGADRIVER 104
#define IDS_FAILEDTOSELVBEDRIVER 105
#define IDS_UNINSTNOTICE 106
#define IDD_WELCOMEPAGE 100
#define IDD_INSERT_VMWARE_TOOLS 101
#define IDD_CONFIG 102
#define IDD_CHOOSEACTION 103
#define IDD_SELECTDRIVER 104
#define IDD_INSTALLATION_FAILED 105
#define IDD_DOUNINSTALL 106
#define IDC_COLORQUALITY 200
#define IDC_CONFIGSETTINGS 201
#define IDC_USEOTHERDRIVER 202
#define IDC_UNINSTALL 203
#define IDC_VGA 204
#define IDC_VBE 205
#endif /* __VMWINST_H */

View file

@ -0,0 +1,133 @@
#include <defines.h>
#include <reactos/resource.h>
#include "vmwinst.h"
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
VS_VERSION_INFO VERSIONINFO
FILEVERSION RES_UINT_FV_MAJOR,RES_UINT_FV_MINOR,RES_UINT_FV_REVISION,RES_UINT_FV_BUILD
PRODUCTVERSION RES_UINT_PV_MAJOR,RES_UINT_PV_MINOR,RES_UINT_PV_REVISION,RES_UINT_PV_BUILD
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x40004L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", RES_STR_COMPANY_NAME
VALUE "FileDescription", "ReactOS VMware(r) driver installation utility\0"
VALUE "FileVersion", RES_STR_FILE_VERSION
VALUE "InternalName", "vmwinst\0"
VALUE "LegalCopyright", RES_STR_LEGAL_COPYRIGHT
VALUE "OriginalFilename", "vmwinst.exe\0"
VALUE "ProductName", RES_STR_PRODUCT_NAME
VALUE "ProductVersion", RES_STR_PRODUCT_VERSION
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
IDD_WELCOMEPAGE DIALOGEX 0, 0, PROPSHEETWIDTH, PROPSHEETHEIGHT
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_DISABLED | WS_CAPTION
CAPTION "Video Driver Installation"
FONT 8, "MS Shell Dlg", 0, 0, 0x0
BEGIN
LTEXT "The ReactOS setup detected, that you run ReactOS inside of VMware(r).\n\n\nIf you like to install the VMware(r) SVGA driver, click 'Next', otherwise click 'Cancel'.",-1,25,25,225,85
END
IDD_INSERT_VMWARE_TOOLS DIALOGEX 0, 0, PROPSHEETWIDTH, PROPSHEETHEIGHT
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_DISABLED | WS_CAPTION
CAPTION "Video Driver Installation"
FONT 8, "MS Shell Dlg", 0, 0, 0x0
BEGIN
LTEXT "The ReactOS Setup doesn't come with the VMware(r) SVGA driver.\n\nTherefore go to 'VM' in your VMware(r) workstation menu bar and select 'Install VMware tools...'\n\n\nClick 'Next' to continue or 'Cancel' to skip the SVGA driver installation.",-1,25,25,225,85
END
IDD_CONFIG DIALOGEX 0, 0, PROPSHEETWIDTH, PROPSHEETHEIGHT
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_DISABLED | WS_CAPTION
CAPTION "Video Driver Installation"
FONT 8, "MS Shell Dlg", 0, 0, 0x0
BEGIN
LTEXT "The VMware(r) SVGA driver has been successfully installed. Please choose your favorite screen resolution:",-1,25,5,225,20
PUSHBUTTON "640x480", 540, 25, 30, 65, 15, BS_AUTORADIOBUTTON
PUSHBUTTON "800x600", 1400, 25, 45, 65, 15, BS_AUTORADIOBUTTON
PUSHBUTTON "1024x768", 1792, 25, 60, 65, 15, BS_AUTORADIOBUTTON
PUSHBUTTON "1152x864", 2016, 25, 75, 65, 15, BS_AUTORADIOBUTTON
PUSHBUTTON "1280x960", 2240, 110, 30, 65, 15, BS_AUTORADIOBUTTON
PUSHBUTTON "1280x1024", 2304, 110, 45, 65, 15, BS_AUTORADIOBUTTON
PUSHBUTTON "1400x1050", 2450, 110, 60, 65, 15, BS_AUTORADIOBUTTON
PUSHBUTTON "1600x1200", 2800, 110, 75, 65, 15, BS_AUTORADIOBUTTON
PUSHBUTTON "1792x1344", 3136, 195, 30, 65, 15, BS_AUTORADIOBUTTON
PUSHBUTTON "1856x1392", 3248, 195, 45, 65, 15, BS_AUTORADIOBUTTON
PUSHBUTTON "1920x1440", 3360, 195, 60, 50, 15, BS_AUTORADIOBUTTON
LTEXT "Please select your favorite color quality:", -1, 25, 93, 225, 12
COMBOBOX IDC_COLORQUALITY, 25, 105, 75, 80, CBS_DROPDOWNLIST | WS_TABSTOP
END
IDD_INSTALLATION_FAILED DIALOGEX 0, 0, PROPSHEETWIDTH, PROPSHEETHEIGHT
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_DISABLED | WS_CAPTION
CAPTION "Video Driver Installation"
FONT 8, "MS Shell Dlg", 0, 0, 0x0
BEGIN
LTEXT "The ReactOS Setup was unable to install the VMware(r) SVGA driver.\n\n\nClick 'Finish' to continue the installation process.",-1,25,25,225,85
END
IDD_CHOOSEACTION DIALOGEX 0, 0, PROPSHEETWIDTH, PROPSHEETHEIGHT
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_DISABLED | WS_CAPTION
CAPTION "Video Driver Installation"
FONT 8, "MS Shell Dlg", 0, 0, 0x0
BEGIN
LTEXT "The VMware(r) SVGA driver is already installed.\n\nPlease choose what you like to do:",-1,25,5,225,30
PUSHBUTTON "Configure the screen settings", IDC_CONFIGSETTINGS, 25, 40, 200, 15, BS_AUTORADIOBUTTON
PUSHBUTTON "Use a different graphics driver", IDC_USEOTHERDRIVER, 25, 55, 200, 15, BS_AUTORADIOBUTTON
PUSHBUTTON "Uninstall the VMware(r) SVGA driver", IDC_UNINSTALL, 25, 70, 200, 15, BS_AUTORADIOBUTTON
LTEXT "Click 'Next' to continue or 'Cancel' to exit the wizard.", -1, 25, 93, 225, 12
END
IDD_SELECTDRIVER DIALOGEX 0, 0, PROPSHEETWIDTH, PROPSHEETHEIGHT
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_DISABLED | WS_CAPTION
CAPTION "Video Driver Installation"
FONT 8, "MS Shell Dlg", 0, 0, 0x0
BEGIN
LTEXT "Please select the graphics driver you would like to use:",-1,25,25,225,15
PUSHBUTTON "ReactOS VGA Driver", IDC_VGA, 25, 40, 225, 15, BS_AUTORADIOBUTTON
PUSHBUTTON "ReactOS VBE Driver (Experimental!)", IDC_VBE, 25, 55, 225, 15, BS_AUTORADIOBUTTON
LTEXT "Click 'Finish' to complete the operation or 'Cancel' to exit the setup without changes.", -1, 25, 93, 225, 20
END
IDD_DOUNINSTALL DIALOGEX 0, 0, PROPSHEETWIDTH, PROPSHEETHEIGHT
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_DISABLED | WS_CAPTION
CAPTION "Video Driver Installation"
FONT 8, "MS Shell Dlg", 0, 0, 0x0
BEGIN
LTEXT "The ReactOS setup is about to uninstall your VMware(r) SVGA driver!!!\n\n\nClick 'Finish' to uninstall the driver or 'Cancel' to leave it as it is.",-1,25,25,225,85
END
STRINGTABLE
BEGIN
IDS_WIZARD_NAME "VMware(r) detected"
IDS_FAILEDTOLOCATEDRIVERS "The ReactOS Setup couldn't find the required files.\nPlease make sure the VMware(r) tools CD-ROM is inserted."
IDS_FAILEDTOCOPYFILES "The ReactOS Setup failed to copy the required files.\nPlease make sure the VMware(r) tools CD-ROM is inserted.\n"
IDS_FAILEDTOACTIVATEDRIVER "Failed to activate the VMware(r) SVGA driver!"
IDS_FAILEDTOSELVGADRIVER "Failed to activate the ReactOS VGA driver!"
IDS_FAILEDTOSELVBEDRIVER "Failed to activate the ReactOS VBE driver!"
IDS_UNINSTNOTICE "The VMware(r) SVGA driver files have not yet been deleted.\nPlease delete them manually after a system reboot."
END
STRINGTABLE
BEGIN
10001 "Lowest (8BPP)"
10002 "Medium (16BPP)"
10003 "Highest (32BPP)"
END