Where does "Bluetooth and other devices" get its information from? - winapi

I am writing C++ code for listing USB HID devices that uses HidD_GetProductString(). One particular device, despite the function's success, returns an empty string.
The classic Device Manager and gwmi in PowerShell both list the device using a generic name. However, Windows 10 Immersive Control Panel's Bluetooth and other devices window lists this device with its actual full name, which does not seem to appear anywhere. I did not find it in the registry either. I want to get access to this information.
Does anyone know where this app gets its information from?
My suspicion is that it gets it directly from the System process, which is also a holder of an open file handle to a device file, and perhaps it is the reason why the function returns an empty output. If so, how could I do it? Any suggestion is appreciated...

Related

Webusb: Access Denied trying to open printer on Windows

I am trying to allow a POS web app to print directly to a StarMicronics (or any receipt printer, for that matter) using the Chrome webusb API.
I am using the example here almost exactly except I have modified the vendorId filter to the Vendor ID of StarMicronics. I have also tried it with a completely empty filter. It works great on the Mac computers I have tested it on, but the problem is on Windows.
When I click the print button, Chrome opens up the connection window, my device is listed and I can select it and click Connect. So navigator.usb.getDevices() is working great. When I refresh the window, after having connected the website to the device, Chrome finds the device again with no problem.
The problem comes when I try to do device.open(). I get this error in the console: DOMException: Access Denied. From this point, I can't do either device.selectConfiguration() or device.claimInterface() because I get the error that the device must first be opened, obviously.
I have enabled all the flags I know of in Chrome:
#enable-experimental-web-platform-features
#enable-webusb
#new-usb-backend
But none of this has helped. I have also tried using other printers, such as an HP deskjet and a Dymo Label Writer all with the same resulting error message that access is denied.
Again, it is working fine on Macs.
Any help on this would be greatly appreciated.
You get the "Access Denied" error on Windows because there is already a driver that has claimed the device. The Windows driver model requires that the "winusb.sys" driver be loaded for any device that will be accessed by a userspace application like Chrome.
See my answer to this earlier question about smartcard readers which encounter the same difficulty on Windows.
You'll need to first download the Star Micronics Windows Driver (available here for the SP700). You want the "USB Vendor Class Driver" (again, available here for the SP700)
Of course, there is no auto-installer (to my knowledge), so you'll have to open up the StarUSBVendorClassDriver_... zipped folder, and navigate to Manuals/usb-vendor-class-driver_im_en.pdf.
In reading this, you'll notice that you actually need to install the driver from the CMD line with the following cmd (note the <version_here>, don't COPY+PASTE):
pnputil -a StarUSBVendorClassDriver_<version_here>\USBVendorClassDriver\SMJUSBCOM.INF
Once you have the correct driver installed, download the Zadig utility from the download page here. The website is ad-ridden, but I had no problems.
Open Zadig, toggle the "Options" menu dropdown, and toggle "List All Devices".
You should then see your device in the drop down below. Select it as shown below.
Then, on the LHS dropdown, you will see a "non WinUSB" driver selected. On the RHS, ensure that WinUSB is selected, and click "Replace Driver".
This should enable WebUSB! Happy printing!

How to determine display - touch device associations for windows 10?

I am currently writing an application that receives touch input through the windows WM_INPUT messages and the HID API. Every touch point received has a handle to the device associated from which it came. This is the same device that the family of WM_POINTER messages would report for the same touch point. My application needs to know which monitor corresponds to a particular touch device. Is there a programmatic way to determine this? If I was using the WM_POINTER API I could use MonitorFromPoint or something similar.
In the control panel under "hardware and sound" there is a category "Tablet PC Settings". If you click this category, a dialog box launches which has a button "Setup". This button launches a calibration tool which allows you to pair a USB HID touch device with a monitor.
Does anyone know where these settings might be saved to?
relevant links:
structure received in WM_INPUT messages:
https://msdn.microsoft.com/en-us/library/windows/desktop/ms645562(v=vs.85).aspx
Structure received in WM_POINTER messages:
https://msdn.microsoft.com/en-us/library/windows/desktop/hh454907(v=vs.85).aspx
Thanks.
A generic way to determine where things are stored in the registry, is to watch registry changes. Process Monitor from the Windows Sysinternals Suite by Mark Russinovich, can be used to watch and log changes to the windows registry. So you can start it logging, and then perform your calibration, and then stop and examine the log for the desired registry activity.
Here is a link to a similar question I asked
Associate HID Touch Device with Pnp Monitor.
In short, you can use the details from the HIDApi calls with queries of registry keys to link HID Touch Devices to monitors.

