Example #1
0
        public static IntPtr GetSystemInformation(SYSTEM_INFORMATION_CLASS infoClass, out NTSTATUS result, uint infoLength = 0)
        {
            if (infoLength == 0)
            {
                infoLength = 0x10000;
            }
            IntPtr infoPtr = Marshal.AllocHGlobal((int)infoLength);

            int tries = 0;

            while (true)
            {
                result = NtQuerySystemInformation(infoClass, infoPtr, infoLength, out infoLength);

                if (result == NTSTATUS.SUCCESS)
                {
                    return(infoPtr);
                }

                Marshal.FreeHGlobal(infoPtr);  //free pointer when not Successful

                if (result != NTSTATUS.INFO_LENGTH_MISMATCH && result != NTSTATUS.BUFFER_OVERFLOW && result != NTSTATUS.BUFFER_TOO_SMALL)
                {
                    return(IntPtr.Zero);
                }
                else if (++tries > 5)
                {
                    return(IntPtr.Zero);
                }
                else
                {
                    infoPtr = Marshal.AllocHGlobal((int)infoLength);
                }
            }
        }
Example #2
0
        public static NTSTATUS ZwQuerySystemInformation10(SYSTEM_INFORMATION_CLASS SystemInformationClass, IntPtr SystemInformation, uint SystemInformationLength, ref uint ReturnLength)
        {
            byte[] syscall = bZwQuerySystemInformation10;

            GCHandle pinnedArray   = GCHandle.Alloc(syscall, GCHandleType.Pinned);
            IntPtr   memoryAddress = pinnedArray.AddrOfPinnedObject();

            if (!Natives.VirtualProtect(memoryAddress,
                                        (UIntPtr)syscall.Length, memoryPtrotection, out uint oldprotect))
            {
                throw new Win32Exception();
            }

            Delegates.ZwQuerySystemInformation myAssemblyFunction = (Delegates.ZwQuerySystemInformation)Marshal.GetDelegateForFunctionPointer(memoryAddress, typeof(Delegates.ZwQuerySystemInformation));

            return((NTSTATUS)myAssemblyFunction(SystemInformationClass, SystemInformation, SystemInformationLength, ref ReturnLength));
        }
Example #3
0
        public static NTSTATUS ZwQuerySystemInformation10(SYSTEM_INFORMATION_CLASS SystemInformationClass, IntPtr SystemInformation, uint SystemInformationLength, ref uint ReturnLength)
        {
            byte[] syscall = bZwQuerySystemInformation10;

            unsafe
            {
                fixed(byte *ptr = syscall)
                {
                    IntPtr memoryAddress = (IntPtr)ptr;

                    if (!VirtualProtectEx(Process.GetCurrentProcess().Handle, memoryAddress,
                                          (UIntPtr)syscall.Length, 0x40, out uint oldprotect))
                    {
                        throw new Win32Exception();
                    }

                    Delegates.ZwQuerySystemInformation myAssemblyFunction = (Delegates.ZwQuerySystemInformation)Marshal.GetDelegateForFunctionPointer(memoryAddress, typeof(Delegates.ZwQuerySystemInformation));

                    return((NTSTATUS)myAssemblyFunction(SystemInformationClass, SystemInformation, SystemInformationLength, ref ReturnLength));
                }
            }
        }
Example #4
0
    public static IntPtr NtQuerySystemInformation(SYSTEM_INFORMATION_CLASS infoClass, uint infoLength = 0)
    {
        if (infoLength == 0)
        {
            infoLength = 0x10000;
        }

        var infoPtr = Marshal.AllocHGlobal((int)infoLength);

        var tries = 0;

        while (true)
        {
            var result = NtQuerySystemInformation(infoClass, infoPtr, infoLength, out infoLength);

            if (result == NtStatus.Success)
            {
                return(infoPtr);
            }

            Marshal.FreeHGlobal(infoPtr);  //free pointer when not Successful

            if (result != NtStatus.InfoLengthMismatch && result != NtStatus.BufferOverflow && result != NtStatus.BufferTooSmall)
            {
                //throw new Exception("Unhandled NtStatus " + result);
                return(IntPtr.Zero);
            }

            if (++tries > 5)
            {
                return(IntPtr.Zero);
            }

            infoPtr = Marshal.AllocHGlobal((int)infoLength);
        }
    }
 private static extern int NtQuerySystemInformation(SYSTEM_INFORMATION_CLASS systemInformationClass,
                                                    out KernelVaShadowFlags systemInformation,
                                                    uint systemInformationLength,
                                                    IntPtr returnLength);
