Leaked source code of windows server 2003
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.

1977 lines
37 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 1999
  3. Module Name:
  4. logobj
  5. Abstract:
  6. This module contains the code definitions for the logging objects.
  7. Author:
  8. Doug Barlow (dbarlow) 12/7/1999
  9. Notes:
  10. ?Notes?
  11. --*/
  12. #ifndef WIN32_LEAN_AND_MEAN
  13. #define WIN32_LEAN_AND_MEAN
  14. #endif
  15. #include <windows.h>
  16. #include "logcsp.h"
  17. //
  18. //==============================================================================
  19. //
  20. // CLogObject
  21. //
  22. /*++
  23. CONSTRUCTOR:
  24. Default log object initialization
  25. Arguments:
  26. plh - Pointer to a log header structure imbedded in the derived class.
  27. Return Value:
  28. None
  29. Author:
  30. Doug Barlow (dbarlow) 2/20/1998
  31. --*/
  32. CLogObject::CLogObject(
  33. LogTypeId id,
  34. LogHeader *plh,
  35. DWORD cbStruct)
  36. {
  37. ZeroMemory(plh, cbStruct);
  38. plh->cbDataOffset = cbStruct;
  39. plh->id = id;
  40. m_plh = plh;
  41. m_pbLogData = 0;
  42. m_cbLogDataLen = 0;
  43. m_cbLogDataUsed = 0;
  44. }
  45. /*++
  46. DESTRUCTOR:
  47. Default log object tear down
  48. Arguments:
  49. None
  50. Return Value:
  51. None
  52. Author:
  53. Doug Barlow (dbarlow) 2/20/1998
  54. --*/
  55. CLogObject::~CLogObject()
  56. {
  57. if (NULL != m_pbLogData)
  58. LocalFree(m_pbLogData);
  59. }
  60. /*++
  61. LogAdd:
  62. Add data to the data buffer.
  63. Arguments:
  64. pbf supplies the pointer to the LogBuffer referencing the data.
  65. sz supplies the data to be added as a string
  66. pb supplies the data to be added as a byte array.
  67. cb supplies the length of the data, in bytes.
  68. Return Value:
  69. None
  70. Author:
  71. Doug Barlow (dbarlow) 2/20/1998
  72. --*/
  73. void
  74. CLogObject::LogAdd(
  75. LogBuffer *pbf,
  76. LPCTSTR sz)
  77. {
  78. if (NULL == sz)
  79. LogAdd(pbf, (const BYTE *)sz, 0);
  80. else
  81. LogAdd(pbf, (const BYTE *)sz, (lstrlen(sz) + 1) * sizeof(TCHAR));
  82. }
  83. void
  84. CLogObject::LogAdd(
  85. LogBuffer *pbf,
  86. const BYTE *pb,
  87. DWORD cb)
  88. {
  89. if (NULL == pb)
  90. {
  91. pbf->cbOffset = (DWORD)(-1);
  92. pbf->cbLength = cb;
  93. }
  94. else if (0 == cb)
  95. {
  96. pbf->cbOffset = m_cbLogDataUsed;
  97. pbf->cbLength = cb;
  98. }
  99. else
  100. {
  101. if (m_cbLogDataUsed + cb > m_cbLogDataLen)
  102. {
  103. DWORD cbNext = m_cbLogDataLen;
  104. LPBYTE pbNext;
  105. while (m_cbLogDataUsed + cb > cbNext)
  106. {
  107. if (0 == cbNext)
  108. cbNext = 256;
  109. else
  110. cbNext *= 2;
  111. }
  112. pbNext = (LPBYTE)LocalAlloc(LPTR, cbNext);
  113. ASSERT(NULL != pbNext);
  114. if (0 < m_cbLogDataUsed)
  115. {
  116. ASSERT(NULL != m_pbLogData);
  117. CopyMemory(pbNext, m_pbLogData, m_cbLogDataUsed);
  118. }
  119. if (NULL != m_pbLogData)
  120. {
  121. ASSERT(0 < m_cbLogDataLen);
  122. LocalFree(m_pbLogData);
  123. }
  124. m_pbLogData = pbNext;
  125. m_cbLogDataLen = cbNext;
  126. }
  127. ASSERT(NULL != m_pbLogData);
  128. CopyMemory(&m_pbLogData[m_cbLogDataUsed], pb, cb);
  129. pbf->cbOffset = m_cbLogDataUsed;
  130. pbf->cbLength = cb;
  131. m_cbLogDataUsed += cb;
  132. }
  133. }
  134. void
  135. CLogObject::Log(
  136. LPCTSTR szLogFile)
  137. {
  138. BOOL fSts;
  139. DWORD dwLen;
  140. HANDLE hLogFile;
  141. m_plh->cbLength = m_plh->cbDataOffset + m_cbLogDataUsed;
  142. hLogFile = CreateFile(
  143. szLogFile,
  144. GENERIC_WRITE,
  145. FILE_SHARE_READ,
  146. NULL,
  147. OPEN_EXISTING,
  148. FILE_ATTRIBUTE_NORMAL,
  149. NULL);
  150. if (INVALID_HANDLE_VALUE != hLogFile)
  151. {
  152. dwLen = SetFilePointer(hLogFile, 0, NULL, FILE_END);
  153. ASSERT(-1 != dwLen);
  154. fSts = WriteFile(
  155. hLogFile,
  156. (LPBYTE)m_plh,
  157. m_plh->cbDataOffset,
  158. &dwLen,
  159. NULL);
  160. ASSERT(fSts);
  161. ASSERT(dwLen == m_plh->cbDataOffset);
  162. if ((0 < m_cbLogDataUsed) && (NULL != m_pbLogData))
  163. {
  164. fSts = WriteFile(
  165. hLogFile,
  166. m_pbLogData,
  167. m_cbLogDataUsed,
  168. &dwLen,
  169. NULL);
  170. ASSERT(fSts);
  171. ASSERT(dwLen == m_cbLogDataUsed);
  172. }
  173. CloseHandle(hLogFile);
  174. }
  175. m_cbLogDataUsed = 0;
  176. }
  177. void
  178. CLogObject::Request(
  179. void)
  180. {
  181. GetLocalTime(&m_plh->startTime);
  182. m_plh->dwProcId = GetCurrentProcessId();
  183. m_plh->dwThreadId = GetCurrentThreadId();
  184. }
  185. void
  186. CLogObject::Response(
  187. CompletionCode code,
  188. DWORD dwError)
  189. {
  190. GetLocalTime(&m_plh->endTime);
  191. m_plh->status = code;
  192. switch (code)
  193. {
  194. case logid_True:
  195. m_plh->dwStatus = ERROR_SUCCESS;
  196. break;
  197. case logid_False:
  198. if (ERROR_SUCCESS == dwError)
  199. m_plh->dwStatus = GetLastError();
  200. else
  201. m_plh->dwStatus = dwError;
  202. break;
  203. case logid_Exception:
  204. m_plh->dwStatus = ERROR_ARENA_TRASHED;
  205. break;
  206. case logid_Setup:
  207. if (ERROR_SUCCESS == dwError)
  208. m_plh->dwStatus = ERROR_CALL_NOT_IMPLEMENTED;
  209. else
  210. m_plh->dwStatus = dwError;
  211. break;
  212. default:
  213. ASSERT(FALSE);
  214. }
  215. }
  216. //
  217. //==============================================================================
  218. //
  219. // CLogAcquireContext
  220. //
  221. CLogAcquireContext::CLogAcquireContext(
  222. void)
  223. : CLogObject(AcquireContext, &m_LogData.lh, sizeof(m_LogData))
  224. {
  225. }
  226. CLogAcquireContext::~CLogAcquireContext()
  227. {
  228. }
  229. void
  230. CLogAcquireContext::Request(
  231. OUT HCRYPTPROV *phProv,
  232. IN LPCTSTR pszContainer,
  233. IN DWORD dwFlags,
  234. IN PVTableProvStruc pVTable)
  235. {
  236. CLogObject::Request();
  237. LogAdd(&m_LogData.bfContainer, pszContainer);
  238. m_LogData.dwFlags = dwFlags;
  239. m_LogData.dwVersion = pVTable->Version;
  240. m_LogData.pvFuncVerifyImage = pVTable->FuncVerifyImage;
  241. if (3 <= pVTable->Version)
  242. {
  243. m_LogData.pvFuncReturnhWnd = pVTable->FuncReturnhWnd;
  244. if (NULL != pVTable->FuncReturnhWnd)
  245. {
  246. try
  247. {
  248. (*pVTable->FuncReturnhWnd)(&m_LogData.hWnd);
  249. }
  250. catch (...)
  251. {
  252. m_LogData.hWnd = (HWND)(-1);
  253. }
  254. }
  255. else
  256. m_LogData.hWnd = NULL;
  257. m_LogData.dwProvType = pVTable->dwProvType;
  258. LogAdd(&m_LogData.bfContextInfo, pVTable->pbContextInfo, pVTable->cbContextInfo);
  259. LogAdd(&m_LogData.bfProvName, (const BYTE *)pVTable->pszProvName, (lstrlen(pVTable->pszProvName) + 1) * sizeof(TCHAR));
  260. }
  261. else
  262. {
  263. m_LogData.pvFuncReturnhWnd = NULL;
  264. m_LogData.dwProvType = NULL;
  265. LogAdd(&m_LogData.bfContextInfo, NULL, 0);
  266. LogAdd(&m_LogData.bfProvName, NULL, 0);
  267. }
  268. }
  269. void
  270. CLogAcquireContext::Response(
  271. BOOL fStatus,
  272. OUT HCRYPTPROV *phProv,
  273. IN LPCTSTR pszContainer,
  274. IN DWORD dwFlags,
  275. IN PVTableProvStruc pVTable)
  276. {
  277. if (fStatus)
  278. {
  279. CLogObject::Response(logid_True);
  280. }
  281. else
  282. {
  283. CLogObject::Response(logid_False);
  284. }
  285. m_LogData.hProv = *phProv;
  286. }
  287. void
  288. CLogAcquireContext::LogException(
  289. void)
  290. {
  291. CLogObject::Response(logid_Exception);
  292. m_LogData.hProv = NULL;
  293. }
  294. void
  295. CLogAcquireContext::LogNotCalled(
  296. DWORD dwSts)
  297. {
  298. CLogObject::Response(logid_Setup, dwSts);
  299. m_LogData.hProv = NULL;
  300. }
  301. //
  302. //==============================================================================
  303. //
  304. // CLogGetProvParam
  305. //
  306. CLogGetProvParam::CLogGetProvParam(
  307. void)
  308. : CLogObject(GetProvParam, &m_LogData.lh, sizeof(m_LogData))
  309. {
  310. }
  311. CLogGetProvParam::~CLogGetProvParam()
  312. {
  313. }
  314. void
  315. CLogGetProvParam::Request(
  316. IN HCRYPTPROV hProv,
  317. IN DWORD dwParam,
  318. OUT BYTE *pbData,
  319. IN OUT DWORD *pdwDataLen,
  320. IN DWORD dwFlags)
  321. {
  322. CLogObject::Request();
  323. m_LogData.hProv = hProv;
  324. m_LogData.dwParam = dwParam;
  325. m_LogData.dwDataLen = *pdwDataLen;
  326. m_LogData.dwFlags = dwFlags;
  327. }
  328. void
  329. CLogGetProvParam::Response(
  330. BOOL fStatus,
  331. IN HCRYPTPROV hProv,
  332. IN DWORD dwParam,
  333. OUT BYTE *pbData,
  334. IN OUT DWORD *pdwDataLen,
  335. IN DWORD dwFlags)
  336. {
  337. if (fStatus)
  338. {
  339. CLogObject::Response(logid_True);
  340. LogAdd(&m_LogData.bfData, pbData, *pdwDataLen);
  341. }
  342. else
  343. {
  344. CLogObject::Response(logid_False);
  345. LogAdd(&m_LogData.bfData, NULL, *pdwDataLen);
  346. }
  347. }
  348. void
  349. CLogGetProvParam::LogException(
  350. void)
  351. {
  352. CLogObject::Response(logid_Exception);
  353. LogAdd(&m_LogData.bfData, NULL, 0);
  354. }
  355. void
  356. CLogGetProvParam::LogNotCalled(
  357. DWORD dwSts)
  358. {
  359. CLogObject::Response(logid_Setup, dwSts);
  360. LogAdd(&m_LogData.bfData, NULL, 0);
  361. }
  362. //
  363. //==============================================================================
  364. //
  365. // CLogReleaseContext
  366. //
  367. CLogReleaseContext::CLogReleaseContext(
  368. void)
  369. : CLogObject(ReleaseContext, &m_LogData.lh, sizeof(m_LogData))
  370. {
  371. }
  372. CLogReleaseContext::~CLogReleaseContext()
  373. {
  374. }
  375. void
  376. CLogReleaseContext::Request(
  377. IN HCRYPTPROV hProv,
  378. IN DWORD dwFlags)
  379. {
  380. CLogObject::Request();
  381. m_LogData.hProv = hProv;
  382. m_LogData.dwFlags = dwFlags;
  383. }
  384. void
  385. CLogReleaseContext::Response(
  386. BOOL fStatus,
  387. IN HCRYPTPROV hProv,
  388. IN DWORD dwFlags)
  389. {
  390. if (fStatus)
  391. {
  392. CLogObject::Response(logid_True);
  393. }
  394. else
  395. {
  396. CLogObject::Response(logid_False);
  397. }
  398. }
  399. void
  400. CLogReleaseContext::LogException(
  401. void)
  402. {
  403. CLogObject::Response(logid_Exception);
  404. }
  405. void
  406. CLogReleaseContext::LogNotCalled(
  407. DWORD dwSts)
  408. {
  409. CLogObject::Response(logid_Setup, dwSts);
  410. }
  411. //
  412. //==============================================================================
  413. //
  414. // CLogSetProvParam
  415. //
  416. CLogSetProvParam::CLogSetProvParam(
  417. void)
  418. : CLogObject(SetProvParam, &m_LogData.lh, sizeof(m_LogData))
  419. {
  420. }
  421. CLogSetProvParam::~CLogSetProvParam()
  422. {
  423. }
  424. void
  425. CLogSetProvParam::Request(
  426. IN HCRYPTPROV hProv,
  427. IN DWORD dwParam,
  428. IN CONST BYTE *pbData,
  429. IN DWORD dwLength,
  430. IN DWORD dwFlags)
  431. {
  432. CLogObject::Request();
  433. m_LogData.hProv = hProv;
  434. m_LogData.dwParam = dwParam;
  435. LogAdd(&m_LogData.bfData, pbData, dwLength);
  436. m_LogData.dwFlags = dwFlags;
  437. }
  438. void
  439. CLogSetProvParam::Response(
  440. BOOL fStatus,
  441. IN HCRYPTPROV hProv,
  442. IN DWORD dwParam,
  443. IN CONST BYTE *pbData,
  444. IN DWORD dwFlags)
  445. {
  446. if (fStatus)
  447. {
  448. CLogObject::Response(logid_True);
  449. }
  450. else
  451. {
  452. CLogObject::Response(logid_False);
  453. }
  454. }
  455. void
  456. CLogSetProvParam::LogException(
  457. void)
  458. {
  459. CLogObject::Response(logid_Exception);
  460. }
  461. void
  462. CLogSetProvParam::LogNotCalled(
  463. DWORD dwSts)
  464. {
  465. CLogObject::Response(logid_Setup, dwSts);
  466. }
  467. //
  468. //==============================================================================
  469. //
  470. // CLogDeriveKey
  471. //
  472. CLogDeriveKey::CLogDeriveKey(
  473. void)
  474. : CLogObject(DeriveKey, &m_LogData.lh, sizeof(m_LogData))
  475. {
  476. }
  477. CLogDeriveKey::~CLogDeriveKey()
  478. {
  479. }
  480. void
  481. CLogDeriveKey::Request(
  482. IN HCRYPTPROV hProv,
  483. IN ALG_ID Algid,
  484. IN HCRYPTHASH hHash,
  485. IN DWORD dwFlags,
  486. OUT HCRYPTKEY * phKey)
  487. {
  488. CLogObject::Request();
  489. m_LogData.hProv = hProv;
  490. m_LogData.Algid = Algid;
  491. m_LogData.hHash = hHash;
  492. m_LogData.dwFlags = dwFlags;
  493. }
  494. void
  495. CLogDeriveKey::Response(
  496. BOOL fStatus,
  497. IN HCRYPTPROV hProv,
  498. IN ALG_ID Algid,
  499. IN HCRYPTHASH hHash,
  500. IN DWORD dwFlags,
  501. OUT HCRYPTKEY * phKey)
  502. {
  503. if (fStatus)
  504. {
  505. CLogObject::Response(logid_True);
  506. }
  507. else
  508. {
  509. CLogObject::Response(logid_False);
  510. }
  511. m_LogData.hKey = *phKey;
  512. }
  513. void
  514. CLogDeriveKey::LogException(
  515. void)
  516. {
  517. CLogObject::Response(logid_Exception);
  518. m_LogData.hKey = NULL;
  519. }
  520. void
  521. CLogDeriveKey::LogNotCalled(
  522. DWORD dwSts)
  523. {
  524. CLogObject::Response(logid_Setup, dwSts);
  525. m_LogData.hKey = NULL;
  526. }
  527. //
  528. //==============================================================================
  529. //
  530. // CLogDestroyKey
  531. //
  532. CLogDestroyKey::CLogDestroyKey(
  533. void)
  534. : CLogObject(DestroyKey, &m_LogData.lh, sizeof(m_LogData))
  535. {
  536. }
  537. CLogDestroyKey::~CLogDestroyKey()
  538. {
  539. }
  540. void
  541. CLogDestroyKey::Request(
  542. IN HCRYPTPROV hProv,
  543. IN HCRYPTKEY hKey)
  544. {
  545. CLogObject::Request();
  546. m_LogData.hProv = hProv;
  547. m_LogData.hKey = hKey;
  548. }
  549. void
  550. CLogDestroyKey::Response(
  551. BOOL fStatus,
  552. IN HCRYPTPROV hProv,
  553. IN HCRYPTKEY hKey)
  554. {
  555. if (fStatus)
  556. {
  557. CLogObject::Response(logid_True);
  558. }
  559. else
  560. {
  561. CLogObject::Response(logid_False);
  562. }
  563. }
  564. void
  565. CLogDestroyKey::LogException(
  566. void)
  567. {
  568. CLogObject::Response(logid_Exception);
  569. }
  570. void
  571. CLogDestroyKey::LogNotCalled(
  572. DWORD dwSts)
  573. {
  574. CLogObject::Response(logid_Setup, dwSts);
  575. }
  576. //
  577. //==============================================================================
  578. //
  579. // CLogExportKey
  580. //
  581. CLogExportKey::CLogExportKey(
  582. void)
  583. : CLogObject(ExportKey, &m_LogData.lh, sizeof(m_LogData))
  584. {
  585. }
  586. CLogExportKey::~CLogExportKey()
  587. {
  588. }
  589. void
  590. CLogExportKey::Request(
  591. IN HCRYPTPROV hProv,
  592. IN HCRYPTKEY hKey,
  593. IN HCRYPTKEY hPubKey,
  594. IN DWORD dwBlobType,
  595. IN DWORD dwFlags,
  596. OUT BYTE *pbData,
  597. IN OUT DWORD *pdwDataLen)
  598. {
  599. CLogObject::Request();
  600. m_LogData.hProv = hProv;
  601. m_LogData.hKey = hKey;
  602. m_LogData.hPubKey = hPubKey;
  603. m_LogData.dwBlobType = dwBlobType;
  604. m_LogData.dwFlags = dwFlags;
  605. m_LogData.dwDataLen = *pdwDataLen;
  606. }
  607. void
  608. CLogExportKey::Response(
  609. BOOL fStatus,
  610. IN HCRYPTPROV hProv,
  611. IN HCRYPTKEY hKey,
  612. IN HCRYPTKEY hPubKey,
  613. IN DWORD dwBlobType,
  614. IN DWORD dwFlags,
  615. OUT BYTE *pbData,
  616. IN OUT DWORD *pdwDataLen)
  617. {
  618. if (fStatus)
  619. {
  620. CLogObject::Response(logid_True);
  621. LogAdd(&m_LogData.bfData, pbData, *pdwDataLen);
  622. }
  623. else
  624. {
  625. CLogObject::Response(logid_False);
  626. LogAdd(&m_LogData.bfData, NULL, *pdwDataLen);
  627. }
  628. }
  629. void
  630. CLogExportKey::LogException(
  631. void)
  632. {
  633. CLogObject::Response(logid_Exception);
  634. LogAdd(&m_LogData.bfData, NULL, 0);
  635. }
  636. void
  637. CLogExportKey::LogNotCalled(
  638. DWORD dwSts)
  639. {
  640. CLogObject::Response(logid_Setup, dwSts);
  641. LogAdd(&m_LogData.bfData, NULL, 0);
  642. }
  643. //
  644. //==============================================================================
  645. //
  646. // CLogGenKey
  647. //
  648. CLogGenKey::CLogGenKey(
  649. void)
  650. : CLogObject(GenKey, &m_LogData.lh, sizeof(m_LogData))
  651. {
  652. }
  653. CLogGenKey::~CLogGenKey()
  654. {
  655. }
  656. void
  657. CLogGenKey::Request(
  658. IN HCRYPTPROV hProv,
  659. IN ALG_ID Algid,
  660. IN DWORD dwFlags,
  661. OUT HCRYPTKEY *phKey)
  662. {
  663. CLogObject::Request();
  664. m_LogData.hProv = hProv;
  665. m_LogData.Algid = Algid;
  666. m_LogData.dwFlags = dwFlags;
  667. }
  668. void
  669. CLogGenKey::Response(
  670. BOOL fStatus,
  671. IN HCRYPTPROV hProv,
  672. IN ALG_ID Algid,
  673. IN DWORD dwFlags,
  674. OUT HCRYPTKEY *phKey)
  675. {
  676. if (fStatus)
  677. {
  678. CLogObject::Response(logid_True);
  679. }
  680. else
  681. {
  682. CLogObject::Response(logid_False);
  683. }
  684. m_LogData.hKey = *phKey;
  685. }
  686. void
  687. CLogGenKey::LogException(
  688. void)
  689. {
  690. CLogObject::Response(logid_Exception);
  691. m_LogData.hKey = NULL;
  692. }
  693. void
  694. CLogGenKey::LogNotCalled(
  695. DWORD dwSts)
  696. {
  697. CLogObject::Response(logid_Setup, dwSts);
  698. m_LogData.hKey = NULL;
  699. }
  700. //
  701. //==============================================================================
  702. //
  703. // CLogGetKeyParam
  704. //
  705. CLogGetKeyParam::CLogGetKeyParam(
  706. void)
  707. : CLogObject(GetKeyParam, &m_LogData.lh, sizeof(m_LogData))
  708. {
  709. }
  710. CLogGetKeyParam::~CLogGetKeyParam()
  711. {
  712. }
  713. void
  714. CLogGetKeyParam::Request(
  715. IN HCRYPTPROV hProv,
  716. IN HCRYPTKEY hKey,
  717. IN DWORD dwParam,
  718. OUT BYTE *pbData,
  719. IN OUT DWORD *pdwDataLen,
  720. IN DWORD dwFlags)
  721. {
  722. CLogObject::Request();
  723. m_LogData.hProv = hProv;
  724. m_LogData.hKey = hKey;
  725. m_LogData.dwParam = dwParam;
  726. m_LogData.dwDataLen = *pdwDataLen;
  727. m_LogData.dwFlags = dwFlags;
  728. }
  729. void
  730. CLogGetKeyParam::Response(
  731. BOOL fStatus,
  732. IN HCRYPTPROV hProv,
  733. IN HCRYPTKEY hKey,
  734. IN DWORD dwParam,
  735. OUT BYTE *pbData,
  736. IN OUT DWORD *pdwDataLen,
  737. IN DWORD dwFlags)
  738. {
  739. if (fStatus)
  740. {
  741. CLogObject::Response(logid_True);
  742. LogAdd(&m_LogData.bfData, pbData, *pdwDataLen);
  743. }
  744. else
  745. {
  746. CLogObject::Response(logid_False);
  747. LogAdd(&m_LogData.bfData, NULL, *pdwDataLen);
  748. }
  749. }
  750. void
  751. CLogGetKeyParam::LogException(
  752. void)
  753. {
  754. CLogObject::Response(logid_Exception);
  755. LogAdd(&m_LogData.bfData, NULL, 0);
  756. }
  757. void
  758. CLogGetKeyParam::LogNotCalled(
  759. DWORD dwSts)
  760. {
  761. CLogObject::Response(logid_Setup, dwSts);
  762. LogAdd(&m_LogData.bfData, NULL, 0);
  763. }
  764. //
  765. //==============================================================================
  766. //
  767. // CLogGenRandom
  768. //
  769. CLogGenRandom::CLogGenRandom(
  770. void)
  771. : CLogObject(GenRandom, &m_LogData.lh, sizeof(m_LogData))
  772. {
  773. }
  774. CLogGenRandom::~CLogGenRandom()
  775. {
  776. }
  777. void
  778. CLogGenRandom::Request(
  779. IN HCRYPTPROV hProv,
  780. IN DWORD dwLen,
  781. IN OUT BYTE *pbBuffer)
  782. {
  783. CLogObject::Request();
  784. m_LogData.hProv = hProv;
  785. m_LogData.dwLen = dwLen;
  786. }
  787. void
  788. CLogGenRandom::Response(
  789. BOOL fStatus,
  790. IN HCRYPTPROV hProv,
  791. IN DWORD dwLen,
  792. IN OUT BYTE *pbBuffer)
  793. {
  794. if (fStatus)
  795. {
  796. CLogObject::Response(logid_True);
  797. LogAdd(&m_LogData.bfBuffer, pbBuffer, dwLen);
  798. }
  799. else
  800. {
  801. CLogObject::Response(logid_False);
  802. LogAdd(&m_LogData.bfBuffer, NULL, 0);
  803. }
  804. }
  805. void
  806. CLogGenRandom::LogException(
  807. void)
  808. {
  809. CLogObject::Response(logid_Exception);
  810. LogAdd(&m_LogData.bfBuffer, NULL, 0);
  811. }
  812. void
  813. CLogGenRandom::LogNotCalled(
  814. DWORD dwSts)
  815. {
  816. CLogObject::Response(logid_Setup, dwSts);
  817. LogAdd(&m_LogData.bfBuffer, NULL, 0);
  818. }
  819. //
  820. //==============================================================================
  821. //
  822. // CLogGetUserKey
  823. //
  824. CLogGetUserKey::CLogGetUserKey(
  825. void)
  826. : CLogObject(GetUserKey, &m_LogData.lh, sizeof(m_LogData))
  827. {
  828. }
  829. CLogGetUserKey::~CLogGetUserKey()
  830. {
  831. }
  832. void
  833. CLogGetUserKey::Request(
  834. IN HCRYPTPROV hProv,
  835. IN DWORD dwKeySpec,
  836. OUT HCRYPTKEY *phUserKey)
  837. {
  838. CLogObject::Request();
  839. m_LogData.hProv = hProv;
  840. m_LogData.dwKeySpec = dwKeySpec;
  841. }
  842. void
  843. CLogGetUserKey::Response(
  844. BOOL fStatus,
  845. IN HCRYPTPROV hProv,
  846. IN DWORD dwKeySpec,
  847. OUT HCRYPTKEY *phUserKey)
  848. {
  849. if (fStatus)
  850. {
  851. CLogObject::Response(logid_True);
  852. }
  853. else
  854. {
  855. CLogObject::Response(logid_False);
  856. }
  857. m_LogData.hUserKey = *phUserKey;
  858. }
  859. void
  860. CLogGetUserKey::LogException(
  861. void)
  862. {
  863. CLogObject::Response(logid_Exception);
  864. m_LogData.hUserKey = NULL;
  865. }
  866. void
  867. CLogGetUserKey::LogNotCalled(
  868. DWORD dwSts)
  869. {
  870. CLogObject::Response(logid_Setup, dwSts);
  871. m_LogData.hUserKey = NULL;
  872. }
  873. //
  874. //==============================================================================
  875. //
  876. // CLogImportKey
  877. //
  878. CLogImportKey::CLogImportKey(
  879. void)
  880. : CLogObject(ImportKey, &m_LogData.lh, sizeof(m_LogData))
  881. {
  882. }
  883. CLogImportKey::~CLogImportKey()
  884. {
  885. }
  886. void
  887. CLogImportKey::Request(
  888. IN HCRYPTPROV hProv,
  889. IN CONST BYTE *pbData,
  890. IN DWORD dwDataLen,
  891. IN HCRYPTKEY hPubKey,
  892. IN DWORD dwFlags,
  893. OUT HCRYPTKEY *phKey)
  894. {
  895. CLogObject::Request();
  896. m_LogData.hProv = hProv;
  897. LogAdd(&m_LogData.bfData, pbData, dwDataLen);
  898. m_LogData.hPubKey = hPubKey;
  899. m_LogData.dwFlags = dwFlags;
  900. }
  901. void
  902. CLogImportKey::Response(
  903. BOOL fStatus,
  904. IN HCRYPTPROV hProv,
  905. IN CONST BYTE *pbData,
  906. IN DWORD dwDataLen,
  907. IN HCRYPTKEY hPubKey,
  908. IN DWORD dwFlags,
  909. OUT HCRYPTKEY *phKey)
  910. {
  911. if (fStatus)
  912. {
  913. CLogObject::Response(logid_True);
  914. }
  915. else
  916. {
  917. CLogObject::Response(logid_False);
  918. }
  919. m_LogData.hKey = *phKey;
  920. }
  921. void
  922. CLogImportKey::LogException(
  923. void)
  924. {
  925. CLogObject::Response(logid_Exception);
  926. m_LogData.hKey = NULL;
  927. }
  928. void
  929. CLogImportKey::LogNotCalled(
  930. DWORD dwSts)
  931. {
  932. CLogObject::Response(logid_Setup, dwSts);
  933. m_LogData.hKey = NULL;
  934. }
  935. //
  936. //==============================================================================
  937. //
  938. // CLogSetKeyParam
  939. //
  940. CLogSetKeyParam::CLogSetKeyParam(
  941. void)
  942. : CLogObject(SetKeyParam, &m_LogData.lh, sizeof(m_LogData))
  943. {
  944. }
  945. CLogSetKeyParam::~CLogSetKeyParam()
  946. {
  947. }
  948. void
  949. CLogSetKeyParam::Request(
  950. IN HCRYPTPROV hProv,
  951. IN HCRYPTKEY hKey,
  952. IN DWORD dwParam,
  953. IN CONST BYTE *pbData,
  954. IN DWORD dwLength,
  955. IN DWORD dwFlags)
  956. {
  957. CLogObject::Request();
  958. m_LogData.hProv = hProv;
  959. m_LogData.hKey = hKey;
  960. m_LogData.dwParam = dwParam;
  961. LogAdd(&m_LogData.bfData, pbData, dwLength);
  962. m_LogData.dwFlags = dwFlags;
  963. }
  964. void
  965. CLogSetKeyParam::Response(
  966. BOOL fStatus,
  967. IN HCRYPTPROV hProv,
  968. IN HCRYPTKEY hKey,
  969. IN DWORD dwParam,
  970. IN CONST BYTE *pbData,
  971. IN DWORD dwFlags)
  972. {
  973. if (fStatus)
  974. {
  975. CLogObject::Response(logid_True);
  976. }
  977. else
  978. {
  979. CLogObject::Response(logid_False);
  980. }
  981. }
  982. void
  983. CLogSetKeyParam::LogException(
  984. void)
  985. {
  986. CLogObject::Response(logid_Exception);
  987. }
  988. void
  989. CLogSetKeyParam::LogNotCalled(
  990. DWORD dwSts)
  991. {
  992. CLogObject::Response(logid_Setup, dwSts);
  993. }
  994. //
  995. //==============================================================================
  996. //
  997. // CLogEncrypt
  998. //
  999. CLogEncrypt::CLogEncrypt(
  1000. void)
  1001. : CLogObject(Encrypt, &m_LogData.lh, sizeof(m_LogData))
  1002. {
  1003. }
  1004. CLogEncrypt::~CLogEncrypt()
  1005. {
  1006. }
  1007. void
  1008. CLogEncrypt::Request(
  1009. IN HCRYPTPROV hProv,
  1010. IN HCRYPTKEY hKey,
  1011. IN HCRYPTHASH hHash,
  1012. IN BOOL Final,
  1013. IN DWORD dwFlags,
  1014. IN OUT BYTE *pbData,
  1015. IN OUT DWORD *pdwDataLen,
  1016. IN DWORD dwBufLen)
  1017. {
  1018. CLogObject::Request();
  1019. m_LogData.hProv = hProv;
  1020. m_LogData.hKey = hKey;
  1021. m_LogData.hHash = hHash;
  1022. m_LogData.Final = Final;
  1023. m_LogData.dwFlags = dwFlags;
  1024. LogAdd(&m_LogData.bfInData, pbData, *pdwDataLen);
  1025. m_LogData.dwBufLen = dwBufLen;
  1026. }
  1027. void
  1028. CLogEncrypt::Response(
  1029. BOOL fStatus,
  1030. IN HCRYPTPROV hProv,
  1031. IN HCRYPTKEY hKey,
  1032. IN HCRYPTHASH hHash,
  1033. IN BOOL Final,
  1034. IN DWORD dwFlags,
  1035. IN OUT BYTE *pbData,
  1036. IN OUT DWORD *pdwDataLen,
  1037. IN DWORD dwBufLen)
  1038. {
  1039. if (fStatus)
  1040. {
  1041. CLogObject::Response(logid_True);
  1042. LogAdd(&m_LogData.bfOutData, pbData, *pdwDataLen);
  1043. }
  1044. else
  1045. {
  1046. CLogObject::Response(logid_False);
  1047. LogAdd(&m_LogData.bfOutData, NULL, *pdwDataLen);
  1048. }
  1049. }
  1050. void
  1051. CLogEncrypt::LogException(
  1052. void)
  1053. {
  1054. CLogObject::Response(logid_Exception);
  1055. LogAdd(&m_LogData.bfOutData, NULL, 0);
  1056. }
  1057. void
  1058. CLogEncrypt::LogNotCalled(
  1059. DWORD dwSts)
  1060. {
  1061. CLogObject::Response(logid_Setup, dwSts);
  1062. LogAdd(&m_LogData.bfOutData, NULL, 0);
  1063. }
  1064. //
  1065. //==============================================================================
  1066. //
  1067. // CLogDecrypt
  1068. //
  1069. CLogDecrypt::CLogDecrypt(
  1070. void)
  1071. : CLogObject(Decrypt, &m_LogData.lh, sizeof(m_LogData))
  1072. {
  1073. }
  1074. CLogDecrypt::~CLogDecrypt()
  1075. {
  1076. }
  1077. void
  1078. CLogDecrypt::Request(
  1079. IN HCRYPTPROV hProv,
  1080. IN HCRYPTKEY hKey,
  1081. IN HCRYPTHASH hHash,
  1082. IN BOOL Final,
  1083. IN DWORD dwFlags,
  1084. IN OUT BYTE *pbData,
  1085. IN OUT DWORD *pdwDataLen)
  1086. {
  1087. CLogObject::Request();
  1088. m_LogData.hProv = hProv;
  1089. m_LogData.hKey = hKey;
  1090. m_LogData.hHash = hHash;
  1091. m_LogData.Final = Final;
  1092. m_LogData.dwFlags = dwFlags;
  1093. LogAdd(&m_LogData.bfInData, pbData, *pdwDataLen);
  1094. }
  1095. void
  1096. CLogDecrypt::Response(
  1097. BOOL fStatus,
  1098. IN HCRYPTPROV hProv,
  1099. IN HCRYPTKEY hKey,
  1100. IN HCRYPTHASH hHash,
  1101. IN BOOL Final,
  1102. IN DWORD dwFlags,
  1103. IN OUT BYTE *pbData,
  1104. IN OUT DWORD *pdwDataLen)
  1105. {
  1106. if (fStatus)
  1107. {
  1108. CLogObject::Response(logid_True);
  1109. LogAdd(&m_LogData.bfOutData, pbData, *pdwDataLen);
  1110. }
  1111. else
  1112. {
  1113. CLogObject::Response(logid_False);
  1114. LogAdd(&m_LogData.bfOutData, NULL, *pdwDataLen);
  1115. }
  1116. }
  1117. void
  1118. CLogDecrypt::LogException(
  1119. void)
  1120. {
  1121. CLogObject::Response(logid_Exception);
  1122. LogAdd(&m_LogData.bfOutData, NULL, 0);
  1123. }
  1124. void
  1125. CLogDecrypt::LogNotCalled(
  1126. DWORD dwSts)
  1127. {
  1128. CLogObject::Response(logid_Setup, dwSts);
  1129. LogAdd(&m_LogData.bfOutData, NULL, 0);
  1130. }
  1131. //
  1132. //==============================================================================
  1133. //
  1134. // CLogCreateHash
  1135. //
  1136. CLogCreateHash::CLogCreateHash(
  1137. void)
  1138. : CLogObject(CreateHash, &m_LogData.lh, sizeof(m_LogData))
  1139. {
  1140. }
  1141. CLogCreateHash::~CLogCreateHash()
  1142. {
  1143. }
  1144. void
  1145. CLogCreateHash::Request(
  1146. IN HCRYPTPROV hProv,
  1147. IN ALG_ID Algid,
  1148. IN HCRYPTKEY hKey,
  1149. IN DWORD dwFlags,
  1150. OUT HCRYPTHASH *phHash)
  1151. {
  1152. CLogObject::Request();
  1153. m_LogData.hProv = hProv;
  1154. m_LogData.Algid = Algid;
  1155. m_LogData.hKey = hKey;
  1156. m_LogData.dwFlags = dwFlags;
  1157. }
  1158. void
  1159. CLogCreateHash::Response(
  1160. BOOL fStatus,
  1161. IN HCRYPTPROV hProv,
  1162. IN ALG_ID Algid,
  1163. IN HCRYPTKEY hKey,
  1164. IN DWORD dwFlags,
  1165. OUT HCRYPTHASH *phHash)
  1166. {
  1167. if (fStatus)
  1168. {
  1169. CLogObject::Response(logid_True);
  1170. }
  1171. else
  1172. {
  1173. CLogObject::Response(logid_False);
  1174. }
  1175. m_LogData.hHash = *phHash;
  1176. }
  1177. void
  1178. CLogCreateHash::LogException(
  1179. void)
  1180. {
  1181. CLogObject::Response(logid_Exception);
  1182. m_LogData.hHash = NULL;
  1183. }
  1184. void
  1185. CLogCreateHash::LogNotCalled(
  1186. DWORD dwSts)
  1187. {
  1188. CLogObject::Response(logid_Setup, dwSts);
  1189. m_LogData.hHash = NULL;
  1190. }
  1191. //
  1192. //==============================================================================
  1193. //
  1194. // CLogDestroyHash
  1195. //
  1196. CLogDestroyHash::CLogDestroyHash(
  1197. void)
  1198. : CLogObject(DestroyHash, &m_LogData.lh, sizeof(m_LogData))
  1199. {
  1200. }
  1201. CLogDestroyHash::~CLogDestroyHash()
  1202. {
  1203. }
  1204. void
  1205. CLogDestroyHash::Request(
  1206. IN HCRYPTPROV hProv,
  1207. IN HCRYPTHASH hHash)
  1208. {
  1209. CLogObject::Request();
  1210. m_LogData.hProv = hProv;
  1211. m_LogData.hHash = hHash;
  1212. }
  1213. void
  1214. CLogDestroyHash::Response(
  1215. BOOL fStatus,
  1216. IN HCRYPTPROV hProv,
  1217. IN HCRYPTHASH hHash)
  1218. {
  1219. if (fStatus)
  1220. {
  1221. CLogObject::Response(logid_True);
  1222. }
  1223. else
  1224. {
  1225. CLogObject::Response(logid_False);
  1226. }
  1227. }
  1228. void
  1229. CLogDestroyHash::LogException(
  1230. void)
  1231. {
  1232. CLogObject::Response(logid_Exception);
  1233. }
  1234. void
  1235. CLogDestroyHash::LogNotCalled(
  1236. DWORD dwSts)
  1237. {
  1238. CLogObject::Response(logid_Setup, dwSts);
  1239. }
  1240. //
  1241. //==============================================================================
  1242. //
  1243. // CLogGetHashParam
  1244. //
  1245. CLogGetHashParam::CLogGetHashParam(
  1246. void)
  1247. : CLogObject(GetHashParam, &m_LogData.lh, sizeof(m_LogData))
  1248. {
  1249. }
  1250. CLogGetHashParam::~CLogGetHashParam()
  1251. {
  1252. }
  1253. void
  1254. CLogGetHashParam::Request(
  1255. IN HCRYPTPROV hProv,
  1256. IN HCRYPTHASH hHash,
  1257. IN DWORD dwParam,
  1258. OUT BYTE *pbData,
  1259. IN OUT DWORD *pdwDataLen,
  1260. IN DWORD dwFlags)
  1261. {
  1262. CLogObject::Request();
  1263. m_LogData.hProv = hProv;
  1264. m_LogData.hHash = hHash;
  1265. m_LogData.dwParam = dwParam;
  1266. m_LogData.dwDataLen = *pdwDataLen;
  1267. m_LogData.dwFlags = dwFlags;
  1268. }
  1269. void
  1270. CLogGetHashParam::Response(
  1271. BOOL fStatus,
  1272. IN HCRYPTPROV hProv,
  1273. IN HCRYPTHASH hHash,
  1274. IN DWORD dwParam,
  1275. OUT BYTE *pbData,
  1276. IN OUT DWORD *pdwDataLen,
  1277. IN DWORD dwFlags)
  1278. {
  1279. if (fStatus)
  1280. {
  1281. CLogObject::Response(logid_True);
  1282. LogAdd(&m_LogData.bfData, pbData, *pdwDataLen);
  1283. }
  1284. else
  1285. {
  1286. CLogObject::Response(logid_False);
  1287. LogAdd(&m_LogData.bfData, NULL, *pdwDataLen);
  1288. }
  1289. }
  1290. void
  1291. CLogGetHashParam::LogException(
  1292. void)
  1293. {
  1294. CLogObject::Response(logid_Exception);
  1295. LogAdd(&m_LogData.bfData, NULL, 0);
  1296. }
  1297. void
  1298. CLogGetHashParam::LogNotCalled(
  1299. DWORD dwSts)
  1300. {
  1301. CLogObject::Response(logid_Setup, dwSts);
  1302. LogAdd(&m_LogData.bfData, NULL, 0);
  1303. }
  1304. //
  1305. //==============================================================================
  1306. //
  1307. // CLogHashData
  1308. //
  1309. CLogHashData::CLogHashData(
  1310. void)
  1311. : CLogObject(HashData, &m_LogData.lh, sizeof(m_LogData))
  1312. {
  1313. }
  1314. CLogHashData::~CLogHashData()
  1315. {
  1316. }
  1317. void
  1318. CLogHashData::Request(
  1319. IN HCRYPTPROV hProv,
  1320. IN HCRYPTHASH hHash,
  1321. IN CONST BYTE *pbData,
  1322. IN DWORD dwDataLen,
  1323. IN DWORD dwFlags)
  1324. {
  1325. CLogObject::Request();
  1326. m_LogData.hProv = hProv;
  1327. m_LogData.hHash = hHash;
  1328. LogAdd(&m_LogData.bfData, pbData, dwDataLen);
  1329. m_LogData.dwFlags = dwFlags;
  1330. }
  1331. void
  1332. CLogHashData::Response(
  1333. BOOL fStatus,
  1334. IN HCRYPTPROV hProv,
  1335. IN HCRYPTHASH hHash,
  1336. IN CONST BYTE *pbData,
  1337. IN DWORD dwDataLen,
  1338. IN DWORD dwFlags)
  1339. {
  1340. if (fStatus)
  1341. {
  1342. CLogObject::Response(logid_True);
  1343. }
  1344. else
  1345. {
  1346. CLogObject::Response(logid_False);
  1347. }
  1348. }
  1349. void
  1350. CLogHashData::LogException(
  1351. void)
  1352. {
  1353. CLogObject::Response(logid_Exception);
  1354. }
  1355. void
  1356. CLogHashData::LogNotCalled(
  1357. DWORD dwSts)
  1358. {
  1359. CLogObject::Response(logid_Setup, dwSts);
  1360. }
  1361. //
  1362. //==============================================================================
  1363. //
  1364. // CLogHashSessionKey
  1365. //
  1366. CLogHashSessionKey::CLogHashSessionKey(
  1367. void)
  1368. : CLogObject(HashSessionKey, &m_LogData.lh, sizeof(m_LogData))
  1369. {
  1370. }
  1371. CLogHashSessionKey::~CLogHashSessionKey()
  1372. {
  1373. }
  1374. void
  1375. CLogHashSessionKey::Request(
  1376. IN HCRYPTPROV hProv,
  1377. IN HCRYPTHASH hHash,
  1378. IN HCRYPTKEY hKey,
  1379. IN DWORD dwFlags)
  1380. {
  1381. CLogObject::Request();
  1382. m_LogData.hProv = hProv;
  1383. m_LogData.hHash = hHash;
  1384. m_LogData.hKey = hKey;
  1385. m_LogData.dwFlags = dwFlags;
  1386. }
  1387. void
  1388. CLogHashSessionKey::Response(
  1389. BOOL fStatus,
  1390. IN HCRYPTPROV hProv,
  1391. IN HCRYPTHASH hHash,
  1392. IN HCRYPTKEY hKey,
  1393. IN DWORD dwFlags)
  1394. {
  1395. if (fStatus)
  1396. {
  1397. CLogObject::Response(logid_True);
  1398. }
  1399. else
  1400. {
  1401. CLogObject::Response(logid_False);
  1402. }
  1403. }
  1404. void
  1405. CLogHashSessionKey::LogException(
  1406. void)
  1407. {
  1408. CLogObject::Response(logid_Exception);
  1409. }
  1410. void
  1411. CLogHashSessionKey::LogNotCalled(
  1412. DWORD dwSts)
  1413. {
  1414. CLogObject::Response(logid_Setup, dwSts);
  1415. }
  1416. //
  1417. //==============================================================================
  1418. //
  1419. // CLogSetHashParam
  1420. //
  1421. CLogSetHashParam::CLogSetHashParam(
  1422. void)
  1423. : CLogObject(SetHashParam, &m_LogData.lh, sizeof(m_LogData))
  1424. {
  1425. }
  1426. CLogSetHashParam::~CLogSetHashParam()
  1427. {
  1428. }
  1429. void
  1430. CLogSetHashParam::Request(
  1431. IN HCRYPTPROV hProv,
  1432. IN HCRYPTHASH hHash,
  1433. IN DWORD dwParam,
  1434. IN CONST BYTE *pbData,
  1435. IN DWORD dwLength,
  1436. IN DWORD dwFlags)
  1437. {
  1438. CLogObject::Request();
  1439. m_LogData.hProv = hProv;
  1440. m_LogData.hHash = hHash;
  1441. m_LogData.dwParam = dwParam;
  1442. LogAdd(&m_LogData.bfData, pbData, dwLength);
  1443. m_LogData.dwFlags = dwFlags;
  1444. }
  1445. void
  1446. CLogSetHashParam::Response(
  1447. BOOL fStatus,
  1448. IN HCRYPTPROV hProv,
  1449. IN HCRYPTHASH hHash,
  1450. IN DWORD dwParam,
  1451. IN CONST BYTE *pbData,
  1452. IN DWORD dwFlags)
  1453. {
  1454. if (fStatus)
  1455. {
  1456. CLogObject::Response(logid_True);
  1457. }
  1458. else
  1459. {
  1460. CLogObject::Response(logid_False);
  1461. }
  1462. }
  1463. void
  1464. CLogSetHashParam::LogException(
  1465. void)
  1466. {
  1467. CLogObject::Response(logid_Exception);
  1468. }
  1469. void
  1470. CLogSetHashParam::LogNotCalled(
  1471. DWORD dwSts)
  1472. {
  1473. CLogObject::Response(logid_Setup, dwSts);
  1474. }
  1475. //
  1476. //==============================================================================
  1477. //
  1478. // CLogSignHash
  1479. //
  1480. CLogSignHash::CLogSignHash(
  1481. void)
  1482. : CLogObject(SignHash, &m_LogData.lh, sizeof(m_LogData))
  1483. {
  1484. }
  1485. CLogSignHash::~CLogSignHash()
  1486. {
  1487. }
  1488. void
  1489. CLogSignHash::Request(
  1490. IN HCRYPTPROV hProv,
  1491. IN HCRYPTHASH hHash,
  1492. IN DWORD dwKeySpec,
  1493. IN LPCTSTR sDescription,
  1494. IN DWORD dwFlags,
  1495. OUT BYTE *pbSignature,
  1496. IN OUT DWORD *pdwSigLen)
  1497. {
  1498. CLogObject::Request();
  1499. m_LogData.hProv = hProv;
  1500. m_LogData.hHash = hHash;
  1501. m_LogData.dwKeySpec = dwKeySpec;
  1502. LogAdd(&m_LogData.bfDescription, sDescription);
  1503. m_LogData.dwFlags = dwFlags;
  1504. m_LogData.dwSigLen = *pdwSigLen;
  1505. }
  1506. void
  1507. CLogSignHash::Response(
  1508. BOOL fStatus,
  1509. IN HCRYPTPROV hProv,
  1510. IN HCRYPTHASH hHash,
  1511. IN DWORD dwKeySpec,
  1512. IN LPCTSTR sDescription,
  1513. IN DWORD dwFlags,
  1514. OUT BYTE *pbSignature,
  1515. IN OUT DWORD *pdwSigLen)
  1516. {
  1517. if (fStatus)
  1518. {
  1519. CLogObject::Response(logid_True);
  1520. LogAdd(&m_LogData.bfSignature, pbSignature, *pdwSigLen);
  1521. }
  1522. else
  1523. {
  1524. CLogObject::Response(logid_False);
  1525. LogAdd(&m_LogData.bfSignature, NULL, *pdwSigLen);
  1526. }
  1527. }
  1528. void
  1529. CLogSignHash::LogException(
  1530. void)
  1531. {
  1532. CLogObject::Response(logid_Exception);
  1533. LogAdd(&m_LogData.bfSignature, NULL, 0);
  1534. }
  1535. void
  1536. CLogSignHash::LogNotCalled(
  1537. DWORD dwSts)
  1538. {
  1539. CLogObject::Response(logid_Setup, dwSts);
  1540. LogAdd(&m_LogData.bfSignature, NULL, 0);
  1541. }
  1542. //
  1543. //==============================================================================
  1544. //
  1545. // CLogVerifySignature
  1546. //
  1547. CLogVerifySignature::CLogVerifySignature(
  1548. void)
  1549. : CLogObject(VerifySignature, &m_LogData.lh, sizeof(m_LogData))
  1550. {}
  1551. CLogVerifySignature::~CLogVerifySignature()
  1552. {}
  1553. void
  1554. CLogVerifySignature::Request(
  1555. IN HCRYPTPROV hProv,
  1556. IN HCRYPTHASH hHash,
  1557. IN CONST BYTE *pbSignature,
  1558. IN DWORD dwSigLen,
  1559. IN HCRYPTKEY hPubKey,
  1560. IN LPCTSTR sDescription,
  1561. IN DWORD dwFlags)
  1562. {
  1563. CLogObject::Request();
  1564. m_LogData.hProv = hProv;
  1565. m_LogData.hHash = hHash;
  1566. LogAdd(&m_LogData.bfSignature, pbSignature, dwSigLen);
  1567. m_LogData.dwSigLen = dwSigLen;
  1568. m_LogData.hPubKey = hPubKey;
  1569. LogAdd(&m_LogData.bfDescription, sDescription);
  1570. m_LogData.dwFlags = dwFlags;
  1571. }
  1572. void
  1573. CLogVerifySignature::Response(
  1574. BOOL fStatus,
  1575. IN HCRYPTPROV hProv,
  1576. IN HCRYPTHASH hHash,
  1577. IN CONST BYTE *pbSignature,
  1578. IN DWORD dwSigLen,
  1579. IN HCRYPTKEY hPubKey,
  1580. IN LPCTSTR sDescription,
  1581. IN DWORD dwFlags)
  1582. {
  1583. if (fStatus)
  1584. {
  1585. CLogObject::Response(logid_True);
  1586. }
  1587. else
  1588. {
  1589. CLogObject::Response(logid_False);
  1590. }
  1591. }
  1592. void
  1593. CLogVerifySignature::LogException(
  1594. void)
  1595. {
  1596. CLogObject::Response(logid_Exception);
  1597. }
  1598. void
  1599. CLogVerifySignature::LogNotCalled(
  1600. DWORD dwSts)
  1601. {
  1602. CLogObject::Response(logid_Setup, dwSts);
  1603. }
  1604. //
  1605. //==============================================================================
  1606. //
  1607. // CLogDuplicateHash
  1608. //
  1609. CLogDuplicateHash::CLogDuplicateHash(
  1610. void)
  1611. : CLogObject(DuplicateHash, &m_LogData.lh, sizeof(m_LogData))
  1612. {}
  1613. CLogDuplicateHash::~CLogDuplicateHash()
  1614. {}
  1615. void
  1616. CLogDuplicateHash::Request(
  1617. IN HCRYPTPROV hUID,
  1618. IN HCRYPTHASH hHash,
  1619. IN DWORD *pdwReserved,
  1620. IN DWORD dwFlags,
  1621. IN HCRYPTHASH *phHash)
  1622. {
  1623. CLogObject::Request();
  1624. m_LogData.hProv = hUID;
  1625. m_LogData.hHash = hHash;
  1626. m_LogData.pdwReserved = pdwReserved;
  1627. m_LogData.dwFlags = dwFlags;
  1628. m_LogData.hPHash = *phHash;
  1629. }
  1630. void
  1631. CLogDuplicateHash::Response(
  1632. BOOL fStatus,
  1633. IN HCRYPTPROV hUID,
  1634. IN HCRYPTHASH hHash,
  1635. IN DWORD *pdwReserved,
  1636. IN DWORD dwFlags,
  1637. IN HCRYPTHASH *phHash)
  1638. {
  1639. if (fStatus)
  1640. {
  1641. CLogObject::Response(logid_True);
  1642. m_LogData.hPHash = *phHash;
  1643. }
  1644. else
  1645. {
  1646. CLogObject::Response(logid_False);
  1647. m_LogData.hPHash = *phHash;
  1648. }
  1649. }
  1650. void
  1651. CLogDuplicateHash::LogException(
  1652. void)
  1653. {
  1654. CLogObject::Response(logid_Exception);
  1655. }
  1656. void
  1657. CLogDuplicateHash::LogNotCalled(
  1658. DWORD dwSts)
  1659. {
  1660. CLogObject::Response(logid_Setup, dwSts);
  1661. }
  1662. //
  1663. //==============================================================================
  1664. //
  1665. // CLogDuplicateKey
  1666. //
  1667. CLogDuplicateKey::CLogDuplicateKey(
  1668. void)
  1669. : CLogObject(DuplicateKey, &m_LogData.lh, sizeof(m_LogData))
  1670. {}
  1671. CLogDuplicateKey::~CLogDuplicateKey()
  1672. {}
  1673. void
  1674. CLogDuplicateKey::Request(
  1675. IN HCRYPTPROV hUID,
  1676. IN HCRYPTKEY hKey,
  1677. IN DWORD *pdwReserved,
  1678. IN DWORD dwFlags,
  1679. IN HCRYPTKEY *phKey)
  1680. {
  1681. CLogObject::Request();
  1682. m_LogData.hProv = hUID;
  1683. m_LogData.hKey = hKey;
  1684. m_LogData.pdwReserved = pdwReserved;
  1685. m_LogData.dwFlags = dwFlags;
  1686. m_LogData.hPKey = *phKey;
  1687. }
  1688. void
  1689. CLogDuplicateKey::Response(
  1690. BOOL fStatus,
  1691. IN HCRYPTPROV hUID,
  1692. IN HCRYPTKEY hKey,
  1693. IN DWORD *pdwReserved,
  1694. IN DWORD dwFlags,
  1695. IN HCRYPTKEY *phKey)
  1696. {
  1697. if (fStatus)
  1698. {
  1699. CLogObject::Response(logid_True);
  1700. m_LogData.hPKey = *phKey;
  1701. }
  1702. else
  1703. {
  1704. CLogObject::Response(logid_False);
  1705. m_LogData.hPKey = *phKey;
  1706. }
  1707. }
  1708. void
  1709. CLogDuplicateKey::LogException(
  1710. void)
  1711. {
  1712. CLogObject::Response(logid_Exception);
  1713. }
  1714. void
  1715. CLogDuplicateKey::LogNotCalled(
  1716. DWORD dwSts)
  1717. {
  1718. CLogObject::Response(logid_Setup, dwSts);
  1719. }