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 PathToVideoDrivers55
[MAX_PATH
+1] = L
"X:\\program files\\VMware\\VMware Tools\\Drivers\\video\\winnt2k\\32Bit\\";
45 static WCHAR PathToVideoDrivers45
[MAX_PATH
+1] = L
"X:\\program files\\VMware\\VMware Tools\\Drivers\\video\\winnt2k\\";
46 static WCHAR PathToVideoDrivers40
[MAX_PATH
+1] = L
"X:\\video\\winnt2k\\";
47 static WCHAR DestinationPath
[MAX_PATH
+1];
48 static WCHAR
*vmx_fb
= L
"vmx_fb.dll";
49 static WCHAR
*vmx_mode
= L
"vmx_mode.dll";
50 static WCHAR
*vmx_svga
= L
"vmx_svga.sys";
52 static WCHAR
*SrcPath
= PathToVideoDrivers45
;
54 static HANDLE hInstallationThread
= NULL
;
55 static HWND hInstallationNotifyWnd
= NULL
;
56 static LONG AbortInstall
= 0;
57 #define WM_INSTABORT (WM_USER + 2)
58 #define WM_INSTCOMPLETE (WM_USER + 3)
59 #define WM_INSTSTATUSUPDATE (WM_USER + 4)
61 /* Helper functions */
63 LONG CALLBACK
VectoredExceptionHandler(PEXCEPTION_POINTERS ExceptionInfo
)
65 /* we're not running in VMware, just terminate the process */
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
)
127 /* If it was a sharing violation the file must already exist */
128 return GetLastError() == ERROR_SHARING_VIOLATION
;
131 if(GetFileSize(FileHandle
, NULL
) <= 0)
133 CloseHandle(FileHandle
);
137 CloseHandle(FileHandle
);
142 CenterWindow(HWND hWnd
)
148 hWndParent
= GetParent(hWnd
);
149 if (hWndParent
== NULL
)
150 hWndParent
= GetDesktopWindow();
152 GetWindowRect(hWndParent
, &rcParent
);
153 GetWindowRect(hWnd
, &rcWindow
);
157 ((rcParent
.right
- rcParent
.left
) - (rcWindow
.right
- rcWindow
.left
)) / 2,
158 ((rcParent
.bottom
- rcParent
.top
) - (rcWindow
.bottom
- rcWindow
.top
)) / 2,
167 InstallFile(WCHAR
*Destination
, WCHAR
*File
)
169 static char Buffer
[1024];
170 WCHAR SourceFileName
[MAX_PATH
+ 1];
171 WCHAR DestFileName
[MAX_PATH
+ 1];
172 HANDLE SourceFileHandle
, DestFileHandle
;
173 DWORD DataRead
, DataWritten
;
175 SourceFileName
[0] = L
'\0';
176 DestFileName
[0] = L
'\0';
177 wcscat(SourceFileName
, SrcPath
);
178 wcscat(SourceFileName
, File
);
179 wcscat(DestFileName
, Destination
);
180 wcscat(DestFileName
, File
);
182 SourceFileHandle
= CreateFile(SourceFileName
, GENERIC_READ
, 0, NULL
, OPEN_EXISTING
, FILE_ATTRIBUTE_NORMAL
, NULL
);
183 if(SourceFileHandle
== INVALID_HANDLE_VALUE
)
187 DestFileHandle
= CreateFile(DestFileName
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, FILE_ATTRIBUTE_NORMAL
, NULL
);
188 if(DestFileHandle
== INVALID_HANDLE_VALUE
)
190 CloseHandle(SourceFileHandle
);
194 while(ReadFile(SourceFileHandle
, Buffer
, sizeof(Buffer
), &DataRead
, NULL
) && DataRead
> 0)
196 if(!WriteFile(DestFileHandle
, Buffer
, DataRead
, &DataWritten
, NULL
) ||
197 DataRead
!= DataWritten
)
199 CloseHandle(SourceFileHandle
);
200 CloseHandle(DestFileHandle
);
201 DeleteFile(DestFileName
);
206 CloseHandle(SourceFileHandle
);
207 CloseHandle(DestFileHandle
);
211 /* Find the drive with the inserted VMware cd-rom */
213 IsVMwareCDInDrive(WCHAR
*Drv
)
215 static WCHAR Drive
[4] = L
"X:\\";
219 for(Current
= 'C'; Current
<= 'Z'; Current
++)
223 if(GetDriveType(Drive
) == DRIVE_CDROM
)
226 PathToVideoDrivers55
[0] = Current
;
227 PathToVideoDrivers40
[0] = Current
;
228 PathToVideoDrivers45
[0] = Current
;
229 if(SetCurrentDirectory(PathToVideoDrivers55
))
230 SrcPath
= PathToVideoDrivers55
;
231 else if(SetCurrentDirectory(PathToVideoDrivers45
))
232 SrcPath
= PathToVideoDrivers45
;
233 else if(SetCurrentDirectory(PathToVideoDrivers40
))
234 SrcPath
= PathToVideoDrivers40
;
237 SetCurrentDirectory(DestinationPath
);
241 if(FileExists(SrcPath
, vmx_fb
) &&
242 FileExists(SrcPath
, vmx_mode
) &&
243 FileExists(SrcPath
, vmx_svga
))
257 LoadResolutionSettings(DWORD
*ResX
, DWORD
*ResY
, DWORD
*ColDepth
)
262 if(RegOpenKeyEx(HKEY_LOCAL_MACHINE
,
263 L
"SYSTEM\\CurrentControlSet\\Hardware Profiles\\Current\\System\\CurrentControlSet\\Services\\vmx_svga\\Device0",
264 0, KEY_QUERY_VALUE
, &hReg
) != ERROR_SUCCESS
)
268 if(RegQueryValueEx(hReg
, L
"DefaultSettings.BitsPerPel", 0, &Type
, (BYTE
*)ColDepth
, &Size
) != ERROR_SUCCESS
||
275 if(RegQueryValueEx(hReg
, L
"DefaultSettings.XResolution", 0, &Type
, (BYTE
*)ResX
, &Size
) != ERROR_SUCCESS
||
282 if(RegQueryValueEx(hReg
, L
"DefaultSettings.YResolution", 0, &Type
, (BYTE
*)ResY
, &Size
) != ERROR_SUCCESS
||
294 IsVmwSVGAEnabled(VOID
)
297 DWORD Type
, Size
, Value
;
299 if(RegOpenKeyEx(HKEY_LOCAL_MACHINE
,
300 L
"SYSTEM\\CurrentControlSet\\Services\\vmx_svga",
301 0, KEY_QUERY_VALUE
, &hReg
) != ERROR_SUCCESS
)
305 if(RegQueryValueEx(hReg
, L
"Start", 0, &Type
, (BYTE
*)&Value
, &Size
) != ERROR_SUCCESS
||
319 SaveResolutionSettings(DWORD ResX
, DWORD ResY
, DWORD ColDepth
)
323 if(RegOpenKeyEx(HKEY_LOCAL_MACHINE
,
324 L
"SYSTEM\\CurrentControlSet\\Hardware Profiles\\Current\\System\\CurrentControlSet\\Services\\vmx_svga\\Device0",
325 0, KEY_SET_VALUE
, &hReg
) != ERROR_SUCCESS
)
329 if(RegSetValueEx(hReg
, L
"DefaultSettings.BitsPerPel", 0, REG_DWORD
, (BYTE
*)&ColDepth
, sizeof(DWORD
)) != ERROR_SUCCESS
)
335 if(RegSetValueEx(hReg
, L
"DefaultSettings.XResolution", 0, REG_DWORD
, (BYTE
*)&ResX
, sizeof(DWORD
)) != ERROR_SUCCESS
)
341 if(RegSetValueEx(hReg
, L
"DefaultSettings.YResolution", 0, REG_DWORD
, (BYTE
*)&ResY
, sizeof(DWORD
)) != ERROR_SUCCESS
)
352 EnableDriver(WCHAR
*Key
, BOOL Enable
)
357 Value
= (Enable
? 1 : 4);
359 if(RegOpenKeyEx(HKEY_LOCAL_MACHINE
, Key
, 0, KEY_SET_VALUE
, &hReg
) != ERROR_SUCCESS
)
363 if(RegSetValueEx(hReg
, L
"Start", 0, REG_DWORD
, (BYTE
*)&Value
, sizeof(DWORD
)) != ERROR_SUCCESS
)
373 /* Activate the vmware driver and deactivate the others */
375 EnableVmwareDriver(BOOL VBE
, BOOL VGA
, BOOL VMX
)
377 if(!EnableDriver(L
"SYSTEM\\CurrentControlSet\\Services\\VBE", VBE
))
381 if(!EnableDriver(L
"SYSTEM\\CurrentControlSet\\Services\\vga", VGA
))
385 if(!EnableDriver(L
"SYSTEM\\CurrentControlSet\\Services\\vmx_svga", VMX
))
393 /* Make sure the required registry entries are present */
395 AddVmwareRegistryEntries()
397 HRSRC VmwareInfResource
;
398 HGLOBAL VmwareInfMem
;
399 PVOID VmwareInfLocked
;
401 WCHAR TempPath
[MAX_PATH
];
403 WCHAR TempFileName
[MAX_PATH
];
406 WCHAR CmdLine
[19 + MAX_PATH
];
408 VmwareInfResource
= FindResourceW(hAppInstance
,
409 MAKEINTRESOURCE(IDR_VMWARE_INF
),
411 if (NULL
== VmwareInfResource
)
415 Size
= SizeofResource(hAppInstance
, VmwareInfResource
);
420 VmwareInfMem
= LoadResource(hAppInstance
, VmwareInfResource
);
421 if (NULL
== VmwareInfMem
)
425 VmwareInfLocked
= LockResource(VmwareInfMem
);
426 if (NULL
== VmwareInfLocked
)
431 BufferSize
= GetTempPathW(sizeof(TempPath
) / sizeof(TempPath
[0]), TempPath
);
432 if (0 == BufferSize
|| sizeof(TempPath
) / sizeof(TempPath
[0]) < BufferSize
)
436 if (0 == GetTempFileNameW(TempPath
, L
"vmx", 0, TempFileName
))
441 TempFile
= CreateFileW(TempFileName
, GENERIC_WRITE
, 0, NULL
, OPEN_EXISTING
,
442 FILE_ATTRIBUTE_NORMAL
, NULL
);
443 if (INVALID_HANDLE_VALUE
== TempFile
)
445 DeleteFile(TempFileName
);
448 if (! WriteFile(TempFile
, VmwareInfLocked
, Size
, &Written
, NULL
) ||
451 CloseHandle(TempFile
);
452 DeleteFile(TempFileName
);
455 CloseHandle(TempFile
);
457 wcscpy(CmdLine
, L
"DefaultInstall 128 ");
458 wcscat(CmdLine
, TempFileName
);
459 InstallHinfSectionW(NULL
, NULL
, CmdLine
, 0);
461 DeleteFile(TempFileName
);
469 InitPropSheetPage(PROPSHEETPAGE
*psp
, WORD idDlg
, DWORD Flags
, DLGPROC DlgProc
)
471 ZeroMemory(psp
, sizeof(PROPSHEETPAGE
));
472 psp
->dwSize
= sizeof(PROPSHEETPAGE
);
473 psp
->dwFlags
= PSP_DEFAULT
| Flags
;
474 psp
->hInstance
= hAppInstance
;
475 psp
->pszTemplate
= MAKEINTRESOURCE(idDlg
);
476 psp
->pfnDlgProc
= DlgProc
;
479 /* Property page dialog callback */
494 /* Center the wizard window */
495 hwndControl
= GetParent(hwndDlg
);
496 CenterWindow (hwndControl
);
498 LPNMHDR pnmh
= (LPNMHDR
)lParam
;
503 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_NEXT
);
510 if(!AddVmwareRegistryEntries())
513 LoadString(hAppInstance
, IDS_FAILEDTOADDREGENTRIES
, Msg
, sizeof(Msg
) / sizeof(WCHAR
));
514 MessageBox(GetParent(hwndDlg
), Msg
, NULL
, MB_ICONWARNING
);
515 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_WELCOMEPAGE
);
518 if(!EnableVmwareDriver(TRUE
, TRUE
, TRUE
))
522 LoadString(hAppInstance
, IDS_FAILEDTOACTIVATEDRIVER
, Msg
, sizeof(Msg
) / sizeof(WCHAR
));
523 MessageBox(GetParent(hwndDlg
), Msg
, NULL
, MB_ICONWARNING
);
524 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_WELCOMEPAGE
);
527 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_CONFIG
);
539 /* Property page dialog callback */
552 LPNMHDR pnmh
= (LPNMHDR
)lParam
;
556 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_BACK
| PSWIZB_NEXT
);
559 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_INSTALLING_VMWARE_TOOLS
);
569 InstTerminateInstaller(BOOL Wait
)
571 if(hInstallationThread
!= NULL
)
575 InterlockedExchange((LONG
*)&AbortInstall
, 2);
576 WaitForSingleObject(hInstallationThread
, INFINITE
);
580 InterlockedExchange((LONG
*)&AbortInstall
, 1);
586 InstInstallationThread(LPVOID lpParameter
)
590 int DrivesTested
= 0;
592 if(AbortInstall
!= 0) goto done
;
593 PostMessage(hInstallationNotifyWnd
, WM_INSTSTATUSUPDATE
, IDS_SEARCHINGFORCDROM
, 0);
595 while(AbortInstall
== 0)
598 DriveAvailable
= IsVMwareCDInDrive(&CDDrive
);
601 if(DrivesTested
++ > 20)
603 PostMessage(hInstallationNotifyWnd
, WM_INSTABORT
, IDS_FAILEDTOLOCATEDRIVERS
, 0);
608 if(AbortInstall
!= 0) goto done
;
609 PostMessage(hInstallationNotifyWnd
, WM_INSTSTATUSUPDATE
, IDS_COPYINGFILES
, 0);
611 if(AbortInstall
!= 0) goto done
;
612 if(!InstallFile(DestinationPath
, vmx_fb
))
614 PostMessage(hInstallationNotifyWnd
, WM_INSTABORT
, IDS_FAILEDTOCOPYFILES
, 0);
620 if(AbortInstall
!= 0) goto done
;
621 if(!InstallFile(DestinationPath
, vmx_mode
))
623 PostMessage(hInstallationNotifyWnd
, WM_INSTABORT
, IDS_FAILEDTOCOPYFILES
, 0);
629 if(AbortInstall
!= 0) goto done
;
630 if(!InstallFile(DestinationDriversPath
, vmx_svga
))
632 PostMessage(hInstallationNotifyWnd
, WM_INSTABORT
, IDS_FAILEDTOCOPYFILES
, 0);
638 if(AbortInstall
!= 0) goto done
;
639 PostMessage(hInstallationNotifyWnd
, WM_INSTSTATUSUPDATE
, IDS_ENABLINGDRIVER
, 0);
640 if(!AddVmwareRegistryEntries())
642 PostMessage(hInstallationNotifyWnd
, WM_INSTABORT
, IDS_FAILEDTOADDREGENTRIES
, 0);
645 if(!EnableVmwareDriver(TRUE
, TRUE
, TRUE
))
647 PostMessage(hInstallationNotifyWnd
, WM_INSTABORT
, IDS_FAILEDTOACTIVATEDRIVER
, 0);
657 SendMessage(hInstallationNotifyWnd
, WM_INSTCOMPLETE
, 0, 0);
660 SendMessage(hInstallationNotifyWnd
, WM_INSTABORT
, 0, 0);
665 hThread
= (HANDLE
)InterlockedExchange((LONG
*)&hInstallationThread
, 0);
668 CloseHandle(hThread
);
674 InstStartInstallationThread(HWND hwndNotify
)
676 if(hInstallationThread
== NULL
)
679 hInstallationNotifyWnd
= hwndNotify
;
681 hInstallationThread
= CreateThread(NULL
,
683 InstInstallationThread
,
687 if(hInstallationThread
== NULL
)
692 ResumeThread(hInstallationThread
);
699 /* Property page dialog callback */
712 LPNMHDR pnmh
= (LPNMHDR
)lParam
;
716 SetDlgItemText(hwndDlg
, IDC_INSTALLINGSTATUS
, NULL
);
717 SendDlgItemMessage(hwndDlg
, IDC_INSTALLINGPROGRESS
, PBM_SETMARQUEE
, TRUE
, 50);
718 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_BACK
);
719 InstStartInstallationThread(hwndDlg
);
722 InstTerminateInstaller(TRUE
);
725 if(hInstallationThread
!= NULL
)
727 PropSheet_SetWizButtons(GetParent(hwndDlg
), 0);
728 InstTerminateInstaller(FALSE
);
729 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, -1);
734 SendDlgItemMessage(hwndDlg
, IDC_INSTALLINGPROGRESS
, PBM_SETMARQUEE
, FALSE
, 0);
735 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_INSERT_VMWARE_TOOLS
);
742 /* go back in case we aborted the installation thread */
743 SendDlgItemMessage(hwndDlg
, IDC_INSTALLINGPROGRESS
, PBM_SETMARQUEE
, FALSE
, 0);
744 PropSheet_SetCurSelByID(GetParent(hwndDlg
), IDD_INSERT_VMWARE_TOOLS
);
748 LoadString(hAppInstance
, wParam
, Msg
, sizeof(Msg
) / sizeof(WCHAR
));
749 MessageBox(GetParent(hwndDlg
), Msg
, NULL
, MB_ICONWARNING
);
752 case WM_INSTCOMPLETE
:
753 SendDlgItemMessage(hwndDlg
, IDC_INSTALLINGPROGRESS
, PBM_SETMARQUEE
, FALSE
, 0);
754 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_BACK
| PSWIZB_NEXT
);
755 PropSheet_SetCurSelByID(GetParent(hwndDlg
), IDD_CONFIG
);
757 case WM_INSTSTATUSUPDATE
:
760 LoadString(hAppInstance
, wParam
, Msg
, sizeof(Msg
) / sizeof(WCHAR
));
761 SetDlgItemText(hwndDlg
, IDC_INSTALLINGSTATUS
, Msg
);
768 /* Property page dialog callback */
770 PageInstallFailedProc(
781 LPNMHDR pnmh
= (LPNMHDR
)lParam
;
785 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_FINISH
);
795 FillComboBox(HWND Dlg
, int idComboBox
, int From
, int To
)
800 for(i
= From
; i
<= To
; i
++)
802 if(LoadString(hAppInstance
, i
, Text
, 255) > 0)
804 SendDlgItemMessage(Dlg
, idComboBox
, CB_ADDSTRING
, 0, (LPARAM
)Text
);
816 /* Property page dialog callback */
829 DWORD ResX
= 0, ResY
= 0, ColDepth
= 0;
832 FillComboBox(hwndDlg
, IDC_COLORQUALITY
, 10001, 10003);
833 if(LoadResolutionSettings(&ResX
, &ResY
, &ColDepth
))
835 SendDlgItemMessage(hwndDlg
, ResX
+ ResY
, BM_SETCHECK
, BST_CHECKED
, 0);
851 SendDlgItemMessage(hwndDlg
, IDC_COLORQUALITY
, CB_SETCURSEL
, cbSel
, 0);
859 /* Center the wizard window */
860 hwndControl
= GetParent(hwndDlg
);
861 CenterWindow (hwndControl
);
863 LPNMHDR pnmh
= (LPNMHDR
)lParam
;
868 PropSheet_SetWizButtons(GetParent(hwndDlg
), ((StartVMwConfigWizard
|| DriverFilesFound
) ? PSWIZB_FINISH
| PSWIZB_BACK
: PSWIZB_FINISH
));
873 if(StartVMwConfigWizard
)
875 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_CHOOSEACTION
);
880 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_WELCOMEPAGE
);
887 DWORD rx
= 800, ry
= 600, cd
= 32;
889 static MAPCTLRES Resolutions
[11] = {
902 for(i
= 0; i
< 11; i
++)
904 if(SendDlgItemMessage(hwndDlg
, Resolutions
[i
].ControlID
, BM_GETCHECK
, 0, 0) == BST_CHECKED
)
906 rx
= Resolutions
[i
].ResX
;
907 ry
= Resolutions
[i
].ResY
;
912 switch(SendDlgItemMessage(hwndDlg
, IDC_COLORQUALITY
, CB_GETCURSEL
, 0, 0))
925 SaveResolutionSettings(rx
, ry
, cd
);
935 /* Property page dialog callback */
937 PageChooseActionProc(
947 SendDlgItemMessage(hwndDlg
, IDC_CONFIGSETTINGS
, BM_SETCHECK
, BST_CHECKED
, 0);
951 LPNMHDR pnmh
= (LPNMHDR
)lParam
;
955 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_NEXT
);
959 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_CHOOSEACTION
);
964 static ULONG SelPage
[4] = {IDD_CONFIG
, IDD_SELECTDRIVER
, IDD_SELECTDRIVER
, IDD_CHOOSEACTION
};
967 for(i
= IDC_CONFIGSETTINGS
; i
<= IDC_UNINSTALL
; i
++)
969 if(SendDlgItemMessage(hwndDlg
, i
, BM_GETCHECK
, 0, 0) == BST_CHECKED
)
975 UninstallDriver
= (i
== IDC_UNINSTALL
);
977 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, SelPage
[i
- IDC_CONFIGSETTINGS
]);
987 /* Property page dialog callback */
989 PageSelectDriverProc(
999 SendDlgItemMessage(hwndDlg
, IDC_VBE
, BM_SETCHECK
, BST_CHECKED
, 0);
1003 LPNMHDR pnmh
= (LPNMHDR
)lParam
;
1007 PropSheet_SetWizButtons(GetParent(hwndDlg
), (UninstallDriver
? PSWIZB_NEXT
| PSWIZB_BACK
: PSWIZB_BACK
| PSWIZB_FINISH
));
1011 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_CHOOSEACTION
);
1016 ActivateVBE
= (SendDlgItemMessage(hwndDlg
, IDC_VBE
, BM_GETCHECK
, 0, 0) == BST_CHECKED
);
1030 ActivateVBE
= (SendDlgItemMessage(hwndDlg
, IDC_VBE
, BM_GETCHECK
, 0, 0) == BST_CHECKED
);
1031 if(!EnableVmwareDriver(ActivateVBE
,
1036 LoadString(hAppInstance
, (ActivateVBE
? IDS_FAILEDTOSELVBEDRIVER
: IDS_FAILEDTOSELVGADRIVER
), Msg
, sizeof(Msg
) / sizeof(WCHAR
));
1037 MessageBox(GetParent(hwndDlg
), Msg
, NULL
, MB_ICONWARNING
);
1038 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_SELECTDRIVER
);
1051 ShowUninstNotice(HWND Owner
)
1054 LoadString(hAppInstance
, IDS_UNINSTNOTICE
, Msg
, sizeof(Msg
) / sizeof(WCHAR
));
1055 MessageBox(Owner
, Msg
, NULL
, MB_ICONINFORMATION
);
1059 PageDoUninstallProc(
1070 LPNMHDR pnmh
= (LPNMHDR
)lParam
;
1074 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_BACK
| PSWIZB_FINISH
);
1080 if(!EnableVmwareDriver(ActivateVBE
,
1085 LoadString(hAppInstance
, (ActivateVBE
? IDS_FAILEDTOSELVBEDRIVER
: IDS_FAILEDTOSELVGADRIVER
), Msg
, sizeof(Msg
) / sizeof(WCHAR
));
1086 MessageBox(GetParent(hwndDlg
), Msg
, NULL
, MB_ICONWARNING
);
1087 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, IDD_SELECTDRIVER
);
1090 ShowUninstNotice(GetParent(hwndDlg
));
1104 PROPSHEETHEADER psh
;
1105 HPROPSHEETPAGE ahpsp
[8];
1107 WCHAR Caption
[1024];
1109 LoadString(hAppInstance
, IDS_WIZARD_NAME
, Caption
, sizeof(Caption
) / sizeof(TCHAR
));
1111 /* Create the Welcome page */
1112 ZeroMemory (&psp
, sizeof(PROPSHEETPAGE
));
1113 psp
.dwSize
= sizeof(PROPSHEETPAGE
);
1114 psp
.dwFlags
= PSP_DEFAULT
| PSP_HIDEHEADER
;
1115 psp
.hInstance
= hAppInstance
;
1116 psp
.pfnDlgProc
= PageWelcomeProc
;
1117 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_WELCOMEPAGE
);
1118 ahpsp
[0] = CreatePropertySheetPage(&psp
);
1120 /* Create the INSERT_VMWARE_TOOLS page */
1121 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1122 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDD_INSERT_VMWARE_TOOLSTITLE
);
1123 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDD_INSERT_VMWARE_TOOLSSUBTITLE
);
1124 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_INSERT_VMWARE_TOOLS
);
1125 psp
.pfnDlgProc
= PageInsertDiscProc
;
1126 ahpsp
[1] = CreatePropertySheetPage(&psp
);
1128 /* Create the INSTALLING_VMWARE_TOOLS page */
1129 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1130 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDD_INSTALLING_VMWARE_TOOLSTITLE
);
1131 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDD_INSTALLING_VMWARE_TOOLSSUBTITLE
);
1132 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_INSTALLING_VMWARE_TOOLS
);
1133 psp
.pfnDlgProc
= PageInstallingProc
;
1134 ahpsp
[2] = CreatePropertySheetPage(&psp
);
1136 /* Create the CONFIG page */
1137 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1138 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDD_CONFIGTITLE
);
1139 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDD_CONFIGSUBTITLE
);
1140 psp
.pfnDlgProc
= PageConfigProc
;
1141 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_CONFIG
);
1142 ahpsp
[3] = CreatePropertySheetPage(&psp
);
1144 /* Create the INSTALLATION_FAILED page */
1145 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1146 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDD_INSTALLATION_FAILEDTITLE
);
1147 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDD_INSTALLATION_FAILEDSUBTITLE
);
1148 psp
.pfnDlgProc
= PageInstallFailedProc
;
1149 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_INSTALLATION_FAILED
);
1150 ahpsp
[4] = CreatePropertySheetPage(&psp
);
1152 /* Create the CHOOSEACTION page */
1153 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1154 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDD_CHOOSEACTIONTITLE
);
1155 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDD_CHOOSEACTIONSUBTITLE
);
1156 psp
.pfnDlgProc
= PageChooseActionProc
;
1157 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_CHOOSEACTION
);
1158 ahpsp
[5] = CreatePropertySheetPage(&psp
);
1160 /* Create the SELECTDRIVER page */
1161 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1162 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDD_SELECTDRIVERTITLE
);
1163 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDD_SELECTDRIVERSUBTITLE
);
1164 psp
.pfnDlgProc
= PageSelectDriverProc
;
1165 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_SELECTDRIVER
);
1166 ahpsp
[6] = CreatePropertySheetPage(&psp
);
1168 /* Create the DOUNINSTALL page */
1169 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1170 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDD_DOUNINSTALLTITLE
);
1171 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDD_DOUNINSTALLSUBTITLE
);
1172 psp
.pfnDlgProc
= PageDoUninstallProc
;
1173 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_DOUNINSTALL
);
1174 ahpsp
[7] = CreatePropertySheetPage(&psp
);
1176 /* Create the property sheet */
1177 psh
.dwSize
= sizeof(PROPSHEETHEADER
);
1178 psh
.dwFlags
= PSH_WIZARD97
| PSH_WATERMARK
| PSH_HEADER
;
1179 psh
.hInstance
= hAppInstance
;
1180 psh
.hwndParent
= NULL
;
1182 psh
.nStartPage
= (StartVMwConfigWizard
? 5 : 0);
1184 psh
.pszbmWatermark
= MAKEINTRESOURCE(IDB_WATERMARK
);
1185 psh
.pszbmHeader
= MAKEINTRESOURCE(IDB_HEADER
);
1187 /* Display the wizard */
1188 return (LONG
)(PropertySheet(&psh
) != -1);
1192 WinMain(HINSTANCE hInstance
,
1193 HINSTANCE hPrevInstance
,
1198 PVOID ExceptionHandler
;
1202 hAppInstance
= hInstance
;
1204 /* Setup a vectored exception handler to protect the detection. Don't use SEH
1205 here so we notice the next time someone removes support for vectored
1206 exception handling from ros... */
1207 if (!(ExceptionHandler
= AddVectoredExceptionHandler(0,
1208 VectoredExceptionHandler
)))
1213 if(!DetectVMware(&Version
))
1218 /* unregister the handler */
1219 RemoveVectoredExceptionHandler(ExceptionHandler
);
1221 lc
= DestinationPath
;
1222 lc
+= GetSystemDirectory(DestinationPath
, MAX_PATH
) - 1;
1223 if(lc
>= DestinationPath
&& *lc
!= L
'\\')
1225 wcscat(DestinationPath
, L
"\\");
1227 DestinationDriversPath
[0] = L
'\0';
1228 wcscat(DestinationDriversPath
, DestinationPath
);
1229 wcscat(DestinationDriversPath
, L
"drivers\\");
1231 SetCurrentDirectory(DestinationPath
);
1233 DriverFilesFound
= FileExists(DestinationPath
, vmx_fb
) &&
1234 FileExists(DestinationPath
, vmx_mode
) &&
1235 FileExists(DestinationDriversPath
, vmx_svga
);
1237 StartVMwConfigWizard
= DriverFilesFound
&& IsVmwSVGAEnabled();
1239 /* Show the wizard */