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.
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)
27 * Klemens Friedl (frik85@hotmail.com)
35 HINSTANCE hAppInstance
;
36 BOOL StartVMwConfigWizard
, DriverFilesFound
, ActivateVBE
= FALSE
, UninstallDriver
= FALSE
;
38 static WCHAR DestinationDriversPath
[MAX_PATH
+1];
39 static WCHAR CDDrive
= L
'\0';
40 static WCHAR PathToVideoDrivers45
[MAX_PATH
+1] = L
"X:\\program files\\VMware\\VMware Tools\\Drivers\\video\\winnt2k\\";
41 static WCHAR PathToVideoDrivers40
[MAX_PATH
+1] = L
"X:\\video\\winnt2k\\";
42 static WCHAR DestinationPath
[MAX_PATH
+1];
43 static WCHAR
*vmx_fb
= L
"vmx_fb.dll";
44 static WCHAR
*vmx_mode
= L
"vmx_mode.dll";
45 static WCHAR
*vmx_svga
= L
"vmx_svga.sys";
47 static WCHAR
*SrcPath
= PathToVideoDrivers45
;
49 static HANDLE hInstallationThread
= NULL
;
50 static HWND hInstallationNotifyWnd
= NULL
;
51 static LONG AbortInstall
= 0;
52 #define WM_INSTABORT (WM_USER + 2)
53 #define WM_INSTCOMPLETE (WM_USER + 3)
54 #define WM_INSTSTATUSUPDATE (WM_USER + 4)
56 /* Helper functions */
58 LONG WINAPI
ExceptionHandler(LPEXCEPTION_POINTERS ExceptionInfo
)
60 /* This is rude, but i don't know how to continue execution properly, that's why
61 we just exit here when we're not running inside of VMware */
62 ExitProcess(ExceptionInfo
->ExceptionRecord
->ExceptionCode
== STATUS_PRIVILEGED_INSTRUCTION
);
63 return EXCEPTION_CONTINUE_EXECUTION
;
67 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
);
137 CenterWindow(HWND hWnd
)
143 hWndParent
= GetParent(hWnd
);
144 if (hWndParent
== NULL
)
145 hWndParent
= GetDesktopWindow();
147 GetWindowRect(hWndParent
, &rcParent
);
148 GetWindowRect(hWnd
, &rcWindow
);
152 ((rcParent
.right
- rcParent
.left
) - (rcWindow
.right
- rcWindow
.left
)) / 2,
153 ((rcParent
.bottom
- rcParent
.top
) - (rcWindow
.bottom
- rcWindow
.top
)) / 2,
162 InstallFile(WCHAR
*Destination
, WCHAR
*File
)
164 static char Buffer
[1024];
165 WCHAR SourceFileName
[MAX_PATH
+ 1];
166 WCHAR DestFileName
[MAX_PATH
+ 1];
167 HANDLE SourceFileHandle
, DestFileHandle
;
168 DWORD DataRead
, DataWritten
;
170 SourceFileName
[0] = L
'\0';
171 DestFileName
[0] = L
'\0';
172 wcscat(SourceFileName
, SrcPath
);
173 wcscat(SourceFileName
, File
);
174 wcscat(DestFileName
, Destination
);
175 wcscat(DestFileName
, File
);
177 SourceFileHandle
= CreateFile(SourceFileName
, GENERIC_READ
, 0, NULL
, OPEN_EXISTING
, FILE_ATTRIBUTE_NORMAL
, NULL
);
178 if(SourceFileHandle
== INVALID_HANDLE_VALUE
)
182 DestFileHandle
= CreateFile(DestFileName
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, FILE_ATTRIBUTE_NORMAL
, NULL
);
183 if(DestFileHandle
== INVALID_HANDLE_VALUE
)
185 CloseHandle(SourceFileHandle
);
189 while(ReadFile(SourceFileHandle
, Buffer
, sizeof(Buffer
), &DataRead
, NULL
) && DataRead
> 0)
191 if(!WriteFile(DestFileHandle
, Buffer
, DataRead
, &DataWritten
, NULL
) ||
192 DataRead
!= DataWritten
)
194 CloseHandle(SourceFileHandle
);
195 CloseHandle(DestFileHandle
);
196 DeleteFile(DestFileName
);
201 CloseHandle(SourceFileHandle
);
202 CloseHandle(DestFileHandle
);
206 /* Find the drive with the inserted VMware cd-rom */
208 IsVMwareCDInDrive(WCHAR
*Drv
)
210 static WCHAR Drive
[4] = L
"X:\\";
214 for(Current
= 'C'; Current
<= 'Z'; Current
++)
218 if(GetDriveType(Drive
) == DRIVE_CDROM
)
221 PathToVideoDrivers40
[0] = Current
;
222 PathToVideoDrivers45
[0] = Current
;
223 if(SetCurrentDirectory(PathToVideoDrivers45
))
224 SrcPath
= PathToVideoDrivers45
;
225 else if(SetCurrentDirectory(PathToVideoDrivers40
))
226 SrcPath
= PathToVideoDrivers40
;
229 SetCurrentDirectory(DestinationPath
);
233 if(FileExists(SrcPath
, vmx_fb
) &&
234 FileExists(SrcPath
, vmx_mode
) &&
235 FileExists(SrcPath
, vmx_svga
))
249 LoadResolutionSettings(DWORD
*ResX
, DWORD
*ResY
, DWORD
*ColDepth
)
254 if(RegOpenKeyEx(HKEY_LOCAL_MACHINE
,
255 L
"SYSTEM\\CurrentControlSet\\Hardware Profiles\\Current\\System\\CurrentControlSet\\Services\\vmx_svga\\Device0",
256 0, KEY_QUERY_VALUE
, &hReg
) != ERROR_SUCCESS
)
260 if(RegQueryValueEx(hReg
, L
"DefaultSettings.BitsPerPel", 0, &Type
, (BYTE
*)ColDepth
, &Size
) != ERROR_SUCCESS
||
267 if(RegQueryValueEx(hReg
, L
"DefaultSettings.XResolution", 0, &Type
, (BYTE
*)ResX
, &Size
) != ERROR_SUCCESS
||
274 if(RegQueryValueEx(hReg
, L
"DefaultSettings.YResolution", 0, &Type
, (BYTE
*)ResY
, &Size
) != ERROR_SUCCESS
||
286 IsVmwSVGAEnabled(VOID
)
289 DWORD Type
, Size
, Value
;
291 if(RegOpenKeyEx(HKEY_LOCAL_MACHINE
,
292 L
"SYSTEM\\CurrentControlSet\\Services\\vmx_svga",
293 0, KEY_QUERY_VALUE
, &hReg
) != ERROR_SUCCESS
)
297 if(RegQueryValueEx(hReg
, L
"Start", 0, &Type
, (BYTE
*)&Value
, &Size
) != ERROR_SUCCESS
||
311 SaveResolutionSettings(DWORD ResX
, DWORD ResY
, DWORD ColDepth
)
315 if(RegOpenKeyEx(HKEY_LOCAL_MACHINE
,
316 L
"SYSTEM\\CurrentControlSet\\Hardware Profiles\\Current\\System\\CurrentControlSet\\Services\\vmx_svga\\Device0",
317 0, KEY_SET_VALUE
, &hReg
) != ERROR_SUCCESS
)
321 if(RegSetValueEx(hReg
, L
"DefaultSettings.BitsPerPel", 0, REG_DWORD
, (BYTE
*)&ColDepth
, sizeof(DWORD
)) != ERROR_SUCCESS
)
327 if(RegSetValueEx(hReg
, L
"DefaultSettings.XResolution", 0, REG_DWORD
, (BYTE
*)&ResX
, sizeof(DWORD
)) != ERROR_SUCCESS
)
333 if(RegSetValueEx(hReg
, L
"DefaultSettings.YResolution", 0, REG_DWORD
, (BYTE
*)&ResY
, sizeof(DWORD
)) != ERROR_SUCCESS
)
344 EnableDriver(WCHAR
*Key
, BOOL Enable
)
349 Value
= (Enable
? 1 : 4);
351 if(RegOpenKeyEx(HKEY_LOCAL_MACHINE
, Key
, 0, KEY_SET_VALUE
, &hReg
) != ERROR_SUCCESS
)
355 if(RegSetValueEx(hReg
, L
"Start", 0, REG_DWORD
, (BYTE
*)&Value
, sizeof(DWORD
)) != ERROR_SUCCESS
)
365 /* Activate the vmware driver and deactivate the others */
367 EnableVmwareDriver(BOOL VBE
, BOOL VGA
, BOOL VMX
)
369 if(!EnableDriver(L
"SYSTEM\\CurrentControlSet\\Services\\VBE", VBE
))
373 if(!EnableDriver(L
"SYSTEM\\CurrentControlSet\\Services\\vga", VGA
))
377 if(!EnableDriver(L
"SYSTEM\\CurrentControlSet\\Services\\vmx_svga", VMX
))
388 InitPropSheetPage(PROPSHEETPAGE
*psp
, WORD idDlg
, DWORD Flags
, DLGPROC DlgProc
)
390 ZeroMemory(psp
, sizeof(PROPSHEETPAGE
));
391 psp
->dwSize
= sizeof(PROPSHEETPAGE
);
392 psp
->dwFlags
= PSP_DEFAULT
| Flags
;
393 psp
->hInstance
= hAppInstance
;
394 psp
->pszTemplate
= MAKEINTRESOURCE(idDlg
);
395 psp
->pfnDlgProc
= DlgProc
;
398 /* Property page dialog callback */
413 /* Center the wizard window */
414 hwndControl
= GetParent(hwndDlg
);
415 CenterWindow (hwndControl
);
417 LPNMHDR pnmh
= (LPNMHDR
)lParam
;
422 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_NEXT
);
429 if(!EnableVmwareDriver(FALSE
, FALSE
, TRUE
))
433 LoadString(hAppInstance
, IDS_FAILEDTOACTIVATEDRIVER
, Msg
, sizeof(Msg
) / sizeof(WCHAR
));
434 MessageBox(GetParent(hwndDlg
), Msg
, NULL
, MB_ICONWARNING
);
435 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_WELCOMEPAGE
);
438 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_CONFIG
);
450 /* Property page dialog callback */
463 LPNMHDR pnmh
= (LPNMHDR
)lParam
;
467 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_BACK
| PSWIZB_NEXT
);
470 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_INSTALLING_VMWARE_TOOLS
);
480 InstTerminateInstaller(BOOL Wait
)
482 if(hInstallationThread
!= NULL
)
486 InterlockedExchange((LONG
*)&AbortInstall
, 2);
487 WaitForSingleObject(hInstallationThread
, INFINITE
);
491 InterlockedExchange((LONG
*)&AbortInstall
, 1);
497 InstInstallationThread(LPVOID lpParameter
)
501 int DrivesTested
= 0;
503 if(AbortInstall
!= 0) goto done
;
504 PostMessage(hInstallationNotifyWnd
, WM_INSTSTATUSUPDATE
, IDS_SEARCHINGFORCDROM
, 0);
506 while(AbortInstall
== 0)
509 DriveAvailable
= IsVMwareCDInDrive(&CDDrive
);
512 if(DrivesTested
++ > 20)
514 PostMessage(hInstallationNotifyWnd
, WM_INSTABORT
, IDS_FAILEDTOLOCATEDRIVERS
, 0);
519 if(AbortInstall
!= 0) goto done
;
520 PostMessage(hInstallationNotifyWnd
, WM_INSTSTATUSUPDATE
, IDS_COPYINGFILES
, 0);
522 if(AbortInstall
!= 0) goto done
;
523 if(!InstallFile(DestinationPath
, vmx_fb
))
525 PostMessage(hInstallationNotifyWnd
, WM_INSTABORT
, IDS_FAILEDTOCOPYFILES
, 0);
531 if(AbortInstall
!= 0) goto done
;
532 if(!InstallFile(DestinationPath
, vmx_mode
))
534 PostMessage(hInstallationNotifyWnd
, WM_INSTABORT
, IDS_FAILEDTOCOPYFILES
, 0);
540 if(AbortInstall
!= 0) goto done
;
541 if(!InstallFile(DestinationDriversPath
, vmx_svga
))
543 PostMessage(hInstallationNotifyWnd
, WM_INSTABORT
, IDS_FAILEDTOCOPYFILES
, 0);
549 if(AbortInstall
!= 0) goto done
;
550 PostMessage(hInstallationNotifyWnd
, WM_INSTSTATUSUPDATE
, IDS_ENABLINGDRIVER
, 0);
551 if(!EnableVmwareDriver(FALSE
, FALSE
, TRUE
))
553 PostMessage(hInstallationNotifyWnd
, WM_INSTABORT
, IDS_FAILEDTOACTIVATEDRIVER
, 0);
563 SendMessage(hInstallationNotifyWnd
, WM_INSTCOMPLETE
, 0, 0);
566 SendMessage(hInstallationNotifyWnd
, WM_INSTABORT
, 0, 0);
571 hThread
= (HANDLE
)InterlockedExchange((LONG
*)&hInstallationThread
, 0);
574 CloseHandle(hThread
);
580 InstStartInstallationThread(HWND hwndNotify
)
582 if(hInstallationThread
== NULL
)
585 hInstallationNotifyWnd
= hwndNotify
;
587 hInstallationThread
= CreateThread(NULL
,
589 InstInstallationThread
,
593 if(hInstallationThread
== NULL
)
598 ResumeThread(hInstallationThread
);
605 /* Property page dialog callback */
618 LPNMHDR pnmh
= (LPNMHDR
)lParam
;
622 SetDlgItemText(hwndDlg
, IDC_INSTALLINGSTATUS
, NULL
);
623 SendDlgItemMessage(hwndDlg
, IDC_INSTALLINGPROGRESS
, PBM_SETMARQUEE
, TRUE
, 50);
624 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_BACK
);
625 InstStartInstallationThread(hwndDlg
);
628 InstTerminateInstaller(TRUE
);
631 if(hInstallationThread
!= NULL
)
633 PropSheet_SetWizButtons(GetParent(hwndDlg
), 0);
634 InstTerminateInstaller(FALSE
);
635 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, -1);
640 SendDlgItemMessage(hwndDlg
, IDC_INSTALLINGPROGRESS
, PBM_SETMARQUEE
, FALSE
, 0);
641 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_INSERT_VMWARE_TOOLS
);
648 /* go back in case we aborted the installation thread */
649 SendDlgItemMessage(hwndDlg
, IDC_INSTALLINGPROGRESS
, PBM_SETMARQUEE
, FALSE
, 0);
650 PropSheet_SetCurSelByID(GetParent(hwndDlg
), IDD_INSERT_VMWARE_TOOLS
);
654 LoadString(hAppInstance
, wParam
, Msg
, sizeof(Msg
) / sizeof(WCHAR
));
655 MessageBox(GetParent(hwndDlg
), Msg
, NULL
, MB_ICONWARNING
);
658 case WM_INSTCOMPLETE
:
659 SendDlgItemMessage(hwndDlg
, IDC_INSTALLINGPROGRESS
, PBM_SETMARQUEE
, FALSE
, 0);
660 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_BACK
| PSWIZB_NEXT
);
661 PropSheet_SetCurSelByID(GetParent(hwndDlg
), IDD_CONFIG
);
663 case WM_INSTSTATUSUPDATE
:
666 LoadString(hAppInstance
, wParam
, Msg
, sizeof(Msg
) / sizeof(WCHAR
));
667 SetDlgItemText(hwndDlg
, IDC_INSTALLINGSTATUS
, Msg
);
674 /* Property page dialog callback */
676 PageInstallFailedProc(
687 LPNMHDR pnmh
= (LPNMHDR
)lParam
;
691 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_FINISH
);
701 FillComboBox(HWND Dlg
, int idComboBox
, int From
, int To
)
706 for(i
= From
; i
<= To
; i
++)
708 if(LoadString(hAppInstance
, i
, Text
, 255) > 0)
710 SendDlgItemMessage(Dlg
, idComboBox
, CB_ADDSTRING
, 0, (LPARAM
)Text
);
722 /* Property page dialog callback */
735 DWORD ResX
= 0, ResY
= 0, ColDepth
= 0;
738 FillComboBox(hwndDlg
, IDC_COLORQUALITY
, 10001, 10003);
739 if(LoadResolutionSettings(&ResX
, &ResY
, &ColDepth
))
741 SendDlgItemMessage(hwndDlg
, ResX
+ ResY
, BM_SETCHECK
, BST_CHECKED
, 0);
757 SendDlgItemMessage(hwndDlg
, IDC_COLORQUALITY
, CB_SETCURSEL
, cbSel
, 0);
765 /* Center the wizard window */
766 hwndControl
= GetParent(hwndDlg
);
767 CenterWindow (hwndControl
);
769 LPNMHDR pnmh
= (LPNMHDR
)lParam
;
774 PropSheet_SetWizButtons(GetParent(hwndDlg
), ((StartVMwConfigWizard
|| DriverFilesFound
) ? PSWIZB_FINISH
| PSWIZB_BACK
: PSWIZB_FINISH
));
779 if(StartVMwConfigWizard
)
781 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_CHOOSEACTION
);
786 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_WELCOMEPAGE
);
793 DWORD rx
= 800, ry
= 600, cd
= 32;
795 static MAPCTLRES Resolutions
[11] = {
808 for(i
= 0; i
< 11; i
++)
810 if(SendDlgItemMessage(hwndDlg
, Resolutions
[i
].ControlID
, BM_GETCHECK
, 0, 0) == BST_CHECKED
)
812 rx
= Resolutions
[i
].ResX
;
813 ry
= Resolutions
[i
].ResY
;
818 switch(SendDlgItemMessage(hwndDlg
, IDC_COLORQUALITY
, CB_GETCURSEL
, 0, 0))
831 SaveResolutionSettings(rx
, ry
, cd
);
841 /* Property page dialog callback */
843 PageChooseActionProc(
853 SendDlgItemMessage(hwndDlg
, IDC_CONFIGSETTINGS
, BM_SETCHECK
, BST_CHECKED
, 0);
857 LPNMHDR pnmh
= (LPNMHDR
)lParam
;
861 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_NEXT
);
865 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_CHOOSEACTION
);
870 static ULONG SelPage
[4] = {IDD_CONFIG
, IDD_SELECTDRIVER
, IDD_SELECTDRIVER
, IDD_CHOOSEACTION
};
873 for(i
= IDC_CONFIGSETTINGS
; i
<= IDC_UNINSTALL
; i
++)
875 if(SendDlgItemMessage(hwndDlg
, i
, BM_GETCHECK
, 0, 0) == BST_CHECKED
)
881 UninstallDriver
= (i
== IDC_UNINSTALL
);
883 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, SelPage
[i
- IDC_CONFIGSETTINGS
]);
893 /* Property page dialog callback */
895 PageSelectDriverProc(
905 SendDlgItemMessage(hwndDlg
, IDC_VBE
, BM_SETCHECK
, BST_CHECKED
, 0);
909 LPNMHDR pnmh
= (LPNMHDR
)lParam
;
913 PropSheet_SetWizButtons(GetParent(hwndDlg
), (UninstallDriver
? PSWIZB_NEXT
| PSWIZB_BACK
: PSWIZB_BACK
| PSWIZB_FINISH
));
917 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_CHOOSEACTION
);
922 ActivateVBE
= (SendDlgItemMessage(hwndDlg
, IDC_VBE
, BM_GETCHECK
, 0, 0) == BST_CHECKED
);
936 ActivateVBE
= (SendDlgItemMessage(hwndDlg
, IDC_VBE
, BM_GETCHECK
, 0, 0) == BST_CHECKED
);
937 if(!EnableVmwareDriver(ActivateVBE
,
942 LoadString(hAppInstance
, (ActivateVBE
? IDS_FAILEDTOSELVBEDRIVER
: IDS_FAILEDTOSELVGADRIVER
), Msg
, sizeof(Msg
) / sizeof(WCHAR
));
943 MessageBox(GetParent(hwndDlg
), Msg
, NULL
, MB_ICONWARNING
);
944 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_SELECTDRIVER
);
957 ShowUninstNotice(HWND Owner
)
960 LoadString(hAppInstance
, IDS_UNINSTNOTICE
, Msg
, sizeof(Msg
) / sizeof(WCHAR
));
961 MessageBox(Owner
, Msg
, NULL
, MB_ICONINFORMATION
);
976 LPNMHDR pnmh
= (LPNMHDR
)lParam
;
980 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_BACK
| PSWIZB_FINISH
);
986 if(!EnableVmwareDriver(ActivateVBE
,
991 LoadString(hAppInstance
, (ActivateVBE
? IDS_FAILEDTOSELVBEDRIVER
: IDS_FAILEDTOSELVGADRIVER
), Msg
, sizeof(Msg
) / sizeof(WCHAR
));
992 MessageBox(GetParent(hwndDlg
), Msg
, NULL
, MB_ICONWARNING
);
993 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_SELECTDRIVER
);
996 ShowUninstNotice(GetParent(hwndDlg
));
1010 PROPSHEETHEADER psh
;
1011 HPROPSHEETPAGE ahpsp
[8];
1013 WCHAR Caption
[1024];
1015 LoadString(hAppInstance
, IDS_WIZARD_NAME
, Caption
, sizeof(Caption
) / sizeof(TCHAR
));
1017 /* Create the Welcome page */
1018 ZeroMemory (&psp
, sizeof(PROPSHEETPAGE
));
1019 psp
.dwSize
= sizeof(PROPSHEETPAGE
);
1020 psp
.dwFlags
= PSP_DEFAULT
| PSP_HIDEHEADER
;
1021 psp
.hInstance
= hAppInstance
;
1022 psp
.pfnDlgProc
= PageWelcomeProc
;
1023 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_WELCOMEPAGE
);
1024 ahpsp
[0] = CreatePropertySheetPage(&psp
);
1026 /* Create the INSERT_VMWARE_TOOLS page */
1027 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1028 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDD_INSERT_VMWARE_TOOLSTITLE
);
1029 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDD_INSERT_VMWARE_TOOLSSUBTITLE
);
1030 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_INSERT_VMWARE_TOOLS
);
1031 psp
.pfnDlgProc
= PageInsertDiscProc
;
1032 ahpsp
[1] = CreatePropertySheetPage(&psp
);
1034 /* Create the INSTALLING_VMWARE_TOOLS page */
1035 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1036 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDD_INSTALLING_VMWARE_TOOLSTITLE
);
1037 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDD_INSTALLING_VMWARE_TOOLSSUBTITLE
);
1038 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_INSTALLING_VMWARE_TOOLS
);
1039 psp
.pfnDlgProc
= PageInstallingProc
;
1040 ahpsp
[2] = CreatePropertySheetPage(&psp
);
1042 /* Create the CONFIG page */
1043 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1044 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDD_CONFIGTITLE
);
1045 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDD_CONFIGSUBTITLE
);
1046 psp
.pfnDlgProc
= PageConfigProc
;
1047 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_CONFIG
);
1048 ahpsp
[3] = CreatePropertySheetPage(&psp
);
1050 /* Create the INSTALLATION_FAILED page */
1051 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1052 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDD_INSTALLATION_FAILEDTITLE
);
1053 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDD_INSTALLATION_FAILEDSUBTITLE
);
1054 psp
.pfnDlgProc
= PageInstallFailedProc
;
1055 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_INSTALLATION_FAILED
);
1056 ahpsp
[4] = CreatePropertySheetPage(&psp
);
1058 /* Create the CHOOSEACTION page */
1059 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1060 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDD_CHOOSEACTIONTITLE
);
1061 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDD_CHOOSEACTIONSUBTITLE
);
1062 psp
.pfnDlgProc
= PageChooseActionProc
;
1063 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_CHOOSEACTION
);
1064 ahpsp
[5] = CreatePropertySheetPage(&psp
);
1066 /* Create the SELECTDRIVER page */
1067 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1068 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDD_SELECTDRIVERTITLE
);
1069 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDD_SELECTDRIVERSUBTITLE
);
1070 psp
.pfnDlgProc
= PageSelectDriverProc
;
1071 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_SELECTDRIVER
);
1072 ahpsp
[6] = CreatePropertySheetPage(&psp
);
1074 /* Create the DOUNINSTALL page */
1075 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1076 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDD_DOUNINSTALLTITLE
);
1077 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDD_DOUNINSTALLSUBTITLE
);
1078 psp
.pfnDlgProc
= PageDoUninstallProc
;
1079 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_DOUNINSTALL
);
1080 ahpsp
[7] = CreatePropertySheetPage(&psp
);
1082 /* Create the property sheet */
1083 psh
.dwSize
= sizeof(PROPSHEETHEADER
);
1084 psh
.dwFlags
= PSH_WIZARD97
| PSH_WATERMARK
| PSH_HEADER
;
1085 psh
.hInstance
= hAppInstance
;
1086 psh
.hwndParent
= NULL
;
1088 psh
.nStartPage
= (StartVMwConfigWizard
? 5 : 0);
1090 psh
.pszbmWatermark
= MAKEINTRESOURCE(IDB_WATERMARK
);
1091 psh
.pszbmHeader
= MAKEINTRESOURCE(IDB_HEADER
);
1093 /* Display the wizard */
1094 return (LONG
)(PropertySheet(&psh
) != -1);
1098 WinMain(HINSTANCE hInstance
,
1099 HINSTANCE hPrevInstance
,
1104 LPTOP_LEVEL_EXCEPTION_FILTER OldHandler
;
1108 hAppInstance
= hInstance
;
1110 /* Setup our exception "handler" ;-) */
1111 OldHandler
= SetUnhandledExceptionFilter(ExceptionHandler
);
1113 if(!DetectVMware(&Version
))
1119 /* restore the exception handler */
1120 SetUnhandledExceptionFilter(OldHandler
);
1122 lc
= DestinationPath
;
1123 lc
+= GetSystemDirectory(DestinationPath
, MAX_PATH
) - 1;
1124 if(lc
>= DestinationPath
&& *lc
!= L
'\\')
1126 wcscat(DestinationPath
, L
"\\");
1128 DestinationDriversPath
[0] = L
'\0';
1129 wcscat(DestinationDriversPath
, DestinationPath
);
1130 wcscat(DestinationDriversPath
, L
"drivers\\");
1132 SetCurrentDirectory(DestinationPath
);
1134 DriverFilesFound
= FileExists(DestinationPath
, vmx_fb
) &&
1135 FileExists(DestinationPath
, vmx_mode
) &&
1136 FileExists(DestinationDriversPath
, vmx_svga
);
1138 StartVMwConfigWizard
= DriverFilesFound
&& IsVmwSVGAEnabled();
1140 /* Show the wizard */