Source code of Windows XP (NT5)
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.

112 lines
3.0 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 2000-2001.
  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. {
  59. }
  60. virtual ~CSaferRootCookie ()
  61. {
  62. };
  63. bool m_bCreateSaferNodes;
  64. };
  65. HRESULT SetRegistryScope (HKEY hKey, bool bIsComputer);
  66. // Returns S_OK if the file has a valid signed hash
  67. HRESULT GetSignedFileHash(
  68. IN LPCWSTR pwszFilename,
  69. OUT BYTE rgbFileHash[SAFER_MAX_HASH_SIZE],
  70. OUT DWORD *pcbFileHash,
  71. OUT ALG_ID *pHashAlgid
  72. );
  73. HRESULT ComputeMD5Hash(IN HANDLE hFile, BYTE hashresult[SAFER_MAX_HASH_SIZE], DWORD& dwHashSize);
  74. CString GetURLZoneFriendlyName (DWORD dwURLZoneID);
  75. BOOL GuidFromString(GUID* pGuid, LPCWSTR lpszGuidString);
  76. HRESULT SaferSetDefinedFileTypes (HWND hWnd, HKEY hGroupPolicyKey, PCWSTR pszFileTypes, int nBufLen);
  77. #define SAFER_TRUSTED_PUBLISHER_STORE_FRIENDLY_NAME L"Safer Trusted Publisher Store"
  78. #define SAFER_DISALLOWED_STORE_FRIENDLY_NAME L"Safer Disallowed Store"
  79. #define SAFER_LEVELOBJECTS_REGKEY \
  80. SAFER_HKLM_REGBASE SAFER_OBJECTS_REGSUBKEY
  81. #define SAFER_COMPUTER_CODEIDS_REGKEY SAFER_HKLM_REGBASE L"\\" SAFER_CODEIDS_REGSUBKEY
  82. #define SAFER_USER_CODEIDS_REGKEY SAFER_HKCU_REGBASE L"\\" SAFER_CODEIDS_REGSUBKEY
  83. #define MD5_HASH_LEN 16
  84. #define SHA1_HASH_LEN 20
  85. #define NO_MORE_SAFER_LEVELS -1
  86. #endif