How does VirtualHere create virtual USB devices on macOS? - macos

How is VirtualHere able to virtualize USB devices on macOS without requiring the user to install kernel extensions?
As far as I am aware, there's no documented way to virtualize USB devices on macOS.
The USB/IP project, for example, only supports clients on Windows and Linux.
I understand this is proprietary software but it must be using some technique available to userspace?
Thanks

Really interesting.
Seems they are using the IOUSBHost.framework, which is at most undocumented.
Using it requires getting custom entitlement from Apple:
com.apple.usb.hostcontrollerinterface, which could possibly take a lot of time.
There are some traces that it could be used to create virtual devices, but no details about it.
You could try to use tools like classdump to get some information directly from the framework, or read some headers on github.
It would be great if someone could share any information about it with community, as Apple seems to be very lazy about doing this.

Related

Where can I find an example of creating a FaceTime comparable camera in OSX

Many of us are working from home more and I envy the Windows guys who have a virtual webcam plugging in OBS (Open Broadcast Studio). OBS and the Windows plugin are open source projects. As a competent software engineer I should be able to create a plugin that works on OSX -But- I am not a hardened OSX dev.
I am sure I am not googling for the correct APIs and Subsystems. If someone(s) could help me with the Apple concept map to this obscure topic. I would be grateful for a set of crumbs that leads to the OSX API to call(s) to create a camera. I know it can be done as SnapCam does it, but that is a closed-source app.
I am aware of the workaround for OBS that
1) uses code injection and requires disabling security features
2) Doesn't even work in the current versions of OSX
3) Requires yet another app running with video previews etc.
I like the challenge of creating this plugin. I am also wise enough to try and ask for a road map if one is available.
Someone beat me to it. https://github.com/johnboiles/obs-mac-virtualcam
I thought I would search just githib.com directly with the search "virtual camera macos site:github.com". Constraining the search to just GitHub was quite useful.

How do I create a virtual gamepad?

How would I go about creating a "gamepad" which appears to DirectInput applications as a normal game controller but the state of its controls is actually defined by software?
Write a device driver to pretend to be one.
Specifically, Windows device drivers handle what are called Interrupt Requests via the Interrupt Request Protocol - which boils down to a wrapped up structure and a set of buffers internally in the driver.
Now the next thing you need to know is that many drivers are actually layered, or stacked, or whichever name you want to use. So for example to write a disk driver, you might interface with the driver above it (as a disk class) but use a driver below it (scsi port, for example) to actually send commands to your devices.
That's how real devices work. Fake devices need to conform to the top level interface requirements, e.g. a disk, or a controller, or a mouse, or whatever it is. However, underneath they can do anything they like - return whatever values they like.
This opens up the possibility of controlling a driver via a user-mode application and pretending to "be" a device. To send a driver messages, you can DeviceIoControl to it; then to actually get those messages you can either:
Stuff them in the Irp that makes up that DeviceIoControl.
Have the driver read them out of your process' memory space.
Drivers can also access \\Registry\\Machine and various other, non-user-specific non-explorer registry areas, so it is possible to communicate that way.
Finally, there's no saying you can't filter existing IO, rather than make it all up via a new device. There are a great many options and ways you can go about doing this.
If you're going to do this, you'll need:
VirtualKD or an expensive debugger cable and two PCs.
You probably also want to start with the references on this blog post. You'll find that there are essentially a bazillion different names for driver code, so I'll interpret some of them:
WDM = Windows Driver Model, basically the NT driver model mixed with (some of) Windows 9x.
KMDF = Kernel mode driver framework - drivers of the above type use this, plus additionally WDF (Windows Driver Foundation) which is a set of libraries on top of WDM to make it quicker to use.
UMDF = User mode driver framework - write a driver without the danger of kernel mode. If you can, use this, as kernel mode drivers that go wrong will bluescreen (in driver parlance, bugcheck) your system.
Edit: I'm not massively knowledgeable on DirectInput - there may be a way to override the various API controls in use via DLL redirection and the like, which may be simpler than the way I've described.
There is vJoy opensource project: http://sourceforge.net/projects/vjoystick/ - can be worth looking at.
The easiest solution may be to emulate an XInput device (Xbox 360 and One). These are supported in most modern games and the set up is very simple. Here is a C++ project here that provides this without any installed drivers or external dependencies: https://github.com/shauleiz/vXboxInterface/
I know it is an old question but for anyone which is interested in this topic it is also worth looking at this project called ViGEm.
You can emulate some well known gamepads like Microsoft Xbox 360 Controller, Sony DualShock 4 Controller and Microsoft Xbox One Controller. The project offers also some API to interact with these virtual controllers. E.g. the C# API can be found here
The simplest solution I found was using vJoy and its C# wrapper.
You need to download the vJoy driver from here.
You can use the vJoy SDK for implementing a feeder program: https://github.com/njz3/vJoy/tree/master/SDK/c%23
Use the C# starter project for this, or simply add the two .dll-s to your existing project as references from the x86 or x64 folder.
You can find instructions on how to use the api in the readme.odt file.

