Skip to content

Commit

Permalink
Merge pull request #1 from afinetapestry/vid-pid
Browse files Browse the repository at this point in the history
Implement vid pid filtering
  • Loading branch information
todbot authored Apr 7, 2021
2 parents 46cbab8 + 1f3c762 commit 951d1c4
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,23 @@ class Program

static void Main(string[] args)
{
Console.WriteLine("WinHIDdump:");
int vid = 0;
int pid = 0;

string vidpid = GetArgument(args, "--vidpid");
// Console.WriteLine("Got vidpid: " + vidpid);
int.TryParse(GetArgument(args, "--vid"), System.Globalization.NumberStyles.HexNumber, null, out vid);
int.TryParse(GetArgument(args, "--pid"), System.Globalization.NumberStyles.HexNumber, null, out pid);

var list = DeviceList.Local;
foreach (var dev in list.GetHidDevices())
{
Console.Write(string.Format("{0:X4}:{1:X4}: {2} - {3}\nPATH:{4}\n",
if ((vid != 0 && vid != dev.VendorID) ||
(pid != 0 && pid != dev.ProductID))
{
continue;
}

Console.Write(string.Format("{0:X4}:{1:X4}: {2} - {3}\nPATH:{4}\n",
dev.VendorID, dev.ProductID, dev.GetManufacturer(), dev.GetProductName(), dev.DevicePath));
// Console.WriteLine(dev.ToString() + " @ " + dev.DevicePath);
byte[] rawReportDescriptor = dev.GetRawReportDescriptor();
Console.Write("DESCRIPTOR:\n ");
for( int i=0; i< rawReportDescriptor.Length; i++)
Expand Down

0 comments on commit 951d1c4

Please sign in to comment.