Changeset 32687 in vbox for trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxSeamless.cpp
- Timestamp:
- Sep 22, 2010 8:40:24 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxSeamless.cpp
r32249 r32687 5 5 6 6 /* 7 * Copyright (C) 2006-20 07Oracle Corporation7 * Copyright (C) 2006-2010 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 23 23 #include <VBox/VMMDev.h> 24 24 #include <iprt/assert.h> 25 #include <VBoxGuestInternal.h> 25 26 #include "helpers.h" 26 27 … … 61 62 GetVersionEx (&OSinfo); 62 63 64 int rc = VINF_SUCCESS; 65 63 66 /* We have to jump out here when using NT4, otherwise it complains about 64 67 a missing API function "UnhookWinEvent" used by the dynamically loaded VBoxHook.dll below */ … … 66 69 { 67 70 Log(("VBoxTray: VBoxSeamlessInit: Windows NT 4.0 or older not supported!\n")); 68 return VERR_NOT_SUPPORTED; 69 } 70 71 /* Will fail if SetWinEventHook is not present (version < NT4 SP6 apparently) */ 72 gCtx.hModule = LoadLibrary(VBOXHOOK_DLL_NAME); 73 if (gCtx.hModule) 74 { 75 *(uintptr_t *)&gCtx.pfnVBoxInstallHook = (uintptr_t)GetProcAddress(gCtx.hModule, "VBoxInstallHook"); 76 *(uintptr_t *)&gCtx.pfnVBoxRemoveHook = (uintptr_t)GetProcAddress(gCtx.hModule, "VBoxRemoveHook"); 77 78 /* inform the host that we support the seamless window mode */ 79 VMMDevReqGuestCapabilities vmmreqGuestCaps = {0}; 80 vmmdevInitRequest((VMMDevRequestHeader*)&vmmreqGuestCaps, VMMDevReq_ReportGuestCapabilities); 81 vmmreqGuestCaps.caps = VMMDEV_GUEST_SUPPORTS_SEAMLESS; 82 83 DWORD cbReturned; 84 if (!DeviceIoControl(pEnv->hDriver, VBOXGUEST_IOCTL_VMMREQUEST(sizeof(vmmreqGuestCaps)), &vmmreqGuestCaps, sizeof(vmmreqGuestCaps), 85 &vmmreqGuestCaps, sizeof(vmmreqGuestCaps), &cbReturned, NULL)) 86 { 87 Log(("VBoxTray: VBoxSeamlessInit: VMMDevReq_ReportGuestCapabilities: error doing IOCTL, last error: %d\n", GetLastError())); 88 return VERR_INVALID_PARAMETER; 89 } 90 91 *pfStartThread = true; 92 *ppInstance = &gCtx; 93 return VINF_SUCCESS; 71 rc = VERR_NOT_SUPPORTED; 94 72 } 95 73 else 96 74 { 97 Log(("VBoxTray: VBoxSeamlessInit: LoadLibrary failed with %d\n", GetLastError())); 98 return VERR_INVALID_PARAMETER; 99 } 100 101 return VINF_SUCCESS; 75 /* Will fail if SetWinEventHook is not present (version < NT4 SP6 apparently) */ 76 gCtx.hModule = LoadLibrary(VBOXHOOK_DLL_NAME); 77 if (gCtx.hModule) 78 { 79 *(uintptr_t *)&gCtx.pfnVBoxInstallHook = (uintptr_t)GetProcAddress(gCtx.hModule, "VBoxInstallHook"); 80 *(uintptr_t *)&gCtx.pfnVBoxRemoveHook = (uintptr_t)GetProcAddress(gCtx.hModule, "VBoxRemoveHook"); 81 82 /* Inform the host that we support the seamless window mode. */ 83 rc = VbglR3SetGuestCaps(VMMDEV_GUEST_SUPPORTS_SEAMLESS, 0); 84 if (RT_SUCCESS(rc)) 85 { 86 *pfStartThread = true; 87 *ppInstance = &gCtx; 88 } 89 else 90 Log(("VBoxTray: VBoxSeamlessInit: Failed to set seamless capability\n")); 91 } 92 else 93 { 94 rc = RTErrConvertFromWin32(GetLastError()); 95 Log(("VBoxTray: VBoxSeamlessInit: LoadLibrary of \"%s\" failed with rc=%Rrc\n", VBOXHOOK_DLL_NAME, rc)); 96 } 97 } 98 99 return rc; 102 100 } 103 101 … … 106 104 { 107 105 Log(("VBoxTray: VBoxSeamlessDestroy\n")); 108 /* inform the host that we no longer support the seamless window mode */ 109 VMMDevReqGuestCapabilities vmmreqGuestCaps = {0}; 110 vmmdevInitRequest((VMMDevRequestHeader*)&vmmreqGuestCaps, VMMDevReq_ReportGuestCapabilities); 111 vmmreqGuestCaps.caps = 0; 112 113 DWORD cbReturned; 114 if (!DeviceIoControl(pEnv->hDriver, VBOXGUEST_IOCTL_VMMREQUEST(sizeof(vmmreqGuestCaps)), &vmmreqGuestCaps, sizeof(vmmreqGuestCaps), 115 &vmmreqGuestCaps, sizeof(vmmreqGuestCaps), &cbReturned, NULL)) 116 { 117 Log(("VBoxTray: VMMDevReq_ReportGuestCapabilities: error doing IOCTL, last error: %d\n", GetLastError())); 118 } 106 107 /* Inform the host that we no longer support the seamless window mode. */ 108 int rc = VbglR3SetGuestCaps(0, VMMDEV_GUEST_SUPPORTS_SEAMLESS); 109 if (RT_FAILURE(rc)) 110 Log(("VBoxTray: VBoxSeamlessDestroy: Failed to unset seamless capability, rc=%Rrc\n", rc)); 119 111 120 112 if (gCtx.pfnVBoxRemoveHook)
Note:
See TracChangeset
for help on using the changeset viewer.