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.

184 lines
5.2 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1996 - 1999
  6. //
  7. // File: misc.h
  8. //
  9. // Definitions and prototypes for miscellaneous stuff
  10. //
  11. //--------------------------------------------------------------------------
  12. #ifndef _MISC_H_
  13. #define _MISC_H_
  14. typedef struct _USER_INFO
  15. {
  16. PSID pSid;
  17. LPCTSTR pszName;
  18. LPCTSTR pszLogonName;
  19. SID_NAME_USE SidType;
  20. } USER_INFO, *PUSER_INFO;
  21. typedef struct _USER_LIST
  22. {
  23. ULONG cUsers;
  24. USER_INFO rgUsers[ANYSIZE_ARRAY];
  25. } USER_LIST, *PUSER_LIST;
  26. PSID GetAceSid(PACE_HEADER pAce);
  27. PSID LocalAllocSid(PSID pOriginal);
  28. void DestroyDPA(HDPA hList);
  29. extern "C" {
  30. #include <ntlsa.h>
  31. }
  32. LSA_HANDLE GetLSAConnection(LPCTSTR pszServer, DWORD dwAccessDesired);
  33. BOOL LookupSid(PSID pSid,
  34. LPCTSTR pszServer,
  35. LPSECURITYINFO2 psi2,
  36. PUSER_LIST *ppUserList);
  37. BOOL LookupSids(HDPA hSids,
  38. LPCTSTR pszServer,
  39. LPSECURITYINFO2 psi2,
  40. PUSER_LIST *ppUserList);
  41. BOOL LookupSidsAsync(HDPA hSids,
  42. LPCTSTR pszServer,
  43. LPSECURITYINFO2 psi2,
  44. HWND hWndNotify,
  45. UINT uMsgNotify,
  46. PHANDLE phThread = NULL);
  47. BOOL BuildUserDisplayName(LPTSTR *ppszDisplayName,
  48. LPCTSTR pszName,
  49. LPCTSTR pszLogonName = NULL);
  50. // Indexes into the SID image list
  51. typedef enum
  52. {
  53. SID_IMAGE_UNKNOWN = 0,
  54. SID_IMAGE_COMPUTER,
  55. SID_IMAGE_GROUP,
  56. SID_IMAGE_LOCALGROUP,
  57. SID_IMAGE_USER
  58. } SID_IMAGE_INDEX;
  59. HIMAGELIST LoadImageList(HINSTANCE hInstance, LPCTSTR pszBitmapID);
  60. SID_IMAGE_INDEX GetSidImageIndex(PSID psid, SID_NAME_USE sidType);
  61. BOOL IsStandalone(LPCTSTR pszMachine, PBOOL pbIsDC = NULL);
  62. #if(_WIN32_WINNT < 0x0500)
  63. HRESULT GetUserGroup(HWND hwndOwner,
  64. DWORD dwFlags,
  65. LPCTSTR pszServer,
  66. BOOL bStandalone,
  67. PUSER_LIST *ppUserList); // Caller must LocalFree this
  68. // Flags for GetUserGroup
  69. #define GU_CONTAINER 0x00000001
  70. #define GU_MULTI_SELECT 0x00000002
  71. #define GU_AUDIT_HLP 0x00000004
  72. #define GU_DC_SERVER 0x00000008
  73. #endif // _WIN32_WINNT < 0x0500
  74. BOOL IsDACLCanonical(PACL pDacl);
  75. BOOL IsDenyACL(PACL pDacl,
  76. BOOL fProtected,
  77. DWORD dwFullControlMask,
  78. LPDWORD pdwWarning);
  79. //
  80. // Possible SIDs that can be retrieved using QuerySystemSid.
  81. //
  82. enum UI_SystemSid
  83. {
  84. // Well-known / universal
  85. UI_SID_World = 0,
  86. UI_SID_CreatorOwner,
  87. UI_SID_CreatorGroup,
  88. UI_SID_Dialup,
  89. UI_SID_Network,
  90. UI_SID_Batch,
  91. UI_SID_Interactive,
  92. UI_SID_Service,
  93. UI_SID_AnonymousLogon,
  94. UI_SID_Proxy,
  95. UI_SID_EnterpriseDC,
  96. UI_SID_Self,
  97. UI_SID_AuthenticatedUser,
  98. UI_SID_RestrictedCode,
  99. UI_SID_TerminalServer,
  100. UI_SID_LocalSystem,
  101. // Aliases ("BUILTIN")
  102. UI_SID_Admins,
  103. UI_SID_Users,
  104. UI_SID_Guests,
  105. UI_SID_PowerUsers,
  106. UI_SID_AccountOps,
  107. UI_SID_SystemOps,
  108. UI_SID_PrintOps,
  109. UI_SID_BackupOps,
  110. UI_SID_Replicator,
  111. UI_SID_RasServers,
  112. // Special value that gives the number of valid UI_SID_* types.
  113. // Don't add any new types after this value (add them before).
  114. UI_SID_Count,
  115. // This special value can be used for initializing enum UI_SystemSid
  116. // variables with a known unused quantity. This value should never
  117. // be passed to QuerySystemSid.
  118. UI_SID_Invalid = -1
  119. };
  120. #define COUNT_SYSTEM_SID_TYPES ((int)UI_SID_Count)
  121. #define COUNT_WELL_KNOWN_SYSTEM_SIDS ((int)UI_SID_Admins)
  122. PSID QuerySystemSid(UI_SystemSid SystemSidType);
  123. #define IsNTAuthority(pSid) EqualPrefixSid(pSid, QuerySystemSid(UI_SID_LocalSystem))
  124. #define IsAliasSid(pSid) EqualPrefixSid(pSid, QuerySystemSid(UI_SID_Admins))
  125. #define IsCreatorSid(pSid) EqualPrefixSid(pSid, QuerySystemSid(UI_SID_CreatorOwner))
  126. #define EqualSystemSid(pSid, uiSid) EqualSid(pSid, QuerySystemSid(uiSid))
  127. //
  128. // Possible SIDs that can be retrieved using QueryTokenSid.
  129. //
  130. enum UI_TokenSid
  131. {
  132. UI_TSID_CurrentProcessUser = 0, // Always the logged on user SID
  133. UI_TSID_CurrentProcessOwner, // Generally logged on user SID, but sometimes not (e.g. Administrators)
  134. UI_TSID_CurrentProcessPrimaryGroup,
  135. UI_TSID_Count,
  136. UI_TSID_Invalid = -1
  137. };
  138. #define COUNT_TOKEN_SID_TYPES ((int)UI_TSID_Count)
  139. PSID QueryTokenSid(UI_TokenSid TokenSidType);
  140. #define EqualTokenSid(pSid, uiSid) EqualSid(pSid, QueryTokenSid(uiSid))
  141. PSID GetAuthenticationID(LPCWSTR pszServer);
  142. int CopyUnicodeString(LPTSTR pszDest, ULONG cchDest, PLSA_UNICODE_STRING pSrc);
  143. int CopyUnicodeString(LPTSTR *ppszResult, PLSA_UNICODE_STRING pSrc);
  144. BOOL IsSameGUID(const GUID *p1, const GUID *p2);
  145. #define IsNullGUID(p) (!(p) || IsSameGUID((p), &GUID_NULL))
  146. //
  147. //Get the count of inheritable aces in the acl
  148. //
  149. DWORD GetCountOfInheritableAces(PACL pAcl);
  150. DWORD GetCountOfInheritableAces(PSECURITY_DESCRIPTOR pSD);
  151. BOOL IsAclBloated(HWND hDlg, SECURITY_INFORMATION si, PSECURITY_DESCRIPTOR pSD, DWORD dwOrgInheritAceCount, BOOL bShowHelp);
  152. HRESULT MakeBold (HWND hwnd, HFONT * phNewFont);
  153. #endif // _MISC_H_