public static extern void MapGenericMask(ref uint Mask, ref GenericRightsMapping map);
public static InheritedFromInfo[] GetInheritanceSource(string objectName, ResourceType objectType, SecurityInfos securityInfo, bool container, IntPtr pAcl, ref GenericRightsMapping pGenericMapping) { int objSize = Marshal.SizeOf(typeof(InheritedFromInfo)); var aceCount = Helper.GetAceCount(pAcl); var ret = new InheritedFromInfo[aceCount]; IntPtr pInherit = Marshal.AllocHGlobal(objSize * (int)aceCount); try { int hr = GetInheritanceSource(objectName, objectType, securityInfo, container, IntPtr.Zero, 0, pAcl, IntPtr.Zero, ref pGenericMapping, pInherit); if (hr != 0) { throw new System.ComponentModel.Win32Exception(hr); } IntPtr pInheritTmp = pInherit; for (int i = 0; i < aceCount; i++) { ret[i] = (InheritedFromInfo)Marshal.PtrToStructure(pInheritTmp, typeof(InheritedFromInfo)); System.Diagnostics.Debug.WriteLine(": " + ret[i].ToString()); pInheritTmp = new IntPtr(pInheritTmp.ToInt32() + objSize); } } catch { } finally { FreeInheritedFromArray(pInherit, (ushort)aceCount, IntPtr.Zero); Marshal.FreeHGlobal(pInherit); } return(ret); }
private static extern int GetInheritanceSource([MarshalAs(UnmanagedType.LPWStr)] string objectName, ResourceType objectType, SecurityInfos securityInfo, [MarshalAs(UnmanagedType.Bool)] bool container, IntPtr pObjectClassGuids, uint guidCount, IntPtr pAcl, IntPtr pfnArray, ref GenericRightsMapping pGenericMapping, IntPtr pInheritArray);