Changeset 46382 in vbox for trunk/src/VBox/Additions/WINNT
- Timestamp:
- Jun 4, 2013 1:32:38 PM (12 years ago)
- Location:
- trunk/src/VBox/Additions/WINNT/VBoxCredProv
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/VBoxCredProv/VBoxCredProvProvider.cpp
r40435 r46382 5 5 6 6 /* 7 * Copyright (C) 2012 Oracle Corporation7 * Copyright (C) 2012-2013 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 19 19 * Header Files * 20 20 *******************************************************************************/ 21 #include <new> /* For bad_alloc. */ 22 21 23 #include <credentialprovider.h> 24 22 25 #include <iprt/err.h> 23 26 #include <VBox/VBoxGuestLib.h> … … 236 239 if (!m_pPoller) 237 240 { 238 /** @todo try catch please. */ 239 m_pPoller = new VBoxCredProvPoller(); 240 AssertPtr(m_pPoller); 241 int rc = m_pPoller->Initialize(this); 242 if (RT_FAILURE(rc)) 243 VBoxCredProvVerbose(0, "VBoxCredProv::SetUsageScenario: Error initializing poller thread, rc=%Rrc\n", rc); 241 try 242 { 243 m_pPoller = new VBoxCredProvPoller(); 244 AssertPtr(m_pPoller); 245 int rc = m_pPoller->Initialize(this); 246 if (RT_FAILURE(rc)) 247 VBoxCredProvVerbose(0, "VBoxCredProv::SetUsageScenario: Error initializing poller thread, rc=%Rrc\n", rc); 248 } 249 catch (std::bad_alloc &ex) 250 { 251 NOREF(ex); 252 hr = E_OUTOFMEMORY; 253 } 244 254 } 245 255 246 if (!m_pCred) 256 if ( SUCCEEDED(hr) 257 && !m_pCred) 247 258 { 248 /** @todo try catch please. */ 249 m_pCred = new VBoxCredProvCredential(); 250 if (m_pCred) 259 try 260 { 261 m_pCred = new VBoxCredProvCredential(); 262 AssertPtr(m_pPoller); 251 263 hr = m_pCred->Initialize(m_enmUsageScenario); 252 else 264 } 265 catch (std::bad_alloc &ex) 266 { 267 NOREF(ex); 253 268 hr = E_OUTOFMEMORY; 269 } 254 270 } 255 271 else … … 524 540 HRESULT hr; 525 541 526 /** @todo try-catch. */527 VBoxCredProvProvider *pProvider = new VBoxCredProvProvider();528 if (pProvider)529 {542 try 543 { 544 VBoxCredProvProvider *pProvider = new VBoxCredProvProvider(); 545 AssertPtr(pProvider); 530 546 hr = pProvider->QueryInterface(interfaceID, ppvInterface); 531 547 pProvider->Release(); 532 548 } 533 else 549 catch (std::bad_alloc &ex) 550 { 551 NOREF(ex); 534 552 hr = E_OUTOFMEMORY; 553 } 535 554 536 555 return hr; -
trunk/src/VBox/Additions/WINNT/VBoxCredProv/VBoxCredentialProvider.cpp
r40940 r46382 5 5 6 6 /* 7 * Copyright (C) 2012 Oracle Corporation7 * Copyright (C) 2012-2013 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 21 21 #include <windows.h> 22 22 #include <initguid.h> 23 #include <new> /* For bad_alloc. */ 23 24 24 25 #ifdef VBOX_WITH_SENS … … 200 201 } 201 202 202 g_pISensLogon = new VBoxCredProvSensLogon(); 203 if (!g_pISensLogon) 204 { 205 VBoxCredProvVerbose(0, "VBoxCredentialProviderRegisterSENS: Could not create interface instance; out of memory\n"); 206 return ERROR_OUTOFMEMORY; 207 } 208 209 IEventSubscription *pIEventSubscription; 210 int i; 211 for (i = 0; i < RT_ELEMENTS(g_aSENSEvents); i++) 212 { 213 VBoxCredProvVerbose(0, "VBoxCredProv: Registering \"%s\" (%s) ...\n", 214 g_aSENSEvents[i].pszMethod, g_aSENSEvents[i].pszSubscriptionName); 215 216 hr = CoCreateInstance(CLSID_CEventSubscription, 0, CLSCTX_SERVER, IID_IEventSubscription, (LPVOID*)&pIEventSubscription); 203 try 204 { 205 g_pISensLogon = new VBoxCredProvSensLogon(); 206 AssertPtr(g_pISensLogon); 207 } 208 catch (std::bad_alloc &ex) 209 { 210 NOREF(ex); 211 hr = E_OUTOFMEMORY; 212 } 213 214 if (SUCCEEDED(hr)) 215 { 216 IEventSubscription *pIEventSubscription; 217 int i; 218 for (i = 0; i < RT_ELEMENTS(g_aSENSEvents); i++) 219 { 220 VBoxCredProvVerbose(0, "VBoxCredProv: Registering \"%s\" (%s) ...\n", 221 g_aSENSEvents[i].pszMethod, g_aSENSEvents[i].pszSubscriptionName); 222 223 hr = CoCreateInstance(CLSID_CEventSubscription, 0, CLSCTX_SERVER, IID_IEventSubscription, (LPVOID*)&pIEventSubscription); 224 if (FAILED(hr)) 225 continue; 226 227 hr = pIEventSubscription->put_EventClassID(L"{d5978630-5b9f-11d1-8dd2-00aa004abd5e}" /* SENSGUID_EVENTCLASS_LOGON */); 228 if (FAILED(hr)) 229 break; 230 231 hr = pIEventSubscription->put_SubscriberInterface((IUnknown*)g_pISensLogon); 232 if (FAILED(hr)) 233 break; 234 235 PRTUTF16 pwszTemp; 236 int rc = RTStrToUtf16(g_aSENSEvents[i].pszMethod, &pwszTemp); 237 if (RT_SUCCESS(rc)) 238 { 239 hr = pIEventSubscription->put_MethodName(pwszTemp); 240 RTUtf16Free(pwszTemp); 241 } 242 else 243 hr = ERROR_OUTOFMEMORY; 244 if (FAILED(hr)) 245 break; 246 247 rc = RTStrToUtf16(g_aSENSEvents[i].pszSubscriptionName, &pwszTemp); 248 if (RT_SUCCESS(rc)) 249 { 250 hr = pIEventSubscription->put_SubscriptionName(pwszTemp); 251 RTUtf16Free(pwszTemp); 252 } 253 else 254 hr = ERROR_OUTOFMEMORY; 255 if (FAILED(hr)) 256 break; 257 258 rc = RTStrToUtf16(g_aSENSEvents[i].pszSubscriptionUUID, &pwszTemp); 259 if (RT_SUCCESS(rc)) 260 { 261 hr = pIEventSubscription->put_SubscriptionID(pwszTemp); 262 RTUtf16Free(pwszTemp); 263 } 264 else 265 hr = ERROR_OUTOFMEMORY; 266 if (FAILED(hr)) 267 break; 268 269 hr = pIEventSubscription->put_PerUser(TRUE); 270 if (FAILED(hr)) 271 break; 272 273 hr = g_pIEventSystem->Store(PROGID_EventSubscription, (IUnknown*)pIEventSubscription); 274 if (FAILED(hr)) 275 break; 276 277 pIEventSubscription->Release(); 278 pIEventSubscription = NULL; 279 } 280 217 281 if (FAILED(hr)) 218 continue; 219 220 hr = pIEventSubscription->put_EventClassID(L"{d5978630-5b9f-11d1-8dd2-00aa004abd5e}" /* SENSGUID_EVENTCLASS_LOGON */); 221 if (FAILED(hr)) 222 break; 223 224 hr = pIEventSubscription->put_SubscriberInterface((IUnknown*)g_pISensLogon); 225 if (FAILED(hr)) 226 break; 227 228 PRTUTF16 pwszTemp; 229 int rc = RTStrToUtf16(g_aSENSEvents[i].pszMethod, &pwszTemp); 230 if (RT_SUCCESS(rc)) 231 { 232 hr = pIEventSubscription->put_MethodName(pwszTemp); 233 RTUtf16Free(pwszTemp); 234 } 235 else 236 hr = ERROR_OUTOFMEMORY; 237 if (FAILED(hr)) 238 break; 239 240 rc = RTStrToUtf16(g_aSENSEvents[i].pszSubscriptionName, &pwszTemp); 241 if (RT_SUCCESS(rc)) 242 { 243 hr = pIEventSubscription->put_SubscriptionName(pwszTemp); 244 RTUtf16Free(pwszTemp); 245 } 246 else 247 hr = ERROR_OUTOFMEMORY; 248 if (FAILED(hr)) 249 break; 250 251 rc = RTStrToUtf16(g_aSENSEvents[i].pszSubscriptionUUID, &pwszTemp); 252 if (RT_SUCCESS(rc)) 253 { 254 hr = pIEventSubscription->put_SubscriptionID(pwszTemp); 255 RTUtf16Free(pwszTemp); 256 } 257 else 258 hr = ERROR_OUTOFMEMORY; 259 if (FAILED(hr)) 260 break; 261 262 hr = pIEventSubscription->put_PerUser(TRUE); 263 if (FAILED(hr)) 264 break; 265 266 hr = g_pIEventSystem->Store(PROGID_EventSubscription, (IUnknown*)pIEventSubscription); 267 if (FAILED(hr)) 268 break; 269 270 pIEventSubscription->Release(); 271 pIEventSubscription = NULL; 282 VBoxCredProvVerbose(0, "VBoxCredentialProviderRegisterSENS: Could not register \"%s\" (%s), hr=%Rhrc\n", 283 g_aSENSEvents[i].pszMethod, g_aSENSEvents[i].pszSubscriptionName, hr); 284 285 if (pIEventSubscription != NULL) 286 pIEventSubscription->Release(); 272 287 } 273 288 274 289 if (FAILED(hr)) 275 VBoxCredProvVerbose(0, "VBoxCredentialProviderRegisterSENS: Could not register \"%s\" (%s), hr=%Rhrc\n",276 g_aSENSEvents[i].pszMethod, g_aSENSEvents[i].pszSubscriptionName, hr);277 278 if (pIEventSubscription != NULL)279 pIEventSubscription->Release(); 290 { 291 VBoxCredProvVerbose(0, "VBoxCredentialProviderRegisterSENS: Error registering SENS provider, hr=%Rhrc\n", hr); 292 if (g_pIEventSystem) 293 g_pIEventSystem->Release(); 294 } 280 295 281 296 return hr; … … 453 468 if (classID == CLSID_VBoxCredProvider) 454 469 { 455 VBoxCredProvFactory* pFactory = new VBoxCredProvFactory(); 456 if (pFactory) 470 try 457 471 { 472 VBoxCredProvFactory* pFactory = new VBoxCredProvFactory(); 473 AssertPtr(pFactory); 458 474 hr = pFactory->QueryInterface(interfaceID, 459 475 ppvInterface); … … 468 484 #endif 469 485 } 470 else 486 catch (std::bad_alloc &ex) 487 { 488 NOREF(ex); 471 489 hr = E_OUTOFMEMORY; 490 } 472 491 } 473 492 else
Note:
See TracChangeset
for help on using the changeset viewer.