Need to develop a Device Driver, which when installed on a system would create multiple Virtual serial port - wdf

This is my first Windows device driver and I have been assigned a task to develop a Windows device driver from scratch. When the user installs this driver on a windows PC it would ask the user, during the installation process, to enter the number of virtual serial port that user requires & after installation of the driver the number of virtual port desired by the user shall be created. Then the user connects his customized printer to the windows PC via USB port. The user should be able to send data to the printer through the Hyper terminal by selecting any of the newly created Virtual serial port at 9600 baud rate, 8 data bit, No parity and 1 stop bit.
Now to get started I am using a windows 7 system on which I have installed Visual Studio 2015 along with Windows Driver Kit 10 form the MSDN website. I have also downloaded the Windows drivers sample codes form the GITHUB this sample soce base contains a virtualSerial UMDF project under serial/Svirtualserial2. This project file contained 2 projects one being the Virtualserial2 project and the other is a FakeModem project so I deleted the FakeModem project (as its was of no use for me) and successfully compiled the source/VirtualSerial2 sample code. after compilation a .dll (as UDMF drivers have .dll extensions) file gets generated in the debug folded but I don't get any .exe for this driver so I am not sure how can I install this driver on my system.
I was also going through this link https://msdn.microsoft.com/en-in/library/windows/hardware/dn745911%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396 that list the process to debug a UMDF driver using WinDbg, in an example it also asks us to run the .exe so my first question is how do I need to generate a .exe file of my driver & test it on a system.
Along with this I have one more query. after I install my driver on the target system (Windows 7 32 bit I need to link it to the hyper terminal). So that I will be able to send the Commands & data to my printer through the hyper terminal and my driver will be responsible to take the data from the hyper terminal and send it to my printer through USB. How can I do that?
Am I going in the right direction?

Related

Custom KMDF driver installed but not in driver list

I'm attempting to build/install a "custom" KMDF driver (really it’s just the KMDF template in Visual Studio as is). My goal is to take a PCIe device in the device manager and update its driver to my new custom driver.
I build the KMDF template, generate an *.inf, right click and install, and I get a message saying that the operation completed.
I then go to Device Manager, right click my PCIe card, Update Driver, Browse for Drivers, Let me pick from a list, show all devices, and at this point I would expect to see "Your Manufacturer Name" in the list, but I don't. I tried changing the "ManufacturerName" in my *.inf file in Visual Studio to a unique name, but I still don't see it in the list.
Also, I'm not seeing any relevant driver information with "driverquery /V"
What do I need to do to make my custom driver appear in the list such that I can "assign" it to the hardware device?
I think the problem was that I had my configuration build set to x86 instead of x64, and I'm on an x64 machine. I changed it, and now it's working.

usbser.sys on Windows 7 Embedded, installed but not found

I've installed a barcode reader on a Windows 7 machine: it is configurated with virtual serial port mode.
At the initial moment the driver was not found; looking in the Windows folders I did not find the usbser.sys file.
So I installed the following package:
pkgmgr /ip /m:winemb-inf-mdmcpq.cab
Looking in the Windows folders now I find the usbser.sys in a couple of locations such as System32\DriverStore\FileRepository... and winsxs... folders.
Still the driver for the barcode reader is not found.
I took a look inside the device and it has as compatible IDs:
USB\Class_02&SubClass_02&Prot_01
USB\Class_02&SubClass_02
USB\Class_02
Is it not sufficient to try to locate the usbser.sys driver?
I solved writing a inf file where I specified the USB VID and PID of the device.
In this way the serial driver was loaded and a port number was assigned.

How To Qt Creator Embedded use PSQL

