Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 

103 wiersze
4.2 KiB

  1. using Microsoft.Win32.SafeHandles;
  2. using System;
  3. using System.Runtime.InteropServices;
  4. namespace Security2
  5. {
  6. internal partial class Win32
  7. {
  8. const string ADVAPI32_DLL = "advapi32.dll";
  9. internal const string KERNEL32_DLL = "kernel32.dll";
  10. internal const string AUTHZ_DLL = "authz.dll";
  11. [DllImport(ADVAPI32_DLL, EntryPoint = "GetInheritanceSourceW", CharSet = CharSet.Unicode)]
  12. static extern UInt32 GetInheritanceSource(
  13. [MarshalAs(UnmanagedType.LPTStr)] string pObjectName,
  14. System.Security.AccessControl.ResourceType ObjectType,
  15. SECURITY_INFORMATION SecurityInfo,
  16. [MarshalAs(UnmanagedType.Bool)]bool Container,
  17. IntPtr pObjectClassGuids,
  18. UInt32 GuidCount,
  19. byte[] pAcl,
  20. IntPtr pfnArray,
  21. ref GENERIC_MAPPING pGenericMapping,
  22. IntPtr pInheritArray
  23. );
  24. [DllImport(ADVAPI32_DLL, EntryPoint = "FreeInheritedFromArray", CharSet = CharSet.Unicode)]
  25. static extern UInt32 FreeInheritedFromArray(
  26. IntPtr pInheritArray,
  27. UInt16 AceCnt,
  28. IntPtr pfnArray
  29. );
  30. [DllImport(AUTHZ_DLL, CharSet = CharSet.Unicode, SetLastError = true)]
  31. [return: MarshalAs(UnmanagedType.Bool)]
  32. static extern bool AuthzInitializeRemoteResourceManager(
  33. IntPtr rpcInitInfo,
  34. out SafeAuthzRMHandle authRM);
  35. [DllImport(AUTHZ_DLL, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
  36. [return: MarshalAs(UnmanagedType.Bool)]
  37. static extern bool AuthzInitializeResourceManager(
  38. AuthzResourceManagerFlags flags,
  39. IntPtr pfnAccessCheck,
  40. IntPtr pfnComputeDynamicGroups,
  41. IntPtr pfnFreeDynamicGroups,
  42. string szResourceManagerName,
  43. out SafeAuthzRMHandle phAuthzResourceManager);
  44. [DllImport(Win32.AUTHZ_DLL, CharSet = CharSet.Unicode, SetLastError = true)]
  45. [return: MarshalAs(UnmanagedType.Bool)]
  46. internal static extern bool AuthzInitializeContextFromSid(
  47. AuthzInitFlags flags,
  48. byte[] rawUserSid,
  49. SafeAuthzRMHandle authzRM,
  50. IntPtr expirationTime,
  51. Win32.LUID Identifier,
  52. IntPtr DynamicGroupArgs,
  53. out IntPtr authzClientContext);
  54. [DllImport(Win32.AUTHZ_DLL, CharSet = CharSet.Unicode, SetLastError = true)]
  55. [return: MarshalAs(UnmanagedType.Bool)]
  56. internal static extern bool AuthzAccessCheck(
  57. AuthzACFlags flags,
  58. IntPtr hAuthzClientContext,
  59. ref AUTHZ_ACCESS_REQUEST pRequest,
  60. IntPtr AuditEvent,
  61. byte[] rawSecurityDescriptor,
  62. IntPtr[] OptionalSecurityDescriptorArray,
  63. UInt32 OptionalSecurityDescriptorCount,
  64. ref AUTHZ_ACCESS_REPLY pReply,
  65. IntPtr cachedResults);
  66. [DllImport(Win32.AUTHZ_DLL, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
  67. [return: MarshalAs(UnmanagedType.Bool)]
  68. internal static extern bool AuthzFreeContext(IntPtr authzClientContext);
  69. [DllImport(Win32.ADVAPI32_DLL, CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Unicode)]
  70. public static extern UInt32 GetSecurityDescriptorLength(IntPtr pSecurityDescriptor);
  71. [DllImport(Win32.ADVAPI32_DLL, CallingConvention = CallingConvention.Winapi, SetLastError = true, CharSet = CharSet.Unicode)]
  72. internal static extern UInt32 GetSecurityInfo(
  73. SafeFileHandle handle,
  74. ObjectType objectType,
  75. SecurityInformationClass infoClass,
  76. IntPtr owner,
  77. IntPtr group,
  78. IntPtr dacl,
  79. IntPtr sacl,
  80. out IntPtr securityDescriptor);
  81. [DllImport(Win32.KERNEL32_DLL, SetLastError = true, CharSet = CharSet.Unicode)]
  82. internal static extern SafeFileHandle CreateFile(
  83. string lpFileName,
  84. FileAccess desiredAccess,
  85. FileShare shareMode,
  86. IntPtr lpSecurityAttributes,
  87. FileMode mode,
  88. FileFlagAttrib flagsAndAttributes,
  89. IntPtr hTemplateFile);
  90. }
  91. }