Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1914 lines
70 KiB

  1. // ConnectionManager.cpp: implementation of the CConnectionManager class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. //
  5. // 03/05/00 v-marfin bug 59643 : Check for empty Marshal list before proceeding in
  6. // UnMarshalCnxMgr()
  7. // 04/05/00 v-marfin bug 62501 : Display appropriate msg when unable to connect to a server.
  8. //
  9. //
  10. #include "stdafx.h"
  11. #include "SnapIn.h"
  12. #ifdef _DEBUG
  13. #undef THIS_FILE
  14. static char THIS_FILE[]=__FILE__;
  15. #define new DEBUG_NEW
  16. #endif
  17. const IID IID_IConnectionManager = {0xFA84E6F2,0x0B7B,0x11D2,{0xBD,0xCB,0x00,0xC0,0x4F,0xA3,0x54,0x47}};
  18. const IID LIBID_CONNMGRLib = {0xFA84E6E5,0x0B7B,0x11D2,{0xBD,0xCB,0x00,0xC0,0x4F,0xA3,0x54,0x47}};
  19. const CLSID CLSID_ConnectionManager = {0xFA84E6F3,0x0B7B,0x11D2,{0xBD,0xCB,0x00,0xC0,0x4F,0xA3,0x54,0x47}};
  20. //////////////////////////////////////////////////////////////////////
  21. // CMarhsalledConnection
  22. CMarshalledConnection::CMarshalledConnection()
  23. {
  24. m_pIMarshalledConnectionManager = NULL;
  25. m_lpMarshalStream = NULL;
  26. }
  27. //////////////////////////////////////////////////////////////////////
  28. // Operations
  29. //////////////////////////////////////////////////////////////////////
  30. HRESULT CMarshalledConnection::Marshal(IConnectionManager* pIConMgr)
  31. {
  32. TRACEX(_T("CMarshalledConnection::Marshal\n"));
  33. TRACEARGn(pIConMgr);
  34. HRESULT hr = S_OK;
  35. if( m_lpMarshalStream == NULL )
  36. {
  37. hr = CoMarshalInterThreadInterfaceInStream(IID_IConnectionManager,pIConMgr,&m_lpMarshalStream);
  38. if( ! CHECKHRESULT(hr) )
  39. {
  40. TRACE(_T("FAILED : CoMarshalInterThreadInterfaceInStream failed.\n"));
  41. }
  42. }
  43. return hr;
  44. }
  45. HRESULT CMarshalledConnection::UnMarshal()
  46. {
  47. TRACEX(_T("CMarshalledConnection::UnMarshal\n"));
  48. HRESULT hr = S_OK;
  49. if( m_pIMarshalledConnectionManager == NULL )
  50. {
  51. hr = CoGetInterfaceAndReleaseStream(m_lpMarshalStream,IID_IConnectionManager,(LPVOID*)(&m_pIMarshalledConnectionManager));
  52. if(!CHECKHRESULT(hr))
  53. {
  54. TRACE(_T("FAILED : CoGetInterfaceAndReleaseStream failed.\n"));
  55. }
  56. }
  57. return hr;
  58. }
  59. IConnectionManager* CMarshalledConnection::GetConnection()
  60. {
  61. TRACEX(_T("CMarshalledConnection::GetConnection\n"));
  62. // make certain the pointer has been unmarshalled
  63. HRESULT hr = UnMarshal();
  64. CHECKHRESULT(hr);
  65. ASSERT(m_pIMarshalledConnectionManager);
  66. return m_pIMarshalledConnectionManager;
  67. }
  68. //////////////////////////////////////////////////////////////////////
  69. // CConnectionManager
  70. IMPLEMENT_DYNCREATE(CConnectionManager,CObject)
  71. //////////////////////////////////////////////////////////////////////
  72. // Construction/Destruction
  73. //////////////////////////////////////////////////////////////////////
  74. CConnectionManager theCnxManager;
  75. CConnectionManager::CConnectionManager()
  76. {
  77. m_pIConnectionManager = NULL;
  78. }
  79. CConnectionManager::~CConnectionManager()
  80. {
  81. Destroy();
  82. }
  83. BOOL CConnectionManager::Create()
  84. {
  85. TRACEX(_T("CConnectionManager::Create\n"));
  86. // create the ConnectionManager object
  87. if( m_pIConnectionManager != NULL )
  88. {
  89. return TRUE;
  90. }
  91. HRESULT hr = CoCreateInstance(CLSID_ConnectionManager,NULL,CLSCTX_LOCAL_SERVER,IID_IConnectionManager,(LPVOID*)&m_pIConnectionManager);
  92. if( !CHECKHRESULT(hr) )
  93. {
  94. TRACE(_T("FAILED : Failed to create Connection Manager !\n"));
  95. return FALSE;
  96. }
  97. ASSERT(m_pIConnectionManager);
  98. return TRUE;
  99. }
  100. void CConnectionManager::Destroy()
  101. {
  102. TRACEX(_T("CConnectionManager::Destroy\n"));
  103. // clean up any marshalled connections laying around
  104. POSITION pos = m_MarshalMap.GetStartPosition();
  105. CMarshalledConnection* pMC = NULL;
  106. DWORD dwKey = 0L;
  107. while( pos )
  108. {
  109. m_MarshalMap.GetNextAssoc(pos,dwKey,pMC);
  110. if( pMC )
  111. {
  112. delete pMC;
  113. }
  114. }
  115. m_MarshalMap.RemoveAll();
  116. // release the ConnectionManager object
  117. if( m_pIConnectionManager )
  118. {
  119. m_pIConnectionManager->Release();
  120. m_pIConnectionManager = NULL;
  121. }
  122. }
  123. //////////////////////////////////////////////////////////////////////
  124. // Connection Operations
  125. //////////////////////////////////////////////////////////////////////
  126. HRESULT CConnectionManager::GetConnection(const CString& sMachineName, IWbemServices*& pIWbemServices, BOOL& bAvailable )
  127. {
  128. TRACEX(_T("CConnectionManager::GetConnection\n"));
  129. TRACEARGs(sMachineName);
  130. ASSERT(m_pIConnectionManager);
  131. if( m_pIConnectionManager == NULL )
  132. {
  133. TRACE(_T("FAILED : CConnectionManager::GetConnection failed. m_pIConnectionManager is NULL.\n"));
  134. pIWbemServices = NULL;
  135. bAvailable = FALSE;
  136. return E_FAIL;
  137. }
  138. BSTR bsMachineName = sMachineName.AllocSysString();
  139. long lAvail = 0L;
  140. HRESULT hr = m_pIConnectionManager->GetConnection(bsMachineName,&pIWbemServices,&lAvail);
  141. if( HRESULT_CODE(hr) == RPC_S_SERVER_UNAVAILABLE )
  142. {
  143. HandleConnMgrException(hr);
  144. Destroy();
  145. Create();
  146. hr = m_pIConnectionManager->GetConnection(bsMachineName,&pIWbemServices,&lAvail);
  147. }
  148. if( hr == RPC_E_WRONG_THREAD )
  149. {
  150. CMarshalledConnection* pConnection = NULL;
  151. DWORD dwThreadID = GetCurrentThreadId();
  152. m_MarshalMap.Lookup(dwThreadID,pConnection);
  153. ASSERT(pConnection);
  154. if( pConnection == NULL )
  155. {
  156. TRACE(_T("FAILED : Could not find a marshalled connection for the calling thread!\n"));
  157. return E_FAIL;
  158. }
  159. IConnectionManager* pCnxMgr = pConnection->GetConnection();
  160. ASSERT(pCnxMgr);
  161. if( pCnxMgr == NULL )
  162. {
  163. TRACE(_T("FAILED : CMarshalledConnection::GetConnection returns NULL. Failed.\n"));
  164. return E_FAIL;
  165. }
  166. hr = pCnxMgr->GetConnection(bsMachineName,&pIWbemServices,&lAvail);
  167. if( HRESULT_CODE(hr) == RPC_S_SERVER_UNAVAILABLE )
  168. {
  169. HandleConnMgrException(hr);
  170. }
  171. if( !SUCCEEDED(hr) )
  172. {
  173. TRACE(_T("The marshalled connection manager's GetConnection failed.\n"));
  174. }
  175. }
  176. SysFreeString(bsMachineName);
  177. bAvailable = lAvail;
  178. if( !CHECKHRESULT(hr) )
  179. {
  180. TRACE(_T("FAILED : IConnectionManager::GetConnection failed.\n"));
  181. return hr;
  182. }
  183. return hr;
  184. }
  185. HRESULT CConnectionManager::ConnectToNamespace(const CString& sNamespace, IWbemServices*& pIWbemServices)
  186. {
  187. TRACEX(_T("CConnectionManager::ConnectToNamespace\n"));
  188. TRACEARGs(sNamespace);
  189. ASSERT(m_pIConnectionManager);
  190. if( m_pIConnectionManager == NULL )
  191. {
  192. TRACE(_T("FAILED : CConnectionManager::ConnectToNamespace failed. m_pIConnectionManager is NULL.\n"));
  193. pIWbemServices = NULL;
  194. return E_FAIL;
  195. }
  196. BSTR bsNamespace = sNamespace.AllocSysString();
  197. HRESULT hr = m_pIConnectionManager->ConnectToNamespace(bsNamespace,&pIWbemServices);
  198. if( HRESULT_CODE(hr) == RPC_S_SERVER_UNAVAILABLE )
  199. {
  200. // v-marfin 62501 HandleConnMgrException(hr);
  201. CString sMsg;
  202. sMsg.Format(IDS_STRING_TRANSPORT_ERROR,sNamespace);
  203. AfxMessageBox(sMsg);
  204. //Destroy();
  205. // v-marfin 62501 - This was here originally, so keep?? --------------------
  206. //Create();
  207. //hr = m_pIConnectionManager->ConnectToNamespace(bsNamespace,&pIWbemServices);
  208. //--------------------------------------------------------------------------
  209. SysFreeString(bsNamespace); // v-marfin 62501
  210. return E_FAIL; // v-marfin 62501
  211. }
  212. if( hr == RPC_E_WRONG_THREAD )
  213. {
  214. CMarshalledConnection* pConnection = NULL;
  215. DWORD dwThreadID = GetCurrentThreadId();
  216. m_MarshalMap.Lookup(dwThreadID,pConnection);
  217. ASSERT(pConnection);
  218. if( pConnection == NULL )
  219. {
  220. TRACE(_T("FAILED : Could not find a marshalled connection for the calling thread!\n"));
  221. return E_FAIL;
  222. }
  223. IConnectionManager* pCnxMgr = pConnection->GetConnection();
  224. ASSERT(pCnxMgr);
  225. if( pCnxMgr == NULL )
  226. {
  227. TRACE(_T("FAILED : CMarshalledConnection::GetConnection returns NULL. Failed.\n"));
  228. return E_FAIL;
  229. }
  230. hr = pCnxMgr->ConnectToNamespace(bsNamespace,&pIWbemServices);
  231. if( HRESULT_CODE(hr) == RPC_S_SERVER_UNAVAILABLE )
  232. {
  233. HandleConnMgrException(hr);
  234. }
  235. if( !SUCCEEDED(hr) )
  236. {
  237. TRACE(_T("The marshalled connection manager's GetConnection failed.\n"));
  238. }
  239. }
  240. SysFreeString(bsNamespace);
  241. if( !CHECKHRESULT(hr) )
  242. {
  243. TRACE(_T("FAILED : IConnectionManager::ConnectToNamespace failed.\n"));
  244. return hr;
  245. }
  246. return hr;
  247. }
  248. HRESULT CConnectionManager::RemoveConnection(const CString& sMachineName, IWbemObjectSink* pSink)
  249. {
  250. TRACEX(_T("CConnectionManager::RemoveConnection\n"));
  251. TRACEARGs(sMachineName);
  252. TRACEARGn(pSink);
  253. ASSERT(m_pIConnectionManager);
  254. if( m_pIConnectionManager == NULL )
  255. {
  256. TRACE(_T("FAILED : CConnectionManager::RemoveConnection failed. m_pIConnectionManager is NULL.\n"));
  257. return FALSE;
  258. }
  259. BSTR bsMachineName = sMachineName.AllocSysString();
  260. HRESULT hr = m_pIConnectionManager->RemoveConnection(bsMachineName,pSink);
  261. SysFreeString(bsMachineName);
  262. if( !CHECKHRESULT(hr) )
  263. {
  264. TRACE(_T("FAILED : IConnectionManager::RemoveConnection failed.\n"));
  265. return hr;
  266. }
  267. return hr;
  268. }
  269. //////////////////////////////////////////////////////////////////////
  270. // Event Operations
  271. //////////////////////////////////////////////////////////////////////
  272. HRESULT CConnectionManager::ExecQueryAsync(const CString& sMachineName, const CString& sQuery, IWbemObjectSink*& pSink)
  273. {
  274. TRACEX(_T("CConnectionManager::ExecQueryAsync\n"));
  275. TRACEARGs(sMachineName);
  276. TRACEARGs(sQuery);
  277. if( ! GfxCheckPtr(m_pIConnectionManager,IConnectionManager) )
  278. {
  279. TRACE(_T("FAILED : m_pIConnectionManager is not a valid pointer.\n"));
  280. return E_FAIL;
  281. }
  282. BSTR bsMachineName = sMachineName.AllocSysString();
  283. BSTR bsQuery = sQuery.AllocSysString();
  284. HRESULT hr = m_pIConnectionManager->ExecQueryAsync(bsMachineName,bsQuery,pSink);
  285. if( hr == RPC_E_WRONG_THREAD )
  286. {
  287. CMarshalledConnection* pConnection = NULL;
  288. DWORD dwThreadID = GetCurrentThreadId();
  289. m_MarshalMap.Lookup(dwThreadID,pConnection);
  290. ASSERT(pConnection);
  291. if( pConnection == NULL )
  292. {
  293. TRACE(_T("FAILED : Could not find a marshalled connection for the calling thread!\n"));
  294. return E_FAIL;
  295. }
  296. IConnectionManager* pCnxMgr = pConnection->GetConnection();
  297. ASSERT(pCnxMgr);
  298. if( pCnxMgr == NULL )
  299. {
  300. TRACE(_T("FAILED : CMarshalledConnection::GetConnection returns NULL. Failed.\n"));
  301. return E_FAIL;
  302. }
  303. hr = pCnxMgr->ExecQueryAsync(bsMachineName,bsQuery,pSink);
  304. if( HRESULT_CODE(hr) == RPC_S_SERVER_UNAVAILABLE )
  305. {
  306. HandleConnMgrException(hr);
  307. }
  308. if( !SUCCEEDED(hr) )
  309. {
  310. TRACE(_T("The marshalled connection manager's GetConnection failed.\n"));
  311. }
  312. }
  313. SysFreeString(bsMachineName);
  314. SysFreeString(bsQuery);
  315. if( !CHECKHRESULT(hr) )
  316. {
  317. TRACE(_T("FAILED : IConnectionManager::ExecQueryAsync failed.\n"));
  318. return hr;
  319. }
  320. return hr;
  321. }
  322. //////////////////////////////////////////////////////////////////////
  323. // Event Operations
  324. //////////////////////////////////////////////////////////////////////
  325. HRESULT CConnectionManager::RegisterEventNotification(const CString& sMachineName, const CString& sQuery, IWbemObjectSink*& pSink)
  326. {
  327. TRACEX(_T("CConnectionManager::RegisterEventNotification\n"));
  328. TRACEARGs(sMachineName);
  329. TRACEARGs(sQuery);
  330. if( ! GfxCheckPtr(m_pIConnectionManager,IConnectionManager) )
  331. {
  332. TRACE(_T("FAILED : m_pIConnectionManager is not a valid pointer.\n"));
  333. return E_FAIL;
  334. }
  335. BSTR bsMachineName = sMachineName.AllocSysString();
  336. BSTR bsQuery = sQuery.AllocSysString();
  337. HRESULT hr = m_pIConnectionManager->RegisterEventNotification(bsMachineName,bsQuery,pSink);
  338. if( HRESULT_CODE(hr) == RPC_S_SERVER_UNAVAILABLE )
  339. {
  340. HandleConnMgrException(hr);
  341. Destroy();
  342. Create();
  343. hr = m_pIConnectionManager->RegisterEventNotification(bsMachineName,bsQuery,pSink);
  344. }
  345. if( hr == RPC_E_WRONG_THREAD )
  346. {
  347. CMarshalledConnection* pConnection = NULL;
  348. DWORD dwThreadID = GetCurrentThreadId();
  349. m_MarshalMap.Lookup(dwThreadID,pConnection);
  350. ASSERT(pConnection);
  351. if( pConnection == NULL )
  352. {
  353. TRACE(_T("FAILED : Could not find a marshalled connection for the calling thread!\n"));
  354. SysFreeString(bsMachineName);
  355. SysFreeString(bsQuery);
  356. return E_FAIL;
  357. }
  358. IConnectionManager* pCnxMgr = pConnection->GetConnection();
  359. ASSERT(pCnxMgr);
  360. if( pCnxMgr == NULL )
  361. {
  362. TRACE(_T("FAILED : CMarshalledConnection::GetConnection returns NULL. Failed.\n"));
  363. SysFreeString(bsMachineName);
  364. SysFreeString(bsQuery);
  365. return E_FAIL;
  366. }
  367. hr = pCnxMgr->RegisterEventNotification(bsMachineName,bsQuery,pSink);
  368. if( HRESULT_CODE(hr) == RPC_S_SERVER_UNAVAILABLE )
  369. {
  370. HandleConnMgrException(hr);
  371. }
  372. if( !SUCCEEDED(hr) )
  373. {
  374. TRACE(_T("The marshalled connection manager's GetConnection failed.\n"));
  375. }
  376. }
  377. SysFreeString(bsMachineName);
  378. SysFreeString(bsQuery);
  379. if( !CHECKHRESULT(hr) )
  380. {
  381. TRACE(_T("FAILED : IConnectionManager::RegisterEventNotification failed.\n"));
  382. return hr;
  383. }
  384. return hr;
  385. }
  386. //////////////////////////////////////////////////////////////////////
  387. // Error Display Operations
  388. //////////////////////////////////////////////////////////////////////
  389. void CConnectionManager::DisplayErrorMsgBox(HRESULT hr, const CString& sMachineName)
  390. {
  391. TRACEX(_T("CConnectionManager::DisplayErrorMsgBox\n"));
  392. TRACEARGn(hr);
  393. TRACEARGs(sMachineName);
  394. CString sText;
  395. CString sTitle;
  396. GetErrorString(hr,sMachineName,sText);
  397. if( ! sText.IsEmpty() )
  398. AfxMessageBox(sText);
  399. }
  400. void CConnectionManager::GetErrorString(HRESULT hr, const CString& sMachineName, CString& sErrorText)
  401. {
  402. TRACEX(_T("CConnectionManager::GetErrorString\n"));
  403. TRACEARGn(hr);
  404. TRACEARGs(sMachineName);
  405. TRACEARGs(sErrorText);
  406. if( hr == S_OK )
  407. return;
  408. switch( hr )
  409. {
  410. case E_FAIL:
  411. {
  412. sErrorText.Format(IDS_STRING_INVALID_MACHINE_NAME,sMachineName);
  413. }
  414. break;
  415. case WBEM_E_INVALID_CLASS:
  416. case E_NOTIMPL:
  417. {
  418. sErrorText.Format(IDS_STRING_INCORRECT_AGENT_VERSION,sMachineName);
  419. }
  420. break;
  421. case REGDB_E_CLASSNOTREG:
  422. {
  423. sErrorText.Format(IDS_STRING_WBEM_NOT_INSTALLED,sMachineName);
  424. }
  425. break;
  426. case E_ACCESSDENIED:
  427. case WBEM_E_ACCESS_DENIED:
  428. {
  429. sErrorText.Format(IDS_STRING_NO_CONNECT,sMachineName);
  430. }
  431. break;
  432. case WBEM_E_PROVIDER_FAILURE:
  433. {
  434. sErrorText.Format(IDS_STRING_PROVIDER_FAILURE,sMachineName,sMachineName);
  435. }
  436. break;
  437. case WBEM_E_PROVIDER_LOAD_FAILURE:
  438. {
  439. sErrorText.Format(IDS_STRING_PROVIDER_LOAD_FAILURE,sMachineName,sMachineName);
  440. }
  441. break;
  442. case WBEM_E_INVALID_NAMESPACE:
  443. {
  444. sErrorText.Format(IDS_STRING_INVALID_NAMESPACE,sMachineName,sMachineName);
  445. }
  446. break;
  447. case WBEM_E_INVALID_PARAMETER:
  448. {
  449. sErrorText.Format(IDS_STRING_INVALID_PARAMETER,sMachineName);
  450. }
  451. break;
  452. case WBEM_E_OUT_OF_MEMORY:
  453. {
  454. sErrorText.Format(IDS_STRING_OUT_OF_MEMORY,sMachineName);
  455. }
  456. break;
  457. case WBEM_E_TRANSPORT_FAILURE:
  458. {
  459. sErrorText.Format(IDS_STRING_TRANSPORT_ERROR,sMachineName);
  460. }
  461. break;
  462. case WBEM_S_OPERATION_CANCELLED:
  463. {
  464. sErrorText.Format(IDS_STRING_OPERATION_CANCELLED,sMachineName);
  465. }
  466. break;
  467. case WBEMESS_E_REGISTRATION_TOO_PRECISE:
  468. {
  469. sErrorText.Format(IDS_STRING_REGISTRATION_TOO_PRECISE,sMachineName);
  470. }
  471. break;
  472. default:
  473. {
  474. if( HRESULT_CODE(hr) == RPC_S_CALL_FAILED || HRESULT_CODE(hr) == RPC_S_CALL_FAILED_DNE )
  475. {
  476. sErrorText.Format(IDS_STRING_WBEM_NOT_AVAILABLE,sMachineName);
  477. return;
  478. }
  479. TCHAR szFacility[_FACILITYLEN];
  480. TCHAR szErrorName[_ERRORNAMELEN];
  481. TCHAR szErrorDesc[_ERRORDESCLEN];
  482. ZeroMemory(szErrorName,sizeof(TCHAR)*_ERRORNAMELEN);
  483. ZeroMemory(szFacility,sizeof(TCHAR)*_FACILITYLEN);
  484. ZeroMemory(szErrorDesc,sizeof(TCHAR)*_ERRORDESCLEN);
  485. DecodeHResult(hr,szFacility,szErrorName,szErrorDesc);
  486. if( szFacility[0] == NULL || szErrorName[0] == NULL || szErrorDesc[0] == NULL )
  487. {
  488. sErrorText.Format(IDS_STRING_UNKNOWN_ERROR,sMachineName,hr);
  489. }
  490. else
  491. {
  492. CString sErrorDesc = szErrorDesc;
  493. sErrorDesc.TrimRight();
  494. sErrorText.Format(IDS_STRING_UNSPECIFIED_ERROR,sMachineName,sErrorDesc);
  495. }
  496. }
  497. }
  498. }
  499. #define CASE_FACILITY(f) \
  500. case f: \
  501. _tcscpy((LPTSTR)szFacility, (LPTSTR)#f); \
  502. break;
  503. #define CASE_HRESULT(hr) \
  504. case hr: \
  505. _tcscpy((LPTSTR)szErrorName, (LPTSTR)#hr); \
  506. FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, hr, \
  507. MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), \
  508. szErrorDesc, sizeof(TCHAR)*_ERRORDESCLEN, NULL);\
  509. break;
  510. #define CASE_CODE(c) \
  511. case c: \
  512. _tcscpy((LPTSTR)szErrorName, (LPTSTR)#c); \
  513. FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, hr, \
  514. MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), \
  515. szErrorDesc, sizeof(TCHAR)*_ERRORDESCLEN, NULL);\
  516. break;
  517. #pragma warning( disable : 4245 )
  518. void CConnectionManager::DecodeHResult(HRESULT hr, LPTSTR pszFacility, LPTSTR pszErrorName, LPTSTR pszErrorDesc)
  519. {
  520. TCHAR szFacility[_FACILITYLEN];
  521. TCHAR szErrorName[_ERRORNAMELEN];
  522. TCHAR szErrorDesc[_ERRORDESCLEN];
  523. ZeroMemory(szErrorName,sizeof(TCHAR)*_ERRORNAMELEN);
  524. ZeroMemory(szFacility,sizeof(TCHAR)*_FACILITYLEN);
  525. ZeroMemory(szErrorDesc,sizeof(TCHAR)*_ERRORDESCLEN);
  526. _tcscpy(szErrorDesc, _T(""));
  527. switch (HRESULT_FACILITY(hr))
  528. {
  529. CASE_FACILITY(FACILITY_WINDOWS)
  530. CASE_FACILITY(FACILITY_STORAGE)
  531. CASE_FACILITY(FACILITY_RPC)
  532. CASE_FACILITY(FACILITY_SSPI)
  533. CASE_FACILITY(FACILITY_WIN32)
  534. CASE_FACILITY(FACILITY_CONTROL)
  535. CASE_FACILITY(FACILITY_NULL)
  536. CASE_FACILITY(FACILITY_INTERNET)
  537. CASE_FACILITY(FACILITY_ITF)
  538. CASE_FACILITY(FACILITY_DISPATCH)
  539. CASE_FACILITY(FACILITY_CERT)
  540. default:
  541. _tcscpy(szFacility, _T(""));
  542. }
  543. switch (hr)
  544. {
  545. CASE_HRESULT(E_UNEXPECTED)
  546. CASE_HRESULT(E_NOTIMPL)
  547. CASE_HRESULT(E_OUTOFMEMORY)
  548. CASE_HRESULT(E_INVALIDARG)
  549. CASE_HRESULT(E_NOINTERFACE)
  550. CASE_HRESULT(E_POINTER)
  551. CASE_HRESULT(E_HANDLE)
  552. CASE_HRESULT(E_ABORT)
  553. CASE_HRESULT(E_FAIL)
  554. CASE_HRESULT(E_ACCESSDENIED)
  555. CASE_HRESULT(E_PENDING)
  556. CASE_HRESULT(CO_E_INIT_TLS)
  557. CASE_HRESULT(CO_E_INIT_SHARED_ALLOCATOR)
  558. CASE_HRESULT(CO_E_INIT_MEMORY_ALLOCATOR)
  559. CASE_HRESULT(CO_E_INIT_CLASS_CACHE)
  560. CASE_HRESULT(CO_E_INIT_RPC_CHANNEL)
  561. CASE_HRESULT(CO_E_INIT_TLS_SET_CHANNEL_CONTROL)
  562. CASE_HRESULT(CO_E_INIT_TLS_CHANNEL_CONTROL)
  563. CASE_HRESULT(CO_E_INIT_UNACCEPTED_USER_ALLOCATOR)
  564. CASE_HRESULT(CO_E_INIT_SCM_MUTEX_EXISTS)
  565. CASE_HRESULT(CO_E_INIT_SCM_FILE_MAPPING_EXISTS)
  566. CASE_HRESULT(CO_E_INIT_SCM_MAP_VIEW_OF_FILE)
  567. CASE_HRESULT(CO_E_INIT_SCM_EXEC_FAILURE)
  568. CASE_HRESULT(CO_E_INIT_ONLY_SINGLE_THREADED)
  569. CASE_HRESULT(CO_E_CANT_REMOTE)
  570. CASE_HRESULT(CO_E_BAD_SERVER_NAME)
  571. CASE_HRESULT(CO_E_WRONG_SERVER_IDENTITY)
  572. CASE_HRESULT(CO_E_OLE1DDE_DISABLED)
  573. CASE_HRESULT(CO_E_RUNAS_SYNTAX)
  574. CASE_HRESULT(CO_E_CREATEPROCESS_FAILURE)
  575. CASE_HRESULT(CO_E_RUNAS_CREATEPROCESS_FAILURE)
  576. CASE_HRESULT(CO_E_RUNAS_LOGON_FAILURE)
  577. CASE_HRESULT(CO_E_LAUNCH_PERMSSION_DENIED)
  578. CASE_HRESULT(CO_E_START_SERVICE_FAILURE)
  579. CASE_HRESULT(CO_E_REMOTE_COMMUNICATION_FAILURE)
  580. CASE_HRESULT(CO_E_SERVER_START_TIMEOUT)
  581. CASE_HRESULT(CO_E_CLSREG_INCONSISTENT)
  582. CASE_HRESULT(CO_E_IIDREG_INCONSISTENT)
  583. CASE_HRESULT(CO_E_NOT_SUPPORTED)
  584. CASE_HRESULT(S_OK)
  585. CASE_HRESULT(S_FALSE)
  586. CASE_HRESULT(OLE_E_OLEVERB)
  587. CASE_HRESULT(OLE_E_ADVF)
  588. CASE_HRESULT(OLE_E_ENUM_NOMORE)
  589. CASE_HRESULT(OLE_E_ADVISENOTSUPPORTED)
  590. CASE_HRESULT(OLE_E_NOCONNECTION)
  591. CASE_HRESULT(OLE_E_NOTRUNNING)
  592. CASE_HRESULT(OLE_E_NOCACHE)
  593. CASE_HRESULT(OLE_E_BLANK)
  594. CASE_HRESULT(OLE_E_CLASSDIFF)
  595. CASE_HRESULT(OLE_E_CANT_GETMONIKER)
  596. CASE_HRESULT(OLE_E_CANT_BINDTOSOURCE)
  597. CASE_HRESULT(OLE_E_STATIC)
  598. CASE_HRESULT(OLE_E_PROMPTSAVECANCELLED)
  599. CASE_HRESULT(OLE_E_INVALIDRECT)
  600. CASE_HRESULT(OLE_E_WRONGCOMPOBJ)
  601. CASE_HRESULT(OLE_E_INVALIDHWND)
  602. CASE_HRESULT(OLE_E_NOT_INPLACEACTIVE)
  603. CASE_HRESULT(OLE_E_CANTCONVERT)
  604. CASE_HRESULT(OLE_E_NOSTORAGE)
  605. CASE_HRESULT(DV_E_FORMATETC)
  606. CASE_HRESULT(DV_E_DVTARGETDEVICE)
  607. CASE_HRESULT(DV_E_STGMEDIUM)
  608. CASE_HRESULT(DV_E_STATDATA)
  609. CASE_HRESULT(DV_E_LINDEX)
  610. CASE_HRESULT(DV_E_TYMED)
  611. CASE_HRESULT(DV_E_CLIPFORMAT)
  612. CASE_HRESULT(DV_E_DVASPECT)
  613. CASE_HRESULT(DV_E_DVTARGETDEVICE_SIZE)
  614. CASE_HRESULT(DV_E_NOIVIEWOBJECT)
  615. CASE_HRESULT(DRAGDROP_E_NOTREGISTERED)
  616. CASE_HRESULT(DRAGDROP_E_ALREADYREGISTERED)
  617. CASE_HRESULT(DRAGDROP_E_INVALIDHWND)
  618. CASE_HRESULT(CLASS_E_NOAGGREGATION)
  619. CASE_HRESULT(CLASS_E_CLASSNOTAVAILABLE)
  620. CASE_HRESULT(VIEW_E_DRAW)
  621. CASE_HRESULT(REGDB_E_READREGDB)
  622. CASE_HRESULT(REGDB_E_WRITEREGDB)
  623. CASE_HRESULT(REGDB_E_KEYMISSING)
  624. CASE_HRESULT(REGDB_E_INVALIDVALUE)
  625. CASE_HRESULT(REGDB_E_CLASSNOTREG)
  626. CASE_HRESULT(REGDB_E_IIDNOTREG)
  627. CASE_HRESULT(CACHE_E_NOCACHE_UPDATED)
  628. CASE_HRESULT(OLEOBJ_E_NOVERBS)
  629. CASE_HRESULT(OLEOBJ_E_INVALIDVERB)
  630. CASE_HRESULT(INPLACE_E_NOTUNDOABLE)
  631. CASE_HRESULT(INPLACE_E_NOTOOLSPACE)
  632. CASE_HRESULT(CONVERT10_E_OLESTREAM_GET)
  633. CASE_HRESULT(CONVERT10_E_OLESTREAM_PUT)
  634. CASE_HRESULT(CONVERT10_E_OLESTREAM_FMT)
  635. CASE_HRESULT(CONVERT10_E_OLESTREAM_BITMAP_TO_DIB)
  636. CASE_HRESULT(CONVERT10_E_STG_FMT)
  637. CASE_HRESULT(CONVERT10_E_STG_NO_STD_STREAM)
  638. CASE_HRESULT(CONVERT10_E_STG_DIB_TO_BITMAP)
  639. CASE_HRESULT(CLIPBRD_E_CANT_OPEN)
  640. CASE_HRESULT(CLIPBRD_E_CANT_EMPTY)
  641. CASE_HRESULT(CLIPBRD_E_CANT_SET)
  642. CASE_HRESULT(CLIPBRD_E_BAD_DATA)
  643. CASE_HRESULT(CLIPBRD_E_CANT_CLOSE)
  644. CASE_HRESULT(MK_E_CONNECTMANUALLY)
  645. CASE_HRESULT(MK_E_EXCEEDEDDEADLINE)
  646. CASE_HRESULT(MK_E_NEEDGENERIC)
  647. CASE_HRESULT(MK_E_UNAVAILABLE)
  648. CASE_HRESULT(MK_E_SYNTAX)
  649. CASE_HRESULT(MK_E_NOOBJECT)
  650. CASE_HRESULT(MK_E_INVALIDEXTENSION)
  651. CASE_HRESULT(MK_E_INTERMEDIATEINTERFACENOTSUPPORTED)
  652. CASE_HRESULT(MK_E_NOTBINDABLE)
  653. CASE_HRESULT(MK_E_NOTBOUND)
  654. CASE_HRESULT(MK_E_CANTOPENFILE)
  655. CASE_HRESULT(MK_E_MUSTBOTHERUSER)
  656. CASE_HRESULT(MK_E_NOINVERSE)
  657. CASE_HRESULT(MK_E_NOSTORAGE)
  658. CASE_HRESULT(MK_E_NOPREFIX)
  659. CASE_HRESULT(MK_E_ENUMERATION_FAILED)
  660. CASE_HRESULT(CO_E_NOTINITIALIZED)
  661. CASE_HRESULT(CO_E_ALREADYINITIALIZED)
  662. CASE_HRESULT(CO_E_CANTDETERMINECLASS)
  663. CASE_HRESULT(CO_E_CLASSSTRING)
  664. CASE_HRESULT(CO_E_IIDSTRING)
  665. CASE_HRESULT(CO_E_APPNOTFOUND)
  666. CASE_HRESULT(CO_E_APPSINGLEUSE)
  667. CASE_HRESULT(CO_E_ERRORINAPP)
  668. CASE_HRESULT(CO_E_DLLNOTFOUND)
  669. CASE_HRESULT(CO_E_ERRORINDLL)
  670. CASE_HRESULT(CO_E_WRONGOSFORAPP)
  671. CASE_HRESULT(CO_E_OBJNOTREG)
  672. CASE_HRESULT(CO_E_OBJISREG)
  673. CASE_HRESULT(CO_E_OBJNOTCONNECTED)
  674. CASE_HRESULT(CO_E_APPDIDNTREG)
  675. CASE_HRESULT(CO_E_RELEASED)
  676. CASE_HRESULT(OLE_S_USEREG)
  677. CASE_HRESULT(OLE_S_STATIC)
  678. CASE_HRESULT(OLE_S_MAC_CLIPFORMAT)
  679. CASE_HRESULT(DRAGDROP_S_DROP)
  680. CASE_HRESULT(DRAGDROP_S_CANCEL)
  681. CASE_HRESULT(DRAGDROP_S_USEDEFAULTCURSORS)
  682. CASE_HRESULT(DATA_S_SAMEFORMATETC)
  683. CASE_HRESULT(VIEW_S_ALREADY_FROZEN)
  684. CASE_HRESULT(CACHE_S_FORMATETC_NOTSUPPORTED)
  685. CASE_HRESULT(CACHE_S_SAMECACHE)
  686. CASE_HRESULT(CACHE_S_SOMECACHES_NOTUPDATED)
  687. CASE_HRESULT(OLEOBJ_S_INVALIDVERB)
  688. CASE_HRESULT(OLEOBJ_S_CANNOT_DOVERB_NOW)
  689. CASE_HRESULT(OLEOBJ_S_INVALIDHWND)
  690. CASE_HRESULT(INPLACE_S_TRUNCATED)
  691. CASE_HRESULT(CONVERT10_S_NO_PRESENTATION)
  692. CASE_HRESULT(MK_S_REDUCED_TO_SELF)
  693. CASE_HRESULT(MK_S_ME)
  694. CASE_HRESULT(MK_S_HIM)
  695. CASE_HRESULT(MK_S_US)
  696. CASE_HRESULT(MK_S_MONIKERALREADYREGISTERED)
  697. CASE_HRESULT(CO_E_CLASS_CREATE_FAILED)
  698. CASE_HRESULT(CO_E_SCM_ERROR)
  699. CASE_HRESULT(CO_E_SCM_RPC_FAILURE)
  700. CASE_HRESULT(CO_E_BAD_PATH)
  701. CASE_HRESULT(CO_E_SERVER_EXEC_FAILURE)
  702. CASE_HRESULT(CO_E_OBJSRV_RPC_FAILURE)
  703. CASE_HRESULT(MK_E_NO_NORMALIZED)
  704. CASE_HRESULT(CO_E_SERVER_STOPPING)
  705. CASE_HRESULT(MEM_E_INVALID_ROOT)
  706. CASE_HRESULT(MEM_E_INVALID_LINK)
  707. CASE_HRESULT(MEM_E_INVALID_SIZE)
  708. CASE_HRESULT(CO_S_NOTALLINTERFACES)
  709. CASE_HRESULT(DISP_E_UNKNOWNINTERFACE)
  710. CASE_HRESULT(DISP_E_MEMBERNOTFOUND)
  711. CASE_HRESULT(DISP_E_PARAMNOTFOUND)
  712. CASE_HRESULT(DISP_E_TYPEMISMATCH)
  713. CASE_HRESULT(DISP_E_UNKNOWNNAME)
  714. CASE_HRESULT(DISP_E_NONAMEDARGS)
  715. CASE_HRESULT(DISP_E_BADVARTYPE)
  716. CASE_HRESULT(DISP_E_EXCEPTION)
  717. CASE_HRESULT(DISP_E_OVERFLOW)
  718. CASE_HRESULT(DISP_E_BADINDEX)
  719. CASE_HRESULT(DISP_E_UNKNOWNLCID)
  720. CASE_HRESULT(DISP_E_ARRAYISLOCKED)
  721. CASE_HRESULT(DISP_E_BADPARAMCOUNT)
  722. CASE_HRESULT(DISP_E_PARAMNOTOPTIONAL)
  723. CASE_HRESULT(DISP_E_BADCALLEE)
  724. CASE_HRESULT(DISP_E_NOTACOLLECTION)
  725. CASE_HRESULT(TYPE_E_BUFFERTOOSMALL)
  726. CASE_HRESULT(TYPE_E_INVDATAREAD)
  727. CASE_HRESULT(TYPE_E_UNSUPFORMAT)
  728. CASE_HRESULT(TYPE_E_REGISTRYACCESS)
  729. CASE_HRESULT(TYPE_E_LIBNOTREGISTERED)
  730. CASE_HRESULT(TYPE_E_UNDEFINEDTYPE)
  731. CASE_HRESULT(TYPE_E_QUALIFIEDNAMEDISALLOWED)
  732. CASE_HRESULT(TYPE_E_INVALIDSTATE)
  733. CASE_HRESULT(TYPE_E_WRONGTYPEKIND)
  734. CASE_HRESULT(TYPE_E_ELEMENTNOTFOUND)
  735. CASE_HRESULT(TYPE_E_AMBIGUOUSNAME)
  736. CASE_HRESULT(TYPE_E_NAMECONFLICT)
  737. CASE_HRESULT(TYPE_E_UNKNOWNLCID)
  738. CASE_HRESULT(TYPE_E_DLLFUNCTIONNOTFOUND)
  739. CASE_HRESULT(TYPE_E_BADMODULEKIND)
  740. CASE_HRESULT(TYPE_E_SIZETOOBIG)
  741. CASE_HRESULT(TYPE_E_DUPLICATEID)
  742. CASE_HRESULT(TYPE_E_INVALIDID)
  743. CASE_HRESULT(TYPE_E_TYPEMISMATCH)
  744. CASE_HRESULT(TYPE_E_OUTOFBOUNDS)
  745. CASE_HRESULT(TYPE_E_IOERROR)
  746. CASE_HRESULT(TYPE_E_CANTCREATETMPFILE)
  747. CASE_HRESULT(TYPE_E_CANTLOADLIBRARY)
  748. CASE_HRESULT(TYPE_E_INCONSISTENTPROPFUNCS)
  749. CASE_HRESULT(TYPE_E_CIRCULARTYPE)
  750. CASE_HRESULT(STG_E_INVALIDFUNCTION)
  751. CASE_HRESULT(STG_E_FILENOTFOUND)
  752. CASE_HRESULT(STG_E_PATHNOTFOUND)
  753. CASE_HRESULT(STG_E_TOOMANYOPENFILES)
  754. CASE_HRESULT(STG_E_ACCESSDENIED)
  755. CASE_HRESULT(STG_E_INVALIDHANDLE)
  756. CASE_HRESULT(STG_E_INSUFFICIENTMEMORY)
  757. CASE_HRESULT(STG_E_INVALIDPOINTER)
  758. CASE_HRESULT(STG_E_NOMOREFILES)
  759. CASE_HRESULT(STG_E_DISKISWRITEPROTECTED)
  760. CASE_HRESULT(STG_E_SEEKERROR)
  761. CASE_HRESULT(STG_E_WRITEFAULT)
  762. CASE_HRESULT(STG_E_READFAULT)
  763. CASE_HRESULT(STG_E_SHAREVIOLATION)
  764. CASE_HRESULT(STG_E_LOCKVIOLATION)
  765. CASE_HRESULT(STG_E_FILEALREADYEXISTS)
  766. CASE_HRESULT(STG_E_INVALIDPARAMETER)
  767. CASE_HRESULT(STG_E_MEDIUMFULL)
  768. CASE_HRESULT(STG_E_PROPSETMISMATCHED)
  769. CASE_HRESULT(STG_E_ABNORMALAPIEXIT)
  770. CASE_HRESULT(STG_E_INVALIDHEADER)
  771. CASE_HRESULT(STG_E_INVALIDNAME)
  772. CASE_HRESULT(STG_E_UNKNOWN)
  773. CASE_HRESULT(STG_E_UNIMPLEMENTEDFUNCTION)
  774. CASE_HRESULT(STG_E_INVALIDFLAG)
  775. CASE_HRESULT(STG_E_INUSE)
  776. CASE_HRESULT(STG_E_NOTCURRENT)
  777. CASE_HRESULT(STG_E_REVERTED)
  778. CASE_HRESULT(STG_E_CANTSAVE)
  779. CASE_HRESULT(STG_E_OLDFORMAT)
  780. CASE_HRESULT(STG_E_OLDDLL)
  781. CASE_HRESULT(STG_E_SHAREREQUIRED)
  782. CASE_HRESULT(STG_E_NOTFILEBASEDSTORAGE)
  783. CASE_HRESULT(STG_E_EXTANTMARSHALLINGS)
  784. CASE_HRESULT(STG_E_DOCFILECORRUPT)
  785. CASE_HRESULT(STG_E_BADBASEADDRESS)
  786. CASE_HRESULT(STG_E_INCOMPLETE)
  787. CASE_HRESULT(STG_E_TERMINATED)
  788. CASE_HRESULT(STG_S_CONVERTED)
  789. CASE_HRESULT(STG_S_BLOCK)
  790. CASE_HRESULT(STG_S_RETRYNOW)
  791. CASE_HRESULT(STG_S_MONITORING)
  792. CASE_HRESULT(RPC_E_CALL_REJECTED)
  793. CASE_HRESULT(RPC_E_CALL_CANCELED)
  794. CASE_HRESULT(RPC_E_CANTPOST_INSENDCALL)
  795. CASE_HRESULT(RPC_E_CANTCALLOUT_INASYNCCALL)
  796. CASE_HRESULT(RPC_E_CANTCALLOUT_INEXTERNALCALL)
  797. CASE_HRESULT(RPC_E_CONNECTION_TERMINATED)
  798. CASE_HRESULT(RPC_E_SERVER_DIED)
  799. CASE_HRESULT(RPC_E_CLIENT_DIED)
  800. CASE_HRESULT(RPC_E_INVALID_DATAPACKET)
  801. CASE_HRESULT(RPC_E_CANTTRANSMIT_CALL)
  802. CASE_HRESULT(RPC_E_CLIENT_CANTMARSHAL_DATA)
  803. CASE_HRESULT(RPC_E_CLIENT_CANTUNMARSHAL_DATA)
  804. CASE_HRESULT(RPC_E_SERVER_CANTMARSHAL_DATA)
  805. CASE_HRESULT(RPC_E_SERVER_CANTUNMARSHAL_DATA)
  806. CASE_HRESULT(RPC_E_INVALID_DATA)
  807. CASE_HRESULT(RPC_E_INVALID_PARAMETER)
  808. CASE_HRESULT(RPC_E_CANTCALLOUT_AGAIN)
  809. CASE_HRESULT(RPC_E_SERVER_DIED_DNE)
  810. CASE_HRESULT(RPC_E_SYS_CALL_FAILED)
  811. CASE_HRESULT(RPC_E_OUT_OF_RESOURCES)
  812. CASE_HRESULT(RPC_E_ATTEMPTED_MULTITHREAD)
  813. CASE_HRESULT(RPC_E_NOT_REGISTERED)
  814. CASE_HRESULT(RPC_E_FAULT)
  815. CASE_HRESULT(RPC_E_SERVERFAULT)
  816. CASE_HRESULT(RPC_E_CHANGED_MODE)
  817. CASE_HRESULT(RPC_E_INVALIDMETHOD)
  818. CASE_HRESULT(RPC_E_DISCONNECTED)
  819. CASE_HRESULT(RPC_E_RETRY)
  820. CASE_HRESULT(RPC_E_SERVERCALL_RETRYLATER)
  821. CASE_HRESULT(RPC_E_SERVERCALL_REJECTED)
  822. CASE_HRESULT(RPC_E_INVALID_CALLDATA)
  823. CASE_HRESULT(RPC_E_CANTCALLOUT_ININPUTSYNCCALL)
  824. CASE_HRESULT(RPC_E_WRONG_THREAD)
  825. CASE_HRESULT(RPC_E_THREAD_NOT_INIT)
  826. CASE_HRESULT(RPC_E_VERSION_MISMATCH)
  827. CASE_HRESULT(RPC_E_INVALID_HEADER)
  828. CASE_HRESULT(RPC_E_INVALID_EXTENSION)
  829. CASE_HRESULT(RPC_E_INVALID_IPID)
  830. CASE_HRESULT(RPC_E_INVALID_OBJECT)
  831. CASE_HRESULT(RPC_S_CALLPENDING)
  832. CASE_HRESULT(RPC_S_WAITONTIMER)
  833. CASE_HRESULT(RPC_E_CALL_COMPLETE)
  834. CASE_HRESULT(RPC_E_UNSECURE_CALL)
  835. CASE_HRESULT(RPC_E_TOO_LATE)
  836. CASE_HRESULT(RPC_E_NO_GOOD_SECURITY_PACKAGES)
  837. CASE_HRESULT(RPC_E_ACCESS_DENIED)
  838. CASE_HRESULT(RPC_E_REMOTE_DISABLED)
  839. CASE_HRESULT(RPC_E_INVALID_OBJREF)
  840. CASE_HRESULT(RPC_E_UNEXPECTED)
  841. CASE_HRESULT(NTE_BAD_UID)
  842. CASE_HRESULT(NTE_BAD_HASH)
  843. CASE_HRESULT(NTE_BAD_KEY)
  844. CASE_HRESULT(NTE_BAD_LEN)
  845. CASE_HRESULT(NTE_BAD_DATA)
  846. CASE_HRESULT(NTE_BAD_SIGNATURE)
  847. CASE_HRESULT(NTE_BAD_VER)
  848. CASE_HRESULT(NTE_BAD_ALGID)
  849. CASE_HRESULT(NTE_BAD_FLAGS)
  850. CASE_HRESULT(NTE_BAD_TYPE)
  851. CASE_HRESULT(NTE_BAD_KEY_STATE)
  852. CASE_HRESULT(NTE_BAD_HASH_STATE)
  853. CASE_HRESULT(NTE_NO_KEY)
  854. CASE_HRESULT(NTE_NO_MEMORY)
  855. CASE_HRESULT(NTE_EXISTS)
  856. CASE_HRESULT(NTE_PERM)
  857. CASE_HRESULT(NTE_NOT_FOUND)
  858. CASE_HRESULT(NTE_DOUBLE_ENCRYPT)
  859. CASE_HRESULT(NTE_BAD_PROVIDER)
  860. CASE_HRESULT(NTE_BAD_PROV_TYPE)
  861. CASE_HRESULT(NTE_BAD_PUBLIC_KEY)
  862. CASE_HRESULT(NTE_BAD_KEYSET)
  863. CASE_HRESULT(NTE_PROV_TYPE_NOT_DEF)
  864. CASE_HRESULT(NTE_PROV_TYPE_ENTRY_BAD)
  865. CASE_HRESULT(NTE_KEYSET_NOT_DEF)
  866. CASE_HRESULT(NTE_KEYSET_ENTRY_BAD)
  867. CASE_HRESULT(NTE_PROV_TYPE_NO_MATCH)
  868. CASE_HRESULT(NTE_SIGNATURE_FILE_BAD)
  869. CASE_HRESULT(NTE_PROVIDER_DLL_FAIL)
  870. CASE_HRESULT(NTE_PROV_DLL_NOT_FOUND)
  871. CASE_HRESULT(NTE_BAD_KEYSET_PARAM)
  872. CASE_HRESULT(NTE_FAIL)
  873. CASE_HRESULT(NTE_SYS_ERR)
  874. CASE_HRESULT(TRUST_E_PROVIDER_UNKNOWN)
  875. CASE_HRESULT(TRUST_E_ACTION_UNKNOWN)
  876. CASE_HRESULT(TRUST_E_SUBJECT_FORM_UNKNOWN)
  877. CASE_HRESULT(TRUST_E_SUBJECT_NOT_TRUSTED)
  878. CASE_HRESULT(DIGSIG_E_ENCODE)
  879. CASE_HRESULT(DIGSIG_E_DECODE)
  880. CASE_HRESULT(DIGSIG_E_EXTENSIBILITY)
  881. CASE_HRESULT(DIGSIG_E_CRYPTO)
  882. CASE_HRESULT(PERSIST_E_SIZEDEFINITE)
  883. CASE_HRESULT(PERSIST_E_SIZEINDEFINITE)
  884. CASE_HRESULT(PERSIST_E_NOTSELFSIZING)
  885. CASE_HRESULT(TRUST_E_NOSIGNATURE)
  886. CASE_HRESULT(CERT_E_EXPIRED)
  887. // CASE_HRESULT(CERT_E_VALIDITYPERIODNESTING)
  888. CASE_HRESULT(CERT_E_ROLE)
  889. CASE_HRESULT(CERT_E_PATHLENCONST)
  890. CASE_HRESULT(CERT_E_CRITICAL)
  891. CASE_HRESULT(CERT_E_PURPOSE)
  892. CASE_HRESULT(CERT_E_ISSUERCHAINING)
  893. CASE_HRESULT(CERT_E_MALFORMED)
  894. CASE_HRESULT(CERT_E_UNTRUSTEDROOT)
  895. CASE_HRESULT(CERT_E_CHAINING)
  896. // OLE controls
  897. CASE_HRESULT(CTL_E_ILLEGALFUNCTIONCALL)
  898. CASE_HRESULT(CTL_E_OVERFLOW)
  899. CASE_HRESULT(CTL_E_OUTOFMEMORY)
  900. CASE_HRESULT(CTL_E_DIVISIONBYZERO)
  901. CASE_HRESULT(CTL_E_OUTOFSTRINGSPACE)
  902. CASE_HRESULT(CTL_E_OUTOFSTACKSPACE)
  903. CASE_HRESULT(CTL_E_BADFILENAMEORNUMBER)
  904. CASE_HRESULT(CTL_E_FILENOTFOUND)
  905. CASE_HRESULT(CTL_E_BADFILEMODE)
  906. CASE_HRESULT(CTL_E_FILEALREADYOPEN)
  907. CASE_HRESULT(CTL_E_DEVICEIOERROR)
  908. CASE_HRESULT(CTL_E_FILEALREADYEXISTS)
  909. CASE_HRESULT(CTL_E_BADRECORDLENGTH)
  910. CASE_HRESULT(CTL_E_DISKFULL)
  911. CASE_HRESULT(CTL_E_BADRECORDNUMBER)
  912. CASE_HRESULT(CTL_E_BADFILENAME)
  913. CASE_HRESULT(CTL_E_TOOMANYFILES)
  914. CASE_HRESULT(CTL_E_DEVICEUNAVAILABLE)
  915. CASE_HRESULT(CTL_E_PERMISSIONDENIED)
  916. CASE_HRESULT(CTL_E_DISKNOTREADY)
  917. CASE_HRESULT(CTL_E_PATHFILEACCESSERROR)
  918. CASE_HRESULT(CTL_E_PATHNOTFOUND)
  919. CASE_HRESULT(CTL_E_INVALIDPATTERNSTRING)
  920. CASE_HRESULT(CTL_E_INVALIDUSEOFNULL)
  921. CASE_HRESULT(CTL_E_INVALIDFILEFORMAT)
  922. CASE_HRESULT(CTL_E_INVALIDPROPERTYVALUE)
  923. CASE_HRESULT(CTL_E_INVALIDPROPERTYARRAYINDEX)
  924. CASE_HRESULT(CTL_E_SETNOTSUPPORTEDATRUNTIME)
  925. CASE_HRESULT(CTL_E_SETNOTSUPPORTED)
  926. CASE_HRESULT(CTL_E_NEEDPROPERTYARRAYINDEX)
  927. CASE_HRESULT(CTL_E_SETNOTPERMITTED)
  928. CASE_HRESULT(CTL_E_GETNOTSUPPORTEDATRUNTIME)
  929. CASE_HRESULT(CTL_E_GETNOTSUPPORTED)
  930. CASE_HRESULT(CTL_E_PROPERTYNOTFOUND)
  931. CASE_HRESULT(CTL_E_INVALIDCLIPBOARDFORMAT)
  932. CASE_HRESULT(CTL_E_INVALIDPICTURE)
  933. CASE_HRESULT(CTL_E_PRINTERERROR)
  934. CASE_HRESULT(CTL_E_CANTSAVEFILETOTEMP)
  935. CASE_HRESULT(CTL_E_SEARCHTEXTNOTFOUND)
  936. CASE_HRESULT(CTL_E_REPLACEMENTSTOOLONG)
  937. CASE_HRESULT(CLASS_E_NOTLICENSED)
  938. default:
  939. // Check if the HRESULT has FACILITY_WIN32. If so,
  940. // extract the code and check against the codes in winerror.h
  941. if (HRESULT_FACILITY(hr) == FACILITY_WIN32)
  942. {
  943. switch (HRESULT_CODE(hr))
  944. {
  945. CASE_CODE(ERROR_SUCCESS)
  946. CASE_CODE(ERROR_INVALID_FUNCTION)
  947. CASE_CODE(ERROR_FILE_NOT_FOUND)
  948. CASE_CODE(ERROR_PATH_NOT_FOUND)
  949. CASE_CODE(ERROR_TOO_MANY_OPEN_FILES)
  950. CASE_CODE(ERROR_ACCESS_DENIED)
  951. CASE_CODE(ERROR_INVALID_HANDLE)
  952. CASE_CODE(ERROR_ARENA_TRASHED)
  953. CASE_CODE(ERROR_NOT_ENOUGH_MEMORY)
  954. CASE_CODE(ERROR_INVALID_BLOCK)
  955. CASE_CODE(ERROR_BAD_ENVIRONMENT)
  956. CASE_CODE(ERROR_BAD_FORMAT)
  957. CASE_CODE(ERROR_INVALID_ACCESS)
  958. CASE_CODE(ERROR_INVALID_DATA)
  959. CASE_CODE(ERROR_OUTOFMEMORY)
  960. CASE_CODE(ERROR_INVALID_DRIVE)
  961. CASE_CODE(ERROR_CURRENT_DIRECTORY)
  962. CASE_CODE(ERROR_NOT_SAME_DEVICE)
  963. CASE_CODE(ERROR_NO_MORE_FILES)
  964. CASE_CODE(ERROR_WRITE_PROTECT)
  965. CASE_CODE(ERROR_BAD_UNIT)
  966. CASE_CODE(ERROR_NOT_READY)
  967. CASE_CODE(ERROR_BAD_COMMAND)
  968. CASE_CODE(ERROR_CRC)
  969. CASE_CODE(ERROR_BAD_LENGTH)
  970. CASE_CODE(ERROR_SEEK)
  971. CASE_CODE(ERROR_NOT_DOS_DISK)
  972. CASE_CODE(ERROR_SECTOR_NOT_FOUND)
  973. CASE_CODE(ERROR_OUT_OF_PAPER)
  974. CASE_CODE(ERROR_WRITE_FAULT)
  975. CASE_CODE(ERROR_READ_FAULT)
  976. CASE_CODE(ERROR_GEN_FAILURE)
  977. CASE_CODE(ERROR_SHARING_VIOLATION)
  978. CASE_CODE(ERROR_LOCK_VIOLATION)
  979. CASE_CODE(ERROR_WRONG_DISK)
  980. CASE_CODE(ERROR_SHARING_BUFFER_EXCEEDED)
  981. CASE_CODE(ERROR_HANDLE_EOF)
  982. CASE_CODE(ERROR_HANDLE_DISK_FULL)
  983. CASE_CODE(ERROR_NOT_SUPPORTED)
  984. CASE_CODE(ERROR_REM_NOT_LIST)
  985. CASE_CODE(ERROR_DUP_NAME)
  986. CASE_CODE(ERROR_BAD_NETPATH)
  987. CASE_CODE(ERROR_NETWORK_BUSY)
  988. CASE_CODE(ERROR_DEV_NOT_EXIST)
  989. CASE_CODE(ERROR_TOO_MANY_CMDS)
  990. CASE_CODE(ERROR_ADAP_HDW_ERR)
  991. CASE_CODE(ERROR_BAD_NET_RESP)
  992. CASE_CODE(ERROR_UNEXP_NET_ERR)
  993. CASE_CODE(ERROR_BAD_REM_ADAP)
  994. CASE_CODE(ERROR_PRINTQ_FULL)
  995. CASE_CODE(ERROR_NO_SPOOL_SPACE)
  996. CASE_CODE(ERROR_PRINT_CANCELLED)
  997. CASE_CODE(ERROR_NETNAME_DELETED)
  998. CASE_CODE(ERROR_NETWORK_ACCESS_DENIED)
  999. CASE_CODE(ERROR_BAD_DEV_TYPE)
  1000. CASE_CODE(ERROR_BAD_NET_NAME)
  1001. CASE_CODE(ERROR_TOO_MANY_NAMES)
  1002. CASE_CODE(ERROR_TOO_MANY_SESS)
  1003. CASE_CODE(ERROR_SHARING_PAUSED)
  1004. CASE_CODE(ERROR_REQ_NOT_ACCEP)
  1005. CASE_CODE(ERROR_REDIR_PAUSED)
  1006. CASE_CODE(ERROR_FILE_EXISTS)
  1007. CASE_CODE(ERROR_CANNOT_MAKE)
  1008. CASE_CODE(ERROR_FAIL_I24)
  1009. CASE_CODE(ERROR_OUT_OF_STRUCTURES)
  1010. CASE_CODE(ERROR_ALREADY_ASSIGNED)
  1011. CASE_CODE(ERROR_INVALID_PASSWORD)
  1012. CASE_CODE(ERROR_INVALID_PARAMETER)
  1013. CASE_CODE(ERROR_NET_WRITE_FAULT)
  1014. CASE_CODE(ERROR_NO_PROC_SLOTS)
  1015. CASE_CODE(ERROR_TOO_MANY_SEMAPHORES)
  1016. CASE_CODE(ERROR_EXCL_SEM_ALREADY_OWNED)
  1017. CASE_CODE(ERROR_SEM_IS_SET)
  1018. CASE_CODE(ERROR_TOO_MANY_SEM_REQUESTS)
  1019. CASE_CODE(ERROR_INVALID_AT_INTERRUPT_TIME)
  1020. CASE_CODE(ERROR_SEM_OWNER_DIED)
  1021. CASE_CODE(ERROR_SEM_USER_LIMIT)
  1022. CASE_CODE(ERROR_DISK_CHANGE)
  1023. CASE_CODE(ERROR_DRIVE_LOCKED)
  1024. CASE_CODE(ERROR_BROKEN_PIPE)
  1025. CASE_CODE(ERROR_OPEN_FAILED)
  1026. CASE_CODE(ERROR_BUFFER_OVERFLOW)
  1027. CASE_CODE(ERROR_DISK_FULL)
  1028. CASE_CODE(ERROR_NO_MORE_SEARCH_HANDLES)
  1029. CASE_CODE(ERROR_INVALID_TARGET_HANDLE)
  1030. CASE_CODE(ERROR_INVALID_CATEGORY)
  1031. CASE_CODE(ERROR_INVALID_VERIFY_SWITCH)
  1032. CASE_CODE(ERROR_BAD_DRIVER_LEVEL)
  1033. CASE_CODE(ERROR_CALL_NOT_IMPLEMENTED)
  1034. CASE_CODE(ERROR_SEM_TIMEOUT)
  1035. CASE_CODE(ERROR_INSUFFICIENT_BUFFER)
  1036. CASE_CODE(ERROR_INVALID_NAME)
  1037. CASE_CODE(ERROR_INVALID_LEVEL)
  1038. CASE_CODE(ERROR_NO_VOLUME_LABEL)
  1039. CASE_CODE(ERROR_MOD_NOT_FOUND)
  1040. CASE_CODE(ERROR_PROC_NOT_FOUND)
  1041. CASE_CODE(ERROR_WAIT_NO_CHILDREN)
  1042. CASE_CODE(ERROR_CHILD_NOT_COMPLETE)
  1043. CASE_CODE(ERROR_DIRECT_ACCESS_HANDLE)
  1044. CASE_CODE(ERROR_NEGATIVE_SEEK)
  1045. CASE_CODE(ERROR_SEEK_ON_DEVICE)
  1046. CASE_CODE(ERROR_IS_JOIN_TARGET)
  1047. CASE_CODE(ERROR_IS_JOINED)
  1048. CASE_CODE(ERROR_IS_SUBSTED)
  1049. CASE_CODE(ERROR_NOT_JOINED)
  1050. CASE_CODE(ERROR_NOT_SUBSTED)
  1051. CASE_CODE(ERROR_JOIN_TO_JOIN)
  1052. CASE_CODE(ERROR_SUBST_TO_SUBST)
  1053. CASE_CODE(ERROR_JOIN_TO_SUBST)
  1054. CASE_CODE(ERROR_SUBST_TO_JOIN)
  1055. CASE_CODE(ERROR_BUSY_DRIVE)
  1056. CASE_CODE(ERROR_SAME_DRIVE)
  1057. CASE_CODE(ERROR_DIR_NOT_ROOT)
  1058. CASE_CODE(ERROR_DIR_NOT_EMPTY)
  1059. CASE_CODE(ERROR_IS_SUBST_PATH)
  1060. CASE_CODE(ERROR_IS_JOIN_PATH)
  1061. CASE_CODE(ERROR_PATH_BUSY)
  1062. CASE_CODE(ERROR_IS_SUBST_TARGET)
  1063. CASE_CODE(ERROR_SYSTEM_TRACE)
  1064. CASE_CODE(ERROR_INVALID_EVENT_COUNT)
  1065. CASE_CODE(ERROR_TOO_MANY_MUXWAITERS)
  1066. CASE_CODE(ERROR_INVALID_LIST_FORMAT)
  1067. CASE_CODE(ERROR_LABEL_TOO_LONG)
  1068. CASE_CODE(ERROR_TOO_MANY_TCBS)
  1069. CASE_CODE(ERROR_SIGNAL_REFUSED)
  1070. CASE_CODE(ERROR_DISCARDED)
  1071. CASE_CODE(ERROR_NOT_LOCKED)
  1072. CASE_CODE(ERROR_BAD_THREADID_ADDR)
  1073. CASE_CODE(ERROR_BAD_ARGUMENTS)
  1074. CASE_CODE(ERROR_BAD_PATHNAME)
  1075. CASE_CODE(ERROR_SIGNAL_PENDING)
  1076. CASE_CODE(ERROR_MAX_THRDS_REACHED)
  1077. CASE_CODE(ERROR_LOCK_FAILED)
  1078. CASE_CODE(ERROR_BUSY)
  1079. CASE_CODE(ERROR_CANCEL_VIOLATION)
  1080. CASE_CODE(ERROR_ATOMIC_LOCKS_NOT_SUPPORTED)
  1081. CASE_CODE(ERROR_INVALID_SEGMENT_NUMBER)
  1082. CASE_CODE(ERROR_INVALID_ORDINAL)
  1083. CASE_CODE(ERROR_ALREADY_EXISTS)
  1084. CASE_CODE(ERROR_INVALID_FLAG_NUMBER)
  1085. CASE_CODE(ERROR_SEM_NOT_FOUND)
  1086. CASE_CODE(ERROR_INVALID_STARTING_CODESEG)
  1087. CASE_CODE(ERROR_INVALID_STACKSEG)
  1088. CASE_CODE(ERROR_INVALID_MODULETYPE)
  1089. CASE_CODE(ERROR_INVALID_EXE_SIGNATURE)
  1090. CASE_CODE(ERROR_EXE_MARKED_INVALID)
  1091. CASE_CODE(ERROR_BAD_EXE_FORMAT)
  1092. CASE_CODE(ERROR_ITERATED_DATA_EXCEEDS_64k)
  1093. CASE_CODE(ERROR_INVALID_MINALLOCSIZE)
  1094. CASE_CODE(ERROR_DYNLINK_FROM_INVALID_RING)
  1095. CASE_CODE(ERROR_IOPL_NOT_ENABLED)
  1096. CASE_CODE(ERROR_INVALID_SEGDPL)
  1097. CASE_CODE(ERROR_AUTODATASEG_EXCEEDS_64k)
  1098. CASE_CODE(ERROR_RING2SEG_MUST_BE_MOVABLE)
  1099. CASE_CODE(ERROR_RELOC_CHAIN_XEEDS_SEGLIM)
  1100. CASE_CODE(ERROR_INFLOOP_IN_RELOC_CHAIN)
  1101. CASE_CODE(ERROR_ENVVAR_NOT_FOUND)
  1102. CASE_CODE(ERROR_NO_SIGNAL_SENT)
  1103. CASE_CODE(ERROR_FILENAME_EXCED_RANGE)
  1104. CASE_CODE(ERROR_RING2_STACK_IN_USE)
  1105. CASE_CODE(ERROR_META_EXPANSION_TOO_LONG)
  1106. CASE_CODE(ERROR_INVALID_SIGNAL_NUMBER)
  1107. CASE_CODE(ERROR_THREAD_1_INACTIVE)
  1108. CASE_CODE(ERROR_LOCKED)
  1109. CASE_CODE(ERROR_TOO_MANY_MODULES)
  1110. CASE_CODE(ERROR_NESTING_NOT_ALLOWED)
  1111. CASE_CODE(ERROR_EXE_MACHINE_TYPE_MISMATCH)
  1112. CASE_CODE(ERROR_BAD_PIPE)
  1113. CASE_CODE(ERROR_PIPE_BUSY)
  1114. CASE_CODE(ERROR_NO_DATA)
  1115. CASE_CODE(ERROR_PIPE_NOT_CONNECTED)
  1116. CASE_CODE(ERROR_MORE_DATA)
  1117. CASE_CODE(ERROR_VC_DISCONNECTED)
  1118. CASE_CODE(ERROR_INVALID_EA_NAME)
  1119. CASE_CODE(ERROR_EA_LIST_INCONSISTENT)
  1120. CASE_CODE(ERROR_NO_MORE_ITEMS)
  1121. CASE_CODE(ERROR_CANNOT_COPY)
  1122. CASE_CODE(ERROR_DIRECTORY)
  1123. CASE_CODE(ERROR_EAS_DIDNT_FIT)
  1124. CASE_CODE(ERROR_EA_FILE_CORRUPT)
  1125. CASE_CODE(ERROR_EA_TABLE_FULL)
  1126. CASE_CODE(ERROR_INVALID_EA_HANDLE)
  1127. CASE_CODE(ERROR_EAS_NOT_SUPPORTED)
  1128. CASE_CODE(ERROR_NOT_OWNER)
  1129. CASE_CODE(ERROR_TOO_MANY_POSTS)
  1130. CASE_CODE(ERROR_PARTIAL_COPY)
  1131. CASE_CODE(ERROR_MR_MID_NOT_FOUND)
  1132. CASE_CODE(ERROR_INVALID_ADDRESS)
  1133. CASE_CODE(ERROR_ARITHMETIC_OVERFLOW)
  1134. CASE_CODE(ERROR_PIPE_CONNECTED)
  1135. CASE_CODE(ERROR_PIPE_LISTENING)
  1136. CASE_CODE(ERROR_EA_ACCESS_DENIED)
  1137. CASE_CODE(ERROR_OPERATION_ABORTED)
  1138. CASE_CODE(ERROR_IO_INCOMPLETE)
  1139. CASE_CODE(ERROR_IO_PENDING)
  1140. CASE_CODE(ERROR_NOACCESS)
  1141. CASE_CODE(ERROR_SWAPERROR)
  1142. CASE_CODE(ERROR_STACK_OVERFLOW)
  1143. CASE_CODE(ERROR_INVALID_MESSAGE)
  1144. CASE_CODE(ERROR_CAN_NOT_COMPLETE)
  1145. CASE_CODE(ERROR_INVALID_FLAGS)
  1146. CASE_CODE(ERROR_UNRECOGNIZED_VOLUME)
  1147. CASE_CODE(ERROR_FILE_INVALID)
  1148. CASE_CODE(ERROR_FULLSCREEN_MODE)
  1149. CASE_CODE(ERROR_NO_TOKEN)
  1150. CASE_CODE(ERROR_BADDB)
  1151. CASE_CODE(ERROR_BADKEY)
  1152. CASE_CODE(ERROR_CANTOPEN)
  1153. CASE_CODE(ERROR_CANTREAD)
  1154. CASE_CODE(ERROR_CANTWRITE)
  1155. CASE_CODE(ERROR_REGISTRY_RECOVERED)
  1156. CASE_CODE(ERROR_REGISTRY_CORRUPT)
  1157. CASE_CODE(ERROR_REGISTRY_IO_FAILED)
  1158. CASE_CODE(ERROR_NOT_REGISTRY_FILE)
  1159. CASE_CODE(ERROR_KEY_DELETED)
  1160. CASE_CODE(ERROR_NO_LOG_SPACE)
  1161. CASE_CODE(ERROR_KEY_HAS_CHILDREN)
  1162. CASE_CODE(ERROR_CHILD_MUST_BE_VOLATILE)
  1163. CASE_CODE(ERROR_NOTIFY_ENUM_DIR)
  1164. CASE_CODE(ERROR_DEPENDENT_SERVICES_RUNNING)
  1165. CASE_CODE(ERROR_INVALID_SERVICE_CONTROL)
  1166. CASE_CODE(ERROR_SERVICE_REQUEST_TIMEOUT)
  1167. CASE_CODE(ERROR_SERVICE_NO_THREAD)
  1168. CASE_CODE(ERROR_SERVICE_DATABASE_LOCKED)
  1169. CASE_CODE(ERROR_SERVICE_ALREADY_RUNNING)
  1170. CASE_CODE(ERROR_INVALID_SERVICE_ACCOUNT)
  1171. CASE_CODE(ERROR_SERVICE_DISABLED)
  1172. CASE_CODE(ERROR_CIRCULAR_DEPENDENCY)
  1173. CASE_CODE(ERROR_SERVICE_DOES_NOT_EXIST)
  1174. CASE_CODE(ERROR_SERVICE_CANNOT_ACCEPT_CTRL)
  1175. CASE_CODE(ERROR_SERVICE_NOT_ACTIVE)
  1176. CASE_CODE(ERROR_FAILED_SERVICE_CONTROLLER_CONNECT)
  1177. CASE_CODE(ERROR_EXCEPTION_IN_SERVICE)
  1178. CASE_CODE(ERROR_DATABASE_DOES_NOT_EXIST)
  1179. CASE_CODE(ERROR_SERVICE_SPECIFIC_ERROR)
  1180. CASE_CODE(ERROR_PROCESS_ABORTED)
  1181. CASE_CODE(ERROR_SERVICE_DEPENDENCY_FAIL)
  1182. CASE_CODE(ERROR_SERVICE_LOGON_FAILED)
  1183. CASE_CODE(ERROR_SERVICE_START_HANG)
  1184. CASE_CODE(ERROR_INVALID_SERVICE_LOCK)
  1185. CASE_CODE(ERROR_SERVICE_MARKED_FOR_DELETE)
  1186. CASE_CODE(ERROR_SERVICE_EXISTS)
  1187. CASE_CODE(ERROR_ALREADY_RUNNING_LKG)
  1188. CASE_CODE(ERROR_SERVICE_DEPENDENCY_DELETED)
  1189. CASE_CODE(ERROR_BOOT_ALREADY_ACCEPTED)
  1190. CASE_CODE(ERROR_SERVICE_NEVER_STARTED)
  1191. CASE_CODE(ERROR_DUPLICATE_SERVICE_NAME)
  1192. CASE_CODE(ERROR_DIFFERENT_SERVICE_ACCOUNT)
  1193. CASE_CODE(ERROR_END_OF_MEDIA)
  1194. CASE_CODE(ERROR_FILEMARK_DETECTED)
  1195. CASE_CODE(ERROR_BEGINNING_OF_MEDIA)
  1196. CASE_CODE(ERROR_SETMARK_DETECTED)
  1197. CASE_CODE(ERROR_NO_DATA_DETECTED)
  1198. CASE_CODE(ERROR_PARTITION_FAILURE)
  1199. CASE_CODE(ERROR_INVALID_BLOCK_LENGTH)
  1200. CASE_CODE(ERROR_DEVICE_NOT_PARTITIONED)
  1201. CASE_CODE(ERROR_UNABLE_TO_LOCK_MEDIA)
  1202. CASE_CODE(ERROR_UNABLE_TO_UNLOAD_MEDIA)
  1203. CASE_CODE(ERROR_MEDIA_CHANGED)
  1204. CASE_CODE(ERROR_BUS_RESET)
  1205. CASE_CODE(ERROR_NO_MEDIA_IN_DRIVE)
  1206. CASE_CODE(ERROR_NO_UNICODE_TRANSLATION)
  1207. CASE_CODE(ERROR_DLL_INIT_FAILED)
  1208. CASE_CODE(ERROR_SHUTDOWN_IN_PROGRESS)
  1209. CASE_CODE(ERROR_NO_SHUTDOWN_IN_PROGRESS)
  1210. CASE_CODE(ERROR_IO_DEVICE)
  1211. CASE_CODE(ERROR_SERIAL_NO_DEVICE)
  1212. CASE_CODE(ERROR_IRQ_BUSY)
  1213. CASE_CODE(ERROR_MORE_WRITES)
  1214. CASE_CODE(ERROR_COUNTER_TIMEOUT)
  1215. CASE_CODE(ERROR_FLOPPY_ID_MARK_NOT_FOUND)
  1216. CASE_CODE(ERROR_FLOPPY_WRONG_CYLINDER)
  1217. CASE_CODE(ERROR_FLOPPY_UNKNOWN_ERROR)
  1218. CASE_CODE(ERROR_FLOPPY_BAD_REGISTERS)
  1219. CASE_CODE(ERROR_DISK_RECALIBRATE_FAILED)
  1220. CASE_CODE(ERROR_DISK_OPERATION_FAILED)
  1221. CASE_CODE(ERROR_DISK_RESET_FAILED)
  1222. CASE_CODE(ERROR_EOM_OVERFLOW)
  1223. CASE_CODE(ERROR_NOT_ENOUGH_SERVER_MEMORY)
  1224. CASE_CODE(ERROR_POSSIBLE_DEADLOCK)
  1225. CASE_CODE(ERROR_MAPPED_ALIGNMENT)
  1226. CASE_CODE(ERROR_SET_POWER_STATE_VETOED)
  1227. CASE_CODE(ERROR_SET_POWER_STATE_FAILED)
  1228. CASE_CODE(ERROR_TOO_MANY_LINKS)
  1229. CASE_CODE(ERROR_OLD_WIN_VERSION)
  1230. CASE_CODE(ERROR_APP_WRONG_OS)
  1231. CASE_CODE(ERROR_SINGLE_INSTANCE_APP)
  1232. CASE_CODE(ERROR_RMODE_APP)
  1233. CASE_CODE(ERROR_INVALID_DLL)
  1234. CASE_CODE(ERROR_NO_ASSOCIATION)
  1235. CASE_CODE(ERROR_DDE_FAIL)
  1236. CASE_CODE(ERROR_DLL_NOT_FOUND)
  1237. CASE_CODE(ERROR_BAD_USERNAME)
  1238. CASE_CODE(ERROR_NOT_CONNECTED)
  1239. CASE_CODE(ERROR_OPEN_FILES)
  1240. CASE_CODE(ERROR_ACTIVE_CONNECTIONS)
  1241. CASE_CODE(ERROR_DEVICE_IN_USE)
  1242. CASE_CODE(ERROR_BAD_DEVICE)
  1243. CASE_CODE(ERROR_CONNECTION_UNAVAIL)
  1244. CASE_CODE(ERROR_DEVICE_ALREADY_REMEMBERED)
  1245. CASE_CODE(ERROR_NO_NET_OR_BAD_PATH)
  1246. CASE_CODE(ERROR_BAD_PROVIDER)
  1247. CASE_CODE(ERROR_CANNOT_OPEN_PROFILE)
  1248. CASE_CODE(ERROR_BAD_PROFILE)
  1249. CASE_CODE(ERROR_NOT_CONTAINER)
  1250. CASE_CODE(ERROR_EXTENDED_ERROR)
  1251. CASE_CODE(ERROR_INVALID_GROUPNAME)
  1252. CASE_CODE(ERROR_INVALID_COMPUTERNAME)
  1253. CASE_CODE(ERROR_INVALID_EVENTNAME)
  1254. CASE_CODE(ERROR_INVALID_DOMAINNAME)
  1255. CASE_CODE(ERROR_INVALID_SERVICENAME)
  1256. CASE_CODE(ERROR_INVALID_NETNAME)
  1257. CASE_CODE(ERROR_INVALID_SHARENAME)
  1258. CASE_CODE(ERROR_INVALID_PASSWORDNAME)
  1259. CASE_CODE(ERROR_INVALID_MESSAGENAME)
  1260. CASE_CODE(ERROR_INVALID_MESSAGEDEST)
  1261. CASE_CODE(ERROR_SESSION_CREDENTIAL_CONFLICT)
  1262. CASE_CODE(ERROR_REMOTE_SESSION_LIMIT_EXCEEDED)
  1263. CASE_CODE(ERROR_DUP_DOMAINNAME)
  1264. CASE_CODE(ERROR_NO_NETWORK)
  1265. CASE_CODE(ERROR_CANCELLED)
  1266. CASE_CODE(ERROR_USER_MAPPED_FILE)
  1267. CASE_CODE(ERROR_CONNECTION_REFUSED)
  1268. CASE_CODE(ERROR_GRACEFUL_DISCONNECT)
  1269. CASE_CODE(ERROR_ADDRESS_ALREADY_ASSOCIATED)
  1270. CASE_CODE(ERROR_ADDRESS_NOT_ASSOCIATED)
  1271. CASE_CODE(ERROR_CONNECTION_INVALID)
  1272. CASE_CODE(ERROR_CONNECTION_ACTIVE)
  1273. CASE_CODE(ERROR_NETWORK_UNREACHABLE)
  1274. CASE_CODE(ERROR_HOST_UNREACHABLE)
  1275. CASE_CODE(ERROR_PROTOCOL_UNREACHABLE)
  1276. CASE_CODE(ERROR_PORT_UNREACHABLE)
  1277. CASE_CODE(ERROR_REQUEST_ABORTED)
  1278. CASE_CODE(ERROR_CONNECTION_ABORTED)
  1279. CASE_CODE(ERROR_RETRY)
  1280. CASE_CODE(ERROR_CONNECTION_COUNT_LIMIT)
  1281. CASE_CODE(ERROR_LOGIN_TIME_RESTRICTION)
  1282. CASE_CODE(ERROR_LOGIN_WKSTA_RESTRICTION)
  1283. CASE_CODE(ERROR_INCORRECT_ADDRESS)
  1284. CASE_CODE(ERROR_ALREADY_REGISTERED)
  1285. CASE_CODE(ERROR_SERVICE_NOT_FOUND)
  1286. CASE_CODE(ERROR_NOT_AUTHENTICATED)
  1287. CASE_CODE(ERROR_NOT_LOGGED_ON)
  1288. CASE_CODE(ERROR_CONTINUE)
  1289. CASE_CODE(ERROR_ALREADY_INITIALIZED)
  1290. CASE_CODE(ERROR_NO_MORE_DEVICES)
  1291. CASE_CODE(ERROR_NOT_ALL_ASSIGNED)
  1292. CASE_CODE(ERROR_SOME_NOT_MAPPED)
  1293. CASE_CODE(ERROR_NO_QUOTAS_FOR_ACCOUNT)
  1294. CASE_CODE(ERROR_LOCAL_USER_SESSION_KEY)
  1295. CASE_CODE(ERROR_NULL_LM_PASSWORD)
  1296. CASE_CODE(ERROR_UNKNOWN_REVISION)
  1297. CASE_CODE(ERROR_REVISION_MISMATCH)
  1298. CASE_CODE(ERROR_INVALID_OWNER)
  1299. CASE_CODE(ERROR_INVALID_PRIMARY_GROUP)
  1300. CASE_CODE(ERROR_NO_IMPERSONATION_TOKEN)
  1301. CASE_CODE(ERROR_CANT_DISABLE_MANDATORY)
  1302. CASE_CODE(ERROR_NO_LOGON_SERVERS)
  1303. CASE_CODE(ERROR_NO_SUCH_LOGON_SESSION)
  1304. CASE_CODE(ERROR_NO_SUCH_PRIVILEGE)
  1305. CASE_CODE(ERROR_PRIVILEGE_NOT_HELD)
  1306. CASE_CODE(ERROR_INVALID_ACCOUNT_NAME)
  1307. CASE_CODE(ERROR_USER_EXISTS)
  1308. CASE_CODE(ERROR_NO_SUCH_USER)
  1309. CASE_CODE(ERROR_GROUP_EXISTS)
  1310. CASE_CODE(ERROR_NO_SUCH_GROUP)
  1311. CASE_CODE(ERROR_MEMBER_IN_GROUP)
  1312. CASE_CODE(ERROR_MEMBER_NOT_IN_GROUP)
  1313. CASE_CODE(ERROR_LAST_ADMIN)
  1314. CASE_CODE(ERROR_WRONG_PASSWORD)
  1315. CASE_CODE(ERROR_ILL_FORMED_PASSWORD)
  1316. CASE_CODE(ERROR_PASSWORD_RESTRICTION)
  1317. CASE_CODE(ERROR_LOGON_FAILURE)
  1318. CASE_CODE(ERROR_ACCOUNT_RESTRICTION)
  1319. CASE_CODE(ERROR_INVALID_LOGON_HOURS)
  1320. CASE_CODE(ERROR_INVALID_WORKSTATION)
  1321. CASE_CODE(ERROR_PASSWORD_EXPIRED)
  1322. CASE_CODE(ERROR_ACCOUNT_DISABLED)
  1323. CASE_CODE(ERROR_NONE_MAPPED)
  1324. CASE_CODE(ERROR_TOO_MANY_LUIDS_REQUESTED)
  1325. CASE_CODE(ERROR_LUIDS_EXHAUSTED)
  1326. CASE_CODE(ERROR_INVALID_SUB_AUTHORITY)
  1327. CASE_CODE(ERROR_INVALID_ACL)
  1328. CASE_CODE(ERROR_INVALID_SID)
  1329. CASE_CODE(ERROR_INVALID_SECURITY_DESCR)
  1330. CASE_CODE(ERROR_BAD_INHERITANCE_ACL)
  1331. CASE_CODE(ERROR_SERVER_DISABLED)
  1332. CASE_CODE(ERROR_SERVER_NOT_DISABLED)
  1333. CASE_CODE(ERROR_INVALID_ID_AUTHORITY)
  1334. CASE_CODE(ERROR_ALLOTTED_SPACE_EXCEEDED)
  1335. CASE_CODE(ERROR_INVALID_GROUP_ATTRIBUTES)
  1336. CASE_CODE(ERROR_BAD_IMPERSONATION_LEVEL)
  1337. CASE_CODE(ERROR_CANT_OPEN_ANONYMOUS)
  1338. CASE_CODE(ERROR_BAD_VALIDATION_CLASS)
  1339. CASE_CODE(ERROR_BAD_TOKEN_TYPE)
  1340. CASE_CODE(ERROR_NO_SECURITY_ON_OBJECT)
  1341. CASE_CODE(ERROR_CANT_ACCESS_DOMAIN_INFO)
  1342. CASE_CODE(ERROR_INVALID_SERVER_STATE)
  1343. CASE_CODE(ERROR_INVALID_DOMAIN_STATE)
  1344. CASE_CODE(ERROR_INVALID_DOMAIN_ROLE)
  1345. CASE_CODE(ERROR_NO_SUCH_DOMAIN)
  1346. CASE_CODE(ERROR_DOMAIN_EXISTS)
  1347. CASE_CODE(ERROR_DOMAIN_LIMIT_EXCEEDED)
  1348. CASE_CODE(ERROR_INTERNAL_DB_CORRUPTION)
  1349. CASE_CODE(ERROR_INTERNAL_ERROR)
  1350. CASE_CODE(ERROR_GENERIC_NOT_MAPPED)
  1351. CASE_CODE(ERROR_BAD_DESCRIPTOR_FORMAT)
  1352. CASE_CODE(ERROR_NOT_LOGON_PROCESS)
  1353. CASE_CODE(ERROR_LOGON_SESSION_EXISTS)
  1354. CASE_CODE(ERROR_NO_SUCH_PACKAGE)
  1355. CASE_CODE(ERROR_BAD_LOGON_SESSION_STATE)
  1356. CASE_CODE(ERROR_LOGON_SESSION_COLLISION)
  1357. CASE_CODE(ERROR_INVALID_LOGON_TYPE)
  1358. CASE_CODE(ERROR_CANNOT_IMPERSONATE)
  1359. CASE_CODE(ERROR_RXACT_INVALID_STATE)
  1360. CASE_CODE(ERROR_RXACT_COMMIT_FAILURE)
  1361. CASE_CODE(ERROR_SPECIAL_ACCOUNT)
  1362. CASE_CODE(ERROR_SPECIAL_GROUP)
  1363. CASE_CODE(ERROR_SPECIAL_USER)
  1364. CASE_CODE(ERROR_MEMBERS_PRIMARY_GROUP)
  1365. CASE_CODE(ERROR_TOKEN_ALREADY_IN_USE)
  1366. CASE_CODE(ERROR_NO_SUCH_ALIAS)
  1367. CASE_CODE(ERROR_MEMBER_NOT_IN_ALIAS)
  1368. CASE_CODE(ERROR_MEMBER_IN_ALIAS)
  1369. CASE_CODE(ERROR_ALIAS_EXISTS)
  1370. CASE_CODE(ERROR_LOGON_NOT_GRANTED)
  1371. CASE_CODE(ERROR_TOO_MANY_SECRETS)
  1372. CASE_CODE(ERROR_SECRET_TOO_LONG)
  1373. CASE_CODE(ERROR_INTERNAL_DB_ERROR)
  1374. CASE_CODE(ERROR_TOO_MANY_CONTEXT_IDS)
  1375. CASE_CODE(ERROR_LOGON_TYPE_NOT_GRANTED)
  1376. CASE_CODE(ERROR_NT_CROSS_ENCRYPTION_REQUIRED)
  1377. CASE_CODE(ERROR_NO_SUCH_MEMBER)
  1378. CASE_CODE(ERROR_INVALID_MEMBER)
  1379. CASE_CODE(ERROR_TOO_MANY_SIDS)
  1380. CASE_CODE(ERROR_LM_CROSS_ENCRYPTION_REQUIRED)
  1381. CASE_CODE(ERROR_NO_INHERITANCE)
  1382. CASE_CODE(ERROR_FILE_CORRUPT)
  1383. CASE_CODE(ERROR_DISK_CORRUPT)
  1384. CASE_CODE(ERROR_NO_USER_SESSION_KEY)
  1385. CASE_CODE(ERROR_LICENSE_QUOTA_EXCEEDED)
  1386. CASE_CODE(ERROR_INVALID_WINDOW_HANDLE)
  1387. CASE_CODE(ERROR_INVALID_MENU_HANDLE)
  1388. CASE_CODE(ERROR_INVALID_CURSOR_HANDLE)
  1389. CASE_CODE(ERROR_INVALID_ACCEL_HANDLE)
  1390. CASE_CODE(ERROR_INVALID_HOOK_HANDLE)
  1391. CASE_CODE(ERROR_INVALID_DWP_HANDLE)
  1392. CASE_CODE(ERROR_TLW_WITH_WSCHILD)
  1393. CASE_CODE(ERROR_CANNOT_FIND_WND_CLASS)
  1394. CASE_CODE(ERROR_WINDOW_OF_OTHER_THREAD)
  1395. CASE_CODE(ERROR_HOTKEY_ALREADY_REGISTERED)
  1396. CASE_CODE(ERROR_CLASS_ALREADY_EXISTS)
  1397. CASE_CODE(ERROR_CLASS_DOES_NOT_EXIST)
  1398. CASE_CODE(ERROR_CLASS_HAS_WINDOWS)
  1399. CASE_CODE(ERROR_INVALID_INDEX)
  1400. CASE_CODE(ERROR_INVALID_ICON_HANDLE)
  1401. CASE_CODE(ERROR_PRIVATE_DIALOG_INDEX)
  1402. CASE_CODE(ERROR_LISTBOX_ID_NOT_FOUND)
  1403. CASE_CODE(ERROR_NO_WILDCARD_CHARACTERS)
  1404. CASE_CODE(ERROR_CLIPBOARD_NOT_OPEN)
  1405. CASE_CODE(ERROR_HOTKEY_NOT_REGISTERED)
  1406. CASE_CODE(ERROR_WINDOW_NOT_DIALOG)
  1407. CASE_CODE(ERROR_CONTROL_ID_NOT_FOUND)
  1408. CASE_CODE(ERROR_INVALID_COMBOBOX_MESSAGE)
  1409. CASE_CODE(ERROR_WINDOW_NOT_COMBOBOX)
  1410. CASE_CODE(ERROR_INVALID_EDIT_HEIGHT)
  1411. CASE_CODE(ERROR_DC_NOT_FOUND)
  1412. CASE_CODE(ERROR_INVALID_HOOK_FILTER)
  1413. CASE_CODE(ERROR_INVALID_FILTER_PROC)
  1414. CASE_CODE(ERROR_HOOK_NEEDS_HMOD)
  1415. CASE_CODE(ERROR_GLOBAL_ONLY_HOOK)
  1416. CASE_CODE(ERROR_JOURNAL_HOOK_SET)
  1417. CASE_CODE(ERROR_HOOK_NOT_INSTALLED)
  1418. CASE_CODE(ERROR_INVALID_LB_MESSAGE)
  1419. CASE_CODE(ERROR_SETCOUNT_ON_BAD_LB)
  1420. CASE_CODE(ERROR_LB_WITHOUT_TABSTOPS)
  1421. CASE_CODE(ERROR_DESTROY_OBJECT_OF_OTHER_THREAD)
  1422. CASE_CODE(ERROR_CHILD_WINDOW_MENU)
  1423. CASE_CODE(ERROR_NO_SYSTEM_MENU)
  1424. CASE_CODE(ERROR_INVALID_MSGBOX_STYLE)
  1425. CASE_CODE(ERROR_INVALID_SPI_VALUE)
  1426. CASE_CODE(ERROR_SCREEN_ALREADY_LOCKED)
  1427. CASE_CODE(ERROR_HWNDS_HAVE_DIFF_PARENT)
  1428. CASE_CODE(ERROR_NOT_CHILD_WINDOW)
  1429. CASE_CODE(ERROR_INVALID_GW_COMMAND)
  1430. CASE_CODE(ERROR_INVALID_THREAD_ID)
  1431. CASE_CODE(ERROR_NON_MDICHILD_WINDOW)
  1432. CASE_CODE(ERROR_POPUP_ALREADY_ACTIVE)
  1433. CASE_CODE(ERROR_NO_SCROLLBARS)
  1434. CASE_CODE(ERROR_INVALID_SCROLLBAR_RANGE)
  1435. CASE_CODE(ERROR_INVALID_SHOWWIN_COMMAND)
  1436. CASE_CODE(ERROR_NO_SYSTEM_RESOURCES)
  1437. CASE_CODE(ERROR_NONPAGED_SYSTEM_RESOURCES)
  1438. CASE_CODE(ERROR_PAGED_SYSTEM_RESOURCES)
  1439. CASE_CODE(ERROR_WORKING_SET_QUOTA)
  1440. CASE_CODE(ERROR_PAGEFILE_QUOTA)
  1441. CASE_CODE(ERROR_COMMITMENT_LIMIT)
  1442. CASE_CODE(ERROR_MENU_ITEM_NOT_FOUND)
  1443. CASE_CODE(ERROR_INVALID_KEYBOARD_HANDLE)
  1444. CASE_CODE(ERROR_HOOK_TYPE_NOT_ALLOWED)
  1445. CASE_CODE(ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION)
  1446. CASE_CODE(ERROR_EVENTLOG_FILE_CORRUPT)
  1447. CASE_CODE(ERROR_EVENTLOG_CANT_START)
  1448. CASE_CODE(ERROR_LOG_FILE_FULL)
  1449. CASE_CODE(ERROR_EVENTLOG_FILE_CHANGED)
  1450. CASE_CODE(RPC_S_INVALID_STRING_BINDING)
  1451. CASE_CODE(RPC_S_WRONG_KIND_OF_BINDING)
  1452. CASE_CODE(RPC_S_INVALID_BINDING)
  1453. CASE_CODE(RPC_S_PROTSEQ_NOT_SUPPORTED)
  1454. CASE_CODE(RPC_S_INVALID_RPC_PROTSEQ)
  1455. CASE_CODE(RPC_S_INVALID_STRING_UUID)
  1456. CASE_CODE(RPC_S_INVALID_ENDPOINT_FORMAT)
  1457. CASE_CODE(RPC_S_INVALID_NET_ADDR)
  1458. CASE_CODE(RPC_S_NO_ENDPOINT_FOUND)
  1459. CASE_CODE(RPC_S_INVALID_TIMEOUT)
  1460. CASE_CODE(RPC_S_OBJECT_NOT_FOUND)
  1461. CASE_CODE(RPC_S_ALREADY_REGISTERED)
  1462. CASE_CODE(RPC_S_TYPE_ALREADY_REGISTERED)
  1463. CASE_CODE(RPC_S_ALREADY_LISTENING)
  1464. CASE_CODE(RPC_S_NO_PROTSEQS_REGISTERED)
  1465. CASE_CODE(RPC_S_NOT_LISTENING)
  1466. CASE_CODE(RPC_S_UNKNOWN_MGR_TYPE)
  1467. CASE_CODE(RPC_S_UNKNOWN_IF)
  1468. CASE_CODE(RPC_S_NO_BINDINGS)
  1469. CASE_CODE(RPC_S_NO_PROTSEQS)
  1470. CASE_CODE(RPC_S_CANT_CREATE_ENDPOINT)
  1471. CASE_CODE(RPC_S_OUT_OF_RESOURCES)
  1472. CASE_CODE(RPC_S_SERVER_UNAVAILABLE)
  1473. CASE_CODE(RPC_S_SERVER_TOO_BUSY)
  1474. CASE_CODE(RPC_S_INVALID_NETWORK_OPTIONS)
  1475. CASE_CODE(RPC_S_NO_CALL_ACTIVE)
  1476. CASE_CODE(RPC_S_CALL_FAILED)
  1477. CASE_CODE(RPC_S_CALL_FAILED_DNE)
  1478. CASE_CODE(RPC_S_PROTOCOL_ERROR)
  1479. CASE_CODE(RPC_S_UNSUPPORTED_TRANS_SYN)
  1480. CASE_CODE(RPC_S_UNSUPPORTED_TYPE)
  1481. CASE_CODE(RPC_S_INVALID_TAG)
  1482. CASE_CODE(RPC_S_INVALID_BOUND)
  1483. CASE_CODE(RPC_S_NO_ENTRY_NAME)
  1484. CASE_CODE(RPC_S_INVALID_NAME_SYNTAX)
  1485. CASE_CODE(RPC_S_UNSUPPORTED_NAME_SYNTAX)
  1486. CASE_CODE(RPC_S_UUID_NO_ADDRESS)
  1487. CASE_CODE(RPC_S_DUPLICATE_ENDPOINT)
  1488. CASE_CODE(RPC_S_UNKNOWN_AUTHN_TYPE)
  1489. CASE_CODE(RPC_S_MAX_CALLS_TOO_SMALL)
  1490. CASE_CODE(RPC_S_STRING_TOO_LONG)
  1491. CASE_CODE(RPC_S_PROTSEQ_NOT_FOUND)
  1492. CASE_CODE(RPC_S_PROCNUM_OUT_OF_RANGE)
  1493. CASE_CODE(RPC_S_BINDING_HAS_NO_AUTH)
  1494. CASE_CODE(RPC_S_UNKNOWN_AUTHN_SERVICE)
  1495. CASE_CODE(RPC_S_UNKNOWN_AUTHN_LEVEL)
  1496. CASE_CODE(RPC_S_INVALID_AUTH_IDENTITY)
  1497. CASE_CODE(RPC_S_UNKNOWN_AUTHZ_SERVICE)
  1498. CASE_CODE(EPT_S_INVALID_ENTRY)
  1499. CASE_CODE(EPT_S_CANT_PERFORM_OP)
  1500. CASE_CODE(EPT_S_NOT_REGISTERED)
  1501. CASE_CODE(RPC_S_NOTHING_TO_EXPORT)
  1502. CASE_CODE(RPC_S_INCOMPLETE_NAME)
  1503. CASE_CODE(RPC_S_INVALID_VERS_OPTION)
  1504. CASE_CODE(RPC_S_NO_MORE_MEMBERS)
  1505. CASE_CODE(RPC_S_NOT_ALL_OBJS_UNEXPORTED)
  1506. CASE_CODE(RPC_S_INTERFACE_NOT_FOUND)
  1507. CASE_CODE(RPC_S_ENTRY_ALREADY_EXISTS)
  1508. CASE_CODE(RPC_S_ENTRY_NOT_FOUND)
  1509. CASE_CODE(RPC_S_NAME_SERVICE_UNAVAILABLE)
  1510. CASE_CODE(RPC_S_INVALID_NAF_ID)
  1511. CASE_CODE(RPC_S_CANNOT_SUPPORT)
  1512. CASE_CODE(RPC_S_NO_CONTEXT_AVAILABLE)
  1513. CASE_CODE(RPC_S_INTERNAL_ERROR)
  1514. CASE_CODE(RPC_S_ZERO_DIVIDE)
  1515. CASE_CODE(RPC_S_ADDRESS_ERROR)
  1516. CASE_CODE(RPC_S_FP_DIV_ZERO)
  1517. CASE_CODE(RPC_S_FP_UNDERFLOW)
  1518. CASE_CODE(RPC_S_FP_OVERFLOW)
  1519. CASE_CODE(RPC_X_NO_MORE_ENTRIES)
  1520. CASE_CODE(RPC_X_SS_CHAR_TRANS_OPEN_FAIL)
  1521. CASE_CODE(RPC_X_SS_CHAR_TRANS_SHORT_FILE)
  1522. CASE_CODE(RPC_X_SS_IN_NULL_CONTEXT)
  1523. CASE_CODE(RPC_X_SS_CONTEXT_DAMAGED)
  1524. CASE_CODE(RPC_X_SS_HANDLES_MISMATCH)
  1525. CASE_CODE(RPC_X_SS_CANNOT_GET_CALL_HANDLE)
  1526. CASE_CODE(RPC_X_NULL_REF_POINTER)
  1527. CASE_CODE(RPC_X_ENUM_VALUE_OUT_OF_RANGE)
  1528. CASE_CODE(RPC_X_BYTE_COUNT_TOO_SMALL)
  1529. CASE_CODE(RPC_X_BAD_STUB_DATA)
  1530. CASE_CODE(ERROR_INVALID_USER_BUFFER)
  1531. CASE_CODE(ERROR_UNRECOGNIZED_MEDIA)
  1532. CASE_CODE(ERROR_NO_TRUST_LSA_SECRET)
  1533. CASE_CODE(ERROR_NO_TRUST_SAM_ACCOUNT)
  1534. CASE_CODE(ERROR_TRUSTED_DOMAIN_FAILURE)
  1535. CASE_CODE(ERROR_TRUSTED_RELATIONSHIP_FAILURE)
  1536. CASE_CODE(ERROR_TRUST_FAILURE)
  1537. CASE_CODE(RPC_S_CALL_IN_PROGRESS)
  1538. CASE_CODE(ERROR_NETLOGON_NOT_STARTED)
  1539. CASE_CODE(ERROR_ACCOUNT_EXPIRED)
  1540. CASE_CODE(ERROR_REDIRECTOR_HAS_OPEN_HANDLES)
  1541. CASE_CODE(ERROR_PRINTER_DRIVER_ALREADY_INSTALLED)
  1542. CASE_CODE(ERROR_UNKNOWN_PORT)
  1543. CASE_CODE(ERROR_UNKNOWN_PRINTER_DRIVER)
  1544. CASE_CODE(ERROR_UNKNOWN_PRINTPROCESSOR)
  1545. CASE_CODE(ERROR_INVALID_SEPARATOR_FILE)
  1546. CASE_CODE(ERROR_INVALID_PRIORITY)
  1547. CASE_CODE(ERROR_INVALID_PRINTER_NAME)
  1548. CASE_CODE(ERROR_PRINTER_ALREADY_EXISTS)
  1549. CASE_CODE(ERROR_INVALID_PRINTER_COMMAND)
  1550. CASE_CODE(ERROR_INVALID_DATATYPE)
  1551. CASE_CODE(ERROR_INVALID_ENVIRONMENT)
  1552. CASE_CODE(RPC_S_NO_MORE_BINDINGS)
  1553. CASE_CODE(ERROR_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT)
  1554. CASE_CODE(ERROR_NOLOGON_WORKSTATION_TRUST_ACCOUNT)
  1555. CASE_CODE(ERROR_NOLOGON_SERVER_TRUST_ACCOUNT)
  1556. CASE_CODE(ERROR_DOMAIN_TRUST_INCONSISTENT)
  1557. CASE_CODE(ERROR_SERVER_HAS_OPEN_HANDLES)
  1558. CASE_CODE(ERROR_RESOURCE_DATA_NOT_FOUND)
  1559. CASE_CODE(ERROR_RESOURCE_TYPE_NOT_FOUND)
  1560. CASE_CODE(ERROR_RESOURCE_NAME_NOT_FOUND)
  1561. CASE_CODE(ERROR_RESOURCE_LANG_NOT_FOUND)
  1562. CASE_CODE(ERROR_NOT_ENOUGH_QUOTA)
  1563. CASE_CODE(RPC_S_NO_INTERFACES)
  1564. CASE_CODE(RPC_S_CALL_CANCELLED)
  1565. CASE_CODE(RPC_S_BINDING_INCOMPLETE)
  1566. CASE_CODE(RPC_S_COMM_FAILURE)
  1567. CASE_CODE(RPC_S_UNSUPPORTED_AUTHN_LEVEL)
  1568. CASE_CODE(RPC_S_NO_PRINC_NAME)
  1569. CASE_CODE(RPC_S_NOT_RPC_ERROR)
  1570. CASE_CODE(RPC_S_UUID_LOCAL_ONLY)
  1571. CASE_CODE(RPC_S_SEC_PKG_ERROR)
  1572. CASE_CODE(RPC_S_NOT_CANCELLED)
  1573. CASE_CODE(RPC_X_INVALID_ES_ACTION)
  1574. CASE_CODE(RPC_X_WRONG_ES_VERSION)
  1575. CASE_CODE(RPC_X_WRONG_STUB_VERSION)
  1576. CASE_CODE(RPC_X_INVALID_PIPE_OBJECT)
  1577. CASE_CODE(RPC_X_INVALID_PIPE_OPERATION)
  1578. CASE_CODE(RPC_X_WRONG_PIPE_VERSION)
  1579. CASE_CODE(RPC_S_GROUP_MEMBER_NOT_FOUND)
  1580. CASE_CODE(EPT_S_CANT_CREATE)
  1581. CASE_CODE(RPC_S_INVALID_OBJECT)
  1582. CASE_CODE(ERROR_INVALID_TIME)
  1583. CASE_CODE(ERROR_INVALID_FORM_NAME)
  1584. CASE_CODE(ERROR_INVALID_FORM_SIZE)
  1585. CASE_CODE(ERROR_ALREADY_WAITING)
  1586. CASE_CODE(ERROR_PRINTER_DELETED)
  1587. CASE_CODE(ERROR_INVALID_PRINTER_STATE)
  1588. CASE_CODE(ERROR_PASSWORD_MUST_CHANGE)
  1589. CASE_CODE(ERROR_DOMAIN_CONTROLLER_NOT_FOUND)
  1590. CASE_CODE(ERROR_ACCOUNT_LOCKED_OUT)
  1591. CASE_CODE(OR_INVALID_OXID)
  1592. CASE_CODE(OR_INVALID_OID)
  1593. CASE_CODE(OR_INVALID_SET)
  1594. CASE_CODE(RPC_S_SEND_INCOMPLETE)
  1595. CASE_CODE(ERROR_NO_BROWSER_SERVERS_FOUND)
  1596. CASE_CODE(ERROR_INVALID_PIXEL_FORMAT)
  1597. CASE_CODE(ERROR_BAD_DRIVER)
  1598. CASE_CODE(ERROR_INVALID_WINDOW_STYLE)
  1599. CASE_CODE(ERROR_METAFILE_NOT_SUPPORTED)
  1600. CASE_CODE(ERROR_TRANSFORM_NOT_SUPPORTED)
  1601. CASE_CODE(ERROR_CLIPPING_NOT_SUPPORTED)
  1602. CASE_CODE(ERROR_UNKNOWN_PRINT_MONITOR)
  1603. CASE_CODE(ERROR_PRINTER_DRIVER_IN_USE)
  1604. CASE_CODE(ERROR_SPOOL_FILE_NOT_FOUND)
  1605. CASE_CODE(ERROR_SPL_NO_STARTDOC)
  1606. CASE_CODE(ERROR_SPL_NO_ADDJOB)
  1607. CASE_CODE(ERROR_PRINT_PROCESSOR_ALREADY_INSTALLED)
  1608. CASE_CODE(ERROR_PRINT_MONITOR_ALREADY_INSTALLED)
  1609. CASE_CODE(ERROR_INVALID_PRINT_MONITOR)
  1610. CASE_CODE(ERROR_PRINT_MONITOR_IN_USE)
  1611. CASE_CODE(ERROR_PRINTER_HAS_JOBS_QUEUED)
  1612. CASE_CODE(ERROR_SUCCESS_REBOOT_REQUIRED)
  1613. CASE_CODE(ERROR_SUCCESS_RESTART_REQUIRED)
  1614. CASE_CODE(ERROR_WINS_INTERNAL)
  1615. CASE_CODE(ERROR_CAN_NOT_DEL_LOCAL_WINS)
  1616. CASE_CODE(ERROR_STATIC_INIT)
  1617. CASE_CODE(ERROR_INC_BACKUP)
  1618. CASE_CODE(ERROR_FULL_BACKUP)
  1619. CASE_CODE(ERROR_REC_NON_EXISTENT)
  1620. CASE_CODE(ERROR_RPL_NOT_ALLOWED)
  1621. default:
  1622. _tcscpy(szErrorName, _T(""));
  1623. FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, hr,
  1624. MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL),
  1625. szErrorDesc, sizeof(TCHAR)*_ERRORDESCLEN, NULL);
  1626. }
  1627. } // if FACILITY_WIN32
  1628. else if (HRESULT_FACILITY(hr) == FACILITY_CONTROL && HRESULT_CODE(hr) >= 600)
  1629. {
  1630. szErrorName[0] = _T('\0');
  1631. _tcscpy(szErrorDesc, _T(""));
  1632. }
  1633. else if (HRESULT_FACILITY(hr) == FACILITY_ITF && HRESULT_CODE(hr) >= 0x200)
  1634. {
  1635. szErrorName[0] = _T('\0');
  1636. _tcscpy(szErrorDesc, _T(""));
  1637. }
  1638. else
  1639. {
  1640. _tcscpy(szErrorName, _T("")); // Not FACILITY_WIN32 or FACILITY_ITF(code >= 0x200) or FACILTY_CONTROL(code >= 600)
  1641. FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, hr,
  1642. MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL),
  1643. szErrorDesc, sizeof(TCHAR)*_ERRORDESCLEN, NULL);
  1644. }
  1645. }
  1646. _tcscpy(pszFacility,szFacility);
  1647. _tcscpy(pszErrorName,szErrorName);
  1648. _tcscpy(pszErrorDesc,szErrorDesc);
  1649. }
  1650. #pragma warning( default : 4245 )
  1651. inline void CConnectionManager::HandleConnMgrException(HRESULT hr)
  1652. {
  1653. TRACEX(_T("CConnectionManager::HandleConnMgrException\n"));
  1654. TRACEARGn(hr);
  1655. AfxMessageBox(IDS_STRING_CONNMGR_DEAD);
  1656. }
  1657. //////////////////////////////////////////////////////////////////////
  1658. // Marshalling Operations
  1659. //////////////////////////////////////////////////////////////////////
  1660. // I support these only because we now need to use Property Pages in the
  1661. // snap-in. Since property pages run in their own thread and the snap-in
  1662. // architeture uses apartment threading model, ANY COM interface pointers
  1663. // to be used within the property page thread must be marshalled...fortunately
  1664. // I have only to marshal IConnectionManager.
  1665. HRESULT CConnectionManager::MarshalCnxMgr()
  1666. {
  1667. TRACEX(_T("CConnectionManager::MarshalCnxMgr\n"));
  1668. HRESULT hr = S_OK;
  1669. // we are called from the snapin's main thread here in prep for marshalling
  1670. CMarshalledConnection* pNewConnection = new CMarshalledConnection;
  1671. hr = pNewConnection->Marshal(m_pIConnectionManager);
  1672. if( !CHECKHRESULT(hr) )
  1673. {
  1674. TRACE(_T("FAILED : CMarshalledConnection::Marshal failed.\n"));
  1675. }
  1676. m_MarshalStack.AddHead(pNewConnection);
  1677. return hr;
  1678. }
  1679. HRESULT CConnectionManager::UnMarshalCnxMgr()
  1680. {
  1681. TRACEX(_T("CConnectionManager::UnMarshalCnxMgr\n"));
  1682. HRESULT hr = S_OK;
  1683. // unmarshal the connection now that we are in the new property page thread
  1684. // v-marfin : bug 59643
  1685. // Check for empty list before proceeding.
  1686. if (m_MarshalStack.IsEmpty())
  1687. {
  1688. TRACE(_T("WARNING : Could not find a connection waiting on the stack!\n"));
  1689. return E_FAIL;
  1690. }
  1691. CMarshalledConnection* pConnection = m_MarshalStack.RemoveTail();
  1692. ASSERT(pConnection);
  1693. if( pConnection == NULL )
  1694. {
  1695. TRACE(_T("FAILED : Could not find a connection waiting on the stack!\n"));
  1696. return E_FAIL;
  1697. }
  1698. // now insert the marshalled connection into the map of thread ids to connections.
  1699. // first check if a connection has already been marshalled before inserting
  1700. // the connection into the map
  1701. DWORD dwThreadID = GetCurrentThreadId();
  1702. CMarshalledConnection* pExistingConnection = NULL;
  1703. if( m_MarshalMap.Lookup(dwThreadID,pExistingConnection) )
  1704. {
  1705. ASSERT(pExistingConnection);
  1706. // delete the connection we were going to add, because it has already been
  1707. // marshalled for this thread id
  1708. delete pConnection;
  1709. return hr;
  1710. }
  1711. else
  1712. {
  1713. m_MarshalMap.SetAt(dwThreadID,pConnection);
  1714. }
  1715. // unmarshal the connection now
  1716. hr = pConnection->UnMarshal();
  1717. if( !CHECKHRESULT(hr) )
  1718. {
  1719. TRACE(_T("FAILED : CMarshalledConnection::UnMarshal failed.\n"));
  1720. return E_FAIL;
  1721. }
  1722. return hr;
  1723. }
  1724. void CConnectionManager::CleanUpMarshalCnxMgr()
  1725. {
  1726. TRACEX(_T("CConnectionManager::CleanUpMarshalCnxMgr\n"));
  1727. // we are called here by the dying thread of the property page which is about to be
  1728. // destroyed. We must clean up by removing the marshalled connection from the map
  1729. DWORD dwThreadID = GetCurrentThreadId();
  1730. CMarshalledConnection* pConnection = NULL;
  1731. m_MarshalMap.Lookup(dwThreadID,pConnection);
  1732. if( pConnection == NULL )
  1733. {
  1734. TRACE(_T("FAILED : Could not find a connection for the calling thread!\n"));
  1735. return;
  1736. }
  1737. if( ! m_MarshalMap.RemoveKey(dwThreadID) )
  1738. {
  1739. TRACE(_T("FAILED : Could not remove the key from the marshal map.\n"));
  1740. return;
  1741. }
  1742. delete pConnection;
  1743. return;
  1744. }
  1745. //////////////////////////////////////////////////////////////////////
  1746. // Implementation Operations
  1747. //////////////////////////////////////////////////////////////////////