public AnyAccessSecurityAttributes() { secAttr = new WinApi.SECURITY_ATTRIBUTES(); IntPtr secDesc = Marshal.AllocHGlobal(WinApi.SECURITY_DESCRIPTOR_MIN_LENGTH); secAttr.nLength = (uint)Marshal.SizeOf(secAttr); secAttr.bInheritHandle = 0; secAttr.lpSecurityDescriptor = secDesc; WinApi.InitializeSecurityDescriptor(secAttr.lpSecurityDescriptor, WinApi.SECURITY_DESCRIPTOR_REVISION); WinApi.SetSecurityDescriptorDacl(secAttr.lpSecurityDescriptor, true, IntPtr.Zero, false); IntPtr sd; uint sdSize; WinApi.ConvertStringSecurityDescriptorToSecurityDescriptor("S:(ML;;NW;;;LW)", WinApi.SDDL_REVISION_1, out sd, out sdSize); IntPtr sacl = IntPtr.Zero; bool saclPresent = false; bool saclDefaulted = false; WinApi.GetSecurityDescriptorSacl(sd, out saclPresent, out sacl, out saclDefaulted); WinApi.SetSecurityDescriptorSacl(secAttr.lpSecurityDescriptor, true, sacl, false); handle = Marshal.AllocHGlobal(Marshal.SizeOf(secAttr)); Marshal.StructureToPtr(secAttr, handle, false); }
public AnyAccessSecurityAttributes () { secAttr = new WinApi.SECURITY_ATTRIBUTES (); IntPtr secDesc = Marshal.AllocHGlobal (WinApi.SECURITY_DESCRIPTOR_MIN_LENGTH); secAttr.nLength = (uint) Marshal.SizeOf (secAttr); secAttr.bInheritHandle = 0; secAttr.lpSecurityDescriptor = secDesc; WinApi.InitializeSecurityDescriptor (secAttr.lpSecurityDescriptor, WinApi.SECURITY_DESCRIPTOR_REVISION); WinApi.SetSecurityDescriptorDacl (secAttr.lpSecurityDescriptor, true, IntPtr.Zero, false); IntPtr sd; uint sdSize; WinApi.ConvertStringSecurityDescriptorToSecurityDescriptor ("S:(ML;;NW;;;LW)", WinApi.SDDL_REVISION_1, out sd, out sdSize); IntPtr sacl = IntPtr.Zero; bool saclPresent = false; bool saclDefaulted = false; WinApi.GetSecurityDescriptorSacl (sd, out saclPresent, out sacl, out saclDefaulted); WinApi.SetSecurityDescriptorSacl (secAttr.lpSecurityDescriptor, true, sacl, false); handle = Marshal.AllocHGlobal (Marshal.SizeOf (secAttr)); Marshal.StructureToPtr (secAttr, handle, false); }