public static extern NtStatus NtQuerySystemInformationEx( SystemInformationClass SystemInformationClass, SafeBuffer InputBuffer, int InputBufferLength, SafeBuffer SystemInformation, int SystemInformationLength, out int ReturnLength);
public static extern NtStatus NtQuerySystemInformation( [In] SystemInformationClass systemInformationClass, IntPtr systemInformation, [In] int systemInformationLength, // ReSharper disable once OptionalParameterRefOut [Out][Optional] out int returnLength );
private static void AllocateSafeBuffer(SafeHGlobalBuffer buffer, SystemInformationClass info_class) { NtStatus status = 0; int return_length = 0; while ((status = NtSystemCalls.NtQuerySystemInformation(info_class, buffer, buffer.Length, out return_length)) == NtStatus.STATUS_INFO_LENGTH_MISMATCH) { int length = buffer.Length * 2; buffer.Resize(length); } status.ToNtException(); }
private static T QueryCached <T>(SystemInformationClass info_class) where T : new() { if (!_cached_info.ContainsKey(info_class)) { var value = Query(info_class, default(T), false); if (value.IsSuccess) { _cached_info[info_class] = value.Result; } else { _cached_info[info_class] = default(T); } } return((T)_cached_info[info_class]); }
/// <summary> /// /// </summary> /// <param name="InfoClass"></param> /// <param name="Info"></param> /// <param name="InfoLength"></param> /// <param name="ReturnLength"></param> /// <returns></returns> public static NTSTATUS NtQuerySystemInformation(SystemInformationClass InfoClass, IntPtr Info, uint InfoLength, out uint ReturnLength, [CallerMemberName] string callerName = "") { if (!PInvokeDebugger.LoggingEnabled) { return(PInvoke_NtQuerySystemInformation(InfoClass, Info, InfoLength, out ReturnLength)); } NTSTATUS returnValue = PInvoke_NtQuerySystemInformation(InfoClass, Info, InfoLength, out ReturnLength); PInvokeDebugInfo debugInfo = PInvokeDebugInfo.TraceDebugInfo( ModuleName, nameof(NtQuerySystemInformation), callerName, returnValue, nameof(InfoClass), InfoClass, nameof(Info), Info, nameof(InfoLength), InfoLength, nameof(ReturnLength), ReturnLength ); PInvokeDebugger.SafeCapture(debugInfo); return(returnValue); }
public static IntPtr NtQuerySystemInformation(SystemInformationClass systemInformationClass, uint infoLength = 0) { if (infoLength == 0) { infoLength = 0x10000; } var infoPtr = Marshal.AllocHGlobal((int)infoLength); var tries = 0; while (true) { var result = NtQuerySystemInformation(SystemInformationClass.SystemHandleInformation, 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); } }
public static extern NtStatus NtQuerySystemInformation( [In] SystemInformationClass systemInformationClass, [In] IntPtr systemInformation, [In] int systemInformationLength, [Out] out int returnedLength);
public static extern NtStatus RtlGetNativeSystemInformation( SystemInformationClass SystemInformationClass, SafeBuffer SystemInformation, int SystemInformationLength, out int ReturnLength );
public static extern int NtQuerySystemInformation(SystemInformationClass infoClass, IntPtr info, uint size, out uint length);
public static unsafe extern int NtQuerySystemInformationEx(SystemInformationClass infoClass, void *inputBuffer, int inputBufferLen, void *buffer, uint size, int *actualSize = null);
public static extern int NtQuerySystemInformation( SystemInformationClass SystemInformationClass, IntPtr SystemInformation, uint SystemInformationLength, out uint ReturnLength);
/// <summary> /// Query a variable buffer from the object and return as bytes. /// </summary> /// <param name="info_class">The information class to query.</param> /// <returns>The result of the query.</returns> /// <exception cref="NtException">Thrown on error.</exception> public static byte[] QueryRawBytes(SystemInformationClass info_class) { return(_system_info_object.QueryRawBytes(info_class)); }
/// <summary> /// Query a variable buffer from the object and return as bytes. /// </summary> /// <param name="info_class">The information class to query.</param> /// <param name="init_buffer">A buffer to initialize the initial query. Can be null.</param> /// <returns>The result of the query.</returns> /// <exception cref="NtException">Thrown on error.</exception> public static byte[] QueryRawBytes(SystemInformationClass info_class, byte[] init_buffer) { return(_system_info_object.QueryRawBytes(info_class, init_buffer)); }
/// <summary> /// Query a variable buffer from the object and return as bytes. /// </summary> /// <param name="info_class">The information class to query.</param> /// <param name="init_buffer">A buffer to initialize the initial query. Can be null.</param> /// <param name="throw_on_error">True to throw on error.</param> /// <returns>The result of the query.</returns> /// <exception cref="NtException">Thrown on error.</exception> public static NtResult <byte[]> QueryRawBytes(SystemInformationClass info_class, byte[] init_buffer, bool throw_on_error) { return(_system_info_object.QueryRawBytes(info_class, init_buffer, throw_on_error)); }
/// <summary> /// Query a variable buffer from the object. /// </summary> /// <param name="info_class">The information class to query.</param> /// <returns>The result of the query.</returns> /// <exception cref="NtException">Thrown on error.</exception> public static SafeHGlobalBuffer QueryRawBuffer(SystemInformationClass info_class) { return(_system_info_object.QueryRawBuffer(info_class)); }
/// <summary> /// Query a variable buffer from the object. /// </summary> /// <typeparam name="T">The type of structure to return.</typeparam> /// <param name="info_class">The information class to query.</param> /// <param name="default_value">A default value for the query.</param> /// <param name="throw_on_error">True to throw on error.</param> /// <returns>The result of the query.</returns> /// <exception cref="NtException">Thrown on error.</exception> public static NtResult <SafeStructureInOutBuffer <T> > QueryBuffer <T>(SystemInformationClass info_class, T default_value, bool throw_on_error) where T : new() { return(_system_info_object.QueryBuffer(info_class, default_value, throw_on_error)); }
public static extern uint NtQuerySystemInformation([In] SystemInformationClass SystemInformationClass, [Out] IntPtr SystemInformation, [In] int SystemInformationLength, [Optional] out int ReturnLength);
/// <summary> /// Query a variable buffer from the object. /// </summary> /// <typeparam name="T">The type of structure to return.</typeparam> /// <param name="info_class">The information class to query.</param> /// <returns>The result of the query.</returns> /// <exception cref="NtException">Thrown on error.</exception> public static SafeStructureInOutBuffer <T> QueryBuffer <T>(SystemInformationClass info_class) where T : new() { return(_system_info_object.QueryBuffer <T>(info_class)); }
public unsafe static extern int NtQuerySystemInformation(SystemInformationClass infoClass, IntPtr buffer, int size, int *actualSize = null);
/// <summary> /// Set a value to the object. /// </summary> /// <typeparam name="T">The type of structure to set.</typeparam> /// <param name="info_class">The information class to set.</param> /// <param name="value">The value to set. If you specify a SafeBuffer then it'll be passed directly.</param> /// <param name="throw_on_error">True to throw on error.</param> /// <returns>The NT status code of the set.</returns> /// <exception cref="NtException">Thrown on error.</exception> public static NtStatus Set <T>(SystemInformationClass info_class, T value, bool throw_on_error) where T : struct { return(_system_info_object.Set(info_class, value, throw_on_error)); }
internal static extern NtStatus NtQuerySystemInformation( [In] SystemInformationClass SystemInformationClass, [In] IntPtr SystemInformation, [In] int SystemInformationLength, [Out] out int ReturnLength);
/// <summary> /// Set a value to the object. /// </summary> /// <typeparam name="T">The type of structure to set.</typeparam> /// <param name="info_class">The information class to set.</param> /// <param name="value">The value to set.</param> /// <returns>The NT status code of the set.</returns> /// <exception cref="NtException">Thrown on error.</exception> public static void Set <T>(SystemInformationClass info_class, T value) where T : struct { _system_info_object.Set(info_class, value); }
/// <summary> /// Set a value to the object from a buffer. /// </summary> /// <param name="info_class">The information class to set.</param> /// <param name="buffer">The value to set.</param> /// <param name="throw_on_error">True to throw on error.</param> /// <returns>The NT status code of the set.</returns> /// <exception cref="NtException">Thrown on error.</exception> public static NtStatus SetBuffer(SystemInformationClass info_class, SafeBuffer buffer, bool throw_on_error) { return(_system_info_object.SetBuffer(info_class, buffer, throw_on_error)); }
/// <summary> /// Set a value to the object from a buffer.. /// </summary> /// <param name="info_class">The information class to set.</param> /// <param name="buffer">The value to set.</param> /// <returns>The NT status code of the set.</returns> /// <exception cref="NtException">Thrown on error.</exception> public static void SetBuffer(SystemInformationClass info_class, SafeBuffer buffer) { _system_info_object.SetBuffer(info_class, buffer); }
internal static extern NTSTATUS PInvoke_NtQuerySystemInformation(SystemInformationClass InfoClass, IntPtr Info, uint InfoLength, out uint ReturnLength);
/// <summary> /// Set a raw value to the object. /// </summary> /// <param name="info_class">The information class to set.</param> /// <param name="value">The raw value to set.</param> /// <param name="throw_on_error">True to throw on error.</param> /// <returns>The NT status code of the set.</returns> /// <exception cref="NtException">Thrown on error.</exception> public static NtStatus SetBytes(SystemInformationClass info_class, byte[] value, bool throw_on_error) { return(_system_info_object.SetBytes(info_class, value, throw_on_error)); }
public static extern NtStatus NtSetSystemInformation( SystemInformationClass SystemInformationClass, SafeBuffer SystemInformation, int SystemInformationLength );
/// <summary> /// Set a raw value to the object. /// </summary> /// <param name="info_class">The information class to set.</param> /// <param name="value">The raw value to set.</param> /// <returns>The NT status code of the set.</returns> /// <exception cref="NtException">Thrown on error.</exception> public static void SetBytes(SystemInformationClass info_class, byte[] value) { _system_info_object.SetBytes(info_class, value); }
public static extern int NtQuerySystemInformation(SystemInformationClass infoClass, IntPtr buffer, uint size, out uint actualSize);
public static extern int NtQuerySystemInformation( SystemInformationClass informationClass, [Out] SystemProcessorPerformanceInformation[] informations, int structSize, out IntPtr returnLength);
public static extern int NtQuerySystemInformation(SystemInformationClass informationClass, [Out] SystemProcessorPerformanceInformation[] informations, int structSize, out IntPtr returnLength);
public static extern NtStatus NtQuerySystemInformation( SystemInformationClass SystemInformationClass, IntPtr SystemInformation, int SystemInformationLength, out int ReturnLength );