Vb6 Serial Port Sniffer Source Code
Introduction First of all excuse my English since it is not my native language and this is my first article. In this article, I'd like to share 'what I know' about how to monitor serial ports. Please note that this is about 'what I know' and I could be wrong about what I understand about driver programming, specially in this article. If you find out that I am wrong, please let me know and we can discuss it further. So, what is a serial port monitor? Well, I believe you know what it is.
Jun 26, 2014 Download Serial line sniffer for free. Serial line sniffer (slsnif). Slsnif is a serial port logging utility. Serial line sniffer (slsnif). Slsnif is a serial port logging utility. It listens to the specified serial port and logs all data going through this port in both directions. And after changing just two lines of code I. Read or Scan Barcodes with this few line of codes. No (API/OCX/DLL) required. This works well with barcode scanner/reader connected to serial comm1 port.
The basic idea of this serial port monitor is: create a system driver and then add the filter driver functionality to it. Okay, let's get on to the detail. System driver As you can see in the source, this is just a system driver (without real hardware) and it implements minimal dispatch functions for the system driver. If you want to see the requirements of a system driver, please take a look at MSDN. In this driver, I simply forward an IRP sent to this driver to the lower level driver as the default handler and use 'standard PnP and Power dispatch handling' as the WDK suggest.
American pie 2 hindi movie. This driver also handles open, clean up, close, read, and control request, plus handles some requests as a serial port driver IRP handler requirement in WDK (Window Driver Kits). Attach to and detach from target device When a client application sends an IO control request to attach to a target device, IOCTL_DKPORTMON_ATTACH_DEVICE with a string parameter of the serial port name, the driver does this: • Driver gets the top of the target device object identified by the string parameter in the IOCTL_DKPORTMON_ATTACH_DEVICE request with IoGetDeviceObjectPointer().
This routine will fill a pointer to the device object variable we provide if successful. • The driver then creates a new device object characteristic of the device object we get from IoGetDeviceObjectPointer() and the 0 size of the device extension. • After that, the driver copies the flags from the device object created by IoGetDeviceObjectPointer() and puts some 'additional flags' if any. • Attaches to the device object we just created with the IoAttachDeviceToDeviceStack() function and then sets up initialization flags.
And the code for attaching device (you can see the details in the function DkCreateAndAttachDevice() in the file DkIoExt.c). Extern PDEVICE_OBJECT g_pThisDevObj. NTSTATUS DkCreateClose(PDEVICE_OBJECT pDevObj, PIRP pIrp) {.
If (pDevObj!= g_pThisDevObj) return DkTgtCreateClose(pDevExt, pIrp). Handling an IO request that is coming to our device object Before we discuss further about handling requests, I'd like to say a little bit about the queue in this driver. This driver uses two kinds of queues, one for handling an IRP (Cancel-Safe queue as WDK suggested) and another for collecting data (simple First In First Out data queue / FIFO data queue). We discuss how we collect data later in the next section. Our driver handles open ( IRP_MJ_CREATE), close ( IRP_MJ_CLOSE), clean up ( IRP_MJ_CLEANUP), read ( IRP_MJ_READ), and control ( IOCTL_DKPORTMON_ATTACH_DEVICE and IOCTL_DKPORTMON_DEATCH_DEVICE) requests.
As you can see in the source, open, close, and clean up requests are handled in the same dispatch routine, that is DkCreateClose(). For open request, we just initialize our FIFO data queue, complete the request with STATUS_SUCCESS, and returns STATUS_SUCCESS. For clean up request, we detach the device (if any, as the detach function state), clean the data queue and Cancel-Safe queue, and then complete the request. For close request, it just 'accepts' it, completes the request, and returns STATUS_SUCCESS. When we receive a read request from the client application program, we retrieve data from FIFO data queue.
If there is data, we copy it to the system buffer which 'represents' the user buffer, and then remove/destroy/delete/free it, and then complete the request with STATUS_SUCCESS and with the size of data we get from the FIFO data queue. If there is no data present in the FIFO data queue, we queue the IRP to Cancel-Safe queue then return a pending status, and indicate that the IRP is queued and will be completed later by another function in this driver ( DkTgtCompletePendedIrp() function). This is the code fragment in file DkIoReq.c, in function DkReadWrite(). As you can see, IRP_MJ_WRITE comes just after IRP_MJ_CREATE. This is because this port monitor does not monitor 'IRP state'. It collects data after/before the driver forwards the request, as we discussed in the previous subsection about collecting data above.