public NativeSecurityAttributes(ObjectSecurity managedSecurityObject, bool inheritHandle)
{
length = Marshal.SizeOf(typeof(NativeSecurityAttributes));
byte[] binarySecurityDescriptor = managedSecurityObject.GetSecurityDescriptorBinaryForm();
securityDescriptor = Marshal.AllocHGlobal(binarySecurityDescriptor.Length);
Marshal.Copy(binarySecurityDescriptor, 0, securityDescriptor, binarySecurityDescriptor.Length);
this.inheritHandle = inheritHandle;
}