How to get connection status on a BLE device in Windows

I have a Bluetooth low-energy device paired to my Windows 10 machine, when an application try to use it, Windows automatically connects the paired device. I want to be able to read if the device is connected or just paired to Windows. Searching around Window's Device Manager (accessible from Control Panel), I saw that the device had the property "Is connected" under the details tab, it's value (true/false) was changing accordingly to the actual device status.
I tried to read to access this property using the SetupDiGetDeviceProperty function with the DEVPKEY_DeviceContainer_IsConnected predefined key but for some reason I get ERROR_NOT_FOUND.
Any ideas?

USB device opens Applications, then types in text field

I got a letter in the mail that contained a small USB device. Here is what it loks like: http://imgur.com/a/VEtNK
When I plug it into my computer it seems to hover over the programs in my Dock and then opens one. It then types a link into a text field that is available. I originally had Skype in the dock and it defaulted to that one, strange. I removed Skype from the dock and now it opens to System Preferences.
Here's a video of what happens as I plug it in: https://www.dropbox.com/s/yuw6ggvo77rkvwh/Test1MysteryDevice.mov
Also, it does not appear like a memory stick does on my computer. I can't seem to locate it when it's plugged in. It would be cool if I could find it somehow. It would be even cooler if I could program it to do something I wanted.
Thanks, and if anyone can help out that's awesome or if you could point me to a forum/anywhere that might be able to help out, that'd be great!
Probably it self-identifies as a HID (Human Interface Device), specifically a keyboard. As soon as it is accepted as a keyboard by the OS it can send any sequence of keystrokes, and the OS will assume that it is input from a human user.
Scripting such behavior is easy using Applescript.
However automatically running a program from a USB stick when it is inserted is supposed to be impossible on OS X, as auto-run is a security risk.
Of course at the very least a custom USB device could be made to act like a mouse and keyboard, so even without autorun it's a risk to plug strange devices into your computer.
To get more info on the device you can go to System Profiler and look for the device on the USB bus.
If it is a custom device pretending to be a keyboard then it's probably hardwired to do what it does, and you probably won't be able to reprogram it; you'd need to find a manufacturer that will sell you customized devices.

Windows: suppress warning when plugging in unformatted flash drive

I'm working on a device that writes some information directly to a flash drive, without using any file system (it just writes blocks of data directly to the disk sectors). After the flash drive is filled, I need to plug it into any computer with windows and read data using my application.
Everything works great except for when I plug the flash drive in windows warns me that flash drive is invalid an offers me to format it. I want to get rid of this message for my flash drives on any computer that have installed my windows application.
My flash drive have signature bytes at the start so I can always make out whether it's my flash drive or just a regular flash drive.
My idea is that I should be able to write some sort of service or driver which will check all flash drives and will disallow OS to mount my drives. However I don't know whether its really possible and I can't find any documents mentioning this sort of functionality.
I'd appreciate any docs / links / functions names that can help me suppress unformatted disk warning.
Make a tiny real partition at the start and format it to keep windows happy.
Then just use the rest of the drive as you please
This seems to work:
Remove the drive letter assigned to the device:
Right-click the 'Computer' (or 'My Computer') icon on your desktop or in the Start Menu and select Manage. The 'Computer Management' window should appear.
From the list on the left, select 'Disk Management' (within the Storage sub-tree).
Right-click the encrypted partition/device and select Change Drive Letter and Paths.
Click Remove.
If Windows prompts you to confirm the action, click OK.

Resources