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 extern VOID CALLBACK
InstallHinfSectionW(HWND hwnd
, HINSTANCE ModuleHandle
,
36 PCWSTR CmdLineBuffer
, INT nCmdShow
);
39 HINSTANCE hAppInstance
;
40 BOOL StartVMwConfigWizard
, DriverFilesFound
, ActivateVBE
= FALSE
, UninstallDriver
= FALSE
;
42 static WCHAR DestinationDriversPath
[MAX_PATH
+1];
43 static WCHAR CDDrive
= L
'\0';
44 static WCHAR PathToVideoDrivers45
[MAX_PATH
+1] = L
"X:\\program files\\VMware\\VMware Tools\\Drivers\\video\\winnt2k\\";
45 static WCHAR PathToVideoDrivers40
[MAX_PATH
+1] = L
"X:\\video\\winnt2k\\";
46 static WCHAR DestinationPath
[MAX_PATH
+1];
47 static WCHAR
*vmx_fb
= L
"vmx_fb.dll";
48 static WCHAR
*vmx_mode
= L
"vmx_mode.dll";
49 static WCHAR
*vmx_svga
= L
"vmx_svga.sys";
51 static WCHAR
*SrcPath
= PathToVideoDrivers45
;
53 static HANDLE hInstallationThread
= NULL
;
54 static HWND hInstallationNotifyWnd
= NULL
;
55 static LONG AbortInstall
= 0;
56 #define WM_INSTABORT (WM_USER + 2)
57 #define WM_INSTCOMPLETE (WM_USER + 3)
58 #define WM_INSTSTATUSUPDATE (WM_USER + 4)
60 /* Helper functions */
62 LONG WINAPI
ExceptionHandler(LPEXCEPTION_POINTERS ExceptionInfo
)
64 /* This is rude, but i don't know how to continue execution properly, that's why
65 we just exit here when we're not running inside of VMware */
66 ExitProcess(ExceptionInfo
->ExceptionRecord
->ExceptionCode
== EXCEPTION_PRIV_INSTRUCTION
);
67 return EXCEPTION_CONTINUE_EXECUTION
;
71 DetectVMware(int *Version
)
78 /* Try using a VMware I/O port. If not running in VMware this'll throw an
80 __asm__
__volatile__("inl %%dx, %%eax"
81 : "=a" (ver
), "=b" (magic
)
82 : "0" (0x564d5868), "d" (0x5658), "c" (0xa));
84 if(magic
== 0x564d5868)
97 if(PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
))
99 TranslateMessage(&msg
);
100 DispatchMessage(&msg
);
107 ProcessMessages(void)
109 while(ProcessMessage());
112 /* try to open the file */
114 FileExists(WCHAR
*Path
, WCHAR
*File
)
116 WCHAR FileName
[MAX_PATH
+ 1];
120 wcscat(FileName
, Path
);
121 wcscat(FileName
, File
);
123 FileHandle
= CreateFile(FileName
, GENERIC_READ
, 0, NULL
, OPEN_EXISTING
, FILE_ATTRIBUTE_NORMAL
, NULL
);
125 if(FileHandle
== INVALID_HANDLE_VALUE
)
130 if(GetFileSize(FileHandle
, NULL
) <= 0)
132 CloseHandle(FileHandle
);
136 CloseHandle(FileHandle
);
141 CenterWindow(HWND hWnd
)
147 hWndParent
= GetParent(hWnd
);
148 if (hWndParent
== NULL
)
149 hWndParent
= GetDesktopWindow();
151 GetWindowRect(hWndParent
, &rcParent
);
152 GetWindowRect(hWnd
, &rcWindow
);
156 ((rcParent
.right
- rcParent
.left
) - (rcWindow
.right
- rcWindow
.left
)) / 2,
157 ((rcParent
.bottom
- rcParent
.top
) - (rcWindow
.bottom
- rcWindow
.top
)) / 2,
166 InstallFile(WCHAR
*Destination
, WCHAR
*File
)
168 static char Buffer
[1024];
169 WCHAR SourceFileName
[MAX_PATH
+ 1];
170 WCHAR DestFileName
[MAX_PATH
+ 1];
171 HANDLE SourceFileHandle
, DestFileHandle
;
172 DWORD DataRead
, DataWritten
;
174 SourceFileName
[0] = L
'\0';
175 DestFileName
[0] = L
'\0';
176 wcscat(SourceFileName
, SrcPath
);
177 wcscat(SourceFileName
, File
);
178 wcscat(DestFileName
, Destination
);
179 wcscat(DestFileName
, File
);
181 SourceFileHandle
= CreateFile(SourceFileName
, GENERIC_READ
, 0, NULL
, OPEN_EXISTING
, FILE_ATTRIBUTE_NORMAL
, NULL
);
182 if(SourceFileHandle
== INVALID_HANDLE_VALUE
)
186 DestFileHandle
= CreateFile(DestFileName
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, FILE_ATTRIBUTE_NORMAL
, NULL
);
187 if(DestFileHandle
== INVALID_HANDLE_VALUE
)
189 CloseHandle(SourceFileHandle
);
193 while(ReadFile(SourceFileHandle
, Buffer
, sizeof(Buffer
), &DataRead
, NULL
) && DataRead
> 0)
195 if(!WriteFile(DestFileHandle
, Buffer
, DataRead
, &DataWritten
, NULL
) ||
196 DataRead
!= DataWritten
)
198 CloseHandle(SourceFileHandle
);
199 CloseHandle(DestFileHandle
);
200 DeleteFile(DestFileName
);
205 CloseHandle(SourceFileHandle
);
206 CloseHandle(DestFileHandle
);
210 /* Find the drive with the inserted VMware cd-rom */
212 IsVMwareCDInDrive(WCHAR
*Drv
)
214 static WCHAR Drive
[4] = L
"X:\\";
218 for(Current
= 'C'; Current
<= 'Z'; Current
++)
222 if(GetDriveType(Drive
) == DRIVE_CDROM
)
225 PathToVideoDrivers40
[0] = Current
;
226 PathToVideoDrivers45
[0] = Current
;
227 if(SetCurrentDirectory(PathToVideoDrivers45
))
228 SrcPath
= PathToVideoDrivers45
;
229 else if(SetCurrentDirectory(PathToVideoDrivers40
))
230 SrcPath
= PathToVideoDrivers40
;
233 SetCurrentDirectory(DestinationPath
);
237 if(FileExists(SrcPath
, vmx_fb
) &&
238 FileExists(SrcPath
, vmx_mode
) &&
239 FileExists(SrcPath
, vmx_svga
))
253 LoadResolutionSettings(DWORD
*ResX
, DWORD
*ResY
, DWORD
*ColDepth
)
258 if(RegOpenKeyEx(HKEY_LOCAL_MACHINE
,
259 L
"SYSTEM\\CurrentControlSet\\Hardware Profiles\\Current\\System\\CurrentControlSet\\Services\\vmx_svga\\Device0",
260 0, KEY_QUERY_VALUE
, &hReg
) != ERROR_SUCCESS
)
264 if(RegQueryValueEx(hReg
, L
"DefaultSettings.BitsPerPel", 0, &Type
, (BYTE
*)ColDepth
, &Size
) != ERROR_SUCCESS
||
271 if(RegQueryValueEx(hReg
, L
"DefaultSettings.XResolution", 0, &Type
, (BYTE
*)ResX
, &Size
) != ERROR_SUCCESS
||
278 if(RegQueryValueEx(hReg
, L
"DefaultSettings.YResolution", 0, &Type
, (BYTE
*)ResY
, &Size
) != ERROR_SUCCESS
||
290 IsVmwSVGAEnabled(VOID
)
293 DWORD Type
, Size
, Value
;
295 if(RegOpenKeyEx(HKEY_LOCAL_MACHINE
,
296 L
"SYSTEM\\CurrentControlSet\\Services\\vmx_svga",
297 0, KEY_QUERY_VALUE
, &hReg
) != ERROR_SUCCESS
)
301 if(RegQueryValueEx(hReg
, L
"Start", 0, &Type
, (BYTE
*)&Value
, &Size
) != ERROR_SUCCESS
||
315 SaveResolutionSettings(DWORD ResX
, DWORD ResY
, DWORD ColDepth
)
319 if(RegOpenKeyEx(HKEY_LOCAL_MACHINE
,
320 L
"SYSTEM\\CurrentControlSet\\Hardware Profiles\\Current\\System\\CurrentControlSet\\Services\\vmx_svga\\Device0",
321 0, KEY_SET_VALUE
, &hReg
) != ERROR_SUCCESS
)
325 if(RegSetValueEx(hReg
, L
"DefaultSettings.BitsPerPel", 0, REG_DWORD
, (BYTE
*)&ColDepth
, sizeof(DWORD
)) != ERROR_SUCCESS
)
331 if(RegSetValueEx(hReg
, L
"DefaultSettings.XResolution", 0, REG_DWORD
, (BYTE
*)&ResX
, sizeof(DWORD
)) != ERROR_SUCCESS
)
337 if(RegSetValueEx(hReg
, L
"DefaultSettings.YResolution", 0, REG_DWORD
, (BYTE
*)&ResY
, sizeof(DWORD
)) != ERROR_SUCCESS
)
348 EnableDriver(WCHAR
*Key
, BOOL Enable
)
353 Value
= (Enable
? 1 : 4);
355 if(RegOpenKeyEx(HKEY_LOCAL_MACHINE
, Key
, 0, KEY_SET_VALUE
, &hReg
) != ERROR_SUCCESS
)
359 if(RegSetValueEx(hReg
, L
"Start", 0, REG_DWORD
, (BYTE
*)&Value
, sizeof(DWORD
)) != ERROR_SUCCESS
)
369 /* Activate the vmware driver and deactivate the others */
371 EnableVmwareDriver(BOOL VBE
, BOOL VGA
, BOOL VMX
)
373 if(!EnableDriver(L
"SYSTEM\\CurrentControlSet\\Services\\VBE", VBE
))
377 if(!EnableDriver(L
"SYSTEM\\CurrentControlSet\\Services\\vga", VGA
))
381 if(!EnableDriver(L
"SYSTEM\\CurrentControlSet\\Services\\vmx_svga", VMX
))
389 /* Make sure the required registry entries are present */
391 AddVmwareRegistryEntries()
393 HRSRC VmwareInfResource
;
394 HGLOBAL VmwareInfMem
;
395 PVOID VmwareInfLocked
;
397 WCHAR TempPath
[MAX_PATH
];
399 WCHAR TempFileName
[MAX_PATH
];
402 WCHAR CmdLine
[19 + MAX_PATH
];
404 VmwareInfResource
= FindResourceW(hAppInstance
,
405 MAKEINTRESOURCE(IDR_VMWARE_INF
),
407 if (NULL
== VmwareInfResource
)
411 Size
= SizeofResource(hAppInstance
, VmwareInfResource
);
416 VmwareInfMem
= LoadResource(hAppInstance
, VmwareInfResource
);
417 if (NULL
== VmwareInfMem
)
421 VmwareInfLocked
= LockResource(VmwareInfMem
);
422 if (NULL
== VmwareInfLocked
)
427 BufferSize
= GetTempPathW(sizeof(TempPath
) / sizeof(TempPath
[0]), TempPath
);
428 if (0 == BufferSize
|| sizeof(TempPath
) / sizeof(TempPath
[0]) < BufferSize
)
432 if (0 == GetTempFileNameW(TempPath
, L
"vmx", 0, TempFileName
))
437 TempFile
= CreateFileW(TempFileName
, GENERIC_WRITE
, 0, NULL
, OPEN_EXISTING
,
438 FILE_ATTRIBUTE_NORMAL
, NULL
);
439 if (INVALID_HANDLE_VALUE
== TempFile
)
441 DeleteFile(TempFileName
);
444 if (! WriteFile(TempFile
, VmwareInfLocked
, Size
, &Written
, NULL
) ||
447 CloseHandle(TempFile
);
448 DeleteFile(TempFileName
);
451 CloseHandle(TempFile
);
453 wcscpy(CmdLine
, L
"DefaultInstall 128 ");
454 wcscat(CmdLine
, TempFileName
);
455 InstallHinfSectionW(NULL
, NULL
, CmdLine
, 0);
457 DeleteFile(TempFileName
);
465 InitPropSheetPage(PROPSHEETPAGE
*psp
, WORD idDlg
, DWORD Flags
, DLGPROC DlgProc
)
467 ZeroMemory(psp
, sizeof(PROPSHEETPAGE
));
468 psp
->dwSize
= sizeof(PROPSHEETPAGE
);
469 psp
->dwFlags
= PSP_DEFAULT
| Flags
;
470 psp
->hInstance
= hAppInstance
;
471 psp
->pszTemplate
= MAKEINTRESOURCE(idDlg
);
472 psp
->pfnDlgProc
= DlgProc
;
475 /* Property page dialog callback */
490 /* Center the wizard window */
491 hwndControl
= GetParent(hwndDlg
);
492 CenterWindow (hwndControl
);
494 LPNMHDR pnmh
= (LPNMHDR
)lParam
;
499 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_NEXT
);
506 if(!AddVmwareRegistryEntries())
509 LoadString(hAppInstance
, IDS_FAILEDTOADDREGENTRIES
, Msg
, sizeof(Msg
) / sizeof(WCHAR
));
510 MessageBox(GetParent(hwndDlg
), Msg
, NULL
, MB_ICONWARNING
);
511 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_WELCOMEPAGE
);
514 if(!EnableVmwareDriver(TRUE
, TRUE
, TRUE
))
518 LoadString(hAppInstance
, IDS_FAILEDTOACTIVATEDRIVER
, Msg
, sizeof(Msg
) / sizeof(WCHAR
));
519 MessageBox(GetParent(hwndDlg
), Msg
, NULL
, MB_ICONWARNING
);
520 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_WELCOMEPAGE
);
523 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_CONFIG
);
535 /* Property page dialog callback */
548 LPNMHDR pnmh
= (LPNMHDR
)lParam
;
552 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_BACK
| PSWIZB_NEXT
);
555 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_INSTALLING_VMWARE_TOOLS
);
565 InstTerminateInstaller(BOOL Wait
)
567 if(hInstallationThread
!= NULL
)
571 InterlockedExchange((LONG
*)&AbortInstall
, 2);
572 WaitForSingleObject(hInstallationThread
, INFINITE
);
576 InterlockedExchange((LONG
*)&AbortInstall
, 1);
582 InstInstallationThread(LPVOID lpParameter
)
586 int DrivesTested
= 0;
588 if(AbortInstall
!= 0) goto done
;
589 PostMessage(hInstallationNotifyWnd
, WM_INSTSTATUSUPDATE
, IDS_SEARCHINGFORCDROM
, 0);
591 while(AbortInstall
== 0)
594 DriveAvailable
= IsVMwareCDInDrive(&CDDrive
);
597 if(DrivesTested
++ > 20)
599 PostMessage(hInstallationNotifyWnd
, WM_INSTABORT
, IDS_FAILEDTOLOCATEDRIVERS
, 0);
604 if(AbortInstall
!= 0) goto done
;
605 PostMessage(hInstallationNotifyWnd
, WM_INSTSTATUSUPDATE
, IDS_COPYINGFILES
, 0);
607 if(AbortInstall
!= 0) goto done
;
608 if(!InstallFile(DestinationPath
, vmx_fb
))
610 PostMessage(hInstallationNotifyWnd
, WM_INSTABORT
, IDS_FAILEDTOCOPYFILES
, 0);
616 if(AbortInstall
!= 0) goto done
;
617 if(!InstallFile(DestinationPath
, vmx_mode
))
619 PostMessage(hInstallationNotifyWnd
, WM_INSTABORT
, IDS_FAILEDTOCOPYFILES
, 0);
625 if(AbortInstall
!= 0) goto done
;
626 if(!InstallFile(DestinationDriversPath
, vmx_svga
))
628 PostMessage(hInstallationNotifyWnd
, WM_INSTABORT
, IDS_FAILEDTOCOPYFILES
, 0);
634 if(AbortInstall
!= 0) goto done
;
635 PostMessage(hInstallationNotifyWnd
, WM_INSTSTATUSUPDATE
, IDS_ENABLINGDRIVER
, 0);
636 if(!EnableVmwareDriver(TRUE
, TRUE
, TRUE
))
638 PostMessage(hInstallationNotifyWnd
, WM_INSTABORT
, IDS_FAILEDTOACTIVATEDRIVER
, 0);
648 SendMessage(hInstallationNotifyWnd
, WM_INSTCOMPLETE
, 0, 0);
651 SendMessage(hInstallationNotifyWnd
, WM_INSTABORT
, 0, 0);
656 hThread
= (HANDLE
)InterlockedExchange((LONG
*)&hInstallationThread
, 0);
659 CloseHandle(hThread
);
665 InstStartInstallationThread(HWND hwndNotify
)
667 if(hInstallationThread
== NULL
)
670 hInstallationNotifyWnd
= hwndNotify
;
672 hInstallationThread
= CreateThread(NULL
,
674 InstInstallationThread
,
678 if(hInstallationThread
== NULL
)
683 ResumeThread(hInstallationThread
);
690 /* Property page dialog callback */
703 LPNMHDR pnmh
= (LPNMHDR
)lParam
;
707 SetDlgItemText(hwndDlg
, IDC_INSTALLINGSTATUS
, NULL
);
708 SendDlgItemMessage(hwndDlg
, IDC_INSTALLINGPROGRESS
, PBM_SETMARQUEE
, TRUE
, 50);
709 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_BACK
);
710 InstStartInstallationThread(hwndDlg
);
713 InstTerminateInstaller(TRUE
);
716 if(hInstallationThread
!= NULL
)
718 PropSheet_SetWizButtons(GetParent(hwndDlg
), 0);
719 InstTerminateInstaller(FALSE
);
720 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, -1);
725 SendDlgItemMessage(hwndDlg
, IDC_INSTALLINGPROGRESS
, PBM_SETMARQUEE
, FALSE
, 0);
726 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_INSERT_VMWARE_TOOLS
);
733 /* go back in case we aborted the installation thread */
734 SendDlgItemMessage(hwndDlg
, IDC_INSTALLINGPROGRESS
, PBM_SETMARQUEE
, FALSE
, 0);
735 PropSheet_SetCurSelByID(GetParent(hwndDlg
), IDD_INSERT_VMWARE_TOOLS
);
739 LoadString(hAppInstance
, wParam
, Msg
, sizeof(Msg
) / sizeof(WCHAR
));
740 MessageBox(GetParent(hwndDlg
), Msg
, NULL
, MB_ICONWARNING
);
743 case WM_INSTCOMPLETE
:
744 SendDlgItemMessage(hwndDlg
, IDC_INSTALLINGPROGRESS
, PBM_SETMARQUEE
, FALSE
, 0);
745 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_BACK
| PSWIZB_NEXT
);
746 PropSheet_SetCurSelByID(GetParent(hwndDlg
), IDD_CONFIG
);
748 case WM_INSTSTATUSUPDATE
:
751 LoadString(hAppInstance
, wParam
, Msg
, sizeof(Msg
) / sizeof(WCHAR
));
752 SetDlgItemText(hwndDlg
, IDC_INSTALLINGSTATUS
, Msg
);
759 /* Property page dialog callback */
761 PageInstallFailedProc(
772 LPNMHDR pnmh
= (LPNMHDR
)lParam
;
776 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_FINISH
);
786 FillComboBox(HWND Dlg
, int idComboBox
, int From
, int To
)
791 for(i
= From
; i
<= To
; i
++)
793 if(LoadString(hAppInstance
, i
, Text
, 255) > 0)
795 SendDlgItemMessage(Dlg
, idComboBox
, CB_ADDSTRING
, 0, (LPARAM
)Text
);
807 /* Property page dialog callback */
820 DWORD ResX
= 0, ResY
= 0, ColDepth
= 0;
823 FillComboBox(hwndDlg
, IDC_COLORQUALITY
, 10001, 10003);
824 if(LoadResolutionSettings(&ResX
, &ResY
, &ColDepth
))
826 SendDlgItemMessage(hwndDlg
, ResX
+ ResY
, BM_SETCHECK
, BST_CHECKED
, 0);
842 SendDlgItemMessage(hwndDlg
, IDC_COLORQUALITY
, CB_SETCURSEL
, cbSel
, 0);
850 /* Center the wizard window */
851 hwndControl
= GetParent(hwndDlg
);
852 CenterWindow (hwndControl
);
854 LPNMHDR pnmh
= (LPNMHDR
)lParam
;
859 PropSheet_SetWizButtons(GetParent(hwndDlg
), ((StartVMwConfigWizard
|| DriverFilesFound
) ? PSWIZB_FINISH
| PSWIZB_BACK
: PSWIZB_FINISH
));
864 if(StartVMwConfigWizard
)
866 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_CHOOSEACTION
);
871 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_WELCOMEPAGE
);
878 DWORD rx
= 800, ry
= 600, cd
= 32;
880 static MAPCTLRES Resolutions
[11] = {
893 for(i
= 0; i
< 11; i
++)
895 if(SendDlgItemMessage(hwndDlg
, Resolutions
[i
].ControlID
, BM_GETCHECK
, 0, 0) == BST_CHECKED
)
897 rx
= Resolutions
[i
].ResX
;
898 ry
= Resolutions
[i
].ResY
;
903 switch(SendDlgItemMessage(hwndDlg
, IDC_COLORQUALITY
, CB_GETCURSEL
, 0, 0))
916 SaveResolutionSettings(rx
, ry
, cd
);
926 /* Property page dialog callback */
928 PageChooseActionProc(
938 SendDlgItemMessage(hwndDlg
, IDC_CONFIGSETTINGS
, BM_SETCHECK
, BST_CHECKED
, 0);
942 LPNMHDR pnmh
= (LPNMHDR
)lParam
;
946 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_NEXT
);
950 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_CHOOSEACTION
);
955 static ULONG SelPage
[4] = {IDD_CONFIG
, IDD_SELECTDRIVER
, IDD_SELECTDRIVER
, IDD_CHOOSEACTION
};
958 for(i
= IDC_CONFIGSETTINGS
; i
<= IDC_UNINSTALL
; i
++)
960 if(SendDlgItemMessage(hwndDlg
, i
, BM_GETCHECK
, 0, 0) == BST_CHECKED
)
966 UninstallDriver
= (i
== IDC_UNINSTALL
);
968 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, SelPage
[i
- IDC_CONFIGSETTINGS
]);
978 /* Property page dialog callback */
980 PageSelectDriverProc(
990 SendDlgItemMessage(hwndDlg
, IDC_VBE
, BM_SETCHECK
, BST_CHECKED
, 0);
994 LPNMHDR pnmh
= (LPNMHDR
)lParam
;
998 PropSheet_SetWizButtons(GetParent(hwndDlg
), (UninstallDriver
? PSWIZB_NEXT
| PSWIZB_BACK
: PSWIZB_BACK
| PSWIZB_FINISH
));
1002 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_CHOOSEACTION
);
1007 ActivateVBE
= (SendDlgItemMessage(hwndDlg
, IDC_VBE
, BM_GETCHECK
, 0, 0) == BST_CHECKED
);
1021 ActivateVBE
= (SendDlgItemMessage(hwndDlg
, IDC_VBE
, BM_GETCHECK
, 0, 0) == BST_CHECKED
);
1022 if(!EnableVmwareDriver(ActivateVBE
,
1027 LoadString(hAppInstance
, (ActivateVBE
? IDS_FAILEDTOSELVBEDRIVER
: IDS_FAILEDTOSELVGADRIVER
), Msg
, sizeof(Msg
) / sizeof(WCHAR
));
1028 MessageBox(GetParent(hwndDlg
), Msg
, NULL
, MB_ICONWARNING
);
1029 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_SELECTDRIVER
);
1042 ShowUninstNotice(HWND Owner
)
1045 LoadString(hAppInstance
, IDS_UNINSTNOTICE
, Msg
, sizeof(Msg
) / sizeof(WCHAR
));
1046 MessageBox(Owner
, Msg
, NULL
, MB_ICONINFORMATION
);
1050 PageDoUninstallProc(
1061 LPNMHDR pnmh
= (LPNMHDR
)lParam
;
1065 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_BACK
| PSWIZB_FINISH
);
1071 if(!EnableVmwareDriver(ActivateVBE
,
1076 LoadString(hAppInstance
, (ActivateVBE
? IDS_FAILEDTOSELVBEDRIVER
: IDS_FAILEDTOSELVGADRIVER
), Msg
, sizeof(Msg
) / sizeof(WCHAR
));
1077 MessageBox(GetParent(hwndDlg
), Msg
, NULL
, MB_ICONWARNING
);
1078 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_SELECTDRIVER
);
1081 ShowUninstNotice(GetParent(hwndDlg
));
1095 PROPSHEETHEADER psh
;
1096 HPROPSHEETPAGE ahpsp
[8];
1098 WCHAR Caption
[1024];
1100 LoadString(hAppInstance
, IDS_WIZARD_NAME
, Caption
, sizeof(Caption
) / sizeof(TCHAR
));
1102 /* Create the Welcome page */
1103 ZeroMemory (&psp
, sizeof(PROPSHEETPAGE
));
1104 psp
.dwSize
= sizeof(PROPSHEETPAGE
);
1105 psp
.dwFlags
= PSP_DEFAULT
| PSP_HIDEHEADER
;
1106 psp
.hInstance
= hAppInstance
;
1107 psp
.pfnDlgProc
= PageWelcomeProc
;
1108 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_WELCOMEPAGE
);
1109 ahpsp
[0] = CreatePropertySheetPage(&psp
);
1111 /* Create the INSERT_VMWARE_TOOLS page */
1112 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1113 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDD_INSERT_VMWARE_TOOLSTITLE
);
1114 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDD_INSERT_VMWARE_TOOLSSUBTITLE
);
1115 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_INSERT_VMWARE_TOOLS
);
1116 psp
.pfnDlgProc
= PageInsertDiscProc
;
1117 ahpsp
[1] = CreatePropertySheetPage(&psp
);
1119 /* Create the INSTALLING_VMWARE_TOOLS page */
1120 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1121 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDD_INSTALLING_VMWARE_TOOLSTITLE
);
1122 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDD_INSTALLING_VMWARE_TOOLSSUBTITLE
);
1123 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_INSTALLING_VMWARE_TOOLS
);
1124 psp
.pfnDlgProc
= PageInstallingProc
;
1125 ahpsp
[2] = CreatePropertySheetPage(&psp
);
1127 /* Create the CONFIG page */
1128 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1129 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDD_CONFIGTITLE
);
1130 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDD_CONFIGSUBTITLE
);
1131 psp
.pfnDlgProc
= PageConfigProc
;
1132 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_CONFIG
);
1133 ahpsp
[3] = CreatePropertySheetPage(&psp
);
1135 /* Create the INSTALLATION_FAILED page */
1136 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1137 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDD_INSTALLATION_FAILEDTITLE
);
1138 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDD_INSTALLATION_FAILEDSUBTITLE
);
1139 psp
.pfnDlgProc
= PageInstallFailedProc
;
1140 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_INSTALLATION_FAILED
);
1141 ahpsp
[4] = CreatePropertySheetPage(&psp
);
1143 /* Create the CHOOSEACTION page */
1144 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1145 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDD_CHOOSEACTIONTITLE
);
1146 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDD_CHOOSEACTIONSUBTITLE
);
1147 psp
.pfnDlgProc
= PageChooseActionProc
;
1148 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_CHOOSEACTION
);
1149 ahpsp
[5] = CreatePropertySheetPage(&psp
);
1151 /* Create the SELECTDRIVER page */
1152 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1153 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDD_SELECTDRIVERTITLE
);
1154 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDD_SELECTDRIVERSUBTITLE
);
1155 psp
.pfnDlgProc
= PageSelectDriverProc
;
1156 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_SELECTDRIVER
);
1157 ahpsp
[6] = CreatePropertySheetPage(&psp
);
1159 /* Create the DOUNINSTALL page */
1160 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1161 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDD_DOUNINSTALLTITLE
);
1162 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDD_DOUNINSTALLSUBTITLE
);
1163 psp
.pfnDlgProc
= PageDoUninstallProc
;
1164 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_DOUNINSTALL
);
1165 ahpsp
[7] = CreatePropertySheetPage(&psp
);
1167 /* Create the property sheet */
1168 psh
.dwSize
= sizeof(PROPSHEETHEADER
);
1169 psh
.dwFlags
= PSH_WIZARD97
| PSH_WATERMARK
| PSH_HEADER
;
1170 psh
.hInstance
= hAppInstance
;
1171 psh
.hwndParent
= NULL
;
1173 psh
.nStartPage
= (StartVMwConfigWizard
? 5 : 0);
1175 psh
.pszbmWatermark
= MAKEINTRESOURCE(IDB_WATERMARK
);
1176 psh
.pszbmHeader
= MAKEINTRESOURCE(IDB_HEADER
);
1178 /* Display the wizard */
1179 return (LONG
)(PropertySheet(&psh
) != -1);
1183 WinMain(HINSTANCE hInstance
,
1184 HINSTANCE hPrevInstance
,
1189 LPTOP_LEVEL_EXCEPTION_FILTER OldHandler
;
1193 hAppInstance
= hInstance
;
1195 /* Setup our exception "handler" ;-) */
1196 OldHandler
= SetUnhandledExceptionFilter(ExceptionHandler
);
1198 if(!DetectVMware(&Version
))
1204 /* restore the exception handler */
1205 SetUnhandledExceptionFilter(OldHandler
);
1207 lc
= DestinationPath
;
1208 lc
+= GetSystemDirectory(DestinationPath
, MAX_PATH
) - 1;
1209 if(lc
>= DestinationPath
&& *lc
!= L
'\\')
1211 wcscat(DestinationPath
, L
"\\");
1213 DestinationDriversPath
[0] = L
'\0';
1214 wcscat(DestinationDriversPath
, DestinationPath
);
1215 wcscat(DestinationDriversPath
, L
"drivers\\");
1217 SetCurrentDirectory(DestinationPath
);
1219 DriverFilesFound
= FileExists(DestinationPath
, vmx_fb
) &&
1220 FileExists(DestinationPath
, vmx_mode
) &&
1221 FileExists(DestinationDriversPath
, vmx_svga
);
1223 StartVMwConfigWizard
= DriverFilesFound
&& IsVmwSVGAEnabled();
1225 /* Show the wizard */