I want to create a virtual printer driver for Windows. How and where can I start properly? The WDK has some printing drivers examples that do not seems a good introductory. MSDN also doesn't seems to be very helpful for a novice.
There are a lot of virtual printers for Windows out there (mostly they generate PDFs), I wonder if someone could tell my how can I do the same?
Any links to the elaborating documentations are appreciated in advance.
Thanks.
When I did it (which about 12 years ago) I started with the postscript driver sample, replaced all the postscript-specific stuff (in my case, to write to a bitmap instead of generating postscript commands).
I also wrote a custom print monitor (the driver writes to the spooler, which write to a monitor): my monitor wrote to a file instead of e.g. to the parallel port.
However, printer driver architecture and/or the set of sample drivers may have changed since then.
You can look to the 'minidriver' development in the from Microsoft (Microsoft MDT), that might help depending on your exact needs. If the port you need to deal with (ie: you are going to take the data from an existing printer driver and want to process) you could look to the source code for RedMon. It doesn't support Vista/Win7 but might point you in the right direction.
This book maybe help you Developing Drivers with the Windows® Driver Foundation
A list of my links
http://www.codeproject.com/KB/system/driverdev.aspx
http://www.microsoft.com/whdc/ddk/winddk.mspx
http://jungo.com/wdusb.html
https://web.archive.org/web/20130717135254/https://msdn.microsoft.com/en-us/library/ff554651.aspx
http://channel9.msdn.com/posts/Rory/Driver-Development-and-Much-More-With-Mike-Calligaro/
One of the drivers you mention is open-source (GPL), maybe you could explore its source or adapt it: http://www.pdfforge.org/products/pdfcreator/download
Someone else already mentioned PDFCreator. Here's a more specific link to their code that's creating the printer, port and monitor. Despite being in VB, I can follow it as someone more used to C++, so I guess you can too. modPrinter.bas does the leg work. modMain.bas, from about line 28 onwards, calls into modPrinter.bas.
Create a Print Port Monitor, associate that port with a printer, and you'll get the data the printer driver sends to the port.
working example of how is it done in Cpp and java can be found here:
http://www.mms-computing.co.uk/uk/co/mmscomputing/device/printmonitor/index.php
Related
I'm having some difficulties writing a kernel mode driver on debian wheezy for a custom touch screen, that has driver only for windows. My main problem is, that I have absolutely no experience in driver programming, apart from the tutorial write-to-system-log module I've found on the internet. Also, I have some more specific problems as can be seen below.
Hardware structure:
The touch screen itself is connected to a microcontroller, that connects through serial port to the computer. I've managed to initialize the controller from user-space program connecting through ttyS0, and recieve raw data from the touch screen, but I just couldn't manage to get started from kernel space.
I've looked around in drivers/input/touchscreen/, opened a few .c files, so maybe I could find out, how to start at least, but I'm pretty stuck around here, because I can't substitute some values to match my hardware. In linux/serio.h there is a long list of defines for serio protocols, that for example elo touch screen's driver is using:
#define SERIO_ELO 0x29
Is there any kind of documentation about these values, their meanings, or how they are interpreted?
Are there any books or websites, from which I could learn more about this topic? For now, this is a really dark spot for me.
I don't intend to ask for a full solution, but I'd really appreciate some examples or tutorials regarding serial communicaton and/or touch event gerenation in kernel mode.
Thanks in advance for your help.
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 ?
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.
There was a smbmrx sample code using RDBSS in WDK Vista.
But since WDK 7600 has been released, the sample was removed. -Do you know why?
I'm finding a nice sample code to learn RDBSS.
Is there a good open source better than smbmrx sample?
It was probably removed because it was getting long in the tooth. It was never the full SMB redirector implementation shipped with Windows, it was some subset of the original version. It also uses TDI which is being deprecated in newer Windows in favor of WSK.
I don't know of any good open source examples. A network redirector is a complicated piece of software to write and there's value there for anyone brave enough to go for it. Why do you need this?
-scott
I need to create a driver that presents itself to Windows as a video capture driver. The driver generates the video itself. How would I go about doing this? And please keep in mind that I'm using Visual C++ Express.
See this :
Virtual WebCam Driver
I'm not sure you can do this with a UMD, so you'll likely need to install the WDK. You probably all ready know this, but writing a driver is a huge undertaking so you should be prepared for that.
Here's a link on writing Windows drivers from MSDN. I'd also suggest you pick up a copy of the Windows Internals book, and check out OSR (and take a class if you can!).
Hope that helps you get started!
I am working with a peripheral device that needs to be communicated through serial. I can send it commands using HyperTerminal, but now I need to write programs that will let me do it without HyperTerminal. Can somebody point me to a website and/or show me a sample hello world program to get me started? I have searched through many sites which give me uncompilable/ancient VC6 code.
In order to interface with the serial port, you open a file with one of the special filenames "COM1" through "COM9". For serial ports with higher numbers, the special filename begins with \\?\, which in C/C++ code must be escaped as "\\\\?\\COM10", etc.
http://msdn.microsoft.com/en-us/library/ms810467.aspx has a really good tutorial on using the serial port. Note that you should use the Windows file I/O functions such as CreateFile(), ReadFile(), and WriteFile(). I'm not sure if it will work to use standard I/O functions such as fopen(), fread(), and fwrite().
Microsoft provides an article with sample code describing how to do this under Win32.
Boost:asio may be able to help as a serial device was added recently.
Fair warning though; the serial port documentation is light, presumably since it's quite new (it was added in asio 1.1.1 which was included in boost 1.36).
But working your way through asio is, IMHO, a better solution than using the raw Win32 API. Why? It'll be easier to read and maintain (it's a higher level API) and it'll be cross platform (except where you need to specify the OS-specific device name).
The Boost - Users and asio.user mailing lists are quite active and friendly and ought to be able to help you out if you get stuck.
If using .NET 2.0 see System.IO.Ports and this article should be helpful. If direct Win32, then Adam's answer is best.
I believe you will find plenty of sample code for C# as well if you find VC6 too ancient. I think there are also a bunch of "free" serial/COM port wrappers but I just wrote my own when I wrote an RS232 device controller piece of software.
google C# and serial port or rs232
I got these:
http://msdn.microsoft.com/en-us/library/system.io.ports.serialport.aspx
http://msmvps.com/blogs/coad/archive/2005/03/23/SerialPort-_2800_RS_2D00_232-Serial-COM-Port_2900_-in-C_2300_-.NET.aspx
You should have no problem finding suitable code with a google search.