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 /* FIXME - check for existing registry entries! */
507 if(!EnableVmwareDriver(TRUE
, TRUE
, TRUE
))
511 LoadString(hAppInstance
, IDS_FAILEDTOACTIVATEDRIVER
, Msg
, sizeof(Msg
) / sizeof(WCHAR
));
512 MessageBox(GetParent(hwndDlg
), Msg
, NULL
, MB_ICONWARNING
);
513 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_WELCOMEPAGE
);
516 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_CONFIG
);
528 /* Property page dialog callback */
541 LPNMHDR pnmh
= (LPNMHDR
)lParam
;
545 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_BACK
| PSWIZB_NEXT
);
548 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_INSTALLING_VMWARE_TOOLS
);
558 InstTerminateInstaller(BOOL Wait
)
560 if(hInstallationThread
!= NULL
)
564 InterlockedExchange((LONG
*)&AbortInstall
, 2);
565 WaitForSingleObject(hInstallationThread
, INFINITE
);
569 InterlockedExchange((LONG
*)&AbortInstall
, 1);
575 InstInstallationThread(LPVOID lpParameter
)
579 int DrivesTested
= 0;
581 if(AbortInstall
!= 0) goto done
;
582 PostMessage(hInstallationNotifyWnd
, WM_INSTSTATUSUPDATE
, IDS_SEARCHINGFORCDROM
, 0);
584 while(AbortInstall
== 0)
587 DriveAvailable
= IsVMwareCDInDrive(&CDDrive
);
590 if(DrivesTested
++ > 20)
592 PostMessage(hInstallationNotifyWnd
, WM_INSTABORT
, IDS_FAILEDTOLOCATEDRIVERS
, 0);
597 if(AbortInstall
!= 0) goto done
;
598 PostMessage(hInstallationNotifyWnd
, WM_INSTSTATUSUPDATE
, IDS_COPYINGFILES
, 0);
600 if(AbortInstall
!= 0) goto done
;
601 if(!InstallFile(DestinationPath
, vmx_fb
))
603 PostMessage(hInstallationNotifyWnd
, WM_INSTABORT
, IDS_FAILEDTOCOPYFILES
, 0);
609 if(AbortInstall
!= 0) goto done
;
610 if(!InstallFile(DestinationPath
, vmx_mode
))
612 PostMessage(hInstallationNotifyWnd
, WM_INSTABORT
, IDS_FAILEDTOCOPYFILES
, 0);
618 if(AbortInstall
!= 0) goto done
;
619 if(!InstallFile(DestinationDriversPath
, vmx_svga
))
621 PostMessage(hInstallationNotifyWnd
, WM_INSTABORT
, IDS_FAILEDTOCOPYFILES
, 0);
627 if(AbortInstall
!= 0) goto done
;
628 PostMessage(hInstallationNotifyWnd
, WM_INSTSTATUSUPDATE
, IDS_ENABLINGDRIVER
, 0);
629 if(!AddVmwareRegistryEntries())
631 PostMessage(hInstallationNotifyWnd
, WM_INSTABORT
, IDS_FAILEDTOADDREGENTRIES
, 0);
634 if(!EnableVmwareDriver(TRUE
, TRUE
, TRUE
))
636 PostMessage(hInstallationNotifyWnd
, WM_INSTABORT
, IDS_FAILEDTOACTIVATEDRIVER
, 0);
646 SendMessage(hInstallationNotifyWnd
, WM_INSTCOMPLETE
, 0, 0);
649 SendMessage(hInstallationNotifyWnd
, WM_INSTABORT
, 0, 0);
654 hThread
= (HANDLE
)InterlockedExchange((LONG
*)&hInstallationThread
, 0);
657 CloseHandle(hThread
);
663 InstStartInstallationThread(HWND hwndNotify
)
665 if(hInstallationThread
== NULL
)
668 hInstallationNotifyWnd
= hwndNotify
;
670 hInstallationThread
= CreateThread(NULL
,
672 InstInstallationThread
,
676 if(hInstallationThread
== NULL
)
681 ResumeThread(hInstallationThread
);
688 /* Property page dialog callback */
701 LPNMHDR pnmh
= (LPNMHDR
)lParam
;
705 SetDlgItemText(hwndDlg
, IDC_INSTALLINGSTATUS
, NULL
);
706 SendDlgItemMessage(hwndDlg
, IDC_INSTALLINGPROGRESS
, PBM_SETMARQUEE
, TRUE
, 50);
707 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_BACK
);
708 InstStartInstallationThread(hwndDlg
);
711 InstTerminateInstaller(TRUE
);
714 if(hInstallationThread
!= NULL
)
716 PropSheet_SetWizButtons(GetParent(hwndDlg
), 0);
717 InstTerminateInstaller(FALSE
);
718 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, -1);
723 SendDlgItemMessage(hwndDlg
, IDC_INSTALLINGPROGRESS
, PBM_SETMARQUEE
, FALSE
, 0);
724 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_INSERT_VMWARE_TOOLS
);
731 /* go back in case we aborted the installation thread */
732 SendDlgItemMessage(hwndDlg
, IDC_INSTALLINGPROGRESS
, PBM_SETMARQUEE
, FALSE
, 0);
733 PropSheet_SetCurSelByID(GetParent(hwndDlg
), IDD_INSERT_VMWARE_TOOLS
);
737 LoadString(hAppInstance
, wParam
, Msg
, sizeof(Msg
) / sizeof(WCHAR
));
738 MessageBox(GetParent(hwndDlg
), Msg
, NULL
, MB_ICONWARNING
);
741 case WM_INSTCOMPLETE
:
742 SendDlgItemMessage(hwndDlg
, IDC_INSTALLINGPROGRESS
, PBM_SETMARQUEE
, FALSE
, 0);
743 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_BACK
| PSWIZB_NEXT
);
744 PropSheet_SetCurSelByID(GetParent(hwndDlg
), IDD_CONFIG
);
746 case WM_INSTSTATUSUPDATE
:
749 LoadString(hAppInstance
, wParam
, Msg
, sizeof(Msg
) / sizeof(WCHAR
));
750 SetDlgItemText(hwndDlg
, IDC_INSTALLINGSTATUS
, Msg
);
757 /* Property page dialog callback */
759 PageInstallFailedProc(
770 LPNMHDR pnmh
= (LPNMHDR
)lParam
;
774 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_FINISH
);
784 FillComboBox(HWND Dlg
, int idComboBox
, int From
, int To
)
789 for(i
= From
; i
<= To
; i
++)
791 if(LoadString(hAppInstance
, i
, Text
, 255) > 0)
793 SendDlgItemMessage(Dlg
, idComboBox
, CB_ADDSTRING
, 0, (LPARAM
)Text
);
805 /* Property page dialog callback */
818 DWORD ResX
= 0, ResY
= 0, ColDepth
= 0;
821 FillComboBox(hwndDlg
, IDC_COLORQUALITY
, 10001, 10003);
822 if(LoadResolutionSettings(&ResX
, &ResY
, &ColDepth
))
824 SendDlgItemMessage(hwndDlg
, ResX
+ ResY
, BM_SETCHECK
, BST_CHECKED
, 0);
840 SendDlgItemMessage(hwndDlg
, IDC_COLORQUALITY
, CB_SETCURSEL
, cbSel
, 0);
848 /* Center the wizard window */
849 hwndControl
= GetParent(hwndDlg
);
850 CenterWindow (hwndControl
);
852 LPNMHDR pnmh
= (LPNMHDR
)lParam
;
857 PropSheet_SetWizButtons(GetParent(hwndDlg
), ((StartVMwConfigWizard
|| DriverFilesFound
) ? PSWIZB_FINISH
| PSWIZB_BACK
: PSWIZB_FINISH
));
862 if(StartVMwConfigWizard
)
864 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_CHOOSEACTION
);
869 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_WELCOMEPAGE
);
876 DWORD rx
= 800, ry
= 600, cd
= 32;
878 static MAPCTLRES Resolutions
[11] = {
891 for(i
= 0; i
< 11; i
++)
893 if(SendDlgItemMessage(hwndDlg
, Resolutions
[i
].ControlID
, BM_GETCHECK
, 0, 0) == BST_CHECKED
)
895 rx
= Resolutions
[i
].ResX
;
896 ry
= Resolutions
[i
].ResY
;
901 switch(SendDlgItemMessage(hwndDlg
, IDC_COLORQUALITY
, CB_GETCURSEL
, 0, 0))
914 SaveResolutionSettings(rx
, ry
, cd
);
924 /* Property page dialog callback */
926 PageChooseActionProc(
936 SendDlgItemMessage(hwndDlg
, IDC_CONFIGSETTINGS
, BM_SETCHECK
, BST_CHECKED
, 0);
940 LPNMHDR pnmh
= (LPNMHDR
)lParam
;
944 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_NEXT
);
948 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_CHOOSEACTION
);
953 static ULONG SelPage
[4] = {IDD_CONFIG
, IDD_SELECTDRIVER
, IDD_SELECTDRIVER
, IDD_CHOOSEACTION
};
956 for(i
= IDC_CONFIGSETTINGS
; i
<= IDC_UNINSTALL
; i
++)
958 if(SendDlgItemMessage(hwndDlg
, i
, BM_GETCHECK
, 0, 0) == BST_CHECKED
)
964 UninstallDriver
= (i
== IDC_UNINSTALL
);
966 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, SelPage
[i
- IDC_CONFIGSETTINGS
]);
976 /* Property page dialog callback */
978 PageSelectDriverProc(
988 SendDlgItemMessage(hwndDlg
, IDC_VBE
, BM_SETCHECK
, BST_CHECKED
, 0);
992 LPNMHDR pnmh
= (LPNMHDR
)lParam
;
996 PropSheet_SetWizButtons(GetParent(hwndDlg
), (UninstallDriver
? PSWIZB_NEXT
| PSWIZB_BACK
: PSWIZB_BACK
| PSWIZB_FINISH
));
1000 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_CHOOSEACTION
);
1005 ActivateVBE
= (SendDlgItemMessage(hwndDlg
, IDC_VBE
, BM_GETCHECK
, 0, 0) == BST_CHECKED
);
1019 ActivateVBE
= (SendDlgItemMessage(hwndDlg
, IDC_VBE
, BM_GETCHECK
, 0, 0) == BST_CHECKED
);
1020 if(!EnableVmwareDriver(ActivateVBE
,
1025 LoadString(hAppInstance
, (ActivateVBE
? IDS_FAILEDTOSELVBEDRIVER
: IDS_FAILEDTOSELVGADRIVER
), Msg
, sizeof(Msg
) / sizeof(WCHAR
));
1026 MessageBox(GetParent(hwndDlg
), Msg
, NULL
, MB_ICONWARNING
);
1027 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_SELECTDRIVER
);
1040 ShowUninstNotice(HWND Owner
)
1043 LoadString(hAppInstance
, IDS_UNINSTNOTICE
, Msg
, sizeof(Msg
) / sizeof(WCHAR
));
1044 MessageBox(Owner
, Msg
, NULL
, MB_ICONINFORMATION
);
1048 PageDoUninstallProc(
1059 LPNMHDR pnmh
= (LPNMHDR
)lParam
;
1063 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_BACK
| PSWIZB_FINISH
);
1069 if(!EnableVmwareDriver(ActivateVBE
,
1074 LoadString(hAppInstance
, (ActivateVBE
? IDS_FAILEDTOSELVBEDRIVER
: IDS_FAILEDTOSELVGADRIVER
), Msg
, sizeof(Msg
) / sizeof(WCHAR
));
1075 MessageBox(GetParent(hwndDlg
), Msg
, NULL
, MB_ICONWARNING
);
1076 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_SELECTDRIVER
);
1079 ShowUninstNotice(GetParent(hwndDlg
));
1093 PROPSHEETHEADER psh
;
1094 HPROPSHEETPAGE ahpsp
[8];
1096 WCHAR Caption
[1024];
1098 LoadString(hAppInstance
, IDS_WIZARD_NAME
, Caption
, sizeof(Caption
) / sizeof(TCHAR
));
1100 /* Create the Welcome page */
1101 ZeroMemory (&psp
, sizeof(PROPSHEETPAGE
));
1102 psp
.dwSize
= sizeof(PROPSHEETPAGE
);
1103 psp
.dwFlags
= PSP_DEFAULT
| PSP_HIDEHEADER
;
1104 psp
.hInstance
= hAppInstance
;
1105 psp
.pfnDlgProc
= PageWelcomeProc
;
1106 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_WELCOMEPAGE
);
1107 ahpsp
[0] = CreatePropertySheetPage(&psp
);
1109 /* Create the INSERT_VMWARE_TOOLS page */
1110 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1111 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDD_INSERT_VMWARE_TOOLSTITLE
);
1112 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDD_INSERT_VMWARE_TOOLSSUBTITLE
);
1113 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_INSERT_VMWARE_TOOLS
);
1114 psp
.pfnDlgProc
= PageInsertDiscProc
;
1115 ahpsp
[1] = CreatePropertySheetPage(&psp
);
1117 /* Create the INSTALLING_VMWARE_TOOLS page */
1118 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1119 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDD_INSTALLING_VMWARE_TOOLSTITLE
);
1120 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDD_INSTALLING_VMWARE_TOOLSSUBTITLE
);
1121 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_INSTALLING_VMWARE_TOOLS
);
1122 psp
.pfnDlgProc
= PageInstallingProc
;
1123 ahpsp
[2] = CreatePropertySheetPage(&psp
);
1125 /* Create the CONFIG page */
1126 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1127 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDD_CONFIGTITLE
);
1128 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDD_CONFIGSUBTITLE
);
1129 psp
.pfnDlgProc
= PageConfigProc
;
1130 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_CONFIG
);
1131 ahpsp
[3] = CreatePropertySheetPage(&psp
);
1133 /* Create the INSTALLATION_FAILED page */
1134 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1135 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDD_INSTALLATION_FAILEDTITLE
);
1136 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDD_INSTALLATION_FAILEDSUBTITLE
);
1137 psp
.pfnDlgProc
= PageInstallFailedProc
;
1138 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_INSTALLATION_FAILED
);
1139 ahpsp
[4] = CreatePropertySheetPage(&psp
);
1141 /* Create the CHOOSEACTION page */
1142 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1143 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDD_CHOOSEACTIONTITLE
);
1144 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDD_CHOOSEACTIONSUBTITLE
);
1145 psp
.pfnDlgProc
= PageChooseActionProc
;
1146 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_CHOOSEACTION
);
1147 ahpsp
[5] = CreatePropertySheetPage(&psp
);
1149 /* Create the SELECTDRIVER page */
1150 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1151 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDD_SELECTDRIVERTITLE
);
1152 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDD_SELECTDRIVERSUBTITLE
);
1153 psp
.pfnDlgProc
= PageSelectDriverProc
;
1154 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_SELECTDRIVER
);
1155 ahpsp
[6] = CreatePropertySheetPage(&psp
);
1157 /* Create the DOUNINSTALL page */
1158 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1159 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDD_DOUNINSTALLTITLE
);
1160 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDD_DOUNINSTALLSUBTITLE
);
1161 psp
.pfnDlgProc
= PageDoUninstallProc
;
1162 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_DOUNINSTALL
);
1163 ahpsp
[7] = CreatePropertySheetPage(&psp
);
1165 /* Create the property sheet */
1166 psh
.dwSize
= sizeof(PROPSHEETHEADER
);
1167 psh
.dwFlags
= PSH_WIZARD97
| PSH_WATERMARK
| PSH_HEADER
;
1168 psh
.hInstance
= hAppInstance
;
1169 psh
.hwndParent
= NULL
;
1171 psh
.nStartPage
= (StartVMwConfigWizard
? 5 : 0);
1173 psh
.pszbmWatermark
= MAKEINTRESOURCE(IDB_WATERMARK
);
1174 psh
.pszbmHeader
= MAKEINTRESOURCE(IDB_HEADER
);
1176 /* Display the wizard */
1177 return (LONG
)(PropertySheet(&psh
) != -1);
1181 WinMain(HINSTANCE hInstance
,
1182 HINSTANCE hPrevInstance
,
1187 LPTOP_LEVEL_EXCEPTION_FILTER OldHandler
;
1191 hAppInstance
= hInstance
;
1193 /* Setup our exception "handler" ;-) */
1194 OldHandler
= SetUnhandledExceptionFilter(ExceptionHandler
);
1196 if(!DetectVMware(&Version
))
1202 /* restore the exception handler */
1203 SetUnhandledExceptionFilter(OldHandler
);
1205 lc
= DestinationPath
;
1206 lc
+= GetSystemDirectory(DestinationPath
, MAX_PATH
) - 1;
1207 if(lc
>= DestinationPath
&& *lc
!= L
'\\')
1209 wcscat(DestinationPath
, L
"\\");
1211 DestinationDriversPath
[0] = L
'\0';
1212 wcscat(DestinationDriversPath
, DestinationPath
);
1213 wcscat(DestinationDriversPath
, L
"drivers\\");
1215 SetCurrentDirectory(DestinationPath
);
1217 DriverFilesFound
= FileExists(DestinationPath
, vmx_fb
) &&
1218 FileExists(DestinationPath
, vmx_mode
) &&
1219 FileExists(DestinationDriversPath
, vmx_svga
);
1221 StartVMwConfigWizard
= DriverFilesFound
&& IsVmwSVGAEnabled();
1223 /* Show the wizard */