I'm trying to use connection to postgres with Qt Creator for embedded device with the Raspberry Pi 3, however the driver is not loaded. The same application on the desktop is ok.
My example is quite simple.
I have a console project with a main class and in it a log with
QSqlDatabase::drivers();
In raspberry list only QSQLITE, and desktop list QSQLITE, QPSQL, QMYSQL among others.
I am using oQt Creator Enterprise, connecting to the device with Boot2Qt, that comes with Qt Creator, compilation and execution is everything correctly, however is not listed PSQL driver in device.
QSqlDatabase::drivers() lists only the drivers that can be loaded on that particular platform, in many cases to have a working driver you need the Qt driver and a specific client library.
Probably there is a postgresql client library for raspberry with your specific linux version somewhere but Boot2Qt does not load it automatically to your board.
You have to find the client library for your specific version of linux (maybe you will have to compile it) then manually copy the postgresql Qt driver onto the board and the QSqlDatabase::drivers() should show you the postgresql driver available.

DummyNet error NDIS drivers install on Windows 7 x64

I've download the current version of DummyNet and according to readme I'm following these steps:
Windows: INSTALL THE NDIS DRIVER
open the configuration panel for the network card in use
(right click on the icon on the SYSTRAY, or go to
Control Panel -> Network and select one card)
click on Properties->Install->Service->Add
click on 'Driver Disk' and select 'netipfw.inf' in this folder
select 'ipfw+dummynet' which is the only service you should see
click accept on the warnings for the installation of an unknown
driver (roughly twice per existing network card)
But when I select 'netipfw.inf' and click OK the system return an error (unable to find any drivers for this device).
Note that I've previously disabled the check control for digital signature typing on Start->Exec the following command:
bcdedit /set nointegritychecks ON
and reeboting the system.
I need to be able to solve this issue because when I try to execute some dummynet command the system returns:
my_socket failed 2, cannot talk to kernel module
ipfw: socket
My network card is a NVIDIA nForce integrated on my mother board Asus Striker II.
Have you any idea to solve the problem? Thanks.
I was able to get this working using Windows 7 x64.
Download DummyNet.
Move the files from ipfw3-2012\binary64 to ipfw3-2012\binary, choose
Move and Replace
Install the driver using instruction in ipfw3-2012\binary\README.txt.
Note I had to reboot with Disable Driver Signature Enforcement as detailed
here before I could install the driver. Should look like this
Dummynet is a 32bit NDIS driver, if you look through the source at: http://info.iet.unipi.it/~luigi/dummynet you can see that the ipfw folder only has exports from ws2_32.dll
You would need to port the driver to x64 to get it to work.
Try running the command prompt as Administrator. For example, open the start menu, find command prompt, right click it and hit "run as administrator" this is likely your issue. It is similar to trying to run this on MacOS and not using the "sudo" command. If this doesn't solve your problem I would be concerned that it was because you are on 64bit and I don't believe Dummynet is compatible on that architecture yet.

Sysinternals' Portmon: Error 2

