Changeset 60255 in vbox for trunk/src/VBox/Additions/WINNT
- Timestamp:
- Mar 30, 2016 8:32:04 AM (9 years ago)
- Location:
- trunk/src/VBox/Additions/WINNT/VBoxCredProv
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/VBoxCredProv/Makefile.kmk
r56301 r60255 5 5 6 6 # 7 # Copyright (C) 2009-201 5Oracle Corporation7 # Copyright (C) 2009-2016 Oracle Corporation 8 8 # 9 9 # This file is part of VirtualBox Open Source Edition (OSE), as … … 19 19 include $(KBUILD_PATH)/subheader.kmk 20 20 21 # Do we want to use Windows SENS (System Event Notification Service)? 22 VBOX_WITH_WIN_SENS := 1 23 21 24 DLLS += VBoxCredProv 22 25 VBoxCredProv_TEMPLATE = VBOXGUESTR3DLL 23 VBoxCredProv_DEFS = VBGL_VBOXGUEST VBOX_WITH_HGCM VBOX_WITH_SENS UNICODE 26 VBoxCredProv_DEFS = VBGL_VBOXGUEST VBOX_WITH_HGCM UNICODE 27 ifdef VBOX_WITH_WIN_SENS 28 VBoxService_DEFS += VBOX_WITH_WIN_SENS 29 endif 24 30 VBoxCredProv_SDKS = ReorderCompilerIncs $(VBOX_WINPSDK_GST_WLH) 25 31 VBoxCredProv_SOURCES = \ … … 33 39 VBoxCredProvUtils.cpp 34 40 41 ifdef VBOX_WITH_WIN_SENS 42 # To use com::Bstr for BSTR handling. 43 VBoxCredProv_SOURCES += \ 44 $(PATH_ROOT)/src/VBox/Main/glue/string.cpp 45 endif 46 35 47 VBoxCredProv_LIBS = \ 36 48 $(VBOX_LIB_IPRT_GUEST_R3) \ -
trunk/src/VBox/Additions/WINNT/VBoxCredProv/VBoxCredentialProvider.cpp
r57358 r60255 5 5 6 6 /* 7 * Copyright (C) 2012-201 4Oracle Corporation7 * Copyright (C) 2012-2016 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 24 24 #include <new> /* For bad_alloc. */ 25 25 26 #ifdef VBOX_WITH_ SENS26 #ifdef VBOX_WITH_WIN_SENS 27 27 # include <eventsys.h> 28 28 # include <sens.h> … … 32 32 #include <iprt/buildconfig.h> 33 33 #include <iprt/initterm.h> 34 #ifdef VBOX_WITH_SENS 35 # include <iprt/string.h> 34 #ifdef VBOX_WITH_WIN_SENS 35 # include <VBox/com/string.h> 36 using namespace com; 36 37 #endif 37 38 #include <VBox/VBoxGuestLib.h> … … 47 48 static HINSTANCE g_hDllInst = NULL; /**< Global DLL hInstance. */ 48 49 49 #ifdef VBOX_WITH_ SENS50 #ifdef VBOX_WITH_WIN_SENS 50 51 static bool g_fSENSEnabled = false; 51 52 static IEventSystem *g_pIEventSystem = NULL; /**< Pointer to IEventSystem interface. */ … … 199 200 if (FAILED(hr)) 200 201 { 201 VBoxCredProvVerbose(0, "VBoxCredentialProviderRegisterSENS: Could not connect to CEventSystem, hr=%Rhrc\n", 202 hr); 202 VBoxCredProvVerbose(0, "VBoxCredentialProviderRegisterSENS: Could not connect to CEventSystem, hr=%Rhrc\n", hr); 203 203 return hr; 204 204 } 205 205 206 /* Note: Bstr class can also throw -- therefore including the setup procedure in the following try block as well. */ 206 207 try 207 208 { 208 209 g_pISensLogon = new VBoxCredProvSensLogon(); 210 211 AssertPtr(g_pIEventSystem); 209 212 AssertPtr(g_pISensLogon); 210 } 211 catch (std::bad_alloc &ex) 212 { 213 NOREF(ex); 214 hr = E_OUTOFMEMORY; 215 } 216 217 if ( SUCCEEDED(hr) 218 && g_pIEventSystem) 219 { 213 220 214 IEventSubscription *pIEventSubscription; 221 215 int i; … … 229 223 continue; 230 224 231 hr = pIEventSubscription->put_EventClassID( L"{d5978630-5b9f-11d1-8dd2-00aa004abd5e}" /* SENSGUID_EVENTCLASS_LOGON */);225 hr = pIEventSubscription->put_EventClassID(Bstr("{d5978630-5b9f-11d1-8dd2-00aa004abd5e}" /* SENSGUID_EVENTCLASS_LOGON */).raw()); 232 226 if (FAILED(hr)) 233 227 break; … … 237 231 break; 238 232 239 PRTUTF16 pwszTemp; 240 int rc = RTStrToUtf16(g_aSENSEvents[i].pszMethod, &pwszTemp); 241 if (RT_SUCCESS(rc)) 242 { 243 hr = pIEventSubscription->put_MethodName(pwszTemp); 244 RTUtf16Free(pwszTemp); 245 } 246 else 247 hr = ERROR_OUTOFMEMORY; 248 if (FAILED(hr)) 249 break; 250 251 rc = RTStrToUtf16(g_aSENSEvents[i].pszSubscriptionName, &pwszTemp); 252 if (RT_SUCCESS(rc)) 253 { 254 hr = pIEventSubscription->put_SubscriptionName(pwszTemp); 255 RTUtf16Free(pwszTemp); 256 } 257 else 258 hr = ERROR_OUTOFMEMORY; 259 if (FAILED(hr)) 260 break; 261 262 rc = RTStrToUtf16(g_aSENSEvents[i].pszSubscriptionUUID, &pwszTemp); 263 if (RT_SUCCESS(rc)) 264 { 265 hr = pIEventSubscription->put_SubscriptionID(pwszTemp); 266 RTUtf16Free(pwszTemp); 267 } 268 else 269 hr = ERROR_OUTOFMEMORY; 233 hr = pIEventSubscription->put_MethodName(Bstr(g_aSENSEvents[i].pszMethod).raw()); 234 if (FAILED(hr)) 235 break; 236 237 hr = pIEventSubscription->put_SubscriptionName(Bstr(g_aSENSEvents[i].pszSubscriptionName).raw()); 238 if (FAILED(hr)) 239 break; 240 241 hr = pIEventSubscription->put_SubscriptionID(Bstr(g_aSENSEvents[i].pszSubscriptionUUID).raw()); 270 242 if (FAILED(hr)) 271 243 break; … … 290 262 pIEventSubscription->Release(); 291 263 } 264 catch (std::bad_alloc &ex) 265 { 266 NOREF(ex); 267 hr = E_OUTOFMEMORY; 268 } 292 269 293 270 if (FAILED(hr)) 294 271 { 295 272 VBoxCredProvVerbose(0, "VBoxCredentialProviderRegisterSENS: Error registering SENS provider, hr=%Rhrc\n", hr); 273 274 if (g_pISensLogon) 275 { 276 delete g_pISensLogon; 277 g_pISensLogon = NULL; 278 } 279 296 280 if (g_pIEventSystem) 297 281 { … … 320 304 HRESULT hr = CoCreateInstance(CLSID_CEventSystem, 0, 321 305 CLSCTX_SERVER, IID_IEventSystem, (void**)&g_pIEventSystem); 322 if ( SUCCEEDED(hr) 323 && g_pIEventSystem) 306 if (FAILED(hr)) 307 VBoxCredProvVerbose(0, "VBoxCredentialProviderUnregisterSENS: Could not reconnect to CEventSystem, hr=%Rhrc\n", hr); 308 309 try 324 310 { 325 311 VBoxCredProvVerbose(0, "VBoxCredentialProviderUnregisterSENS\n"); … … 329 315 for (int i = 0; i < RT_ELEMENTS(g_aSENSEvents); i++) 330 316 { 331 int iErrorIdX; 332 333 char *pszSubToRemove; 334 if (!RTStrAPrintf(&pszSubToRemove, "SubscriptionID=%s", 335 g_aSENSEvents[i].pszSubscriptionUUID)) 317 int iErrorIdX; 318 Bstr strSubToRemove = Utf8StrFmt("SubscriptionID=%s", g_aSENSEvents[i].pszSubscriptionUUID); 319 hr = g_pIEventSystem->Remove(PROGID_EventSubscription, strSubToRemove.raw(), &iErrorIdX); 320 if (FAILED(hr)) 336 321 { 337 continue; /* Keep going. */ 322 VBoxCredProvVerbose(0, "VBoxCredentialProviderUnregisterSENS: Could not unregister \"%s\" (query: %ls), hr=%Rhrc (index: %d)\n", 323 g_aSENSEvents[i].pszMethod, strSubToRemove.raw(), hr, iErrorIdX); 324 /* Keep going. */ 338 325 } 339 340 PRTUTF16 pwszTemp; 341 int rc2 = RTStrToUtf16(pszSubToRemove, &pwszTemp); 342 if (RT_SUCCESS(rc2)) 343 { 344 hr = g_pIEventSystem->Remove(PROGID_EventSubscription, pwszTemp, 345 &iErrorIdX); 346 RTUtf16Free(pwszTemp); 347 } 348 else 349 hr = ERROR_OUTOFMEMORY; 350 351 if (FAILED(hr)) 352 VBoxCredProvVerbose(0, "VBoxCredentialProviderUnregisterSENS: Could not unregister \"%s\" (query: %s), hr=%Rhrc (index: %d)\n", 353 g_aSENSEvents[i].pszMethod, pszSubToRemove, hr, iErrorIdX); 354 /* Keep going. */ 355 356 RTStrFree(pszSubToRemove); 357 } 358 326 } 327 } 328 catch (std::bad_alloc &ex) 329 { 330 NOREF(ex); 331 hr = E_OUTOFMEMORY; 332 } 333 334 if (g_pISensLogon) 335 { 336 delete g_pISensLogon; 337 g_pISensLogon = NULL; 338 } 339 340 if (g_pIEventSystem) 341 { 359 342 g_pIEventSystem->Release(); 360 343 g_pIEventSystem = NULL; 361 344 } 362 345 363 if (g_pISensLogon)364 {365 delete g_pISensLogon;366 g_pISensLogon = NULL;367 }368 369 346 VBoxCredProvVerbose(0, "VBoxCredentialProviderUnregisterSENS: Returning hr=%Rhrc\n", hr); 370 347 } 371 #endif /* VBOX_WITH_ SENS */348 #endif /* VBOX_WITH_WIN_SENS */ 372 349 373 350 … … 461 438 g_cDllRefs); 462 439 463 #ifdef VBOX_WITH_ SENS440 #ifdef VBOX_WITH_WIN_SENS 464 441 if (!g_cDllRefs) 465 442 { … … 499 476 pFactory->Release(); 500 477 501 #ifdef VBOX_WITH_ SENS478 #ifdef VBOX_WITH_WIN_SENS 502 479 g_fSENSEnabled = true; /* By default SENS support is enabled. */ 503 480 … … 533 510 #else 534 511 VBoxCredProvVerbose(0, "VBoxCredentialProviderCreate: SENS support is disabled\n"); 535 #endif 512 #endif /* VBOX_WITH_WIN_SENS */ 536 513 } 537 514 catch (std::bad_alloc &ex)
Note:
See TracChangeset
for help on using the changeset viewer.