fork download
  1. while (pCertContext = CertEnumCertificatesInStore(hStore,pCertContext))
  2. {
  3. if ( FileTimeIsMoreThanSystem((pCertContext)->pCertInfo->NotAfter) == 0 )
  4. continue;
  5. TCHAR fullCertId[100];
  6. TCHAR timeBefore[32];
  7. TCHAR timeAfter[32];
  8. CString pszNameString = GetCertName1(pCertContext);
  9.  
  10. if (!ConvertFileTimeToString((pCertContext)->pCertInfo->NotBefore,(LPTSTR)&timeBefore))
  11. _tcscpy(timeBefore, _T("--.--.----"));
  12. if (!ConvertFileTimeToString((pCertContext)->pCertInfo->NotAfter,(LPTSTR)&timeAfter) )
  13. _tcscpy(timeAfter, _T("--.--.----"));
  14.  
  15. CString a =
  16. bin_to_hex2((pCertContext)->pCertInfo->SerialNumber.cbData, (pCertContext)->pCertInfo->SerialNumber.pbData, &logFile);
  17.  
  18. swprintf( fullCertId,_T("%s#%s#%s#%s#"),(LPCWSTR)pszNameString,
  19. a,
  20. timeBefore, timeAfter );
  21. bool oldAlg = false;
  22. if (_tcsstr(a_Name,_T("#")) > 0)
  23. {
  24. if (_tcscmp(fullCertId, a_Name) == 0)
  25. certFinded = true;
  26. }
  27.  
  28. if (certFinded)
  29. {
  30. //i++;
  31.  
  32. break;
  33. }
  34.  
  35. if (_tcsstr(m_certsNames,fullCertId) == 0)
  36. {
  37. m_certsNames.Append(fullCertId);
  38. //_tcscat(certsNames, fullCertId);
  39. m_certsNames.Append(_T(";"));
  40. //AfxMessageBox(certsNames);
  41. }
  42.  
  43. if (debug_sign == 2)
  44. logFile.WriteLn(_T("recycle"), 0);
  45.  
  46.  
  47. CString bin_to_hex2(DWORD sizeData, BYTE* pbData, CLogFile* LFile)
  48. {
  49. // перевод из бинарного вида в текстовый.
  50. //LPSTR sig = static_cast<LPSTR>(malloc((sizeData*2+1)));
  51. //ZeroMemory(sig, sizeData*2+1 + 1);
  52.  
  53. CString st;
  54.  
  55. std:wstring stmp = _T("");
  56.  
  57. //LPTSTR tmp = static_cast<LPTSTR>(malloc(4/*sizeData*/));
  58. //ZeroMemory(tmp, /*sizeData*/4 + 1);
  59.  
  60. //wchar_t tmp[3] = _T(" ");
  61. wchar_t tmp[] = _T(" ");
  62.  
  63. if (debug_sign == 2 && LFile != NULL)
  64. {
  65. const TCHAR str[] = _T("before new TCHAR");
  66. LFile->WriteLn(str, 0);
  67. }
  68.  
  69. wchar_t* hexStr = new TCHAR [(sizeData * sizeof(TCHAR))+2];
  70.  
  71. if (debug_sign == 2 && LFile != NULL)
  72. {
  73. const TCHAR str[] = _T("after new TCHAR");
  74. LFile->WriteLn(str, 0);
  75. }
  76.  
  77. while(sizeData > 0)
  78. {
  79. swprintf(tmp,_T("%02x"),pbData[--sizeData]);
  80. //if (debug_sign == 2 && LFile != NULL)
  81. //LFile->WriteLn(tmp, 0);
  82.  
  83. //st.Append((LPCWSTR)tmp);
  84.  
  85. stmp.append(tmp);
  86.  
  87. //if (debug_sign == 2 && LFile != NULL)
  88. // LFile->WriteLn(stmp.c_str(), 0);
  89.  
  90. //st.Append(stmp.c_str());
  91.  
  92. //st.AppendFormat(_T("%s"), tmp);
  93. //if (debug_sign == 2 && LFile != NULL)
  94. // LFile->WriteLn(st, 0);
  95. //strcat(sig, tmp);
  96. }
  97.  
  98.  
  99. /*
  100. if (debug_sign == 2 && LFile != NULL)
  101. {
  102. const TCHAR str[] = _T("before free(tmp)");
  103. LFile->WriteLn(str, 0);
  104. }
  105.  
  106. if (tmp)
  107. {
  108. free(tmp);
  109. tmp = NULL;
  110. }
  111. */
  112.  
  113. // if (debug_sign == 2 && LFile != NULL)
  114. // LFile->WriteLn(st, 0);
  115.  
  116. if (stmp != _T(""))
  117. {
  118. st.Append(stmp.c_str());
  119.  
  120. if (debug_sign == 2 && LFile != NULL)
  121. LFile->WriteLn(st, 0);
  122.  
  123. hexStr = T2W(st.GetBuffer());
  124. st.ReleaseBuffer();
  125. st = hexStr;
  126.  
  127. if (debug_sign == 2 && LFile != NULL)
  128. {
  129. const TCHAR str[] = _T("before delete");
  130. LFile->WriteLn(str, 0);
  131. }
  132.  
  133. if (hexStr)
  134. delete hexStr;
  135.  
  136. if (debug_sign == 2 && LFile != NULL)
  137. {
  138. const TCHAR str[] = _T("after delete");
  139. LFile->WriteLn(str, 0);
  140. }
  141.  
  142. //AfxMessageBox(st);
  143. }
  144. else
  145. if (debug_sign == 2 && LFile != NULL)
  146. {
  147. const TCHAR str[] = _T("return empty");
  148. LFile->WriteLn(str, 0);
  149. }
  150.  
  151.  
  152. /*
  153. // DWORD len_w ;
  154. //*hexSize = MultiByteToWideChar(CP_ACP, 0, sig, -1, NULL, 0);
  155. *hexSize = MultiByteToWideChar(CP_ACP, 0, st.c_, -1, NULL, 0);
  156. if (*hexSize > 0 || hexStr != NULL )
  157. {
  158. MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, st.GetBuffer(), *hexSize, hexStr, *hexSize);
  159. }
  160. */
  161.  
  162. /*
  163. if (sig)
  164. {
  165. free(sig);
  166. sig = NULL;
  167. }
  168. */
  169.  
  170. return st;
  171. }
  172.  
  173.  
  174.  
  175. CString GetCertName1( PCCERT_CONTEXT a_pCertContext)
  176. {
  177.  
  178. bool nextStep = true;
  179. LPTSTR pszName;
  180. CString tmp;
  181. DWORD cbSize;
  182. if(!(cbSize = CertGetNameString(
  183. a_pCertContext,
  184. CERT_NAME_SIMPLE_DISPLAY_TYPE,
  185. 0,
  186. NULL,
  187. NULL,
  188. 0)))
  189. {
  190. MyHandleError(TEXT("CertGetName 1 failed."));
  191. nextStep = false;
  192. }
  193.  
  194. if (nextStep)
  195.  
  196. //if(!(pszName = (LPTSTR)malloc(cbSize * sizeof(TCHAR)+2)))
  197. if(!(pszName = (new TCHAR [cbSize*sizeof(TCHAR)+2])))
  198. {
  199. MyHandleError(TEXT("Memory allocation failed."));
  200. nextStep = false;
  201. }
  202.  
  203. if (nextStep)
  204. if(!CertGetNameString(
  205. a_pCertContext,
  206. CERT_NAME_SIMPLE_DISPLAY_TYPE,
  207. 0,
  208. NULL,
  209. pszName,
  210. cbSize))
  211. //
  212. // {
  213. // //_tprintf(TEXT("\!!!!!!nSubject -> %s.\n"), pszName);
  214. //
  215. // //-------------------------------------------------------
  216. // // Free the memory allocated for the string.
  217. // //free(pszName);
  218. // }
  219. // else
  220. {
  221. MyHandleError(TEXT("CertGetName failed."));
  222. }
  223.  
  224. if (nextStep)
  225. {
  226. tmp = pszName;
  227. if (pszName)
  228. {
  229. delete pszName;
  230. //free(pszName);
  231. //pszName = NULL;
  232. }
  233. //AfxMessageBox(tmp);
  234. return tmp;
  235. }
  236.  
  237. return _T("");
  238. }
  239.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1:1: error: expected unqualified-id before ‘while’
 while (pCertContext = CertEnumCertificatesInStore(hStore,pCertContext))
 ^~~~~
stdout
Standard output is empty