Reading files from Android devices using WebUSB on Windows - mtp

I was wondering whether it is possible implement a subset of MTP on top of WebUSB, connect to an Android device from Windows, and retrieve files from the device?
If I install a WinUSB driver with Zadig, I can claim the interface. However, when I try to use the default "MTP USB Device" driver, I'm not able to claim the interface. I'm assuming that this is because the Windows MTP stack automatically claims the interface, even if the "MTP USB Device" is also a WinUSB driver?
The reason why I can't just use the WinUSB driver from Zadig, is that it breaks MTP access for programs that use the Windows Portable Device API. Is it at all possible to create a USB driver that will allow both MTP access and USB access, to allow for a user-space MTP driver, as there's no MTP functionality built into Chrome?

Trying to share access to the device between two low-level USB drivers (MTP and Chrome) is likely to cause data corruption if the device cannot differentiate between requests from each. I am not too familiar with the MTP driver built into Windows but this is a place where the experimental Native File System API should be able to provide access to the device at a high level where access can be shared.

Related

Windows Biometric Framework for fingerprint device

We have our fingerprint device which is working properly as USB device.
Data capturing works fine with our proprietary application.
Currently we are using custom vendor USB class for driver development.
When we plug this device, this device is listed in "Universial Serial Bus Controller" catagories in Windows Device Manager.
We want to use Windows Biometric Framework for the same device to achieve Windows Biometric login.
I understand that, we need to write WBDI compitible driver but I have query related to fingerprint device hardware.
We are targeting Windows 7 and later operating systems.
Will there be any changes required in hardware to work with WBDI driver ?

How to get a device handle to pass to WriteFile within UWP C#

I have an UWP C# application that needs to use printers that are connected via USB. Unfortunately the UWP built-in functionality for these sorts of devices (Windows.Devices.Usb namespace) has some major shortcomings. It doesn't recognize the USB printers as printers without installing the manufacture's driver (because Pnp manager doesn't provide enough info to the registry). Installing a specific driver is something that I don't want to do. I have written a C++ script using CreateFile and WriteFile to access the printers, but unfortunately UWP doesn't offer support for CreateFile and CreateFile2 has limited access only to app's local folder and the package's installed location.
Do you have any suggestions how I might be able to bypass the UWP restrictions, or maybe some other way besides CreateFile to get the device handle that I could pass to WriteFile?
UWP app run sandboxed, it only can access certain file system locations by default as the document File access permissions. So my suggestion is that you can try to create a classic app to use these specific APIs, then convert it to UWP using Desktop Bridge.

How to connect hardware device to an Iphone application over Bluetooth

I have a hardware device which would communicate with a third party application on Android and IOS over Bluetooth to send to and fro data.
With Android I am able to achieve this, however in case of IOS I don't have any information.
Till now the information gathered to work with IOS devices is:
1. Application runs on Iphone 5
2. Hardware is MFI enabled
3. IAP2 is supported
Please guide how to connect the hardware to an application and what other information is essential?
Is AppName, BundleID, BundleSeedID and ProtocolName required to connect? If yes how we can get these details?
I tried unzipping the application but the Info.plist file looks garbled and not able to get much info from that.
Currently I am able to connect the hardware with IPhone over Bluetooth, but my real concern is how to communicate with a specific application on it.
Also if you can provide some link or pseudo code to initiate a session between hardware and IOS application.
I assume you've already connected the SPP profile on Android. However for iOS the SPP(BLE is another story and do not need MFi) was hidden but need MFi authentication for raw data links.
Since you want to establish the raw data link between your hardware device and your iPhone, you need:
Make sure your hardware has MFi chip, generally this chip is connected with your hardware by I2C.
After step 1 make sure you can communicate with this chip at your hardware, fortunately the hardware vendor or MFi vendor will support this kind of code or binary.
The MFi channel have a specific UUID(which may defined by Apple?) to replace the SPP official(which defined by Bluetooth SIG) UUID, hence if you want to make connection between your hardware and your iPhone, you need register the iOS defined UUID and make them as same as the normal SPP profile.
After the RFCOMM channel created, iOS would first authenticate the link, just like 3-way handshaking or something, so your hardware just communicate with the MFi chip and transfer the token to iOS.
After that iOS would set this RFCOMM channel(same as SPP actually) for your hardware, then you can send/recv data between them.

Windows form application for USB port

Previously I have work with Windows Form application to establish some RS232 connection. I used the already provided serial port component (SerialPort), and I was able to establish RS232 communication relatively easy.
Now, I was wondering if there will be something similar in Winodows Form application to establish a USB communication ?
It seems there is this WinUSB API that provides a very low level interfacing with the device.
However, I am not sure how easy will that be? Also, not sure how easy will it be to integrate into Windows Form application ?!
Will there be a simpler version of such USB interface API?
I don't have to stick to Visual Studio. Is there other c++ USB API, besides WinUSB, that is more standard that people use? I would like to develop a GUI API that does some communication over USB. If need be, I can use Python or some other tools if it facilitates the process?
Thanks in advance.
Although USB is a serial protocol, you can't treat USB like a serial port:
It's dependant on what the actual device is. For example a mobile phone, may provide several "endpoints" for USB, one being a serial port to use the phone as a modem, one as a storage device allowing you to transfer photos and music files to/from the phones storage, and as a camera device that you can take photos with. All of these have different behaviour and need a USB driver-plugin to make it behave correctly - these are typically shipped with Windows, and your phone will appear as COM5:, the E: or "Samsung Galaxy S3 Mini" drives and as a camera under the "cameras and scanners".
Of course, you can programmatically open all these devices, but it is done as the device-type that they present as on the inside of windows (so you use serial port functions or file functions or camera functions).
You CAN also write a device driver for a device, if you have sufficient details of how it works.
But there's no real way to "open the port". The USB API is a driver API, not a user-mode API. Here's a page to start from to understand USB drivers:
http://msdn.microsoft.com/en-gb/library/windows/hardware/ff540215%28v=vs.85%29.aspx
There is a WinUSB driver, which allows a single application to access a single device, assuming you know how to operate that device.

how to read certificate from USB device and send it to browser like firefox

I want to write a c++ dll that read certificate from my USB device and send that to browsers like Firefox.And I should mention that i have built my USB device with an ATMega32A which have 2K EEPROM and i stored a sample certificate on that.
I have read some about PKCS#11 standard but i cant figure out where to start. Could anyone help me on this?
It sounds like you're creating a PKI hardware device. I think your biggest hurdle will be accessing the ATMega32. It'll be up to you to implement an interface on the ATMega side, be that a RS232-usb bridge, USB Mass Storage, or proprietary with a custom driver.
A simple solution might be to use a USB Mass Storage interface to present a certificate as file on a pseudo disk.
Taking the custom driver route, Firefox (and other Mozilla products) use libraries that have interfaces for PKI hardware. See NSS and OpenSC.
At a guess it's possible that there's a PKI / PKCS11 driver API for Windows that you can implement.
You can not "add to Firefox" but you can expose your data to firefox and make them available for use. To do this you need to implement PKCS#11 API and create so-called PKCS#11 driver (the user-mode DLL which implements those 70 or so functions defined in PKCS#11 API). Those functions would talk to the hardware device in order to perform certain operations. Then you plug this PKCS#11 DLL to Firefox and Firefox can use certificates on your device.
Step 1: write a dll that can read data from the USB device. You could use Winusb. This will require the firmware to support it.
Step 2: write a dll that can add a certificate to Firefox
Step 3: combine previous steps into one dll
If you get stuck on something specific, write a new question and show us what you have done so far.