Changeset 45802 in vbox for trunk/src/VBox/Additions/WINNT/VBoxTray
- Timestamp:
- Apr 29, 2013 8:46:41 AM (12 years ago)
- Location:
- trunk/src/VBox/Additions/WINNT/VBoxTray
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxTray.cpp
r45779 r45802 80 80 static BOOL vboxDtIsInputDesktop(); 81 81 static HANDLE vboxDtGetNotifyEvent(); 82 static BOOL vboxDtCheckTimer(WPARAM wParam); 82 83 83 84 /* caps API */ … … 617 618 } 618 619 620 static void VBoxTrayCheckDt() 621 { 622 BOOL fOldAllowedState = VBoxConsoleIsAllowed(); 623 if (vboxDtHandleEvent()) 624 { 625 if (!VBoxConsoleIsAllowed() != !fOldAllowedState) 626 VBoxConsoleEnable(!fOldAllowedState); 627 } 628 } 629 619 630 static int vboxTrayServiceMain(void) 620 631 { … … 738 749 { 739 750 Log(("VBoxTray: Event 'Dt' triggered\n")); 740 BOOL fOldAllowedState = VBoxConsoleIsAllowed(); 741 if (vboxDtHandleEvent()) 742 { 743 if (!VBoxConsoleIsAllowed() != !fOldAllowedState) 744 VBoxConsoleEnable(!fOldAllowedState); 745 } 751 VBoxTrayCheckDt(); 746 752 fHandled = TRUE; 747 753 } … … 909 915 if (VBoxCapsCheckTimer(wParam)) 910 916 return 0; 917 if(vboxDtCheckTimer(wParam)) 918 return 0; 911 919 912 920 switch (wParam) … … 1158 1166 HANDLE hNotifyEvent; 1159 1167 BOOL fIsInputDesktop; 1168 UINT_PTR idTimer; 1160 1169 HMODULE hHookModule; 1161 1170 BOOL (* pfnVBoxHookInstallActiveDesktopTracker)(HMODULE hDll); … … 1196 1205 return fIsInputDt; 1197 1206 } 1207 1208 static BOOL vboxDtCheckTimer(WPARAM wParam) 1209 { 1210 if (wParam != gVBoxDt.idTimer) 1211 return FALSE; 1212 1213 VBoxTrayCheckDt(); 1214 1215 return TRUE; 1216 } 1217 1198 1218 static int vboxDtInit() 1199 1219 { … … 1210 1230 memset(&gVBoxDt, 0, sizeof (gVBoxDt)); 1211 1231 1212 /* For Vista and up we need to change the integrity of the security descriptor, too. */ 1213 if (gMajorVersion >= 6) 1214 { 1215 gVBoxDt.hNotifyEvent = CreateEvent(NULL, FALSE, FALSE, VBOXHOOK_GLOBAL_DT_EVENT_NAME); 1216 if (gVBoxDt.hNotifyEvent != NULL) 1217 { 1218 gVBoxDt.hHookModule = LoadLibrary(VBOXHOOK_DLL_NAME); 1219 if (gVBoxDt.hHookModule) 1220 { 1221 *(uintptr_t *)&gVBoxDt.pfnVBoxHookInstallActiveDesktopTracker = (uintptr_t)GetProcAddress(gVBoxDt.hHookModule, "VBoxHookInstallActiveDesktopTracker"); 1222 if (!gVBoxDt.pfnVBoxHookInstallActiveDesktopTracker) 1232 gVBoxDt.hNotifyEvent = CreateEvent(NULL, FALSE, FALSE, VBOXHOOK_GLOBAL_DT_EVENT_NAME); 1233 if (gVBoxDt.hNotifyEvent != NULL) 1234 { 1235 gVBoxDt.hHookModule = LoadLibrary(VBOXHOOK_DLL_NAME); 1236 if (gVBoxDt.hHookModule) 1237 { 1238 *(uintptr_t *)&gVBoxDt.pfnVBoxHookInstallActiveDesktopTracker = (uintptr_t)GetProcAddress(gVBoxDt.hHookModule, "VBoxHookInstallActiveDesktopTracker"); 1239 if (!gVBoxDt.pfnVBoxHookInstallActiveDesktopTracker) 1240 { 1241 WARN(("VBoxTray: VBoxHookInstallActiveDesktopTracker not found\n")); 1242 rc = VERR_NOT_SUPPORTED; 1243 } 1244 1245 *(uintptr_t *)&gVBoxDt.pfnVBoxHookRemoveActiveDesktopTracker = (uintptr_t)GetProcAddress(gVBoxDt.hHookModule, "VBoxHookInstallActiveDesktopTracker"); 1246 if (!gVBoxDt.pfnVBoxHookRemoveActiveDesktopTracker) 1247 { 1248 WARN(("VBoxTray: VBoxHookRemoveActiveDesktopTracker not found\n")); 1249 rc = VERR_NOT_SUPPORTED; 1250 } 1251 1252 if (VINF_SUCCESS == rc) 1253 { 1254 gVBoxDt.hUSER32 = LoadLibrary("User32.dll"); 1255 if (gVBoxDt.hUSER32) 1223 1256 { 1224 WARN(("VBoxTray: VBoxHookInstallActiveDesktopTracker not found\n")); 1225 rc = VERR_NOT_SUPPORTED; 1226 } 1227 1228 *(uintptr_t *)&gVBoxDt.pfnVBoxHookRemoveActiveDesktopTracker = (uintptr_t)GetProcAddress(gVBoxDt.hHookModule, "VBoxHookInstallActiveDesktopTracker"); 1229 if (!gVBoxDt.pfnVBoxHookRemoveActiveDesktopTracker) 1230 { 1231 WARN(("VBoxTray: VBoxHookRemoveActiveDesktopTracker not found\n")); 1232 rc = VERR_NOT_SUPPORTED; 1233 } 1234 1235 if (VINF_SUCCESS == rc) 1236 { 1237 gVBoxDt.hUSER32 = LoadLibrary("User32.dll"); 1238 if (gVBoxDt.hUSER32) 1257 *(uintptr_t *)&gVBoxDt.pfnGetThreadDesktop = (uintptr_t)GetProcAddress(gVBoxDt.hUSER32, "GetThreadDesktop"); 1258 if (!gVBoxDt.pfnGetThreadDesktop) 1239 1259 { 1240 *(uintptr_t *)&gVBoxDt.pfnGetThreadDesktop = (uintptr_t)GetProcAddress(gVBoxDt.hUSER32, "GetThreadDesktop"); 1241 if (!gVBoxDt.pfnGetThreadDesktop) 1260 WARN(("VBoxTray: GetThreadDesktop not found\n")); 1261 rc = VERR_NOT_SUPPORTED; 1262 } 1263 1264 *(uintptr_t *)&gVBoxDt.pfnOpenInputDesktop = (uintptr_t)GetProcAddress(gVBoxDt.hUSER32, "OpenInputDesktop"); 1265 if (!gVBoxDt.pfnOpenInputDesktop) 1266 { 1267 WARN(("VBoxTray: OpenInputDesktop not found\n")); 1268 rc = VERR_NOT_SUPPORTED; 1269 } 1270 1271 *(uintptr_t *)&gVBoxDt.pfnCloseDesktop = (uintptr_t)GetProcAddress(gVBoxDt.hUSER32, "CloseDesktop"); 1272 if (!gVBoxDt.pfnCloseDesktop) 1273 { 1274 WARN(("VBoxTray: CloseDesktop not found\n")); 1275 rc = VERR_NOT_SUPPORTED; 1276 } 1277 1278 if (VINF_SUCCESS == rc) 1279 { 1280 BOOL bRc = FALSE; 1281 /* For Vista and up we need to change the integrity of the security descriptor, too. */ 1282 if (gMajorVersion >= 6) 1242 1283 { 1243 WARN(("VBoxTray: GetThreadDesktop not found\n")); 1244 rc = VERR_NOT_SUPPORTED; 1284 bRc = gVBoxDt.pfnVBoxHookInstallActiveDesktopTracker(gVBoxDt.hHookModule); 1285 if (!bRc) 1286 { 1287 DWORD dwErr = GetLastError(); 1288 WARN(("VBoxTray: pfnVBoxHookInstallActiveDesktopTracker failed, last error = %08X\n", dwErr)); 1289 } 1245 1290 } 1246 1291 1247 *(uintptr_t *)&gVBoxDt.pfnOpenInputDesktop = (uintptr_t)GetProcAddress(gVBoxDt.hUSER32, "OpenInputDesktop"); 1248 if (!gVBoxDt.pfnOpenInputDesktop) 1292 if (!bRc) 1249 1293 { 1250 WARN(("VBoxTray: OpenInputDesktop not found\n")); 1251 rc = VERR_NOT_SUPPORTED; 1294 gVBoxDt.idTimer = SetTimer(ghwndToolWindow, TIMERID_VBOXTRAY_DT_TIMER, 500, (TIMERPROC)NULL); 1295 if (!gVBoxDt.idTimer) 1296 { 1297 DWORD dwErr = GetLastError(); 1298 WARN(("VBoxTray: SetTimer error %08X\n", dwErr)); 1299 rc = RTErrConvertFromWin32(dwErr); 1300 } 1252 1301 } 1253 1302 1254 *(uintptr_t *)&gVBoxDt.pfnCloseDesktop = (uintptr_t)GetProcAddress(gVBoxDt.hUSER32, "CloseDesktop"); 1255 if (!gVBoxDt.pfnCloseDesktop) 1303 if (RT_SUCCESS(rc)) 1256 1304 { 1257 WARN(("VBoxTray: CloseDesktop not found\n"));1258 rc = VERR_NOT_SUPPORTED;1259 }1260 1261 if (VINF_SUCCESS == rc)1262 {1263 gVBoxDt.pfnVBoxHookInstallActiveDesktopTracker(gVBoxDt.hHookModule);1264 1305 gVBoxDt.fIsInputDesktop = vboxDtCalculateIsInputDesktop(); 1265 1306 return VINF_SUCCESS; 1266 1307 } 1267 FreeLibrary(gVBoxDt.hUSER32);1268 1308 } 1309 FreeLibrary(gVBoxDt.hUSER32); 1269 1310 } 1270 1271 FreeLibrary(gVBoxDt.hHookModule); 1272 } 1273 else 1274 { 1275 DWORD dwErr = GetLastError(); 1276 WARN(("VBoxTray: CreateEvent for Seamless failed, last error = %08X\n", dwErr)); 1277 rc = RTErrConvertFromWin32(dwErr); 1278 } 1279 1280 CloseHandle(gVBoxDt.hNotifyEvent); 1311 } 1312 1313 FreeLibrary(gVBoxDt.hHookModule); 1281 1314 } 1282 1315 else … … 1286 1319 rc = RTErrConvertFromWin32(dwErr); 1287 1320 } 1288 } 1321 1322 CloseHandle(gVBoxDt.hNotifyEvent); 1323 } 1324 else 1325 { 1326 DWORD dwErr = GetLastError(); 1327 WARN(("VBoxTray: CreateEvent for Seamless failed, last error = %08X\n", dwErr)); 1328 rc = RTErrConvertFromWin32(dwErr); 1329 } 1330 1289 1331 1290 1332 memset(&gVBoxDt, 0, sizeof (gVBoxDt)); -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxTray.h
r45760 r45802 82 82 #define TIMERID_VBOXTRAY_CHECK_HOSTVERSION 1000 83 83 #define TIMERID_VBOXTRAY_CAPS_TIMER 1001 84 #define TIMERID_VBOXTRAY_DT_TIMER 1002 84 85 85 86 /* The environment information for services. */
Note:
See TracChangeset
for help on using the changeset viewer.