Exemple #1
0
 private static extern bool DuplicateTokenEx(
     Kernel32.SafeObjectHandle hExistingToken,
     Kernel32.ACCESS_MASK dwDesiredAccess,
     ref Kernel32.SECURITY_ATTRIBUTES lpTokenAttributes,
     Kernel32.SECURITY_IMPERSONATION_LEVEL impersonationLevel,
     TOKEN_TYPE tokenType,
     out Kernel32.SafeObjectHandle phNewToken);
Exemple #2
0
    public unsafe void NtQueryInformationProcess_Test()
    {
        var desiredAccess = new Kernel32.ACCESS_MASK(Kernel32.ProcessAccess.PROCESS_QUERY_LIMITED_INFORMATION);

        using (var process = Kernel32.OpenProcess(desiredAccess, false, Process.GetCurrentProcess().Id))
        {
            PROCESS_BASIC_INFORMATION pbi = default;

            var result = NtQueryInformationProcess(
                process,
                PROCESSINFOCLASS.ProcessBasicInformation,
                &pbi,
                sizeof(PROCESS_BASIC_INFORMATION),
                out int _);

            Assert.Equal(NTSTATUS.Code.STATUS_SUCCESS, result.Value);
        }
    }
Exemple #3
0
 public Builder DesiredAccess(int accessType)
 {
     desiredAccess = accessType;
     return(this);
 }
Exemple #4
0
 private static extern bool OpenProcessToken(
     IntPtr processHandle,
     Kernel32.ACCESS_MASK desiredAccess,
     out Kernel32.SafeObjectHandle tokenHandle);