Esempio n. 1
0
 internal DllDebugData(SafeHGlobalBuffer buffer) : this()
 {
     Magic = buffer.Read <uint>(0);
     if (Magic == CV_RSDS_MAGIC)
     {
         Id            = new Guid(buffer.ReadBytes(4, 16));
         Age           = buffer.Read <int>(20);
         PdbPath       = buffer.ReadNulTerminatedAnsiString(24, Encoding.UTF8);
         IdentiferPath = $"{Id:N}{Age:X}".ToUpper();
     }
 }
Esempio n. 2
0
        internal static DeviceProperty GetProperty(int devinst, DEVPROPKEY key)
        {
            DeviceProperty ret = new DeviceProperty()
            {
                Name = DevicePropertyKeys.KeyToName(key), FmtId = key.fmtid, Pid = key.pid, Data = new byte[0]
            };

            using (var buffer = new SafeHGlobalBuffer(2000)) {
                int length = buffer.Length;
                if (DeviceNativeMethods.CM_Get_DevNode_PropertyW(devinst, key, out DEVPROPTYPE type, buffer, ref length, 0) == CrError.SUCCESS)
                {
                    ret.Type = type;
                    ret.Data = buffer.ReadBytes(length);
                }
            }
            return(ret);
        }
Esempio n. 3
0
    public static Natives.WnfStateData QueryWnf(ulong state)
    {
        var data  = new Natives.WnfStateData();
        int tries = 10;
        int size  = 4096;

        while (tries-- > 0)
        {
            using (var buffer = new SafeHGlobalBuffer(size))
            {
                int status;
                status = Natives.ZwQueryWnfStateData(ref state, null, IntPtr.Zero, out int changestamp, buffer, ref size);

                if (status == 0xC0000023)
                {
                    continue;
                }
                data = new Natives.WnfStateData(changestamp, buffer.ReadBytes(size));
            }
        }
        return(data);
    }
Esempio n. 4
0
 /// <summary>
 /// Send a message to the filter.
 /// </summary>
 /// <param name="input">The input buffer.</param>
 /// <param name="max_output_length">The maximum size of the output buffer.</param>
 /// <param name="throw_on_error">true to throw on error.</param>
 /// <returns>The output buffer.</returns>
 public NtResult <byte[]> SendMessage(byte[] input, int max_output_length, bool throw_on_error)
 {
     using (var input_buffer = input?.ToBuffer())
     {
         using (var output_buffer = new SafeHGlobalBuffer(max_output_length))
         {
             return(SendMessage(input_buffer, output_buffer, throw_on_error).Map(i => output_buffer.ReadBytes(i)));
         }
     }
 }