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.

152 lines
4.6 KiB

  1. #ifdef __cplusplus
  2. #include "capi.h"
  3. // WinVerifyTrust delay load modelled on shell's urlmonp.h
  4. #define DELAY_LOAD_WVT
  5. extern BOOL g_bNT5OrGreater;
  6. class CDownload;
  7. class Cwvt
  8. {
  9. public:
  10. #ifdef DELAY_LOAD_WVT
  11. #define DELAYWVTAPI(_fn, _args, _nargs) \
  12. HRESULT _fn _args { \
  13. HRESULT hres = Init(); \
  14. if (SUCCEEDED(hres)) { \
  15. hres = _pfn##_fn _nargs; \
  16. } \
  17. return hres; } \
  18. HRESULT (STDAPICALLTYPE* _pfn##_fn) _args;
  19. /*
  20. * Should be called only for NT5 or greater for catalog verification and installation.
  21. */
  22. #define DELAYNT5API(_fn, _args, _nargs, ret) \
  23. ret _fn _args \
  24. { \
  25. HRESULT hres; \
  26. ret retval = 0; \
  27. if (g_bNT5OrGreater) \
  28. { \
  29. hres = Init(); \
  30. if (SUCCEEDED(hres) && (_pfn##_fn)) \
  31. { \
  32. retval = _pfn##_fn _nargs; \
  33. } \
  34. } \
  35. return retval; \
  36. } \
  37. ret (STDAPICALLTYPE* _pfn##_fn) _args;
  38. HRESULT Init(void);
  39. Cwvt();
  40. ~Cwvt();
  41. BOOL m_fInited;
  42. HMODULE m_hMod;
  43. #else
  44. #define DELAYWVTAPI(_fn, _args, _nargs) \
  45. HRESULT _fn _args { \
  46. HRESULT hr = ::#_fn _nargs; \
  47. }
  48. #endif
  49. private:
  50. DELAYWVTAPI(WinVerifyTrust,
  51. (HWND hwnd, GUID * ActionID, LPVOID ActionData),
  52. (hwnd, ActionID, ActionData));
  53. DELAYNT5API(IsCatalogFile,
  54. (HANDLE hFile, WCHAR* pwszFileName),
  55. (hFile, pwszFileName),
  56. BOOL);
  57. DELAYNT5API(CryptCATAdminAcquireContext,
  58. (HCATADMIN* phCatAdmin, GUID* pgSubsystem, DWORD dwFlags),
  59. (phCatAdmin, pgSubsystem, dwFlags),
  60. BOOL);
  61. DELAYNT5API(CryptCATAdminReleaseContext,
  62. (HCATADMIN hCatAdmin, DWORD dwFlags),
  63. (hCatAdmin, dwFlags),
  64. BOOL);
  65. DELAYNT5API(CryptCATAdminReleaseCatalogContext,
  66. (HCATADMIN hCatAdmin, HCATINFO hCatInfo, DWORD dwFlags),
  67. (hCatAdmin, hCatInfo, dwFlags),
  68. BOOL);
  69. DELAYNT5API(CryptCATAdminEnumCatalogFromHash,
  70. (HCATADMIN hCatAdmin, BYTE* pbHash, DWORD cbHash, DWORD dwFlags, HCATINFO* phPrevCatInfo),
  71. (hCatAdmin, pbHash, cbHash, dwFlags, phPrevCatInfo),
  72. HCATINFO);
  73. DELAYNT5API(CryptCATAdminCalcHashFromFileHandle,
  74. (HANDLE hFile, DWORD* pcbHash, BYTE* pbHash, DWORD dwFlags),
  75. (hFile, pcbHash, pbHash, dwFlags),
  76. BOOL);
  77. DELAYNT5API(CryptCATAdminAddCatalog,
  78. (HCATADMIN hCatAdmin, WCHAR* pwszCatalogFile, WCHAR* pwszSelectBaseName, DWORD dwFlags),
  79. (hCatAdmin, pwszCatalogFile, pwszSelectBaseName, dwFlags),
  80. HCATINFO);
  81. DELAYNT5API(CryptCATAdminRemoveCatalog,
  82. (HCATADMIN hCatAdmin, WCHAR* pwszCatalogFile, DWORD dwFlags),
  83. (hCatAdmin, pwszCatalogFile, dwFlags),
  84. BOOL);
  85. DELAYNT5API(CryptCATCatalogInfoFromContext,
  86. (HCATINFO hCatInfo, CATALOG_INFO* psCatInfo, DWORD dwFlags),
  87. (hCatInfo, psCatInfo, dwFlags),
  88. BOOL);
  89. DELAYNT5API(CryptCATAdminResolveCatalogPath,
  90. (HCATADMIN hCatAdmin, WCHAR* pwszCatalogFile, CATALOG_INFO* psCatInfo, DWORD dwFlags),
  91. (hCatAdmin, pwszCatalogFile, psCatInfo, dwFlags),
  92. BOOL);
  93. public:
  94. HRESULT VerifyTrust(HANDLE hFile, HWND hWnd, PJAVA_TRUST *ppJavaTrust,
  95. LPCWSTR szStatusText,
  96. IInternetHostSecurityManager *pHostSecurityManager,
  97. LPSTR szFilePath, LPSTR szCatalogFile,
  98. CDownload *pdl);
  99. /*
  100. return value:
  101. S_OK - all ok.
  102. S_FALSE - failed to get full path back but file verified.
  103. E_FAIL - all other.
  104. */
  105. HRESULT Cwvt::VerifyFileAgainstSystemCatalog(LPCSTR pcszFile, LPWSTR pwszFullPathCatalogFile, DWORD* pdwBuffer);
  106. /*
  107. return value:
  108. from WinVerifyTrust
  109. */
  110. HRESULT VerifyTrustOnCatalogFile(LPCWSTR pwszCatalogFile);
  111. /*
  112. return value:
  113. S_OK - all ok.
  114. E_FAIL - either not valid catalog file or failed trust
  115. */
  116. HRESULT IsValidCatalogFile(LPCWSTR pwszCatalogFile);
  117. /*
  118. return value:
  119. S_OK - all ok.
  120. S_FALSE - failed to remove catalog.
  121. */
  122. HRESULT UninstallCatalogFile(LPWSTR pwszFullPathCatalogFile);
  123. /*
  124. return value:
  125. S_OK - all ok.
  126. S_FALSE - AddCatalog succeeded, but getting fullPathofCatfile failed.
  127. E_FAIL - any other failure
  128. */
  129. HRESULT InstallCatalogFile(LPSTR pszCatalogFile);
  130. HRESULT WinVerifyTrust_Wrap(HWND hwnd, GUID * ActionID, WINTRUST_DATA* ActionData);
  131. private:
  132. BOOL m_bHaveWTData;
  133. WINTRUST_CATALOG_INFO m_wtCatalogInfo;
  134. };
  135. #endif