Skip to content

Commit 3cf255f

Browse files
committed
Added method to test protected access.
1 parent 0960d5a commit 3cf255f

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

NtApiDotNet/NtProcess.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,17 @@ public static NtProcess OpenCurrent()
488488
return Current.Duplicate();
489489
}
490490

491+
/// <summary>
492+
/// Test whether a process can access another protected process.
493+
/// </summary>
494+
/// <param name="current">The current process.</param>
495+
/// <param name="target">The target process.</param>
496+
/// <returns>True if the process can be accessed.</returns>
497+
public static bool TestProtectedAccess(NtProcess current, NtProcess target)
498+
{
499+
return NtRtl.RtlTestProtectedAccess(current.Protection.Level, target.Protection.Level);
500+
}
501+
491502
#endregion
492503

493504
#region Public Methods
@@ -1869,6 +1880,16 @@ public NtResult<int> GetSessionId(bool throw_on_error)
18691880
default, throw_on_error).Map(s => s.SessionId);
18701881
}
18711882

1883+
/// <summary>
1884+
/// Test whether the current process can access another protected process.
1885+
/// </summary>
1886+
/// <param name="target">The target process.</param>
1887+
/// <returns>True if the process can be accessed.</returns>
1888+
public bool TestProtectedAccess(NtProcess target)
1889+
{
1890+
return TestProtectedAccess(this, target);
1891+
}
1892+
18721893
/// <summary>
18731894
/// Method to query information for this object type.
18741895
/// </summary>

NtApiDotNet/NtProcessNative.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,10 @@ public static extern NtStatus RtlCreateProcessParametersEx(
758758

759759
[DllImport("ntdll.dll")]
760760
public static extern void RtlDestroyProcessParameters(IntPtr pProcessParameters);
761+
762+
[DllImport("ntdll.dll")]
763+
[return: MarshalAs(UnmanagedType.U1)]
764+
public static extern bool RtlTestProtectedAccess(byte request_level, byte target_level);
761765
}
762766

763767
[Flags]

0 commit comments

Comments
 (0)