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.12 2004/10/11 21:08:05 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
)
73 /* Try using a VMware I/O port. If not running in VMware this'll throw an
75 __asm__
__volatile__("inl %%dx, %%eax"
76 : "=a" (ver
), "=b" (magic
)
77 : "0" (0x564d5868), "d" (0x5658), "c" (0xa));
79 if(magic
== 0x564d5868)
92 if(PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
))
94 TranslateMessage(&msg
);
95 DispatchMessage(&msg
);
102 ProcessMessages(void)
104 while(ProcessMessage());
107 /* try to open the file */
109 FileExists(WCHAR
*Path
, WCHAR
*File
)
111 WCHAR FileName
[MAX_PATH
+ 1];
115 wcscat(FileName
, Path
);
116 wcscat(FileName
, File
);
118 FileHandle
= CreateFile(FileName
, GENERIC_READ
, 0, NULL
, OPEN_EXISTING
, FILE_ATTRIBUTE_NORMAL
, NULL
);
120 if(FileHandle
== INVALID_HANDLE_VALUE
)
125 if(GetFileSize(FileHandle
, NULL
) <= 0)
127 CloseHandle(FileHandle
);
131 CloseHandle(FileHandle
);
137 InstallFile(WCHAR
*Destination
, WCHAR
*File
)
139 static char Buffer
[1024];
140 WCHAR SourceFileName
[MAX_PATH
+ 1];
141 WCHAR DestFileName
[MAX_PATH
+ 1];
142 HANDLE SourceFileHandle
, DestFileHandle
;
143 DWORD DataRead
, DataWritten
;
145 SourceFileName
[0] = L
'\0';
146 DestFileName
[0] = L
'\0';
147 wcscat(SourceFileName
, SrcPath
);
148 wcscat(SourceFileName
, File
);
149 wcscat(DestFileName
, Destination
);
150 wcscat(DestFileName
, File
);
152 SourceFileHandle
= CreateFile(SourceFileName
, GENERIC_READ
, 0, NULL
, OPEN_EXISTING
, FILE_ATTRIBUTE_NORMAL
, NULL
);
153 if(SourceFileHandle
== INVALID_HANDLE_VALUE
)
157 DestFileHandle
= CreateFile(DestFileName
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, FILE_ATTRIBUTE_NORMAL
, NULL
);
158 if(DestFileHandle
== INVALID_HANDLE_VALUE
)
160 CloseHandle(SourceFileHandle
);
164 while(ReadFile(SourceFileHandle
, Buffer
, sizeof(Buffer
), &DataRead
, NULL
) && DataRead
> 0)
166 if(!WriteFile(DestFileHandle
, Buffer
, DataRead
, &DataWritten
, NULL
) ||
167 DataRead
!= DataWritten
)
169 CloseHandle(SourceFileHandle
);
170 CloseHandle(DestFileHandle
);
171 DeleteFile(DestFileName
);
176 CloseHandle(SourceFileHandle
);
177 CloseHandle(DestFileHandle
);
181 /* Find the drive with the inserted VMware cd-rom */
183 IsVMwareCDInDrive(WCHAR
*Drv
)
185 static WCHAR Drive
[4] = L
"X:\\";
189 for(Current
= 'C'; Current
<= 'Z'; Current
++)
193 if(GetDriveType(Drive
) == DRIVE_CDROM
)
196 PathToVideoDrivers40
[0] = Current
;
197 PathToVideoDrivers45
[0] = Current
;
198 if(SetCurrentDirectory(PathToVideoDrivers45
))
199 SrcPath
= PathToVideoDrivers45
;
200 else if(SetCurrentDirectory(PathToVideoDrivers40
))
201 SrcPath
= PathToVideoDrivers40
;
204 SetCurrentDirectory(DestinationPath
);
208 if(FileExists(SrcPath
, vmx_fb
) &&
209 FileExists(SrcPath
, vmx_mode
) &&
210 FileExists(SrcPath
, vmx_svga
))
224 LoadResolutionSettings(DWORD
*ResX
, DWORD
*ResY
, DWORD
*ColDepth
)
229 if(RegOpenKeyEx(HKEY_LOCAL_MACHINE
,
230 L
"SYSTEM\\CurrentControlSet\\Hardware Profiles\\Current\\System\\CurrentControlSet\\Services\\vmx_svga\\Device0",
231 0, KEY_QUERY_VALUE
, &hReg
) != ERROR_SUCCESS
)
235 if(RegQueryValueEx(hReg
, L
"DefaultSettings.BitsPerPel", 0, &Type
, (BYTE
*)ColDepth
, &Size
) != ERROR_SUCCESS
||
242 if(RegQueryValueEx(hReg
, L
"DefaultSettings.XResolution", 0, &Type
, (BYTE
*)ResX
, &Size
) != ERROR_SUCCESS
||
249 if(RegQueryValueEx(hReg
, L
"DefaultSettings.YResolution", 0, &Type
, (BYTE
*)ResY
, &Size
) != ERROR_SUCCESS
||
261 IsVmwSVGAEnabled(VOID
)
264 DWORD Type
, Size
, Value
;
266 if(RegOpenKeyEx(HKEY_LOCAL_MACHINE
,
267 L
"SYSTEM\\CurrentControlSet\\Services\\vmx_svga",
268 0, KEY_QUERY_VALUE
, &hReg
) != ERROR_SUCCESS
)
272 if(RegQueryValueEx(hReg
, L
"Start", 0, &Type
, (BYTE
*)&Value
, &Size
) != ERROR_SUCCESS
||
284 SaveResolutionSettings(DWORD ResX
, DWORD ResY
, DWORD ColDepth
)
288 if(RegOpenKeyEx(HKEY_LOCAL_MACHINE
,
289 L
"SYSTEM\\CurrentControlSet\\Hardware Profiles\\Current\\System\\CurrentControlSet\\Services\\vmx_svga\\Device0",
290 0, KEY_QUERY_VALUE
, &hReg
) != ERROR_SUCCESS
)
294 if(RegSetValueEx(hReg
, L
"DefaultSettings.BitsPerPel", 0, REG_DWORD
, (BYTE
*)&ColDepth
, sizeof(DWORD
)) != ERROR_SUCCESS
)
300 if(RegSetValueEx(hReg
, L
"DefaultSettings.XResolution", 0, REG_DWORD
, (BYTE
*)&ResX
, sizeof(DWORD
)) != ERROR_SUCCESS
)
306 if(RegSetValueEx(hReg
, L
"DefaultSettings.YResolution", 0, REG_DWORD
, (BYTE
*)&ResY
, sizeof(DWORD
)) != ERROR_SUCCESS
)
317 EnableDriver(WCHAR
*Key
, BOOL Enable
)
322 Value
= (Enable
? 1 : 4);
324 if(RegOpenKeyEx(HKEY_LOCAL_MACHINE
, Key
, 0, KEY_SET_VALUE
, &hReg
) != ERROR_SUCCESS
)
328 if(RegSetValueEx(hReg
, L
"Start", 0, REG_DWORD
, (BYTE
*)&Value
, sizeof(DWORD
)) != ERROR_SUCCESS
)
338 /* Activate the vmware driver and deactivate the others */
340 EnableVmwareDriver(BOOL VBE
, BOOL VGA
, BOOL VMX
)
342 if(!EnableDriver(L
"SYSTEM\\CurrentControlSet\\Services\\VBE", VBE
))
346 if(!EnableDriver(L
"SYSTEM\\CurrentControlSet\\Services\\vga", VGA
))
350 if(!EnableDriver(L
"SYSTEM\\CurrentControlSet\\Services\\vmx_svga", VMX
))
361 InitPropSheetPage(PROPSHEETPAGE
*psp
, WORD idDlg
, DWORD Flags
, DLGPROC DlgProc
)
363 ZeroMemory(psp
, sizeof(PROPSHEETPAGE
));
364 psp
->dwSize
= sizeof(PROPSHEETPAGE
);
365 psp
->dwFlags
= PSP_DEFAULT
| Flags
;
366 psp
->hInstance
= hAppInstance
;
367 psp
->pszTemplate
= MAKEINTRESOURCE(idDlg
);
368 psp
->pfnDlgProc
= DlgProc
;
371 /* Property page dialog callback */
384 LPNMHDR pnmh
= (LPNMHDR
)lParam
;
389 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_NEXT
);
396 if(!EnableVmwareDriver(FALSE
, FALSE
, TRUE
))
399 LoadString(hAppInstance
, IDS_FAILEDTOACTIVATEDRIVER
, Msg
, sizeof(Msg
) / sizeof(WCHAR
));
400 MessageBox(GetParent(hwndDlg
), Msg
, NULL
, MB_ICONWARNING
);
401 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_WELCOMEPAGE
);
404 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_CONFIG
);
416 /* Property page dialog callback */
429 LPNMHDR pnmh
= (LPNMHDR
)lParam
;
433 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_BACK
| PSWIZB_NEXT
);
436 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_INSTALLING_VMWARE_TOOLS
);
446 InstTerminateInstaller(BOOL Wait
)
448 if(hInstallationThread
!= NULL
)
452 InterlockedExchange((LONG
*)&AbortInstall
, 2);
453 WaitForSingleObject(hInstallationThread
, INFINITE
);
457 InterlockedExchange((LONG
*)&AbortInstall
, 1);
463 InstInstallationThread(LPVOID lpParameter
)
467 int DrivesTested
= 0;
469 if(AbortInstall
!= 0) goto done
;
470 PostMessage(hInstallationNotifyWnd
, WM_INSTSTATUSUPDATE
, IDS_SEARCHINGFORCDROM
, 0);
472 while(AbortInstall
== 0)
475 DriveAvailable
= IsVMwareCDInDrive(&CDDrive
);
478 if(DrivesTested
++ > 20)
480 PostMessage(hInstallationNotifyWnd
, WM_INSTABORT
, IDS_FAILEDTOLOCATEDRIVERS
, 0);
485 if(AbortInstall
!= 0) goto done
;
486 PostMessage(hInstallationNotifyWnd
, WM_INSTSTATUSUPDATE
, IDS_COPYINGFILES
, 0);
488 if(AbortInstall
!= 0) goto done
;
489 if(!InstallFile(DestinationPath
, vmx_fb
))
491 PostMessage(hInstallationNotifyWnd
, WM_INSTABORT
, IDS_FAILEDTOCOPYFILES
, 0);
497 if(AbortInstall
!= 0) goto done
;
498 if(!InstallFile(DestinationPath
, vmx_mode
))
500 PostMessage(hInstallationNotifyWnd
, WM_INSTABORT
, IDS_FAILEDTOCOPYFILES
, 0);
506 if(AbortInstall
!= 0) goto done
;
507 if(!InstallFile(DestinationDriversPath
, vmx_svga
))
509 PostMessage(hInstallationNotifyWnd
, WM_INSTABORT
, IDS_FAILEDTOCOPYFILES
, 0);
515 if(AbortInstall
!= 0) goto done
;
516 PostMessage(hInstallationNotifyWnd
, WM_INSTSTATUSUPDATE
, IDS_ENABLINGDRIVER
, 0);
517 if(!EnableVmwareDriver(FALSE
, FALSE
, TRUE
))
519 PostMessage(hInstallationNotifyWnd
, WM_INSTABORT
, IDS_FAILEDTOACTIVATEDRIVER
, 0);
529 SendMessage(hInstallationNotifyWnd
, WM_INSTCOMPLETE
, 0, 0);
532 SendMessage(hInstallationNotifyWnd
, WM_INSTABORT
, 0, 0);
537 hThread
= (HANDLE
)InterlockedExchange((LONG
*)&hInstallationThread
, 0);
540 CloseHandle(hThread
);
546 InstStartInstallationThread(HWND hwndNotify
)
548 if(hInstallationThread
== NULL
)
551 hInstallationNotifyWnd
= hwndNotify
;
553 hInstallationThread
= CreateThread(NULL
,
555 InstInstallationThread
,
559 if(hInstallationThread
== NULL
)
564 ResumeThread(hInstallationThread
);
571 /* Property page dialog callback */
584 LPNMHDR pnmh
= (LPNMHDR
)lParam
;
588 SetDlgItemText(hwndDlg
, IDC_INSTALLINGSTATUS
, NULL
);
589 SendDlgItemMessage(hwndDlg
, IDC_INSTALLINGPROGRESS
, PBM_SETMARQUEE
, TRUE
, 50);
590 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_BACK
);
591 InstStartInstallationThread(hwndDlg
);
594 InstTerminateInstaller(TRUE
);
597 if(hInstallationThread
!= NULL
)
599 PropSheet_SetWizButtons(GetParent(hwndDlg
), 0);
600 InstTerminateInstaller(FALSE
);
601 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, -1);
606 SendDlgItemMessage(hwndDlg
, IDC_INSTALLINGPROGRESS
, PBM_SETMARQUEE
, FALSE
, 0);
607 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_INSERT_VMWARE_TOOLS
);
614 /* go back in case we aborted the installation thread */
615 SendDlgItemMessage(hwndDlg
, IDC_INSTALLINGPROGRESS
, PBM_SETMARQUEE
, FALSE
, 0);
616 PropSheet_SetCurSelByID(GetParent(hwndDlg
), IDD_INSERT_VMWARE_TOOLS
);
620 LoadString(hAppInstance
, wParam
, Msg
, sizeof(Msg
) / sizeof(WCHAR
));
621 MessageBox(GetParent(hwndDlg
), Msg
, NULL
, MB_ICONWARNING
);
624 case WM_INSTCOMPLETE
:
625 SendDlgItemMessage(hwndDlg
, IDC_INSTALLINGPROGRESS
, PBM_SETMARQUEE
, FALSE
, 0);
626 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_BACK
| PSWIZB_NEXT
);
627 PropSheet_SetCurSelByID(GetParent(hwndDlg
), IDD_CONFIG
);
629 case WM_INSTSTATUSUPDATE
:
632 LoadString(hAppInstance
, wParam
, Msg
, sizeof(Msg
) / sizeof(WCHAR
));
633 SetDlgItemText(hwndDlg
, IDC_INSTALLINGSTATUS
, Msg
);
640 /* Property page dialog callback */
642 PageInstallFailedProc(
653 LPNMHDR pnmh
= (LPNMHDR
)lParam
;
657 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_FINISH
);
667 FillComboBox(HWND Dlg
, int idComboBox
, int From
, int To
)
672 for(i
= From
; i
<= To
; i
++)
674 if(LoadString(hAppInstance
, i
, Text
, 255) > 0)
676 SendDlgItemMessage(Dlg
, idComboBox
, CB_ADDSTRING
, 0, (LPARAM
)Text
);
688 /* Property page dialog callback */
701 DWORD ResX
= 0, ResY
= 0, ColDepth
= 0;
704 FillComboBox(hwndDlg
, IDC_COLORQUALITY
, 10001, 10003);
705 if(LoadResolutionSettings(&ResX
, &ResY
, &ColDepth
))
707 SendDlgItemMessage(hwndDlg
, ResX
+ ResY
, BM_SETCHECK
, BST_CHECKED
, 0);
723 SendDlgItemMessage(hwndDlg
, IDC_COLORQUALITY
, CB_SETCURSEL
, cbSel
, 0);
729 LPNMHDR pnmh
= (LPNMHDR
)lParam
;
734 PropSheet_SetWizButtons(GetParent(hwndDlg
), ((StartVMwConfigWizard
|| DriverFilesFound
) ? PSWIZB_FINISH
| PSWIZB_BACK
: PSWIZB_FINISH
));
739 if(StartVMwConfigWizard
)
741 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_CHOOSEACTION
);
746 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_WELCOMEPAGE
);
753 DWORD rx
= 800, ry
= 600, cd
= 32;
755 static MAPCTLRES Resolutions
[11] = {
768 for(i
= 0; i
< 11; i
++)
770 if(SendDlgItemMessage(hwndDlg
, Resolutions
[i
].ControlID
, BM_GETCHECK
, 0, 0) == BST_CHECKED
)
772 rx
= Resolutions
[i
].ResX
;
773 ry
= Resolutions
[i
].ResY
;
778 switch(SendDlgItemMessage(hwndDlg
, IDC_COLORQUALITY
, CB_GETCURSEL
, 0, 0))
791 SaveResolutionSettings(rx
, ry
, cd
);
801 /* Property page dialog callback */
803 PageChooseActionProc(
813 SendDlgItemMessage(hwndDlg
, IDC_CONFIGSETTINGS
, BM_SETCHECK
, BST_CHECKED
, 0);
817 LPNMHDR pnmh
= (LPNMHDR
)lParam
;
821 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_NEXT
);
825 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_CHOOSEACTION
);
830 static ULONG SelPage
[4] = {IDD_CONFIG
, IDD_SELECTDRIVER
, IDD_SELECTDRIVER
, IDD_CHOOSEACTION
};
833 for(i
= IDC_CONFIGSETTINGS
; i
<= IDC_UNINSTALL
; i
++)
835 if(SendDlgItemMessage(hwndDlg
, i
, BM_GETCHECK
, 0, 0) == BST_CHECKED
)
841 UninstallDriver
= (i
== IDC_UNINSTALL
);
843 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, SelPage
[i
- IDC_CONFIGSETTINGS
]);
853 /* Property page dialog callback */
855 PageSelectDriverProc(
865 SendDlgItemMessage(hwndDlg
, IDC_VBE
, BM_SETCHECK
, BST_CHECKED
, 0);
869 LPNMHDR pnmh
= (LPNMHDR
)lParam
;
873 PropSheet_SetWizButtons(GetParent(hwndDlg
), (UninstallDriver
? PSWIZB_NEXT
| PSWIZB_BACK
: PSWIZB_BACK
| PSWIZB_FINISH
));
877 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_CHOOSEACTION
);
882 ActivateVBE
= (SendDlgItemMessage(hwndDlg
, IDC_VBE
, BM_GETCHECK
, 0, 0) == BST_CHECKED
);
896 ActivateVBE
= (SendDlgItemMessage(hwndDlg
, IDC_VBE
, BM_GETCHECK
, 0, 0) == BST_CHECKED
);
897 if(!EnableVmwareDriver(ActivateVBE
,
902 LoadString(hAppInstance
, (ActivateVBE
? IDS_FAILEDTOSELVBEDRIVER
: IDS_FAILEDTOSELVGADRIVER
), Msg
, sizeof(Msg
) / sizeof(WCHAR
));
903 MessageBox(GetParent(hwndDlg
), Msg
, NULL
, MB_ICONWARNING
);
904 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_SELECTDRIVER
);
917 ShowUninstNotice(HWND Owner
)
920 LoadString(hAppInstance
, IDS_UNINSTNOTICE
, Msg
, sizeof(Msg
) / sizeof(WCHAR
));
921 MessageBox(Owner
, Msg
, NULL
, MB_ICONINFORMATION
);
936 LPNMHDR pnmh
= (LPNMHDR
)lParam
;
940 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_BACK
| PSWIZB_FINISH
);
946 if(!EnableVmwareDriver(ActivateVBE
,
951 LoadString(hAppInstance
, (ActivateVBE
? IDS_FAILEDTOSELVBEDRIVER
: IDS_FAILEDTOSELVGADRIVER
), Msg
, sizeof(Msg
) / sizeof(WCHAR
));
952 MessageBox(GetParent(hwndDlg
), Msg
, NULL
, MB_ICONWARNING
);
953 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_SELECTDRIVER
);
956 ShowUninstNotice(GetParent(hwndDlg
));
970 PROPSHEETPAGE psp
[8];
974 LoadString(hAppInstance
, IDS_WIZARD_NAME
, Caption
, sizeof(Caption
) / sizeof(TCHAR
));
976 ZeroMemory(&psh
, sizeof(PROPSHEETHEADER
));
977 psh
.dwSize
= sizeof(PROPSHEETHEADER
);
978 psh
.dwFlags
= PSH_PROPSHEETPAGE
| PSH_WIZARD97
| PSH_WATERMARK
| PSH_HEADER
;
979 psh
.hwndParent
= NULL
;
980 psh
.hInstance
= hAppInstance
;
982 psh
.pszCaption
= Caption
;
984 psh
.nStartPage
= (StartVMwConfigWizard
? 5 : 0);
986 psh
.pszbmWatermark
= MAKEINTRESOURCE(IDB_WATERMARK
);
987 psh
.pszbmHeader
= MAKEINTRESOURCE(IDB_HEADER
);
989 InitPropSheetPage(&psp
[0], IDD_WELCOMEPAGE
, PSP_HIDEHEADER
, PageWelcomeProc
);
990 InitPropSheetPage(&psp
[1], IDD_INSERT_VMWARE_TOOLS
, PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
, PageInsertDiscProc
);
991 InitPropSheetPage(&psp
[2], IDD_INSTALLING_VMWARE_TOOLS
, PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
, PageInstallingProc
);
992 InitPropSheetPage(&psp
[3], IDD_CONFIG
, PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
, PageConfigProc
);
993 InitPropSheetPage(&psp
[4], IDD_INSTALLATION_FAILED
, PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
, PageInstallFailedProc
);
994 InitPropSheetPage(&psp
[5], IDD_CHOOSEACTION
, PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
, PageChooseActionProc
);
995 InitPropSheetPage(&psp
[6], IDD_SELECTDRIVER
, PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
, PageSelectDriverProc
);
996 InitPropSheetPage(&psp
[7], IDD_DOUNINSTALL
, PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
, PageDoUninstallProc
);
998 return (LONG
)(PropertySheet(&psh
) != -1);
1002 WinMain(HINSTANCE hInstance
,
1003 HINSTANCE hPrevInstance
,
1007 LPTOP_LEVEL_EXCEPTION_FILTER OldHandler
;
1011 hAppInstance
= hInstance
;
1013 /* Setup our exception "handler" ;-) */
1014 OldHandler
= SetUnhandledExceptionFilter(ExceptionHandler
);
1016 if(!DetectVMware(&Version
))
1022 /* restore the exception handler */
1023 SetUnhandledExceptionFilter(OldHandler
);
1025 lc
= DestinationPath
;
1026 lc
+= GetSystemDirectory(DestinationPath
, MAX_PATH
) - 1;
1027 if(lc
>= DestinationPath
&& *lc
!= L
'\\')
1029 wcscat(DestinationPath
, L
"\\");
1031 DestinationDriversPath
[0] = L
'\0';
1032 wcscat(DestinationDriversPath
, DestinationPath
);
1033 wcscat(DestinationDriversPath
, L
"drivers\\");
1035 SetCurrentDirectory(DestinationPath
);
1037 DriverFilesFound
= FileExists(DestinationPath
, vmx_fb
) &&
1038 FileExists(DestinationPath
, vmx_mode
) &&
1039 FileExists(DestinationDriversPath
, vmx_svga
);
1041 StartVMwConfigWizard
= DriverFilesFound
&& IsVmwSVGAEnabled();
1043 /* Show the wizard */