/// <summary> /// Save the opened key into a file. /// </summary> /// <param name="file">The file to save to.</param> /// <param name="flags">Save key flags</param> public void Save(NtFile file, SaveKeyFlags flags) { NtSystemCalls.NtSaveKeyEx(Handle, file.Handle, flags).ToNtException(); }
/// <summary> /// Restore key from a file. /// </summary> /// <param name="file">The file to restore from</param> /// <param name="flags">Restore key flags</param> public void Restore(NtFile file, RestoreKeyFlags flags) { NtSystemCalls.NtRestoreKey(Handle, file.Handle, flags).ToNtException(); }
/// <summary> /// Create a data section from a file. /// </summary> /// <param name="file">The file to create from.</param> /// <returns>The created section object.</returns> public static NtSection CreateReadOnlyDataSection(NtFile file) { return(Create(null, SectionAccessRights.MapRead, null, MemoryAllocationProtect.ReadOnly, SectionAttributes.Commit, file)); }
/// <summary> /// Create a section object /// </summary> /// <param name="object_attributes">The object attributes</param> /// <param name="desired_access">The desired access</param> /// <param name="size">Optional size of the section</param> /// <param name="protection">The section protection</param> /// <param name="attributes">The section attributes. The lower 5 bits can be used to specify the NUMA node.</param> /// <param name="file">Optional backing file</param> /// <param name="throw_on_error">True to throw an exception on error.</param> /// <returns>The NT status code and object result.</returns> public static NtResult <NtSection> Create(ObjectAttributes object_attributes, SectionAccessRights desired_access, LargeInteger size, MemoryAllocationProtect protection, SectionAttributes attributes, NtFile file, bool throw_on_error) { return(NtSystemCalls.NtCreateSection(out SafeKernelObjectHandle section_handle, desired_access, object_attributes, size, protection, attributes, file.GetHandle()).CreateResult(throw_on_error, () => new NtSection(section_handle))); }
/// <summary> /// Create an Image section object /// </summary> /// <param name="file">The file to create the image section from</param> /// <returns>The opened section</returns> /// <exception cref="NtException">Thrown on error.</exception> public static NtSection CreateImageSection(NtFile file) { return(CreateImageSection(null, file)); }
/// <summary> /// Create a section object /// </summary> /// <param name="object_attributes">The object attributes</param> /// <param name="desired_access">The desired access</param> /// <param name="size">Optional size of the section</param> /// <param name="protection">The section protection</param> /// <param name="attributes">The section attributes</param> /// <param name="file">Optional backing file</param> /// <param name="extended_parameters">Extended parameters for section create.</param> /// <returns>The NT status code and object result.</returns> public static NtSection CreateEx(ObjectAttributes object_attributes, SectionAccessRights desired_access, LargeInteger size, MemoryAllocationProtect protection, SectionAttributes attributes, NtFile file, MemSectionExtendedParameter[] extended_parameters) { return(CreateEx(object_attributes, desired_access, size, protection, attributes, file, extended_parameters, true).Result); }
/// <summary> /// Create a section object /// </summary> /// <param name="path">The path to the section</param> /// <param name="root">The root if path is relative</param> /// <param name="desired_access">The desired access</param> /// <param name="size">Optional size of the section</param> /// <param name="protection">The section protection</param> /// <param name="attributes">The section attributes. The lower 5 bits can be used to specify the NUMA node.</param> /// <param name="file">Optional backing file</param> /// <returns>The opened section</returns> /// <exception cref="NtException">Thrown on error.</exception> public static NtSection Create(string path, NtObject root, SectionAccessRights desired_access, long?size, MemoryAllocationProtect protection, SectionAttributes attributes, NtFile file) { using (ObjectAttributes obj_attr = new ObjectAttributes(path, AttributeFlags.CaseInsensitive, root)) { return(Create(obj_attr, desired_access, size.HasValue ? new LargeInteger(size.Value) : null, protection, attributes, file)); } }
/// <summary> /// Create a section object /// </summary> /// <param name="object_attributes">The object attributes</param> /// <param name="desired_access">The desired access</param> /// <param name="size">Optional size of the section</param> /// <param name="protection">The section protection</param> /// <param name="attributes">The section attributes</param> /// <param name="file">Optional backing file</param> /// <returns>The opened section</returns> /// <exception cref="NtException">Thrown on error.</exception> public static NtSection Create(ObjectAttributes object_attributes, SectionAccessRights desired_access, LargeInteger size, MemoryAllocationProtect protection, SectionAttributes attributes, NtFile file) { return(Create(object_attributes, desired_access, size, protection, attributes, file, true).Result); }
/// <summary> /// Create an Image section object /// </summary> /// <param name="file">The file to create the image section from</param> /// <returns>The opened section</returns> /// <exception cref="NtException">Thrown on error.</exception> public static NtSection CreateImageSection(NtFile file) { return(Create(null, SectionAccessRights.MaximumAllowed, null, MemoryAllocationProtect.Execute, SectionAttributes.Image, file)); }