10

I want to write something like DaemonTools: a software that presents itself to the system as a real device (a DVD-ROM in the previous example) but it reads the data from a file instead. My requirement is not limited to DVD-ROM. The first goal is a joystick/gamepad for Windows.

I'm a web developer, so I don't know from where I could start such a project. I believe it will have to be written in C/C++, but other than that, I have no clue where to start.

Did anyone tried something like this and can give me some starting tips ?

Nicu Surdu
  • 8,172
  • 9
  • 68
  • 108
  • How would you use a gamepad in this way, surely once you had loaded your gaming application etc you would no longer have any focus set or control with the virtual (as I understand it) gamepad? – Matt Donnan Jan 19 '12 at 10:29
  • What if you control the "gamepad" from another machine via lan/internet/TCP ? – Nicu Surdu Jan 19 '12 at 10:58
  • In theory that should be possible, however the main reason for developing virtual solutions is to save on the hardware cost of the product etc, in this case however you wouldn't need to buy a gamepad but would need to buy another pc to run it on if you didn't already have one. I appreciate this is just a project but it's worth thinking about how the implementation will work before spending hours coding it : ) – Matt Donnan Jan 20 '12 at 11:36

1 Answers1

16

Most drivers are written in either C or C++, so if you don't know those languages reasonably well, you'll want to get familiar with them before you start. Windows programming uses a lot of interesting shortcuts that might be confusing to a beginner - for example PVOIDs (typedef void* PVOID) and LPVOIDs (typedef void* far LPVOD;). You'll need to be happy with pointers as concepts as well as structures because you'll be using a lot of them. I'd suggest writing a really straightforward win32 app as an exercise in getting to grips with the Windows style of doing C/C++.

Your next port of call then is to navigate the Windows Driver Kit - specifically, you'll need it to build drivers for Windows. At this stage my ability to advise really depends on what you're doing and the hardware you have available etc, or whether or not you're really using hardware. You'll need to know how to drive your hardware and from there you'll need to choose an appropriate way of writing a driver - there are several different types of driver depending on what you need to achieve and it might be you can plug into one of these.

The windows driver kit contains quite a large number of samples, including a driver that implements a virtual toaster. These should provide you with starting points.

I strongly suggest you do the testing of this in a virtual machine. If your driver successfully builds, but causes a runtime error, the result could well crash windows entirely if you're in kernel-mode. You will therefore save yourself some pain by being able to revert the virtual machine if you damage it, as well as not having to wait on your system restarting. It'll also make debugging easier as virtual serial cables can be used.


This is quite a big undertaking, so before you start, I'd research Windows development more thoroughly - check you can't do it using the Windows APIs first, then have a look at the user-mode driver framework, then finally and only if you need to, look at the kernel level stuff.

Community
  • 1
  • 1
  • 4
    +1 a lot of answers to questions like this are "don't". Even though doing this may be inadvisable, your answer was very informative. – John Dood Jul 05 '16 at 16:29
  • 2
    Thanks for mentioning the microsoft driver sample virtual toaster where I found a program plug.exe that creates a phantom device but I can't find its source code (https://github.com/microsoft/Windows-driver-samples/tree/master/general/WinHEC%202017%20Lab/PlugInToaster). Does anyone know how to create a phantom device? – Juan Rojas Mar 12 '20 at 15:47