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.

117 lines
3.2 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 2000-2002.
  5. //
  6. // File: SaferUtil.h
  7. //
  8. // Contents:
  9. //
  10. //----------------------------------------------------------------------------
  11. #ifndef __SAFERUTIL_H
  12. #define __SAFERUTIL_H
  13. #include <winsafer.h>
  14. #include <winsaferp.h>
  15. #include "cookie.h"
  16. #include "storegpe.h"
  17. #include "StoreRSOP.h"
  18. #include "SaferStore.h"
  19. CString SaferGetLevelFriendlyName (DWORD dwLevelID, HKEY hGroupPolicyKey, const bool bIsComputer);
  20. CString SaferGetLevelDescription (DWORD dwLevelID, HKEY hGroupPolicyKey, const bool bIsComputer);
  21. void InitializeSecurityLevelComboBox (
  22. CComboBox& comboBox,
  23. bool bLimit,
  24. DWORD dwLevelID,
  25. HKEY hGroupPolicyKey,
  26. DWORD* pdwSaferLevels,
  27. bool bIsComputer);
  28. HRESULT SaferGetLevelID (SAFER_LEVEL_HANDLE hLevel, DWORD& dwLevelID);
  29. class CSaferEntries : public CCertMgrCookie
  30. {
  31. public:
  32. CSaferEntries (
  33. bool bIsMachine,
  34. PCWSTR pszMachineName,
  35. PCWSTR pszObjectName,
  36. IGPEInformation* pGPEInformation,
  37. IRSOPInformation* pRSOPInformation,
  38. CRSOPObjectArray& m_rsopObjectArray,
  39. LPCONSOLE pConsole);
  40. virtual ~CSaferEntries ();
  41. HRESULT GetDisallowedStore (CCertStore** ppStore);
  42. HRESULT GetTrustedPublishersStore (CCertStore** ppStore);
  43. protected:
  44. private:
  45. CCertStore* m_pTrustedPublishersStore;
  46. CCertStore* m_pDisallowedStore;
  47. };
  48. class CSaferRootCookie : public CCertMgrCookie
  49. {
  50. public:
  51. CSaferRootCookie (
  52. CertificateManagerObjectType objecttype,
  53. PCWSTR pszMachineName,
  54. PCWSTR pszObjectName)
  55. : CCertMgrCookie (objecttype,
  56. pszMachineName, pszObjectName),
  57. m_bCreateSaferNodes (true),
  58. m_bExpandedOnce (false)
  59. {
  60. }
  61. virtual ~CSaferRootCookie ()
  62. {
  63. };
  64. bool m_bCreateSaferNodes;
  65. bool m_bExpandedOnce;
  66. };
  67. HRESULT SetRegistryScope (HKEY hKey, bool bIsComputer);
  68. // Returns S_OK if the file has a valid signed hash
  69. HRESULT GetSignedFileHash(
  70. IN LPCWSTR pwszFilename,
  71. OUT BYTE rgbFileHash[SAFER_MAX_HASH_SIZE],
  72. OUT DWORD *pcbFileHash,
  73. OUT ALG_ID *pHashAlgid
  74. );
  75. HRESULT ComputeMD5Hash(IN HANDLE hFile, BYTE hashresult[SAFER_MAX_HASH_SIZE], DWORD& dwHashSize);
  76. CString GetURLZoneFriendlyName (DWORD dwURLZoneID);
  77. BOOL GuidFromString(GUID* pGuid, const CString& szGuidString);
  78. HRESULT SaferSetDefinedFileTypes (HWND hWnd, HKEY hGroupPolicyKey, PCWSTR pszFileTypes, int nBufLen);
  79. #define SAFER_TRUSTED_PUBLISHER_STORE_FRIENDLY_NAME L"Safer Trusted Publisher Store"
  80. #define SAFER_DISALLOWED_STORE_FRIENDLY_NAME L"Safer Disallowed Store"
  81. #define SAFER_LEVELOBJECTS_REGKEY \
  82. SAFER_HKLM_REGBASE SAFER_OBJECTS_REGSUBKEY
  83. #define SAFER_COMPUTER_CODEIDS_REGKEY SAFER_HKLM_REGBASE L"\\" SAFER_CODEIDS_REGSUBKEY
  84. #define SAFER_USER_CODEIDS_REGKEY SAFER_HKCU_REGBASE L"\\" SAFER_CODEIDS_REGSUBKEY
  85. #define MD5_HASH_LEN 16
  86. #define SHA1_HASH_LEN 20
  87. #define NO_MORE_SAFER_LEVELS -1
  88. #define ILLEGAL_FAT_CHARS L"\"+,;<=>[]|"
  89. #endif