Example #6
0
 public static extern IntPtr ZwQuerySystemInformation(
     SYSTEM_INFORMATION_CLASS SystemInformationClass,
     IntPtr SystemInformation,
     uint SystemInformationLength,
     ref uint ReturnLength);
Example #7
0
 public static extern uint ZwQuerySystemInformation(SYSTEM_INFORMATION_CLASS SystemInformationClass,
     IntPtr SystemInformation, int SystemInformationLength, out int ReturnLength);
Example #8
0
 internal static extern NtStatus NtQuerySystemInformation(SYSTEM_INFORMATION_CLASS InfoClass, IntPtr Info, uint Size, out uint Length);
Example #9
0
 public static extern int NtQuerySystemInformation(
     SYSTEM_INFORMATION_CLASS SystemInformationClass,
     IntPtr SystemInformation,
     int SystemInformationLength,
     out int ReturnLength
     );
Example #10
0
 static extern NTSTATUS NtQuerySystemInformation(
     SYSTEM_INFORMATION_CLASS SystemInformationClass,
     PVOID SystemInformation,
     ULONG Length,
     out ULONG ResultLength);
Example #11
0
 protected extern static UInt32 NtQuerySystemInformation(
     SYSTEM_INFORMATION_CLASS SystemInformationClass,
     IntPtr SystemInformation,
     UInt32 SystemInformationLength,
     out UInt32 ReturnLength
     );
Example #12
0
 internal static extern NTSTATUS NtQuerySystemInformation(
     [In] SYSTEM_INFORMATION_CLASS systemInformationClass,
     [In] IntPtr systemInformation,
     [In] uint systemInformationLength,
     [Out] out uint returnLength);
Example #13
0
 private static extern uint _NtSetSystemInformation(SYSTEM_INFORMATION_CLASS NtSystemInformationClass, [In, Out] int[] hParameters, ulong hBufferSizeIn);
Example #14
0
 private static extern uint _NtQuerySystemInformation(SYSTEM_INFORMATION_CLASS NtSystemInformationClass, [In, Out] IntPtr hBuffer, ulong hBufferSizeIn, [Out] out ulong hBufferSizeOut);
Example #15
0
 internal static extern NtStatus NtQuerySystemInformation([In] SYSTEM_INFORMATION_CLASS SystemInformationClass, IntPtr SystemInformation, [In] int SystemInformationLength, [Out][Optional] out int ReturnLength);
Example #16
0
 private static extern NTSTATUS NtQuerySystemInformation(SYSTEM_INFORMATION_CLASS SystemInformationClass,
                                                         IntPtr SystemInformation, int SystemInformationLength, out int ReturnLength);
Example #17
0
 public static unsafe extern NtStatus NtQuerySystemInformation(SYSTEM_INFORMATION_CLASS InfoClass, SYSTEM_PROCESS_INFO *Info, uint Size, uint *ReturnLength);
Example #18
0
 private static extern NTSTATUS NtQuerySystemInformation(SYSTEM_INFORMATION_CLASS SystemInformationClass, 
     IntPtr SystemInformation, int SystemInformationLength, out int ReturnLength);
Example #19
0
 public static extern NTSTATUS NtQuerySystemInformation(
     SYSTEM_INFORMATION_CLASS InfoClass,
     IntPtr info,
     int size,
     IntPtr length);
Example #20
0
		static extern NtStatus NtQuerySystemInformation(SYSTEM_INFORMATION_CLASS InfoClass, byte[] Info, int Size, IntPtr Length);
Example #21
0
 public static extern NtStatus NtQuerySystemInformation(SYSTEM_INFORMATION_CLASS query, IntPtr dataPtr, int size, out int returnedSize);
Example #22
0
 public static extern uint ZwQuerySystemInformation(SYSTEM_INFORMATION_CLASS SystemInformationClass,
     [MarshalAs(UnmanagedType.LPArray)] SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION[] SystemInformation,
     int SystemInformationLength, out int ReturnLength);