How to scan Wifi access point on Windows Mobile?

I need to scan Wifi access point on Windows Mobile and connect the one of scanned results.
Currently I am using C# language, Windows Mobile 6.5 device, also to scan I am using the below code.
[DllImport(wlanapi.dll", SetLastError=true)]
I am using wlanapi.dll, but it seems that not possible to use on Mobile.
Does anyone know about the belows.
Could I use the dll in Windows Mobile 6.5 to scan and connect?
If the 1 is not possible, please let me know the different methods..
Please give me the clues.
wlanapi.dll doesn't exist in WinMo/WinCE. You have to use an API that is supported.
Most WinMo WiFi drivers (though probably not all) support the Wireless Zero Config (WZC) set of APIs. The native versions of these APIs, like WZCQueryInterface, are outlined in MSDN.
Microsoft does not provide any managed interface for these APIs, in fact the native documentation for them is pretty bad too. The definitive "example" of it's use is in the NETUI component source of Platform Builder. Gettign the eval version just for the source is very worthwhile if you plan to do much WinCE/WinMo development.
From a managed perspective I wrote an MSDN article back in '06 that talks about using the SDF for getting network info. The SDF has been reworked a lot since then, especially in the WZC area, but it's still pretty similar.
I did an updated blog post in '07 about custom-drawn ListBoxes, and while that's not what you're after, the data being displayed is wireless network info, which is in line with what you're after.

Bluetooth in Ruby (Mac/Cross Platform)

I'm trying to get a list of the bluetooth addresses (the MAC address-like hex digits unique to each bluetooth device) within range of the bluetooth device inside my mac in the ruby language.
I'm hoping to make my work publicly available, so it'd be nice if it was platform agnostic.
Googling only helps so much:
hcitool etc aren't available on OS X: snippets.dzone.com/posts/show/5764
Ruby_Bluetooth is nearly 4 years old, and I can't make it work!: rubyforge.org/projects/ruby-bluetooth/
Herval is attempting to continue that project, but the git repo is only a day old…
I don't need to create any services or interact with bluetooth in any extensive way, only list the device ids that are within range.
Does anyone have any other ideas? (Even for non ruby, platform specific hcitool equivalents?)
Have you thought about leveraging a Java Bluetooth API and using it from JRuby?
This might make it easier to create platform agnostic code.
For instance bluecove looks like it would cover all the major platforms.
You could go the non-platform specific route and use the native frameworks instead.
For example
RubyCocoa for the bridge between Ruby and Objective-C
OSX's native Bluetooth API Call out to this from Ruby using RubyCocoa
There are other options for other platforms, such as Ruby and Win32OLE/COM.

Help writing a DVB driver for OS X

I'm looking at options to access DVB data on OS X. Initially I want to support the EyeTV DTT USB device, but in the long-run I'd like to support a number of popular devices. The problem I have is that there is no standard way of controlling such devices.
All the applications I know of that use them either hide the driver code within the application (for example EyeTV itself, all it's drivers are implemented totally in userspace and are not accessible to external apps), or they use the seemingly defunkt MMInputFamily driver (no source code availible any more, author gone walkabouts).
I've done some research and found that a number of the devices I want to support are supported within the Linux DVB project. Further research indicates that some years ago there was an attempt to abstract the linux implementation so that it could potentially be recompiled on other platforms. The idea being that efforts to support devices should be pooled and the best way to do that would be to make the current open source implementation work on multiple platforms: it seems in the end to have amounted to little however.
The idea of compiling linux drivers against other *nix type platforms has also been taken up elsewhere with some success. The approach the author took is detailed on the page I linked, it seems potentially viable on OS X as well.
At any rate, there seem to be a number of options, but no clear winner:
Find the source code for the MMInputFamily driver, try to get it working on OS X 10.6 and add support for the devices I require, referrencing the linux source code for pointers. Problem: the source code is nowhere to be found, nor is the author. Additionally it seems the author might perhaps have gone down another route had he fully appreciated the previous efforts to port the linux drivers to OS X.
Attempt to port the linux drivers to OS X in a manner similar to the FreeBSD project I linked. Problem: this is very low-level work and work in this layer is not recommended by Apple if it can be avoided.
Write a driver with OS X's IOKit: this is the preferred method for implementing drivers but I would have to do everything from scratch, clearly not a small job.
If I could I would really like to use the Linux source code, but I'm unsure if such a thing is really viable. Does anyone have any advice or ideas on the best way to proceed with this task?

Resources