/// <summary> /// Convert a DOS filename to an NT filename and get as an ObjectAttributes structure /// </summary> /// <param name="filename">The filename</param> /// <returns>The object attributes</returns> public static ObjectAttributes DosFileNameToObjectAttributes(string filename) { if (filename == null) { throw new ArgumentNullException("filename"); } UnicodeStringOut nt_name = new UnicodeStringOut(); RtlRelativeName relative_name = new RtlRelativeName(); try { NtRtl.RtlDosPathNameToRelativeNtPathName_U_WithStatus(filename, out nt_name, out IntPtr short_path, relative_name).ToNtException(); if (relative_name.RelativeName.Buffer != IntPtr.Zero) { return new ObjectAttributes(relative_name.RelativeName.ToString(), AttributeFlags.CaseInsensitive, new SafeKernelObjectHandle(relative_name.ContainingDirectory, false), null, null); } else { return new ObjectAttributes(nt_name.ToString(), AttributeFlags.CaseInsensitive); } } finally { if (nt_name.Buffer != IntPtr.Zero) { NtRtl.RtlFreeUnicodeString(ref nt_name); } if (relative_name.RelativeName.Buffer != IntPtr.Zero) { NtRtl.RtlReleaseRelativeName(relative_name); } } }
/// <summary> /// Convert a DOS filename to an NT filename and get as an ObjectAttributes structure /// </summary> /// <param name="filename">The DOS filename.</param> /// <param name="attributes">The object attribute flags.</param> /// <param name="sqos">An optional security quality of service.</param> /// <param name="security_descriptor">An optional security descriptor.</param> /// <param name="throw_on_error">True to throw on error.</param> /// <returns>The object attributes</returns> public static NtResult <ObjectAttributes> DosFileNameToObjectAttributes(string filename, AttributeFlags attributes, SecurityQualityOfService sqos, SecurityDescriptor security_descriptor, bool throw_on_error) { if (filename == null) { throw new ArgumentNullException("filename"); } UnicodeStringOut nt_name = new UnicodeStringOut(); RtlRelativeName relative_name = new RtlRelativeName(); try { NtStatus status = NtRtl.RtlDosPathNameToRelativeNtPathName_U_WithStatus(filename, out nt_name, out IntPtr short_path, relative_name); if (!status.IsSuccess()) { return(status.CreateResultFromError <ObjectAttributes>(throw_on_error)); } string final_name; SafeKernelObjectHandle root = SafeKernelObjectHandle.Null; if (relative_name.RelativeName.Buffer != IntPtr.Zero) { final_name = relative_name.RelativeName.ToString(); root = new SafeKernelObjectHandle(relative_name.ContainingDirectory, false); } else { final_name = nt_name.ToString(); } return(status.CreateResult(false, () => new ObjectAttributes(final_name, attributes, root, sqos, security_descriptor))); } finally { if (nt_name.Buffer != IntPtr.Zero) { NtRtl.RtlFreeUnicodeString(ref nt_name); } if (relative_name.RelativeName.Buffer != IntPtr.Zero) { NtRtl.RtlReleaseRelativeName(relative_name); } } }
/// <summary> /// Convert to an SDDL format string. /// </summary> /// <returns>The SDDL format string (e.g. S-1-1-0)</returns> public override string ToString() { using (SafeSidBufferHandle sid = ToSafeBuffer()) { UnicodeStringOut str = new UnicodeStringOut(); NtRtl.RtlConvertSidToUnicodeString(ref str, sid.DangerousGetHandle(), true).ToNtException(); try { return(str.ToString()); } finally { NtRtl.RtlFreeUnicodeString(ref str); } } }
/// <summary> /// Convert a DOS filename to an absolute NT filename /// </summary> /// <param name="filename">The filename, can be relative</param> /// <returns>The NT filename</returns> public static string DosFileNameToNt(string filename) { UnicodeStringOut nt_name = new UnicodeStringOut(); try { IntPtr short_path; NtRtl.RtlDosPathNameToRelativeNtPathName_U_WithStatus(filename, out nt_name, out short_path, null).ToNtException(); return(nt_name.ToString()); } finally { if (nt_name.Buffer != IntPtr.Zero) { NtRtl.RtlFreeUnicodeString(ref nt_name); } } }
internal NtUserProcessParameters ToObject(NtProcess process) { return(new NtUserProcessParameters() { Flags = Flags, DebugFlags = DebugFlags, ConsoleHandle = ConsoleHandle, ConsoleFlags = ConsoleFlags, StdInputHandle = StdInputHandle, StdOutputHandle = StdOutputHandle, StdErrorHandle = StdErrorHandle, CurrentDirectoryPath = CurrentDirectory.DosPath.ToString(process), CurrentDirectoryHandle = CurrentDirectory.Handle, DllPath = DllPath.ToString(process), ImagePathName = ImagePathName.ToString(process), CommandLine = CommandLine.ToString(process), Environment = Environment, StartingPositionLeft = StartingPositionLeft, StartingPositionTop = StartingPositionTop, Width = Width, Height = Height, CharWidth = CharWidth, CharHeight = CharHeight, ConsoleTextAttributes = ConsoleTextAttributes, WindowFlags = WindowFlags, ShowWindowFlags = ShowWindowFlags, WindowTitle = WindowTitle.ToString(process), DesktopName = DesktopName.ToString(process), ShellInfo = ShellInfo.ToString(process), RuntimeData = RuntimeData.ToString(process), //CurrentDirectores = CurrentDirectores.Select(d => d.Convert()).ToArray(), EnvironmentSize = EnvironmentSize, EnvironmentVersion = EnvironmentVersion, PackageDependencyData = PackageDependencyData, ProcessGroupId = ProcessGroupId, LoaderThreads = LoaderThreads, RedirectionDllName = RedirectionDllName.ToString(process), HeapPartitionName = HeapPartitionName.ToString(process), DefaultThreadpoolCpuSetMasks = DefaultThreadpoolCpuSetMasks, DefaultThreadpoolCpuSetMaskCount = DefaultThreadpoolCpuSetMaskCount }); }
/// <summary> /// Convert a DOS filename to an absolute NT filename /// </summary> /// <param name="filename">The filename, can be relative</param> /// <returns>The NT filename</returns> public static string DosFileNameToNt(string filename) { if (filename == null) { throw new ArgumentNullException("filename"); } UnicodeStringOut nt_name = new UnicodeStringOut(); try { NtRtl.RtlDosPathNameToRelativeNtPathName_U_WithStatus(filename, out nt_name, out IntPtr short_path, null).ToNtException(); return nt_name.ToString(); } finally { if (nt_name.Buffer != IntPtr.Zero) { NtRtl.RtlFreeUnicodeString(ref nt_name); } } }
string ISecurityAttributeV1.GetName() { return(Name.ToString()); }
public override string ToString() { return(String.ToString()); }
/// <summary> /// Convert a DOS filename to an absolute NT filename /// </summary> /// <param name="filename">The filename, can be relative</param> /// <param name="throw_on_error">True to throw on error.</param> /// <returns>The NT filename</returns> public static NtResult <string> DosFileNameToNt(string filename, bool throw_on_error) { if (filename == null) { throw new ArgumentNullException("filename"); } UnicodeStringOut nt_name = new UnicodeStringOut(); try { return(NtRtl.RtlDosPathNameToRelativeNtPathName_U_WithStatus(filename, out nt_name, out IntPtr short_path, null).CreateResult(throw_on_error, () => nt_name.ToString())); } finally { if (nt_name.Buffer != IntPtr.Zero) { NtRtl.RtlFreeUnicodeString(ref nt_name); } } }
/// <summary> /// Convert to an SDDL format string. /// </summary> /// <returns>The SDDL format string (e.g. S-1-1-0)</returns> public override string ToString() { using (SafeSidBufferHandle sid = ToSafeBuffer()) { UnicodeStringOut str = new UnicodeStringOut(); NtRtl.RtlConvertSidToUnicodeString(ref str, sid.DangerousGetHandle(), true).ToNtException(); try { return str.ToString(); } finally { NtRtl.RtlFreeUnicodeString(ref str); } } }