When I try to connect to local ports, Computer -> Connect local, using Portmon v. 3.02, I'm getting an error message, Error 2, in a small error dialog box:
I run the tool as an administrator (if not, I get error 6).
By the way this is a Windows 7 x64. On 32-bit, in Windows 7 x86, it works fine. How can I fix this problem?
Sysinternals' Portmon works only on 32-bit versions of Windows. It does not support 64-bit (probably its driver is not signed).
From the Portmon homepage:
Runs on:
Client: Windows XP (32-bit) and higher (32-bit).
Server: Windows Server 2003 (32-bit) and higher (32-bit).
In Windows Explorer, right click on portmon.exe --> select Properties --> click the Compatibility tab, and Run in Windows XP compatibility mode. It works fine like that in Windows 7 64-bit.
"Error 2" is "Cannot find the file specified", that is, cannot find a required DLL file.
Originally, you got this error when you tried to run Portmon from a network location: that broke the security trust, causing Portmon to be untrusted (or perhaps just messing up the search path somehow).
On my copy of Windows 7 64 bit, Microsoft Dependency Walker (depends.exe) tells me that PORTMSYS.SYS (the file created/loaded by Portmon.exe), has unresolved dependencies on ci.dll, clfs.sys, hal.dll and kdcom.dll.
Those are the
code integrity
common log file system
hardware abstraction layer
kernel debugger com
libraries, and they aren't actually missing: if they were, Windows wouldn't boot. However, I don't see a copy of those files in SysWow64. This suggests to me that the problem is not with portman.sys: the problem is with the win32 compatibility layer in Windows 7/64 bit: It doesn't support debug properly.
It is now 2018. There is no 64-bit version of Portmon. Serial ports are a legacy standard. The Windows 7 problem was fixed by the release of Windows 8.1. However, there is a faint chance that some Visual Studio utility or security update back-ported to Windows 7 will fix the problem. Perhaps someone who is familiar with SysWow and debugging will comment.
Instead of portmon for Windows x64, you can use an emulator of a pair of virtual COM ports and a simple program that will connect the physical port and one of the virtual ones, as well as perform the logging function.
To create a pair of virtual COM ports you can use:
com0com (preferably version "com0com-2.2.2.0-x64-fre-signed", because it contains signed x64 driver)
Virtual Serial Ports Emulator (VSPE), every time it starts on x64 it asks to purchase a driver, but it works even if you refuse.
Simple mapping and logging program can be found e.g. here or you can write it yourself, it is simple.
The sequence of actions is follows:
Сreate a pair of virtual COM ports using emulator (for example, COM28 and COM29)
Let the external device be connected to the computer COM1 port. In the program, whose exchange with external device we want to listen to, we set up a port COM28 (instead of СОМ1) for communication.
In the mapping program, we set up that we want to bind and log ports COM1 and COM29 (don't forget to set the port baud rate).
I haven't tried it yet, but this question mentions com0com. It creates two virtual serial ports and emulates a null modem cable between them. It claims to be able to run on 64 bit Windows. I'm not sure whether it comes with software that lets you just pipe input from a real port into one of the virtual ports. One of the FAQ's says that you can turn on logging.
I guess in the worst case, you could write your own small program that pipes data from a real port to one of the virtual ports and logs it all.
There's also this question on open-source alternatives that mentions a couple of projects.
I've used AccessPort
http://sudt.com/en/ap/download.htm and it works great. Very similar to Portmon
Don't start Portmon from a network drive/path or something else.
Copy on to the hard disk drive, e.g. on the desktop, restart and try again!
If you run Portmon in compatibility mode, it will work.
Check Make older programs run in this version of Windows.
It says:
To run the Program Compatibility troubleshooter:
Open the Program Compatibility troubleshooter by clicking the Start button Picture of the Start button, and then clicking Control Panel. In the search box, type troubleshooter, and then click Troubleshooting. Under Programs, click Run programs made for previous versions of Windows.
Follow the instructions in the troubleshooter.
The above is a public explanation from Microsoft for a common situation when running older applications in Windows.
But, I can say it briefly;
Right click on portmon.exe
Select menu about "troubleshooting compatibility problem" or something like that (I'm using a foreign version of Windows, so I don't see correct name of that menu in English.)
Select automatic mode
It will detect the problem and recommend Windows XP (SP2) mode
Select it and execute Portmon again.
I hope it works!
Instead of Portmon you can also use the IO Ninja program with the "Serial Monitor" plugin.
It gives a little less information than Portmon, but in a more understandable form. The main thing is, just like a Portmon, it allows you to see the data that is transmitted between a third-party application and an external device via a serial port. The program works under modern versions of Windows (I tried it myself on Windows 10 x64). The aforementioned plugin "Serial Monitor" is paid (but has an evaluation period).
Note: the port that you want to monitor must first be connected to the "IO Ninja" program, and then opened in a third-party application whose exchange with an external device you want to track.
Just to test that the hardware is working, you could perhaps boot a Linux live CD and run the statserial and/or minicom program to verify that it works. The Knoppix distribution seems to contain both those programs.
Serial ports on Linux are named /dev/ttyS0 for COM1, /dev/ttyS1 for COM2, etc.

Resources