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.

207 lines
7.3 KiB

  1. #include "richedit.h"
  2. //////////////////////////////////////////////////////////
  3. #ifdef MAC
  4. #define wszCRLF L"\n\r"
  5. #define szCRLF "\n\r"
  6. #define wchCR L'\n'
  7. #define wchLF L'\r'
  8. #define chCR '\n'
  9. #define chLF '\r'
  10. #else // !MAC
  11. #ifndef WIN16
  12. #define wszCRLF L"\r\n"
  13. #define szCRLF "\r\n"
  14. #define wchCR L'\r'
  15. #define wchLF L'\n'
  16. #define chCR '\r'
  17. #define chLF '\n'
  18. #else
  19. #define wszCRLF "\r\n"
  20. #define szCRLF "\r\n"
  21. #define wchCR '\r'
  22. #define wchLF '\n'
  23. #define chCR '\r'
  24. #define chLF '\n'
  25. #endif // !WIN16
  26. #endif // MAC
  27. #ifndef MAC
  28. BOOL IsWin95(void);
  29. #endif // !MAC
  30. extern BOOL FIsWin95;
  31. #ifndef WIN16
  32. #undef SetWindowLong
  33. #define SetWindowLong SetWindowLongA
  34. #undef GetWindowLong
  35. #define GetWindowLong GetWindowLongA
  36. #undef SetWindowLongPtr
  37. #define SetWindowLongPtr SetWindowLongPtrA
  38. #undef GetWindowLongPtr
  39. #define GetWindowLongPtr GetWindowLongPtrA
  40. #undef SendMessage
  41. #define SendMessage SendMessageA
  42. #else // WIN16
  43. #define TEXTMETRICA TEXTMETRIC
  44. #define TEXTRANGEA TEXTRANGE
  45. #define CHARFORMATA CHARFORMAT
  46. #define PROPSHEETHEADERA PROPSHEETHEADER
  47. #define PROPSHEETPAGEA PROPSHEETPAGE
  48. #define TVN_SELCHANGEDA TVN_SELCHANGED
  49. #define TVM_SETITEMA TVM_SETITEM
  50. #define TVM_GETITEMA TVM_GETITEM
  51. #define GetTextExtentPointA GetTextExtentPoint
  52. #define SetDlgItemTextA SetDlgItemText
  53. #define GetTextMetricsA GetTextMetrics
  54. #define SendDlgItemMessageA SendDlgItemMessage
  55. #define LoadBitmapA LoadBitmap
  56. #define PropertySheetA PropertySheet
  57. #define WinHelpA WinHelp
  58. #endif // !WIN16
  59. LRESULT MySendDlgItemMessageW(HWND hwnd, int id, UINT msg, WPARAM w, LPARAM l);
  60. BOOL MySetDlgItemTextW(HWND hwnd, int id, LPCWSTR pwsz);
  61. UINT MyGetDlgItemTextW(HWND hwnd, int id, LPWSTR pwsz, int nMax);
  62. DWORD MyFormatMessageW(DWORD dwFlags, LPCVOID pbSource, DWORD dwMessageId,
  63. DWORD dwLangId, LPWSTR lpBuffer, DWORD nSize,
  64. va_list * args);
  65. int MyLoadStringW(HINSTANCE hInstance, UINT uID, LPWSTR lpBuffer, int cbBuffer);
  66. #ifndef WIN16
  67. BOOL MyCryptAcquireContextW(HCRYPTPROV * phProv, LPCWSTR pszContainer,
  68. LPCWSTR pszProvider, DWORD dwProvType, DWORD dwFlags);
  69. #else
  70. BOOL WINAPI MyCryptAcquireContextW(HCRYPTPROV * phProv, LPCWSTR pszContainer,
  71. LPCWSTR pszProvider, DWORD dwProvType, DWORD dwFlags);
  72. #endif // !WIN16
  73. BOOL MyWinHelpW(HWND hWndMain, LPCWSTR szHelp,UINT uCommand, ULONG_PTR dwData);
  74. DWORD TruncateToWindowA(HWND hwndDlg, int id, LPSTR psz);
  75. DWORD TruncateToWindowW(HWND hwndDlg, int id, LPWSTR pwsz);
  76. BOOL FinePrint(PCCERT_CONTEXT pccert, HWND hwndParent);
  77. //
  78. // Formatting algorithms for the common dialogs
  79. //
  80. BOOL FormatAlgorithm(HWND /*hwnd*/, UINT /*id*/, PCCERT_CONTEXT /*pccert*/);
  81. BOOL FormatBinary(HWND hwnd, UINT id, LPBYTE pb, DWORD cb);
  82. BOOL FormatCPS(HWND hwnd, UINT id, PCCERT_CONTEXT pccert);
  83. BOOL FormatDate(HWND hwnd, UINT id, FILETIME ft);
  84. BOOL FormatIssuer(HWND hwnd, UINT id, PCCERT_CONTEXT pccert,
  85. DWORD dwFlags = CERT_SIMPLE_NAME_STR);
  86. BOOL FormatSerialNo(HWND hwnd, UINT id, PCCERT_CONTEXT pccert);
  87. BOOL FormatSubject(HWND hwnd, UINT id, PCCERT_CONTEXT pccert,
  88. DWORD dwFlags = CERT_SIMPLE_NAME_STR);
  89. BOOL FormatThumbprint(HWND hwnd, UINT id, PCCERT_CONTEXT pccert);
  90. BOOL FormatValidity(HWND hwnd, UINT id, PCCERT_CONTEXT pccert);
  91. //
  92. // These routines extract and pretty print fields in the certs. The
  93. // routines use crt to allocate and return a buffer
  94. //
  95. LPWSTR PrettySubject(PCCERT_CONTEXT pccert);
  96. LPWSTR PrettyIssuer(PCCERT_CONTEXT pccert);
  97. LPWSTR PrettySubjectIssuer(PCCERT_CONTEXT pccert);
  98. //
  99. LPWSTR FindURL(PCCERT_CONTEXT pccert);
  100. BOOL LoadStringInWindow(HWND hwnd, UINT id, HMODULE hmod, UINT id2);
  101. BOOL LoadStringsInWindow(HWND hwnd, UINT id, HMODULE hmod, UINT *pidStrings);
  102. //
  103. typedef struct {
  104. DWORD dw1;
  105. DWORD dw2;
  106. } HELPMAP;
  107. BOOL OnContextHelp(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam,
  108. HELPMAP const * rgCtxMap);
  109. VOID RecognizeURLs(HWND hwndRE);
  110. #ifdef MAC
  111. EXTERN_C BOOL FNoteDlgNotifyLink(HWND hwndDlg, ENLINK * penlink, LPSTR szURL);
  112. #else // !MAC
  113. BOOL FNoteDlgNotifyLink(HWND hwndDlg, ENLINK * penlink, LPSTR szURL);
  114. #endif // MAC
  115. ////////////////////////////////////////////////////////////////////////////////
  116. ////////////////////////////////////////////////////////////////////////////////
  117. const MaxCertificateParents = 5;
  118. extern const GUID GuidCertValidate;
  119. LPWSTR FormatValidityFailures(DWORD);
  120. typedef struct {
  121. #ifndef NT5BUILD
  122. LPSTR szOid;
  123. #endif // !NT5BUILD
  124. DWORD fRootStore:1;
  125. DWORD fExplicitTrust:1; // This item is explicity Trusted
  126. DWORD fExplicitDistrust:1; // This item is explicity Distructed
  127. DWORD fTrust:1; // Ancestor is explicity Trusted
  128. DWORD fDistrust:1; // Ancestor is explicity Distrusted
  129. DWORD fError:1;
  130. DWORD newTrust:2; // 0 - not modified
  131. // 1 - now explicit Distrust
  132. // 2 - now inherit
  133. // 3 - now explicit trust
  134. DWORD cbTrustData;
  135. LPBYTE pbTrustData;
  136. } STrustDesc;
  137. typedef class CCertFrame * PCCertFrame;
  138. class CCertFrame {
  139. public:
  140. CCertFrame(PCCERT_CONTEXT pccert);
  141. ~CCertFrame(void);
  142. int m_fSelfSign:1; // Is Cert self signed?
  143. int m_fRootStore:1; // Cert can from a root store
  144. int m_fLeaf:1; // Leaf Cert
  145. int m_fExpired:1; // Cert has expired
  146. PCCERT_CONTEXT m_pccert; // Certificate in this frame
  147. PCCertFrame m_pcfNext; //
  148. DWORD m_dwFlags; // Flags from GetIssuer
  149. int m_cParents; // Count of parents
  150. PCCertFrame m_rgpcfParents[MaxCertificateParents]; // Assume there are
  151. // a limited number of parents
  152. // to list
  153. int m_cTrust; // size of array trust
  154. STrustDesc * m_rgTrust; // Array of trust
  155. };
  156. HRESULT HrDoTrustWork(PCCERT_CONTEXT pccertToCheck, DWORD dwControl,
  157. DWORD dwValidityMask,
  158. DWORD cPurposes, LPSTR * rgszPurposes, HCRYPTPROV,
  159. DWORD cRoots, HCERTSTORE * rgRoots,
  160. DWORD cCAs, HCERTSTORE * rgCAs,
  161. DWORD cTrust, HCERTSTORE * rgTrust,
  162. PFNTRUSTHELPER pfn, DWORD lCustData,
  163. PCCertFrame * ppcfRoot, DWORD * pcNodes,
  164. PCCertFrame * rgpcfResult,
  165. HANDLE * phReturnStateData); // optional: return WinVerifyTrust state handle here
  166. void FreeWVTHandle(HANDLE hWVTState);
  167. BOOL FModifyTrust(HWND hwnd, PCCERT_CONTEXT pccert, DWORD dwNewTrust,
  168. LPSTR szPurpose);
  169. //////////////////////////////////////////////////////
  170. LPVOID PVCryptDecode(LPCSTR, DWORD, LPBYTE);