/// <summary> /// Rollback the transaction /// </summary> public void Rollback() { NtSystemCalls.NtRollbackRegistryTransaction(Handle, true).ToNtException(); }
static void Main(string[] args) { try { if (args.Length < 1) { return; } EnablePrivileges(); using (var dir = OpenReparseDirectory(args[0])) { using (var buffer = new SafeStructureInOutBuffer <FileReparseTagInformation>()) { using (var io_status = new SafeIoStatusBuffer()) { while (true) { NtStatus status = NtSystemCalls.NtQueryDirectoryFile(dir.Handle, SafeKernelObjectHandle.Null, IntPtr.Zero, IntPtr.Zero, io_status, buffer, buffer.Length, FileInformationClass.FileReparsePointInformation, true, null, false); if (status == NtStatus.STATUS_NO_MORE_FILES) { break; } if (status != NtStatus.STATUS_SUCCESS) { throw new NtException(status); } var result = buffer.Result; var filedata = GetFileData(dir, result.Tag, result.FileReferenceNumber); Console.WriteLine("{0} {1}", filedata.FileName, filedata.Reparse.Tag); if (filedata.Reparse is MountPointReparseBuffer mount_point) { Console.WriteLine("Target: {0}", mount_point.SubstitutionName); Console.WriteLine("Print: {0}", mount_point.PrintName); } else if (filedata.Reparse is SymlinkReparseBuffer symlink) { Console.WriteLine("Target: {0}", symlink.SubstitutionName); Console.WriteLine("Print: {0}", symlink.PrintName); Console.WriteLine("Flags: {0}", symlink.Flags); } else if (filedata.Reparse is ExecutionAliasReparseBuffer alias) { Console.WriteLine("Target: {0}", alias.Target); Console.WriteLine("Package: {0}", alias.PackageName); Console.WriteLine("Entry Point: {0}", alias.EntryPoint); Console.WriteLine("AppType: {0}", alias.AppType); } else if (filedata.Reparse is OpaqueReparseBuffer opaque) { HexDumpBuilder builder = new HexDumpBuilder(true, true, true, false, 0); builder.Append(opaque.Data); Console.WriteLine(builder); } } } } } } catch (Exception ex) { Console.WriteLine(ex); } }
/// <summary> /// Commit the transaction /// </summary> public void Commit() { NtSystemCalls.NtCommitRegistryTransaction(Handle, true).ToNtException(); }
/// <summary> /// Create a partition object /// </summary> /// <param name="object_attributes">The object attributes</param> /// <param name="parent_partition">Optional parent parition.</param> /// <param name="desired_access">Desired access for the partition.</param> /// <param name="preferred_node">The preferred node, -1 for any node.</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 <NtPartition> Create(ObjectAttributes object_attributes, MemoryPartitionAccessRights desired_access, NtPartition parent_partition, int preferred_node, bool throw_on_error) { return(NtSystemCalls.NtCreatePartition(parent_partition.GetHandle(), out SafeKernelObjectHandle handle, desired_access, object_attributes, preferred_node).CreateResult(throw_on_error, () => new NtPartition(handle))); }