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.

525 lines
16 KiB

  1. //+--------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1996 - 1999
  5. //
  6. // File: column.cpp
  7. //
  8. // Contents: CertCli implementation
  9. //
  10. //---------------------------------------------------------------------------
  11. #include "pch.cpp"
  12. #pragma hdrstop
  13. #include "csprop.h"
  14. #include "resource.h"
  15. extern HINSTANCE g_hInstance;
  16. typedef struct _COLUMNTRANSLATE
  17. {
  18. WCHAR const *pwszColumnName;
  19. DWORD idMsgDisplayName;
  20. WCHAR const *pwszDisplayName;
  21. } COLUMNTRANSLATE;
  22. COLUMNTRANSLATE g_aColTable[] =
  23. {
  24. { wszPROPREQUESTDOT wszPROPREQUESTREQUESTID, IDS_COLUMN_REQUESTID, },
  25. { wszPROPREQUESTDOT wszPROPREQUESTRAWREQUEST, IDS_COLUMN_REQUESTRAWREQUEST, },
  26. { wszPROPREQUESTDOT wszPROPREQUESTRAWARCHIVEDKEY, IDS_COLUMN_REQUESTRAWARCHIVEDKEY, },
  27. { wszPROPREQUESTDOT wszPROPREQUESTKEYRECOVERYHASHES, IDS_COLUMN_REQUESTKEYRECOVERYHASHES, },
  28. { wszPROPREQUESTDOT wszPROPREQUESTRAWOLDCERTIFICATE, IDS_COLUMN_REQUESTRAWOLDCERTIFICATE, },
  29. { wszPROPREQUESTDOT wszPROPREQUESTATTRIBUTES, IDS_COLUMN_REQUESTATTRIBUTES, },
  30. { wszPROPREQUESTDOT wszPROPREQUESTTYPE, IDS_COLUMN_REQUESTTYPE, },
  31. { wszPROPREQUESTDOT wszPROPREQUESTFLAGS, IDS_COLUMN_REQUESTFLAGS, },
  32. { wszPROPREQUESTDOT L"Status", IDS_COLUMN_REQUESTSTATUS, },
  33. { wszPROPREQUESTDOT wszPROPREQUESTSTATUSCODE, IDS_COLUMN_REQUESTSTATUSCODE, },
  34. { wszPROPREQUESTDOT wszPROPREQUESTDISPOSITION, IDS_COLUMN_REQUESTDISPOSITION, },
  35. { wszPROPREQUESTDOT wszPROPREQUESTDISPOSITIONMESSAGE, IDS_COLUMN_REQUESTDISPOSITIONMESSAGE, },
  36. { wszPROPREQUESTDOT wszPROPREQUESTSUBMITTEDWHEN, IDS_COLUMN_REQUESTSUBMITTEDWHEN, },
  37. { wszPROPREQUESTDOT wszPROPREQUESTRESOLVEDWHEN, IDS_COLUMN_REQUESTRESOLVEDWHEN, },
  38. { wszPROPREQUESTDOT wszPROPREQUESTREVOKEDWHEN, IDS_COLUMN_REQUESTREVOKEDWHEN, },
  39. { wszPROPREQUESTDOT wszPROPREQUESTREVOKEDEFFECTIVEWHEN, IDS_COLUMN_REQUESTREVOKEDEFFECTIVEWHEN, },
  40. { wszPROPREQUESTDOT wszPROPREQUESTREVOKEDREASON, IDS_COLUMN_REQUESTREVOKEDREASON, },
  41. { wszPROPREQUESTDOT wszPROPREQUESTERNAME, IDS_COLUMN_REQUESTERNAME, },
  42. { wszPROPREQUESTDOT wszPROPCALLERNAME, IDS_COLUMN_CALLERNAME, },
  43. { wszPROPREQUESTDOT wszPROPREQUESTERADDRESS, IDS_COLUMN_REQUESTERADDRESS, },
  44. { wszPROPREQUESTDOT wszPROPDISTINGUISHEDNAME, IDS_COLUMN_REQUESTDISTINGUISHEDNAME, },
  45. { wszPROPREQUESTDOT wszPROPRAWNAME, IDS_COLUMN_REQUESTRAWNAME, },
  46. { wszPROPREQUESTDOT wszPROPCOUNTRY, IDS_COLUMN_REQUESTCOUNTRY, },
  47. { wszPROPREQUESTDOT wszPROPORGANIZATION, IDS_COLUMN_REQUESTORGANIZATION, },
  48. { wszPROPREQUESTDOT wszPROPORGUNIT, IDS_COLUMN_REQUESTORGUNIT, },
  49. { wszPROPREQUESTDOT wszPROPCOMMONNAME, IDS_COLUMN_REQUESTCOMMONNAME, },
  50. { wszPROPREQUESTDOT wszPROPLOCALITY, IDS_COLUMN_REQUESTLOCALITY, },
  51. { wszPROPREQUESTDOT wszPROPSTATE, IDS_COLUMN_REQUESTSTATE, },
  52. { wszPROPREQUESTDOT wszPROPTITLE, IDS_COLUMN_REQUESTTITLE, },
  53. { wszPROPREQUESTDOT wszPROPGIVENNAME, IDS_COLUMN_REQUESTGIVENNAME, },
  54. { wszPROPREQUESTDOT wszPROPINITIALS, IDS_COLUMN_REQUESTINITIALS, },
  55. { wszPROPREQUESTDOT wszPROPSURNAME, IDS_COLUMN_REQUESTSURNAME, },
  56. { wszPROPREQUESTDOT wszPROPDOMAINCOMPONENT, IDS_COLUMN_REQUESTDOMAINCOMPONENT, },
  57. { wszPROPREQUESTDOT wszPROPEMAIL, IDS_COLUMN_REQUESTEMAIL, },
  58. { wszPROPREQUESTDOT wszPROPSTREETADDRESS, IDS_COLUMN_REQUESTSTREETADDRESS, },
  59. { wszPROPREQUESTDOT wszPROPUNSTRUCTUREDNAME, IDS_COLUMN_REQUESTUNSTRUCTUREDNAME, },
  60. { wszPROPREQUESTDOT wszPROPUNSTRUCTUREDADDRESS, IDS_COLUMN_REQUESTUNSTRUCTUREDADDRESS, },
  61. { wszPROPREQUESTDOT wszPROPDEVICESERIALNUMBER, IDS_COLUMN_REQUESTDEVICESERIALNUMBER },
  62. { wszPROPREQUESTDOT wszPROPSIGNERPOLICIES, IDS_COLUMN_REQUESTSIGNERPOLICIES },
  63. { wszPROPREQUESTDOT wszPROPSIGNERAPPLICATIONPOLICIES, IDS_COLUMN_REQUESTSIGNERAPPLICATIONPOLICIES },
  64. { wszPROPCERTIFICATEREQUESTID, IDS_COLUMN_CERTIFICATEREQUESTID, },
  65. { wszPROPRAWCERTIFICATE, IDS_COLUMN_CERTIFICATERAWCERTIFICATE, },
  66. { wszPROPCERTIFICATEHASH, IDS_COLUMN_CERTIFICATECERTIFICATEHASH, },
  67. { wszPROPCERTIFICATETEMPLATE, IDS_COLUMN_PROPCERTIFICATETEMPLATE, },
  68. { wszPROPCERTIFICATEENROLLMENTFLAGS, IDS_COLUMN_PROPCERTIFICATEENROLLMENTFLAGS, },
  69. { wszPROPCERTIFICATEGENERALFLAGS, IDS_COLUMN_PROPCERTIFICATEGENERALFLAGS, },
  70. { wszPROPCERTIFICATESERIALNUMBER, IDS_COLUMN_CERTIFICATESERIALNUMBER, },
  71. { wszPROPCERTIFICATEISSUERNAMEID, IDS_COLUMN_CERTIFICATEISSUERNAMEID, },
  72. { wszPROPCERTIFICATENOTBEFOREDATE, IDS_COLUMN_CERTIFICATENOTBEFOREDATE, },
  73. { wszPROPCERTIFICATENOTAFTERDATE, IDS_COLUMN_CERTIFICATENOTAFTERDATE, },
  74. { wszPROPCERTIFICATESUBJECTKEYIDENTIFIER, IDS_COLUMN_CERTIFICATESUBJECTKEYIDENTIFIER , },
  75. { wszPROPCERTIFICATERAWPUBLICKEY, IDS_COLUMN_CERTIFICATERAWPUBLICKEY, },
  76. { wszPROPCERTIFICATEPUBLICKEYLENGTH, IDS_COLUMN_CERTIFICATEPUBLICKEYLENGTH, },
  77. { wszPROPCERTIFICATEPUBLICKEYALGORITHM, IDS_COLUMN_CERTIFICATEPUBLICKEYALGORITHM, },
  78. { wszPROPCERTIFICATERAWPUBLICKEYALGORITHMPARAMETERS, IDS_COLUMN_CERTIFICATERAWPUBLICKEYALGORITHMPARAMETERS, },
  79. { wszPROPCERTIFICATEUPN, IDS_COLUMN_CERTIFICATEUPN, },
  80. { wszPROPDISTINGUISHEDNAME, IDS_COLUMN_CERTIFICATEDISTINGUISHEDNAME, },
  81. { wszPROPRAWNAME, IDS_COLUMN_CERTIFICATERAWNAME, },
  82. { wszPROPCOUNTRY, IDS_COLUMN_CERTIFICATECOUNTRY, },
  83. { wszPROPORGANIZATION, IDS_COLUMN_CERTIFICATEORGANIZATION, },
  84. { wszPROPORGUNIT, IDS_COLUMN_CERTIFICATEORGUNIT, },
  85. { wszPROPCOMMONNAME, IDS_COLUMN_CERTIFICATECOMMONNAME, },
  86. { wszPROPLOCALITY, IDS_COLUMN_CERTIFICATELOCALITY, },
  87. { wszPROPSTATE, IDS_COLUMN_CERTIFICATESTATE, },
  88. { wszPROPTITLE, IDS_COLUMN_CERTIFICATETITLE, },
  89. { wszPROPGIVENNAME, IDS_COLUMN_CERTIFICATEGIVENNAME, },
  90. { wszPROPINITIALS, IDS_COLUMN_CERTIFICATEINITIALS, },
  91. { wszPROPSURNAME, IDS_COLUMN_CERTIFICATESURNAME, },
  92. { wszPROPDOMAINCOMPONENT, IDS_COLUMN_CERTIFICATEDOMAINCOMPONENT, },
  93. { wszPROPEMAIL, IDS_COLUMN_CERTIFICATEEMAIL, },
  94. { wszPROPSTREETADDRESS, IDS_COLUMN_CERTIFICATESTREETADDRESS, },
  95. { wszPROPUNSTRUCTUREDNAME, IDS_COLUMN_CERTIFICATEUNSTRUCTUREDNAME, },
  96. { wszPROPUNSTRUCTUREDADDRESS, IDS_COLUMN_CERTIFICATEUNSTRUCTUREDADDRESS, },
  97. { wszPROPDEVICESERIALNUMBER, IDS_COLUMN_CERTIFICATEDEVICESERIALNUMBER },
  98. { wszPROPEXTREQUESTID, IDS_COLUMN_EXTREQUESTID, },
  99. { wszPROPEXTNAME, IDS_COLUMN_EXTNAME, },
  100. { wszPROPEXTFLAGS, IDS_COLUMN_EXTFLAGS, },
  101. { wszPROPEXTRAWVALUE, IDS_COLUMN_EXTRAWVALUE, },
  102. { wszPROPATTRIBREQUESTID, IDS_COLUMN_ATTRIBREQUESTID, },
  103. { wszPROPATTRIBNAME, IDS_COLUMN_ATTRIBNAME, },
  104. { wszPROPATTRIBVALUE, IDS_COLUMN_ATTRIBVALUE, },
  105. { wszPROPCRLROWID, IDS_COLUMN_CRLROWID, },
  106. { wszPROPCRLNUMBER, IDS_COLUMN_CRLNUMBER, },
  107. { wszPROPCRLMINBASE, IDS_COLUMN_CRLMINBASE, },
  108. { wszPROPCRLNAMEID, IDS_COLUMN_CRLNAMEID, },
  109. { wszPROPCRLCOUNT, IDS_COLUMN_CRLCOUNT, },
  110. { wszPROPCRLTHISUPDATE, IDS_COLUMN_CRLTHISUPDATE, },
  111. { wszPROPCRLNEXTUPDATE, IDS_COLUMN_CRLNEXTUPDATE, },
  112. { wszPROPCRLTHISPUBLISH, IDS_COLUMN_CRLTHISPUBLISH, },
  113. { wszPROPCRLNEXTPUBLISH, IDS_COLUMN_CRLNEXTPUBLISH, },
  114. { wszPROPCRLEFFECTIVE, IDS_COLUMN_CRLEFFECTIVE, },
  115. { wszPROPCRLPROPAGATIONCOMPLETE, IDS_COLUMN_CRLPROPAGATIONCOMPLETE, },
  116. { wszPROPCRLLASTPUBLISHED, IDS_COLUMN_CRLLASTPUBLISHED, },
  117. { wszPROPCRLPUBLISHATTEMPTS, IDS_COLUMN_CRLPUBLISHATTEMPTS, },
  118. { wszPROPCRLPUBLISHFLAGS, IDS_COLUMN_CRLPUBLISHFLAGS, },
  119. { wszPROPCRLPUBLISHSTATUSCODE, IDS_COLUMN_CRLPUBLISHSTATUSCODE, },
  120. { wszPROPCRLPUBLISHERROR, IDS_COLUMN_CRLPUBLISHERROR, },
  121. { wszPROPCRLRAWCRL, IDS_COLUMN_CRLRAWCRL, },
  122. // Obsolete:
  123. { wszPROPCERTIFICATETYPE, IDS_COLUMN_CERTIFICATETYPE, },
  124. { wszPROPCERTIFICATERAWSMIMECAPABILITIES, IDS_COLUMN_CERTIFICATERAWSMIMECAPABILITIES },
  125. { wszPROPNAMETYPE, IDS_COLUMN_CERTIFICATENAMETYPE, },
  126. { wszPROPREQUESTDOT wszPROPNAMETYPE, IDS_COLUMN_REQUESTNAMETYPE, },
  127. { NULL, 0, },
  128. };
  129. #define CCOL_MAX (ARRAYSIZE(g_aColTable) - 1)
  130. typedef struct _CAPROPTRANSLATE
  131. {
  132. LONG lPropId;
  133. DWORD idMsgDisplayName;
  134. WCHAR const *pwszDisplayName;
  135. } CAPROPTRANSLATE;
  136. CAPROPTRANSLATE g_aCAPropTable[] =
  137. {
  138. { CR_PROP_FILEVERSION, IDS_CAPROP_FILEVERSION, },
  139. { CR_PROP_PRODUCTVERSION, IDS_CAPROP_PRODUCTVERSION, },
  140. { CR_PROP_EXITCOUNT, IDS_CAPROP_EXITCOUNT, },
  141. { CR_PROP_EXITDESCRIPTION, IDS_CAPROP_EXITDESCRIPTION, },
  142. { CR_PROP_POLICYDESCRIPTION, IDS_CAPROP_POLICYDESCRIPTION, },
  143. { CR_PROP_CANAME, IDS_CAPROP_CANAME, },
  144. { CR_PROP_SANITIZEDCANAME, IDS_CAPROP_SANITIZEDCANAME, },
  145. { CR_PROP_SHAREDFOLDER, IDS_CAPROP_SHAREDFOLDER, },
  146. { CR_PROP_PARENTCA, IDS_CAPROP_PARENTCA, },
  147. { CR_PROP_CATYPE, IDS_CAPROP_CATYPE, },
  148. { CR_PROP_CASIGCERTCOUNT, IDS_CAPROP_CASIGCERTCOUNT, },
  149. { CR_PROP_CASIGCERT, IDS_CAPROP_CASIGCERT, },
  150. { CR_PROP_CASIGCERTCHAIN, IDS_CAPROP_CASIGCERTCHAIN, },
  151. { CR_PROP_CAXCHGCERTCOUNT, IDS_CAPROP_CAXCHGCERTCOUNT, },
  152. { CR_PROP_CAXCHGCERT, IDS_CAPROP_CAXCHGCERT, },
  153. { CR_PROP_CAXCHGCERTCHAIN, IDS_CAPROP_CAXCHGCERTCHAIN, },
  154. { CR_PROP_BASECRL, IDS_CAPROP_BASECRL, },
  155. { CR_PROP_DELTACRL, IDS_CAPROP_DELTACRL, },
  156. { CR_PROP_CACERTSTATE, IDS_CAPROP_CACERTSTATE, },
  157. { CR_PROP_CRLSTATE, IDS_CAPROP_CRLSTATE, },
  158. { CR_PROP_CAPROPIDMAX, IDS_CAPROP_CAPROPIDMAX, },
  159. { CR_PROP_DNSNAME, IDS_CAPROP_DNSNAME, },
  160. { CR_PROP_KRACERTUSEDCOUNT, IDS_CAPROP_KRACERTUSEDCOUNT, },
  161. { CR_PROP_KRACERTCOUNT, IDS_CAPROP_KRACERTCOUNT, },
  162. { CR_PROP_KRACERT, IDS_CAPROP_KRACERT, },
  163. { CR_PROP_KRACERTSTATE, IDS_CAPROP_KRACERTSTATE, },
  164. { CR_PROP_ADVANCEDSERVER, IDS_CAPROP_ADVANCEDSERVER, },
  165. { CR_PROP_TEMPLATES, IDS_CAPROP_TEMPLATES, },
  166. { CR_PROP_BASECRLPUBLISHSTATUS, IDS_CAPROP_BASECRLPUBLISHSTATUS, },
  167. { CR_PROP_DELTACRLPUBLISHSTATUS, IDS_CAPROP_DELTACRLPUBLISHSTATUS, },
  168. { CR_PROP_CASIGCERTCRLCHAIN, IDS_CAPROP_CASIGCERTCRLCHAIN, },
  169. { CR_PROP_CAXCHGCERTCRLCHAIN,IDS_CAPROP_CAXCHGCERTCRLCHAIN, },
  170. { CR_PROP_CACERTSTATUSCODE, IDS_CAPROP_CACERTSTATUSCODE, },
  171. { 0, 0, },
  172. };
  173. #define CAPROP_MAX (ARRAYSIZE(g_aCAPropTable) - 1)
  174. HRESULT
  175. LoadDisplayNames()
  176. {
  177. HRESULT hr;
  178. COLUMNTRANSLATE *pct;
  179. CAPROPTRANSLATE *pcapt;
  180. WCHAR awc[512];
  181. for (pct = g_aColTable; NULL != pct->pwszColumnName; pct++)
  182. {
  183. WCHAR *pwsz;
  184. if (!LoadString(
  185. g_hInstance,
  186. pct->idMsgDisplayName,
  187. awc,
  188. ARRAYSIZE(awc)))
  189. {
  190. hr = myHLastError();
  191. CSASSERT(S_OK != hr);
  192. _JumpError(hr, error, "LoadString");
  193. }
  194. pwsz = (WCHAR *) LocalAlloc(
  195. LMEM_FIXED,
  196. (wcslen(awc) + 1) * sizeof(WCHAR));
  197. if (NULL == pwsz)
  198. {
  199. hr = E_OUTOFMEMORY;
  200. _JumpError(hr, error, "LocalAlloc display name");
  201. }
  202. wcscpy(pwsz, awc);
  203. pct->pwszDisplayName = pwsz;
  204. DBGPRINT((
  205. DBG_SS_CERTLIBI,
  206. "%x: '%ws' --> '%ws'\n",
  207. SAFE_SUBTRACT_POINTERS(pct, g_aColTable),
  208. pct->pwszColumnName,
  209. pct->pwszDisplayName));
  210. }
  211. for (pcapt = g_aCAPropTable; 0 != pcapt->lPropId; pcapt++)
  212. {
  213. WCHAR *pwsz;
  214. if (!LoadString(
  215. g_hInstance,
  216. pcapt->idMsgDisplayName,
  217. awc,
  218. ARRAYSIZE(awc)))
  219. {
  220. hr = myHLastError();
  221. CSASSERT(S_OK != hr);
  222. _JumpError(hr, error, "LoadString");
  223. }
  224. pwsz = (WCHAR *) LocalAlloc(
  225. LMEM_FIXED,
  226. (wcslen(awc) + 1) * sizeof(WCHAR));
  227. if (NULL == pwsz)
  228. {
  229. hr = E_OUTOFMEMORY;
  230. _JumpError(hr, error, "LocalAlloc display name");
  231. }
  232. wcscpy(pwsz, awc);
  233. pcapt->pwszDisplayName = pwsz;
  234. DBGPRINT((
  235. DBG_SS_CERTLIBI,
  236. "%x: %x --> '%ws'\n",
  237. SAFE_SUBTRACT_POINTERS(pcapt, g_aCAPropTable),
  238. pcapt->lPropId,
  239. pcapt->pwszDisplayName));
  240. }
  241. hr = S_OK;
  242. error:
  243. if(S_OK != hr)
  244. {
  245. for (pct = g_aColTable; NULL != pct->pwszColumnName; pct++)
  246. {
  247. if(pct->pwszDisplayName)
  248. {
  249. LocalFree(const_cast<WCHAR *>(pct->pwszDisplayName));
  250. pct->pwszDisplayName = NULL;
  251. }
  252. }
  253. }
  254. return(hr);
  255. }
  256. HRESULT
  257. myGetColumnDisplayName(
  258. IN WCHAR const *pwszColumnName,
  259. OUT WCHAR const **ppwszDisplayName)
  260. {
  261. HRESULT hr;
  262. COLUMNTRANSLATE *pct;
  263. *ppwszDisplayName = NULL;
  264. if (NULL == g_aColTable[0].pwszDisplayName)
  265. {
  266. hr = LoadDisplayNames();
  267. _JumpIfError(hr, error, "LoadDisplayNames");
  268. }
  269. hr = E_INVALIDARG;
  270. for (pct = g_aColTable; NULL != pct->pwszColumnName; pct++)
  271. {
  272. if (0 == lstrcmpi(pct->pwszColumnName, pwszColumnName))
  273. {
  274. *ppwszDisplayName = pct->pwszDisplayName;
  275. hr = S_OK;
  276. break;
  277. }
  278. }
  279. _JumpIfError(hr, error, "Bad Column Name");
  280. DBGPRINT((
  281. DBG_SS_CERTLIBI,
  282. "myGetColumnDisplayName(%ws) --> '%ws'\n",
  283. pwszColumnName,
  284. *ppwszDisplayName));
  285. error:
  286. return(hr);
  287. }
  288. HRESULT
  289. myGetColumnName(
  290. IN DWORD Index,
  291. IN BOOL fDisplayName,
  292. OUT WCHAR const **ppwszName)
  293. {
  294. HRESULT hr;
  295. COLUMNTRANSLATE *pct;
  296. *ppwszName = NULL;
  297. if (NULL == g_aColTable[0].pwszDisplayName)
  298. {
  299. hr = LoadDisplayNames();
  300. _JumpIfError(hr, error, "LoadDisplayNames");
  301. }
  302. if (CCOL_MAX <= Index)
  303. {
  304. hr = E_INVALIDARG;
  305. _JumpError(hr, error, "Bad Index");
  306. }
  307. pct = &g_aColTable[Index];
  308. *ppwszName = fDisplayName? pct->pwszDisplayName : pct->pwszColumnName;
  309. hr = S_OK;
  310. DBGPRINT((
  311. DBG_SS_CERTLIBI,
  312. "myGetColumnName(%x, fDisplay=%d) --> '%ws'\n",
  313. Index,
  314. fDisplayName,
  315. *ppwszName));
  316. error:
  317. return(hr);
  318. }
  319. VOID
  320. myFreeColumnDisplayNames2()
  321. {
  322. COLUMNTRANSLATE *pct;
  323. CAPROPTRANSLATE *pcapt;
  324. if (NULL != g_aColTable[0].pwszDisplayName)
  325. {
  326. for (pct = g_aColTable; NULL != pct->pwszColumnName; pct++)
  327. {
  328. LocalFree(const_cast<WCHAR *>(pct->pwszDisplayName));
  329. pct->pwszDisplayName = NULL;
  330. }
  331. for (pcapt = g_aCAPropTable; 0 != pcapt->lPropId; pcapt++)
  332. {
  333. LocalFree(const_cast<WCHAR *>(pcapt->pwszDisplayName));
  334. pcapt->pwszDisplayName = NULL;
  335. }
  336. }
  337. }
  338. HRESULT
  339. myCAPropGetDisplayName(
  340. IN LONG lPropId,
  341. OUT WCHAR const **ppwszDisplayName)
  342. {
  343. HRESULT hr;
  344. CAPROPTRANSLATE *pcapt;
  345. *ppwszDisplayName = NULL;
  346. if (NULL == g_aColTable[0].pwszDisplayName)
  347. {
  348. hr = LoadDisplayNames();
  349. _JumpIfError(hr, error, "LoadDisplayNames");
  350. }
  351. hr = E_INVALIDARG;
  352. for (pcapt = g_aCAPropTable; 0 != pcapt->lPropId; pcapt++)
  353. {
  354. if (lPropId == pcapt->lPropId)
  355. {
  356. *ppwszDisplayName = pcapt->pwszDisplayName;
  357. hr = S_OK;
  358. break;
  359. }
  360. }
  361. _JumpIfError(hr, error, "Bad PropId");
  362. error:
  363. DBGPRINT((
  364. S_OK == hr? DBG_SS_CERTLIBI : DBG_SS_CERTLIB,
  365. "myCAPropGetDisplayName(%x) --> hr=%x, '%ws'\n",
  366. lPropId,
  367. hr,
  368. *ppwszDisplayName));
  369. return(hr);
  370. }
  371. HRESULT
  372. myCAPropInfoUnmarshal(
  373. IN OUT CAPROP *pCAPropInfo,
  374. IN LONG cCAPropInfo,
  375. IN DWORD cbCAPropInfo)
  376. {
  377. HRESULT hr;
  378. CAPROP *pcap;
  379. CAPROP *pcapEnd;
  380. BYTE *pbEnd;
  381. LONG i;
  382. if (NULL == pCAPropInfo)
  383. {
  384. hr = E_POINTER;
  385. _JumpError(hr, error, "NULL parm");
  386. }
  387. pbEnd = (BYTE *) Add2Ptr(pCAPropInfo, cbCAPropInfo);
  388. pcapEnd = &pCAPropInfo[cCAPropInfo];
  389. for (pcap = pCAPropInfo; pcap < pcapEnd; pcap++)
  390. {
  391. WCHAR const *pwszDisplayName;
  392. WCHAR const *pwszT;
  393. hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATA);
  394. if ((BYTE *) (pcap + 1) > pbEnd)
  395. {
  396. _JumpError(hr, error, "bad marshalled data");
  397. }
  398. pwszDisplayName = NULL;
  399. if (NULL != pcap->pwszDisplayName)
  400. {
  401. pwszDisplayName = (WCHAR *) Add2Ptr(
  402. pCAPropInfo,
  403. pcap->pwszDisplayName);
  404. if ((BYTE *) pwszDisplayName < (BYTE *) (pcap + 1) ||
  405. (BYTE *) pwszDisplayName >= pbEnd)
  406. {
  407. _JumpError(hr, error, "bad marshalled pointer");
  408. }
  409. pwszT = pwszDisplayName + wcslen(pwszDisplayName) + 1;
  410. if ((BYTE *) pwszT > pbEnd)
  411. {
  412. _JumpError(hr, error, "bad marshalled string");
  413. }
  414. }
  415. hr = myCAPropGetDisplayName(pcap->lPropId, &pwszT);
  416. _PrintIfError(hr, "myCAPropGetDisplayName");
  417. if (S_OK == hr)
  418. {
  419. pwszDisplayName = pwszT;
  420. }
  421. pcap->pwszDisplayName = const_cast<WCHAR *>(pwszDisplayName);
  422. DBGPRINT((
  423. DBG_SS_CERTLIBI,
  424. "RequestGetCAPropertyInfo: ielt=%d idx=%x t=%x \"%ws\"\n",
  425. SAFE_SUBTRACT_POINTERS(pcap, pCAPropInfo),
  426. pcap->lPropId,
  427. pcap->lPropFlags,
  428. pcap->pwszDisplayName));
  429. }
  430. hr = S_OK;
  431. error:
  432. return(hr);
  433. }
  434. HRESULT
  435. myCAPropInfoLookup(
  436. IN CAPROP const *pCAPropInfo,
  437. IN LONG cCAPropInfo,
  438. IN LONG lPropId,
  439. OUT CAPROP const **ppcap)
  440. {
  441. HRESULT hr;
  442. CAPROP const *pcap;
  443. CAPROP const *pcapEnd;
  444. if (NULL == ppcap)
  445. {
  446. hr = E_POINTER;
  447. _JumpError(hr, error, "NULL parm");
  448. }
  449. *ppcap = NULL;
  450. hr = HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND);
  451. pcapEnd = &pCAPropInfo[cCAPropInfo];
  452. for (pcap = pCAPropInfo; pcap < pcapEnd; pcap++)
  453. {
  454. if (lPropId == pcap->lPropId)
  455. {
  456. *ppcap = pcap;
  457. hr = S_OK;
  458. break;
  459. }
  460. }
  461. _JumpIfError(hr, error, "Bad lPropId");
  462. error:
  463. return(hr);
  464. }