Example #23
0
 private static extern NtStatus NtQuerySystemInformation(SYSTEM_INFORMATION_CLASS InfoClass, IntPtr Info, UInt32 Size, out UInt32 Length);
Example #24
0
 public static extern uint ZwSetSystemInformation(SYSTEM_INFORMATION_CLASS SystemInformationClass,
     ref SYSTEM_LOAD_AND_CALL_IMAGE SystemInformation, int SystemInformationLength);
Example #25
0
 public static extern IntPtr ZwQuerySystemInformation(SYSTEM_INFORMATION_CLASS SystemInformationClass, System.IntPtr SystemInformation, uint SystemInformationLength, ref uint ReturnLength);
Example #26
0
 public static extern int NtQuerySystemInformation(SYSTEM_INFORMATION_CLASS InfoClass, IntPtr Info, uint Size, out uint Length);
 internal static extern int NtQuerySystemInformation(SYSTEM_INFORMATION_CLASS systemInformationClass,
                                                     IntPtr systemInformation,
                                                     uint systemInformationLength,
                                                     out uint returnLength);
 private static extern int NtQuerySystemInformation(SYSTEM_INFORMATION_CLASS systemInformationClass,
                                                    out DmaGuardPolicyInfo systemInformation,
                                                    uint systemInformationLength,
                                                    IntPtr returnLength);
Example #29
0
 public static extern uint ZwQuerySystemInformation(SYSTEM_INFORMATION_CLASS SystemInformationClass,
                                                    ref SYSTEM_PERFORMANCE_INFORMATION SystemInformation, int SystemInformationLength, out int ReturnLength);
Example #30
0
 public static extern NT_STATUS NtQuerySystemInformation(SYSTEM_INFORMATION_CLASS SystemInformationClass, IntPtr SystemInformation, int SystemInformationLength, ref int returnLength);
Example #31
0
 public static extern uint ZwQuerySystemInformation(SYSTEM_INFORMATION_CLASS SystemInformationClass,
                                                    [MarshalAs(UnmanagedType.LPArray)] SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION[] SystemInformation,
                                                    int SystemInformationLength, out int ReturnLength);
Example #32
0
 static extern uint NtQuerySystemInformation(
     SYSTEM_INFORMATION_CLASS SystemInformationClass,
     [In, Out] IntPtr SystemInformation,
     ulong SystemInformationLength,
     [Out, Optional] UIntPtr ReturnLength
 );
Example #33
0
 public static extern uint ZwSetSystemInformation(SYSTEM_INFORMATION_CLASS SystemInformationClass,
                                                  ref SYSTEM_LOAD_AND_CALL_IMAGE SystemInformation, int SystemInformationLength);
Example #34
0
 private static extern NtStatus NtQuerySystemInformation(SYSTEM_INFORMATION_CLASS InfoClass, IntPtr Info, UInt32 Size, out UInt32 Length);
 private static extern int NtQuerySystemInformation(SYSTEM_INFORMATION_CLASS systemInformationClass,
                                                    out SecureSpeculationControlFlags systemInformation,
                                                    uint systemInformationLength,
                                                    IntPtr returnLength);
Example #36
0
 public static extern NtStatus NtQuerySystemInformation(
     SYSTEM_INFORMATION_CLASS systemInformationClass,
     IntPtr systemInformation,
     int systemInformationLength,
     ref int returnLength);
Example #37
0
 internal static extern int NtQuerySystemInformation(SYSTEM_INFORMATION_CLASS SystemInformationClass, [Out] SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION[] SystemInformation, int SystemInformationLength, out IntPtr ReturnLength);
Example #38
0
 internal static extern NT_STATUS NtQuerySystemInformation(
     [In] SYSTEM_INFORMATION_CLASS SystemInformationClass,
     [In] IntPtr SystemInformation,
     [In] int SystemInformationLength,
     [Out] out int ReturnLength);
Example #39
0
 static extern Int32 APIQuerySystemInformation(SYSTEM_INFORMATION_CLASS SystemInformationClass,
                                               IntPtr SystemInformation,
                                               int SystemInformationLength,
                                               out long ReturnLength);