none
code to get vid/pid of connected usb devices RRS feed

  • Question

  • I am developing usb filter driver.i want to get vid and pid of connected usb device.Can you give me sample code?
    Monday, October 15, 2018 1:44 PM

Answers

  • I wrote a USB white list driver for a client that does what you want, and it was very complex. This isn't something that someone new to Windows drivers will be able to write because it requires a great deal of knowledge of the Plug and Play manager, bus drivers, USB, and it requires a lot of workarounds because of some poor implementation decisions by the developers of the USBCCGP (composite device) driver. Frankly, given the questions that you're asking, this project is beyond your current abilities to implement.

     -Brian


    Azius Developer Training www.azius.com Windows device driver, internals, security, & forensics training and consulting. Blog at www.azius.com/blog

    Friday, November 16, 2018 6:47 PM
    Moderator

All replies

  • What type of filter driver are you writing? A bus, class, or device filter? What bigger problem are you trying to solve with your filter?

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Monday, October 15, 2018 2:19 PM
  • Device filter.

    Tuesday, November 13, 2018 6:42 AM
  • I want to restrict  specific usb devices based on their vendor id. 
    Tuesday, November 13, 2018 6:52 AM
  • vendor ID isn't sufficient as you need the PID as well.  for a device filter to work for all devices from a specific VID, you would need a bus filter driver so you see all attached devices as they come. if you know each PID, you know the full hardware ID and can use PNP group policy to stop a device from loading based on a HWID

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Tuesday, November 13, 2018 7:06 AM
  • Thank You sir,

    Your explanation means lot to me.

    So,according to your explanation, my first target is to get vid and pid of device.So,do you have sample code or helpful link for it?


    Tuesday, November 13, 2018 7:12 AM
  • If you know the vid and pid you don’t need a driver at all. You can configure pnp itself to block the device through policy

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Tuesday, November 13, 2018 2:46 PM
  • Have you done any searching AT ALL for this?  Do you have any knowledge of USB? Do you know where the VID and PID are stored?  If so, then surely you must know how to fetch them.

    Remember that a device filter filters one device, based on VID and PID.  In that case, you already know the VID and PID.


    Tim Roberts | Driver MVP Emeritus | Providenza & Boekelheide, Inc.

    Wednesday, November 14, 2018 7:45 AM
  • But it will be limited for my own PC only.So,I am developing driver that can block specific device based on vid and pid i.e. it should not be recognized by my pc.
    Wednesday, November 14, 2018 10:18 AM
  • sure sir,I have read about your suggested topics.I know how to get vid and pid of device once it is recognized by system.But,I need to catch it before it recognize.

    I am also confused about API used for it,So I need some sample code that I can learn exact procedure.

    Wednesday, November 14, 2018 10:23 AM
  • What are you really trying to do?   You state you want to catch it before it is recognized by the system, by that do you mean you want to stop a driver from loading?   If so why do you want to do this?   It is easier as has been pointed out by Doron to disable the device from being used.


    Don Burn Windows Driver Consulting Website: http://www.windrvr.com

    Wednesday, November 14, 2018 2:47 PM
  • My project as,

    As soon as you connect your  usb device to port,my driver will block it and don't even give notification to user.

    So,for blocking purpose,I need to find vid and pid of corresponding device.

    thank you

    Friday, November 16, 2018 5:14 AM
  • I wrote a USB white list driver for a client that does what you want, and it was very complex. This isn't something that someone new to Windows drivers will be able to write because it requires a great deal of knowledge of the Plug and Play manager, bus drivers, USB, and it requires a lot of workarounds because of some poor implementation decisions by the developers of the USBCCGP (composite device) driver. Frankly, given the questions that you're asking, this project is beyond your current abilities to implement.

     -Brian


    Azius Developer Training www.azius.com Windows device driver, internals, security, & forensics training and consulting. Blog at www.azius.com/blog

    Friday, November 16, 2018 6:47 PM
    Moderator