/// <summary> /// Constructor /// </summary> /// <param name="object_name">The object name, can be null.</param> /// <param name="attributes">The object attribute flags.</param> /// <param name="root">An optional root handle, can be SafeKernelObjectHandle.Null. Will duplicate the handle.</param> /// <param name="sqos">An optional security quality of service.</param> /// <param name="security_descriptor">An optional security descriptor.</param> public ObjectAttributes(string object_name, AttributeFlags attributes, SafeKernelObjectHandle root, SecurityQualityOfService sqos, SecurityDescriptor security_descriptor) { Length = Marshal.SizeOf(this); if (object_name != null) { ObjectName = new UnicodeString(object_name).ToBuffer(); } else { ObjectName = SafeHGlobalBuffer.Null; } Attributes = attributes; if (sqos != null) { SecurityQualityOfService = sqos.ToBuffer(); } else { SecurityQualityOfService = SafeHGlobalBuffer.Null; } RootDirectory = !root.IsInvalid ? NtObject.DuplicateHandle(root) : SafeKernelObjectHandle.Null; if (security_descriptor != null) { SecurityDescriptor = security_descriptor.ToSafeBuffer(); } else { SecurityDescriptor = SafeHGlobalBuffer.Null; } }
private ObjectAttributes(SafeBuffer object_name, AttributeFlags attributes, SafeKernelObjectHandle root, SecurityQualityOfService sqos, SecurityDescriptor security_descriptor) { try { if (root == null) { throw new ArgumentNullException(nameof(root), "Use SafeKernelObjectHandle.Null for a null handle"); } Length = Marshal.SizeOf(this); ObjectName = object_name; Attributes = attributes; if (sqos != null) { SecurityQualityOfService = sqos.ToBuffer(); } else { SecurityQualityOfService = SafeHGlobalBuffer.Null; } RootDirectory = !root.IsInvalid ? NtObject.DuplicateHandle(root) : SafeKernelObjectHandle.Null; if (security_descriptor != null) { SecurityDescriptor = security_descriptor.ToSafeBuffer(); } else { SecurityDescriptor = SafeHGlobalBuffer.Null; } } catch { Dispose(); throw; } }
/// <summary> /// Constructor /// </summary> /// <param name="object_name">The object name, can be null.</param> /// <param name="attributes">The object attribute flags.</param> /// <param name="root">An optional root handle, can be SafeKernelObjectHandle.Null. Will duplicate the handle.</param> /// <param name="sqos">An optional security quality of service.</param> /// <param name="security_descriptor">An optional security descriptor.</param> public ObjectAttributes(string object_name, AttributeFlags attributes, SafeKernelObjectHandle root, SecurityQualityOfService sqos, SecurityDescriptor security_descriptor) { Length = Marshal.SizeOf(this); if (object_name != null) { ObjectName = new UnicodeString(object_name).ToBuffer(); } else { ObjectName = SafeHGlobalBuffer.Null; } Attributes = attributes; if (sqos != null) { SecurityQualityOfService = sqos.ToBuffer(); } else { SecurityQualityOfService = SafeHGlobalBuffer.Null; } RootDirectory = !root.IsInvalid ? NtObject.DuplicateHandle(root) : SafeKernelObjectHandle.Null; if (security_descriptor != null) { SecurityDescriptor = security_descriptor.ToSafeBuffer(); } else { SecurityDescriptor = SafeHGlobalBuffer.Null; } }