2 * ReactOS VMware(r) driver installation utility
3 * Copyright (C) 2004 ReactOS Team
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 * VMware is a registered trademark of VMware, Inc.
21 /* $Id: vmwinst.c,v 1.10 2004/09/24 20:18:15 weiden Exp $
23 * COPYRIGHT: See COPYING in the top level directory
24 * PROJECT: ReactOS VMware(r) driver installation utility
25 * FILE: subsys/system/vmwinst/vmwinst.c
26 * PROGRAMMERS: Thomas Weidenmueller (w3seek@users.sourceforge.net)
34 HINSTANCE hAppInstance
;
35 BOOL StartVMwConfigWizard
, DriverFilesFound
, ActivateVBE
= FALSE
, UninstallDriver
= FALSE
;
37 static WCHAR DestinationDriversPath
[MAX_PATH
+1];
38 static WCHAR CDDrive
= L
'\0';
39 static WCHAR PathToVideoDrivers45
[MAX_PATH
+1] = L
"X:\\program files\\VMware\\VMware Tools\\Drivers\\video\\winnt2k\\";
40 static WCHAR PathToVideoDrivers40
[MAX_PATH
+1] = L
"X:\\video\\winnt2k\\";
41 static WCHAR DestinationPath
[MAX_PATH
+1];
42 static WCHAR
*vmx_fb
= L
"vmx_fb.dll";
43 static WCHAR
*vmx_mode
= L
"vmx_mode.dll";
44 static WCHAR
*vmx_svga
= L
"vmx_svga.sys";
46 static WCHAR
*SrcPath
= PathToVideoDrivers45
;
48 static HANDLE hInstallationThread
= NULL
;
49 static HWND hInstallationNotifyWnd
= NULL
;
50 static LONG AbortInstall
= 0;
51 #define WM_INSTABORT (WM_USER + 2)
52 #define WM_INSTCOMPLETE (WM_USER + 3)
53 #define WM_INSTSTATUSUPDATE (WM_USER + 4)
55 /* Helper functions */
57 LONG WINAPI
ExceptionHandler(LPEXCEPTION_POINTERS ExceptionInfo
)
59 /* This is rude, but i don't know how to continue execution properly, that's why
60 we just exit here when we're not running inside of VMware */
61 ExitProcess(ExceptionInfo
->ExceptionRecord
->ExceptionCode
== STATUS_PRIVILEGED_INSTRUCTION
);
62 return EXCEPTION_CONTINUE_EXECUTION
;
66 DetectVMware(int *Version
)
74 /* Try using a VMware I/O port. If not running in VMware this'll throw an
76 __asm__
__volatile__("inl %%dx, %%eax"
77 : "=a" (ver
), "=b" (magic
)
78 : "0" (0x564d5868), "d" (0x5658), "c" (0xa));
80 if(magic
== 0x564d5868)
93 if(PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
))
95 TranslateMessage(&msg
);
96 DispatchMessage(&msg
);
103 ProcessMessages(void)
105 while(ProcessMessage());
108 /* try to open the file */
110 FileExists(WCHAR
*Path
, WCHAR
*File
)
112 WCHAR FileName
[MAX_PATH
+ 1];
116 wcscat(FileName
, Path
);
117 wcscat(FileName
, File
);
119 FileHandle
= CreateFile(FileName
, GENERIC_READ
, 0, NULL
, OPEN_EXISTING
, FILE_ATTRIBUTE_NORMAL
, NULL
);
121 if(FileHandle
== INVALID_HANDLE_VALUE
)
126 if(GetFileSize(FileHandle
, NULL
) <= 0)
128 CloseHandle(FileHandle
);
132 CloseHandle(FileHandle
);
138 InstallFile(WCHAR
*Destination
, WCHAR
*File
)
140 static char Buffer
[1024];
141 WCHAR SourceFileName
[MAX_PATH
+ 1];
142 WCHAR DestFileName
[MAX_PATH
+ 1];
143 HANDLE SourceFileHandle
, DestFileHandle
;
144 DWORD DataRead
, DataWritten
;
146 SourceFileName
[0] = L
'\0';
147 DestFileName
[0] = L
'\0';
148 wcscat(SourceFileName
, SrcPath
);
149 wcscat(SourceFileName
, File
);
150 wcscat(DestFileName
, Destination
);
151 wcscat(DestFileName
, File
);
153 SourceFileHandle
= CreateFile(SourceFileName
, GENERIC_READ
, 0, NULL
, OPEN_EXISTING
, FILE_ATTRIBUTE_NORMAL
, NULL
);
154 if(SourceFileHandle
== INVALID_HANDLE_VALUE
)
158 DestFileHandle
= CreateFile(DestFileName
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, FILE_ATTRIBUTE_NORMAL
, NULL
);
159 if(DestFileHandle
== INVALID_HANDLE_VALUE
)
161 CloseHandle(SourceFileHandle
);
165 while(ReadFile(SourceFileHandle
, Buffer
, sizeof(Buffer
), &DataRead
, NULL
) && DataRead
> 0)
167 if(!WriteFile(DestFileHandle
, Buffer
, DataRead
, &DataWritten
, NULL
) ||
168 DataRead
!= DataWritten
)
170 CloseHandle(SourceFileHandle
);
171 CloseHandle(DestFileHandle
);
172 DeleteFile(DestFileName
);
177 CloseHandle(SourceFileHandle
);
178 CloseHandle(DestFileHandle
);
182 /* Find the drive with the inserted VMware cd-rom */
184 IsVMwareCDInDrive(WCHAR
*Drv
)
186 static WCHAR Drive
[4] = L
"X:\\";
190 for(Current
= 'C'; Current
<= 'Z'; Current
++)
194 if(GetDriveType(Drive
) == DRIVE_CDROM
)
197 PathToVideoDrivers40
[0] = Current
;
198 PathToVideoDrivers45
[0] = Current
;
199 if(SetCurrentDirectory(PathToVideoDrivers45
))
200 SrcPath
= PathToVideoDrivers45
;
201 else if(SetCurrentDirectory(PathToVideoDrivers40
))
202 SrcPath
= PathToVideoDrivers40
;
205 SetCurrentDirectory(DestinationPath
);
209 if(FileExists(SrcPath
, vmx_fb
) &&
210 FileExists(SrcPath
, vmx_mode
) &&
211 FileExists(SrcPath
, vmx_svga
))
225 LoadResolutionSettings(DWORD
*ResX
, DWORD
*ResY
, DWORD
*ColDepth
)
230 if(RegOpenKeyEx(HKEY_LOCAL_MACHINE
,
231 L
"SYSTEM\\CurrentControlSet\\Hardware Profiles\\Current\\System\\CurrentControlSet\\Services\\vmx_svga\\Device0",
232 0, KEY_QUERY_VALUE
, &hReg
) != ERROR_SUCCESS
)
236 if(RegQueryValueEx(hReg
, L
"DefaultSettings.BitsPerPel", 0, &Type
, (BYTE
*)ColDepth
, &Size
) != ERROR_SUCCESS
||
243 if(RegQueryValueEx(hReg
, L
"DefaultSettings.XResolution", 0, &Type
, (BYTE
*)ResX
, &Size
) != ERROR_SUCCESS
||
250 if(RegQueryValueEx(hReg
, L
"DefaultSettings.YResolution", 0, &Type
, (BYTE
*)ResY
, &Size
) != ERROR_SUCCESS
||
262 IsVmwSVGAEnabled(VOID
)
265 DWORD Type
, Size
, Value
;
267 if(RegOpenKeyEx(HKEY_LOCAL_MACHINE
,
268 L
"SYSTEM\\CurrentControlSet\\Services\\vmx_svga",
269 0, KEY_QUERY_VALUE
, &hReg
) != ERROR_SUCCESS
)
273 if(RegQueryValueEx(hReg
, L
"Start", 0, &Type
, (BYTE
*)&Value
, &Size
) != ERROR_SUCCESS
||
285 SaveResolutionSettings(DWORD ResX
, DWORD ResY
, DWORD ColDepth
)
289 if(RegOpenKeyEx(HKEY_LOCAL_MACHINE
,
290 L
"SYSTEM\\CurrentControlSet\\Hardware Profiles\\Current\\System\\CurrentControlSet\\Services\\vmx_svga\\Device0",
291 0, KEY_QUERY_VALUE
, &hReg
) != ERROR_SUCCESS
)
295 if(RegSetValueEx(hReg
, L
"DefaultSettings.BitsPerPel", 0, REG_DWORD
, (BYTE
*)&ColDepth
, sizeof(DWORD
)) != ERROR_SUCCESS
)
301 if(RegSetValueEx(hReg
, L
"DefaultSettings.XResolution", 0, REG_DWORD
, (BYTE
*)&ResX
, sizeof(DWORD
)) != ERROR_SUCCESS
)
307 if(RegSetValueEx(hReg
, L
"DefaultSettings.YResolution", 0, REG_DWORD
, (BYTE
*)&ResY
, sizeof(DWORD
)) != ERROR_SUCCESS
)
318 EnableDriver(WCHAR
*Key
, BOOL Enable
)
323 Value
= (Enable
? 1 : 4);
325 if(RegOpenKeyEx(HKEY_LOCAL_MACHINE
, Key
, 0, KEY_SET_VALUE
, &hReg
) != ERROR_SUCCESS
)
329 if(RegSetValueEx(hReg
, L
"Start", 0, REG_DWORD
, (BYTE
*)&Value
, sizeof(DWORD
)) != ERROR_SUCCESS
)
339 /* Activate the vmware driver and deactivate the others */
341 EnableVmwareDriver(BOOL VBE
, BOOL VGA
, BOOL VMX
)
343 if(!EnableDriver(L
"SYSTEM\\CurrentControlSet\\Services\\VBE", VBE
))
347 if(!EnableDriver(L
"SYSTEM\\CurrentControlSet\\Services\\vga", VGA
))
351 if(!EnableDriver(L
"SYSTEM\\CurrentControlSet\\Services\\vmx_svga", VMX
))
362 InitPropSheetPage(PROPSHEETPAGE
*psp
, WORD idDlg
, DWORD Flags
, DLGPROC DlgProc
)
364 ZeroMemory(psp
, sizeof(PROPSHEETPAGE
));
365 psp
->dwSize
= sizeof(PROPSHEETPAGE
);
366 psp
->dwFlags
= PSP_DEFAULT
| Flags
;
367 psp
->hInstance
= hAppInstance
;
368 psp
->pszTemplate
= MAKEINTRESOURCE(idDlg
);
369 psp
->pfnDlgProc
= DlgProc
;
372 /* Property page dialog callback */
385 LPNMHDR pnmh
= (LPNMHDR
)lParam
;
390 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_NEXT
);
397 if(!EnableVmwareDriver(FALSE
, FALSE
, TRUE
))
400 LoadString(hAppInstance
, IDS_FAILEDTOACTIVATEDRIVER
, Msg
, sizeof(Msg
) / sizeof(WCHAR
));
401 MessageBox(GetParent(hwndDlg
), Msg
, NULL
, MB_ICONWARNING
);
402 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_WELCOMEPAGE
);
405 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_CONFIG
);
417 /* Property page dialog callback */
430 LPNMHDR pnmh
= (LPNMHDR
)lParam
;
434 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_BACK
| PSWIZB_NEXT
);
437 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_INSTALLING_VMWARE_TOOLS
);
447 InstTerminateInstaller(BOOL Wait
)
449 if(hInstallationThread
!= NULL
)
453 InterlockedExchange((LONG
*)&AbortInstall
, 2);
454 WaitForSingleObject(hInstallationThread
, INFINITE
);
458 InterlockedExchange((LONG
*)&AbortInstall
, 1);
464 InstInstallationThread(LPVOID lpParameter
)
468 int DrivesTested
= 0;
470 if(AbortInstall
!= 0) goto done
;
471 PostMessage(hInstallationNotifyWnd
, WM_INSTSTATUSUPDATE
, IDS_SEARCHINGFORCDROM
, 0);
473 while(AbortInstall
== 0)
476 DriveAvailable
= IsVMwareCDInDrive(&CDDrive
);
479 if(DrivesTested
++ > 20)
481 PostMessage(hInstallationNotifyWnd
, WM_INSTABORT
, IDS_FAILEDTOLOCATEDRIVERS
, 0);
486 if(AbortInstall
!= 0) goto done
;
487 PostMessage(hInstallationNotifyWnd
, WM_INSTSTATUSUPDATE
, IDS_COPYINGFILES
, 0);
489 if(AbortInstall
!= 0) goto done
;
490 if(!InstallFile(DestinationPath
, vmx_fb
))
492 PostMessage(hInstallationNotifyWnd
, WM_INSTABORT
, IDS_FAILEDTOCOPYFILES
, 0);
498 if(AbortInstall
!= 0) goto done
;
499 if(!InstallFile(DestinationPath
, vmx_mode
))
501 PostMessage(hInstallationNotifyWnd
, WM_INSTABORT
, IDS_FAILEDTOCOPYFILES
, 0);
507 if(AbortInstall
!= 0) goto done
;
508 if(!InstallFile(DestinationDriversPath
, vmx_svga
))
510 PostMessage(hInstallationNotifyWnd
, WM_INSTABORT
, IDS_FAILEDTOCOPYFILES
, 0);
516 if(AbortInstall
!= 0) goto done
;
517 PostMessage(hInstallationNotifyWnd
, WM_INSTSTATUSUPDATE
, IDS_ENABLINGDRIVER
, 0);
518 if(!EnableVmwareDriver(FALSE
, FALSE
, TRUE
))
520 PostMessage(hInstallationNotifyWnd
, WM_INSTABORT
, IDS_FAILEDTOACTIVATEDRIVER
, 0);
530 SendMessage(hInstallationNotifyWnd
, WM_INSTCOMPLETE
, 0, 0);
533 SendMessage(hInstallationNotifyWnd
, WM_INSTABORT
, 0, 0);
538 hThread
= (HANDLE
)InterlockedExchange((LONG
*)&hInstallationThread
, 0);
541 CloseHandle(hThread
);
547 InstStartInstallationThread(HWND hwndNotify
)
549 if(hInstallationThread
== NULL
)
552 hInstallationNotifyWnd
= hwndNotify
;
554 hInstallationThread
= CreateThread(NULL
,
556 InstInstallationThread
,
560 if(hInstallationThread
== NULL
)
565 ResumeThread(hInstallationThread
);
572 /* Property page dialog callback */
585 LPNMHDR pnmh
= (LPNMHDR
)lParam
;
589 SetDlgItemText(hwndDlg
, IDC_INSTALLINGSTATUS
, NULL
);
590 SendDlgItemMessage(hwndDlg
, IDC_INSTALLINGPROGRESS
, PBM_SETMARQUEE
, TRUE
, 50);
591 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_BACK
);
592 InstStartInstallationThread(hwndDlg
);
595 InstTerminateInstaller(TRUE
);
598 if(hInstallationThread
!= NULL
)
600 PropSheet_SetWizButtons(GetParent(hwndDlg
), 0);
601 InstTerminateInstaller(FALSE
);
602 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, -1);
607 SendDlgItemMessage(hwndDlg
, IDC_INSTALLINGPROGRESS
, PBM_SETMARQUEE
, FALSE
, 0);
608 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_INSERT_VMWARE_TOOLS
);
615 /* go back in case we aborted the installation thread */
616 SendDlgItemMessage(hwndDlg
, IDC_INSTALLINGPROGRESS
, PBM_SETMARQUEE
, FALSE
, 0);
617 PropSheet_SetCurSelByID(GetParent(hwndDlg
), IDD_INSERT_VMWARE_TOOLS
);
621 LoadString(hAppInstance
, wParam
, Msg
, sizeof(Msg
) / sizeof(WCHAR
));
622 MessageBox(GetParent(hwndDlg
), Msg
, NULL
, MB_ICONWARNING
);
625 case WM_INSTCOMPLETE
:
626 SendDlgItemMessage(hwndDlg
, IDC_INSTALLINGPROGRESS
, PBM_SETMARQUEE
, FALSE
, 0);
627 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_BACK
| PSWIZB_NEXT
);
628 PropSheet_SetCurSelByID(GetParent(hwndDlg
), IDD_CONFIG
);
630 case WM_INSTSTATUSUPDATE
:
633 LoadString(hAppInstance
, wParam
, Msg
, sizeof(Msg
) / sizeof(WCHAR
));
634 SetDlgItemText(hwndDlg
, IDC_INSTALLINGSTATUS
, Msg
);
641 /* Property page dialog callback */
643 PageInstallFailedProc(
654 LPNMHDR pnmh
= (LPNMHDR
)lParam
;
658 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_FINISH
);
668 FillComboBox(HWND Dlg
, int idComboBox
, int From
, int To
)
673 for(i
= From
; i
<= To
; i
++)
675 if(LoadString(hAppInstance
, i
, Text
, 255) > 0)
677 SendDlgItemMessage(Dlg
, idComboBox
, CB_ADDSTRING
, 0, (LPARAM
)Text
);
689 /* Property page dialog callback */
702 DWORD ResX
= 0, ResY
= 0, ColDepth
= 0;
705 FillComboBox(hwndDlg
, IDC_COLORQUALITY
, 10001, 10003);
706 if(LoadResolutionSettings(&ResX
, &ResY
, &ColDepth
))
708 SendDlgItemMessage(hwndDlg
, ResX
+ ResY
, BM_SETCHECK
, BST_CHECKED
, 0);
724 SendDlgItemMessage(hwndDlg
, IDC_COLORQUALITY
, CB_SETCURSEL
, cbSel
, 0);
730 LPNMHDR pnmh
= (LPNMHDR
)lParam
;
735 PropSheet_SetWizButtons(GetParent(hwndDlg
), ((StartVMwConfigWizard
|| DriverFilesFound
) ? PSWIZB_FINISH
| PSWIZB_BACK
: PSWIZB_FINISH
));
740 if(StartVMwConfigWizard
)
742 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_CHOOSEACTION
);
747 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_WELCOMEPAGE
);
754 DWORD rx
= 800, ry
= 600, cd
= 32;
756 static MAPCTLRES Resolutions
[11] = {
769 for(i
= 0; i
< 11; i
++)
771 if(SendDlgItemMessage(hwndDlg
, Resolutions
[i
].ControlID
, BM_GETCHECK
, 0, 0) == BST_CHECKED
)
773 rx
= Resolutions
[i
].ResX
;
774 ry
= Resolutions
[i
].ResY
;
779 switch(SendDlgItemMessage(hwndDlg
, IDC_COLORQUALITY
, CB_GETCURSEL
, 0, 0))
792 SaveResolutionSettings(rx
, ry
, cd
);
802 /* Property page dialog callback */
804 PageChooseActionProc(
814 SendDlgItemMessage(hwndDlg
, IDC_CONFIGSETTINGS
, BM_SETCHECK
, BST_CHECKED
, 0);
818 LPNMHDR pnmh
= (LPNMHDR
)lParam
;
822 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_NEXT
);
826 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_CHOOSEACTION
);
831 static ULONG SelPage
[4] = {IDD_CONFIG
, IDD_SELECTDRIVER
, IDD_SELECTDRIVER
, IDD_CHOOSEACTION
};
834 for(i
= IDC_CONFIGSETTINGS
; i
<= IDC_UNINSTALL
; i
++)
836 if(SendDlgItemMessage(hwndDlg
, i
, BM_GETCHECK
, 0, 0) == BST_CHECKED
)
842 UninstallDriver
= (i
== IDC_UNINSTALL
);
844 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, SelPage
[i
- IDC_CONFIGSETTINGS
]);
854 /* Property page dialog callback */
856 PageSelectDriverProc(
866 SendDlgItemMessage(hwndDlg
, IDC_VBE
, BM_SETCHECK
, BST_CHECKED
, 0);
870 LPNMHDR pnmh
= (LPNMHDR
)lParam
;
874 PropSheet_SetWizButtons(GetParent(hwndDlg
), (UninstallDriver
? PSWIZB_NEXT
| PSWIZB_BACK
: PSWIZB_BACK
| PSWIZB_FINISH
));
878 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_CHOOSEACTION
);
883 ActivateVBE
= (SendDlgItemMessage(hwndDlg
, IDC_VBE
, BM_GETCHECK
, 0, 0) == BST_CHECKED
);
897 ActivateVBE
= (SendDlgItemMessage(hwndDlg
, IDC_VBE
, BM_GETCHECK
, 0, 0) == BST_CHECKED
);
898 if(!EnableVmwareDriver(ActivateVBE
,
903 LoadString(hAppInstance
, (ActivateVBE
? IDS_FAILEDTOSELVBEDRIVER
: IDS_FAILEDTOSELVGADRIVER
), Msg
, sizeof(Msg
) / sizeof(WCHAR
));
904 MessageBox(GetParent(hwndDlg
), Msg
, NULL
, MB_ICONWARNING
);
905 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_SELECTDRIVER
);
918 ShowUninstNotice(HWND Owner
)
921 LoadString(hAppInstance
, IDS_UNINSTNOTICE
, Msg
, sizeof(Msg
) / sizeof(WCHAR
));
922 MessageBox(Owner
, Msg
, NULL
, MB_ICONINFORMATION
);
937 LPNMHDR pnmh
= (LPNMHDR
)lParam
;
941 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_BACK
| PSWIZB_FINISH
);
947 if(!EnableVmwareDriver(ActivateVBE
,
952 LoadString(hAppInstance
, (ActivateVBE
? IDS_FAILEDTOSELVBEDRIVER
: IDS_FAILEDTOSELVGADRIVER
), Msg
, sizeof(Msg
) / sizeof(WCHAR
));
953 MessageBox(GetParent(hwndDlg
), Msg
, NULL
, MB_ICONWARNING
);
954 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_SELECTDRIVER
);
957 ShowUninstNotice(GetParent(hwndDlg
));
971 PROPSHEETPAGE psp
[8];
975 LoadString(hAppInstance
, IDS_WIZARD_NAME
, Caption
, sizeof(Caption
) / sizeof(TCHAR
));
977 ZeroMemory(&psh
, sizeof(PROPSHEETHEADER
));
978 psh
.dwSize
= sizeof(PROPSHEETHEADER
);
979 psh
.dwFlags
= PSH_PROPSHEETPAGE
| PSH_WIZARD97
| PSH_WATERMARK
| PSH_HEADER
;
980 psh
.hwndParent
= NULL
;
981 psh
.hInstance
= hAppInstance
;
983 psh
.pszCaption
= Caption
;
985 psh
.nStartPage
= (StartVMwConfigWizard
? 5 : 0);
987 psh
.pszbmWatermark
= MAKEINTRESOURCE(IDB_WATERMARK
);
988 psh
.pszbmHeader
= MAKEINTRESOURCE(IDB_HEADER
);
990 InitPropSheetPage(&psp
[0], IDD_WELCOMEPAGE
, PSP_HIDEHEADER
, PageWelcomeProc
);
991 InitPropSheetPage(&psp
[1], IDD_INSERT_VMWARE_TOOLS
, PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
, PageInsertDiscProc
);
992 InitPropSheetPage(&psp
[2], IDD_INSTALLING_VMWARE_TOOLS
, PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
, PageInstallingProc
);
993 InitPropSheetPage(&psp
[3], IDD_CONFIG
, PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
, PageConfigProc
);
994 InitPropSheetPage(&psp
[4], IDD_INSTALLATION_FAILED
, PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
, PageInstallFailedProc
);
995 InitPropSheetPage(&psp
[5], IDD_CHOOSEACTION
, PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
, PageChooseActionProc
);
996 InitPropSheetPage(&psp
[6], IDD_SELECTDRIVER
, PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
, PageSelectDriverProc
);
997 InitPropSheetPage(&psp
[7], IDD_DOUNINSTALL
, PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
, PageDoUninstallProc
);
999 return (LONG
)(PropertySheet(&psh
) != -1);
1003 WinMain(HINSTANCE hInstance
,
1004 HINSTANCE hPrevInstance
,
1008 LPTOP_LEVEL_EXCEPTION_FILTER OldHandler
;
1012 hAppInstance
= hInstance
;
1014 /* Setup our exception "handler" ;-) */
1015 OldHandler
= SetUnhandledExceptionFilter(ExceptionHandler
);
1017 if(!DetectVMware(&Version
))
1023 /* restore the exception handler */
1024 SetUnhandledExceptionFilter(OldHandler
);
1026 lc
= DestinationPath
;
1027 lc
+= GetSystemDirectory(DestinationPath
, MAX_PATH
) - 1;
1028 if(lc
>= DestinationPath
&& *lc
!= L
'\\')
1030 wcscat(DestinationPath
, L
"\\");
1032 DestinationDriversPath
[0] = L
'\0';
1033 wcscat(DestinationDriversPath
, DestinationPath
);
1034 wcscat(DestinationDriversPath
, L
"drivers\\");
1036 SetCurrentDirectory(DestinationPath
);
1038 DriverFilesFound
= FileExists(DestinationPath
, vmx_fb
) &&
1039 FileExists(DestinationPath
, vmx_mode
) &&
1040 FileExists(DestinationDriversPath
, vmx_svga
);
1042 StartVMwConfigWizard
= DriverFilesFound
&& IsVmwSVGAEnabled();
1044 /* Show the wizard */