Click here to Skip to main content
Click here to Skip to main content

A simple demo for WDM Driver development

By , 25 Oct 2004
 
Prize winner in Competition "MFC/C++ Sep 2004"

Introduction

A lot of articles have been investigating in application layer issues, like skin-based dialogs, MFC, ATL, thread, process, registry etc. It won't be easy to find any driver related articles posted with full source code. The root cause is that most drivers are developed for specific hardware. Without the domain knowledge, you will never want to get in touch with it. I believe a lot of software engineers are afraid when they involve in kernel mode programming for the very first time, and there are not too much resources that can guide them through the whole process from DDK study to program stage. Hence I decided to share some of my experiences in driver programming in Windows. This demo focuses on a quick introduction to WDM Driver's architecture, and will introduce two I/O modes coming with Windows, which are Direct I/O and Buffered I/O, how to communicate with drivers residing in system kernel space, and read/write data to it.

There is no need for you to read the demo program with any hardware related background, the demo drivers are all pseudo drivers. That's drivers installed without a physical device in computer.

The member functions defined in this demo program can be used as templates for later driver development by you.

Background

You might be a well-experienced software engineer and might want to involve in kernel programming.

Create your WDM Driver: a Pseudo Driver tutorial

Before we start, declaration for member routines and structures is required. The most important driver-required data structure is - DEVICE_EXTENSION!

typedef struct tagDEVICE_EXTENSION {
    PDEVICE_OBJECT DeviceObject;       // device object this driver creates
    PDEVICE_OBJECT NextDeviceObject;   // next-layered device object in this
                                       // device stack
    DEVICE_CAPABILITIES pdc;           // device capability
    IO_REMOVE_LOCK RemoveLock;         // removal control locking structure
    LONG handles;                      // # open handles
    PVOID DataBuffer;                  // Internal Buffer for Read/Write I/O
    UNICODE_STRING Device_Description; // Device Description
    SYSTEM_POWER_STATE SysPwrState;    // Current System Power State
    DEVICE_POWER_STATE DevPwrState;    // Current Device Power State
    PIRP PowerIrp;                     // Current Handling Power-Related IRP
} DEVICE_EXTENSION, *PDEVICE_EXTENSION;

Code segment below demonstrates the start of creating a valid WDM Driver.

There are mandatory and optional members in a WDM Driver. A valid WDM Driver should come with the following member routines, the most important task item for DriverEntry is to register all member routines to kernel:

//
NTSTATUS
DriverEntry( 
IN PDRIVER_OBJECT DriverObject, 
IN PUNICODE_STRING RegistryPath 
)
{
RtlInitUnicodeString(
&Global_sz_Drv_RegInfo,
RegistryPath->Buffer);

// Initialize function pointers

DriverObject->DriverUnload = DriverUnload;
DriverObject->DriverExtension->AddDevice = AddDevice;

DriverObject->MajorFunction[IRP_MJ_CREATE] = PsdoDispatchCreate;
DriverObject->MajorFunction[IRP_MJ_CLOSE] = PsdoDispatchClose;
DriverObject->MajorFunction[IRP_MJ_READ] = PsdoDispatchRead;
DriverObject->MajorFunction[IRP_MJ_WRITE] = PsdoDispatchWrite;
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = PsdoDispatchDeviceControl;
DriverObject->MajorFunction[IRP_MJ_POWER] = PsdoDispatchPower;
DriverObject->MajorFunction[IRP_MJ_PNP] = PsdoDispatchPnP;

return STATUS_SUCCESS;
}
//

Normal operation workflow within WDM Driver

Code segment below demonstrates the workflow in AddDevice routine: the most important task for AddDevice routine is to create a Device object, and attach it to the existing device stack.

NTSTATUS
AddDevice(
IN PDRIVER_OBJECT DriverObject,
IN PDEVICE_OBJECT PhysicalDeviceObject 
)
{
    ULONG DeviceExtensionSize;
    PDEVICE_EXTENSION p_DVCEXT;
    PDEVICE_OBJECT ptr_PDO;
    NTSTATUS status;

    RtlInitUnicodeString(
        &Global_sz_DeviceName, L"");
    //Get DEVICE_EXTENSION required memory space
    DeviceExtensionSize = sizeof(DEVICE_EXTENSION);
    //Create Device Object
    status = IoCreateDevice(
        DriverObject,
        DeviceExtensionSize,
        &Global_sz_DeviceName,
        FILE_DEVICE_UNKNOWN,
        FILE_DEVICE_SECURE_OPEN, 
        FALSE,
        &ptr_PDO
        );

    if (NT_SUCCESS(status)) {
        ptr_PDO->Flags &= ~DO_DEVICE_INITIALIZING;
<FONT color=#ff0000>        ptr_PDO->Flags |= DO_BUFFERED_IO;  //For Buffered I/O
        //ptr_PDO->Flags |= DO_DIRECT_IO;  //For Direct I/O</FONT>
        p_DVCEXT = ptr_PDO->DeviceExtension;
        p_DVCEXT->DeviceObject = ptr_PDO;
        RtlInitUnicodeString(

        /*
        //Other initialization tasks go here
        */

        //Store next-layered device object
        //Attach device object to device stack
        p_DVCEXT->NextDeviceObject = 
            IoAttachDeviceToDeviceStack(ptr_PDO, PhysicalDeviceObject);
    }

    return status;
}

Code segment below shows how to support IRP_MJ_CREATE, it is send when client application tries to connect to the underlying Pseudo Driver. Before proceeding, see graph below in advance to realize the connection process.

Usually, you will use CreateFile/fopen Win32 API to connect to the underlying device. It is the right time that Win32 Subsystem submits IRP_MJ_CREATE and asks driver to connect to the target device!

NTSTATUS
PsdoDispatchCreate(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp
)
{
    PIO_STACK_LOCATION p_IO_STK;
    PDEVICE_EXTENSION p_DVCEXT;
    NTSTATUS status;

    p_IO_STK = IoGetCurrentIrpStackLocation(Irp);
    p_DVCEXT = DeviceObject->DeviceExtension;
    status = IoAcquireRemoveLock(&p_DVCEXT->RemoveLock, p_IO_STK->FileObject);
    if (NT_SUCCESS(status)) {
        CompleteRequest(Irp, STATUS_SUCCESS, 0);
        return STATUS_SUCCESS;
    } else {
        IoReleaseRemoveLock(&p_DVCEXT->RemoveLock, p_IO_STK->FileObject);
        CompleteRequest(Irp, status, 0);
        return status;
    }
}

Code segment below shows how to support IRP_MJ_CLOSE, the IRP is sent when client application tries to close connection to the underlying Pseudo Driver. Before proceeding, see graph below in advance to realize the closing process.

Usually, you will use CloseHandle/fclose Win32 API to close connection to the underlying device. It is the right time that Win32 Subsystem submits IRP_MJ_CLOSE and asks driver to close connection to target device!

NTSTATUS
PsdoDispatchClose(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp
)
{
    PIO_STACK_LOCATION p_IO_STK;
    PDEVICE_EXTENSION p_DVCEXT;

    p_IO_STK = IoGetCurrentIrpStackLocation(Irp);
    p_DVCEXT = DeviceObject->DeviceExtension;
    IoReleaseRemoveLock(&p_DVCEXT->RemoveLock, 
    p_IO_STK->FileObject);
    CompleteRequest(Irp, STATUS_SUCCESS, 0);
    return STATUS_SUCCESS;
}

I/O Support : Buffered I/O Mode

There are three I/O modes in Windows kernel, they are Buffer, Direct and Neither modes. Now, we'll talk about Buffered I/O, and this article will not involve Neither mode for data transfer if processing under user-thread occupied memory space, it might be dangerous!! If client application is going to read/write data to and from driver, the memory address of data source will not be directly referenced by the underlying driver. System kernel will allocate another data buffer with equivalent size in kernel. All data transferred must be copied into this area before they are to the target place. Usually, you will call ReadFile/WriteFile or fread/fwrite to make read/write request.

Below code segment demos the workflow in I/O handle for read request. As we can see, the routine that is registered for reading is PsdoDispatchRead in DriverEntry, this member routine will read data out of Driver's internal member - DataBuffer to client application:

NTSTATUS
PsdoDispatchRead(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp
)
{
    PVOID Buf; //Buffer provided by user program
    ULONG BufLen; //Buffer length for user provided buffer
    LONGLONG Offset;//Buffer Offset
    PVOID DataBuf; //Buffer provided by Driver
    ULONG DataLen; //Buffer length for Driver Data Buffer
    ULONG ByteTransferred;
    PIO_STACK_LOCATION p_IO_STK;
    PDEVICE_EXTENSION p_DVCEXT;

    DbgPrint("IRP_MJ_READ : Begin\r\n");
    //Get I/o Stack Location & Device Extension
    p_IO_STK = IoGetCurrentIrpStackLocation(Irp);
    p_DVCEXT = DeviceObject->DeviceExtension;

    //Get User Output Buffer & Length 
    BufLen = p_IO_STK->Parameters.Read.Length;
    Offset = p_IO_STK->Parameters.Read.ByteOffset.QuadPart;
    Buf = (PUCHAR)(Irp->AssociatedIrp.SystemBuffer) + Offset;

    //Get Driver Data Buffer & Length
    DataBuf = p_DVCEXT->DataBuffer;
    if (DataBuf == NULL)
        DataLen = 0;
    else
        DataLen = 1024;

    IoAcquireRemoveLock(&p_DVCEXT->RemoveLock, Irp);

    DbgPrint("Output Buffer Length : %d\r\n", BufLen);
    DbgPrint("Driver Data Length : %d\r\n", DataLen);
    //
    if (BufLen <= DataLen) {
        ByteTransferred = BufLen; 
    } else {
        ByteTransferred = DataLen;
    }

    RtlCopyMemory(
        Buf, DataBuf, 
        ByteTransferred);

    IoReleaseRemoveLock(&p_DVCEXT->RemoveLock, Irp);
    CompleteRequest(Irp, STATUS_SUCCESS, ByteTransferred);

    DbgPrint("IRP_MJ_READ : End\r\n");
    return STATUS_SUCCESS;
}

Below code segment demos the possible task items in workflow that can support the normal I/O requests to write data from application to driver.

NTSTATUS
PsdoDispatchWrite(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp
)
{
    PVOID Buf; //Buffer provided by user program
    ULONG BufLen; //Buffer length for user provided buffer
    LONGLONG Offset;//Buffer Offset
    PVOID DataBuf; //Buffer provided by Driver
    ULONG DataLen; //Buffer length for Driver Data Buffer
    ULONG ByteTransferred;
    PIO_STACK_LOCATION p_IO_STK;
    PDEVICE_EXTENSION p_DVCEXT;
    NTSTATUS status;

    DbgPrint("IRP_MJ_WRITE : Begin\r\n");

    //Get I/o Stack Location & Device Extension
    p_IO_STK = IoGetCurrentIrpStackLocation(Irp);
    p_DVCEXT = DeviceObject->DeviceExtension;

    //Get User Input Buffer & Length 
    BufLen = p_IO_STK->Parameters.Write.Length;
    Offset = p_IO_STK->Parameters.Read.ByteOffset.QuadPart;
    Buf = (PUCHAR)(Irp->AssociatedIrp.SystemBuffer) + Offset;

    //Get Driver Data Buffer & Length
    DataBuf = p_DVCEXT->DataBuffer;
    DataLen = 1024;

    IoAcquireRemoveLock(&p_DVCEXT->RemoveLock, Irp);

    DbgPrint("Input Buffer Length : %d\r\n", BufLen);
    DbgPrint("Driver Data Length : %d\r\n", DataLen);

    if (BufLen <= DataLen) {
        ByteTransferred = BufLen; 
    } else {
        ByteTransferred = DataLen;
    }

    ByteTransferred = BufLen;
        RtlZeroMemory(
        p_DVCEXT->DataBuffer,
        1024);

    RtlCopyMemory(
        DataBuf,
        Buf, 
        ByteTransferred);

    IoReleaseRemoveLock(&p_DVCEXT->RemoveLock, Irp);
    CompleteRequest(Irp, STATUS_SUCCESS, ByteTransferred);

    DbgPrint("IRP_MJ_WRITE : End\r\n");
    return STATUS_SUCCESS;
}

I/O Support : Direct I/O Mode

Below graph exhibits how Direct I/O mode is supported when data is transferred between client application and driver. Under Direct I/O mode, Memory Manager will create MDL (Memory Descriptor List) to reference the physical address taken by user-provided buffer, all data can be directly referenced via MDL from kernel environment.

In DDK, some MMXxx routines are provided to help you to get MDL that maps to physical address of user-provided buffer.

Below code segment contains the statements that can support data reading under Direct I/O mode. It is achieved by Mmxxx routine, please read it carefully, and you can also find the full code in the zip file. The most important MmXxx you will use in this mode should be - MmGetSystemAddressForMdlSafe, it can obtain the MDL that references the physical address of user-buffer.

NTSTATUS
PsdoDispatchRead(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp
)
{
    PVOID Buf; //Buffer provided by user program
    ULONG BufLen; //Buffer length for user provided buffer
    ULONG Offset;//Buffer Offset
    PVOID DataBuf; //Buffer provided by Driver
    ULONG DataLen; //Buffer length for Driver Data Buffer
    ULONG ByteTransferred;
    PIO_STACK_LOCATION p_IO_STK;
    PDEVICE_EXTENSION p_DVCEXT;

    DbgPrint("IRP_MJ_READ : Begin\r\n");
    //Get I/o Stack Location & Device Extension
    p_IO_STK = IoGetCurrentIrpStackLocation(Irp);
    p_DVCEXT = DeviceObject->DeviceExtension;

    //Get User Output Buffer & Length 
    Buf = MmGetSystemAddressForMdlSafe(
        Irp->MdlAddress, HighPagePriority);

    if (Buf == NULL) {
        DbgPrint("Can't get Virtual Address from MDL\r\n");
        return STATUS_INSUFFICIENT_RESOURCES;
    }
    BufLen = MmGetMdlByteCount(Irp->MdlAddress);
    Offset = MmGetMdlByteOffset(Irp->MdlAddress);

    //Get Driver Data Buffer & Length
    DataBuf = p_DVCEXT->DataBuffer;
    if (DataBuf == NULL)
        DataLen = 0;
    else
        DataLen = 1024;

    IoAcquireRemoveLock(&p_DVCEXT->RemoveLock, Irp);

    DbgPrint("Output Buffer Length : %d\r\n", BufLen);
    DbgPrint("Offset for Buffer in the Memory Page: %d\r\n", Offset);
    DbgPrint("Driver Data Length : %d\r\n", DataLen);
    //
    if (BufLen <= DataLen) {
        ByteTransferred = BufLen; 
    } else {
        ByteTransferred = DataLen;
    }

    RtlCopyMemory(
        Buf, 
        DataBuf, 
        ByteTransferred);

    IoReleaseRemoveLock(&p_DVCEXT->RemoveLock, Irp);
    CompleteRequest(Irp, STATUS_SUCCESS, ByteTransferred);

    DbgPrint("IRP_MJ_READ : End\r\n");
    return STATUS_SUCCESS;
}

Below code segment demos the possible workflow to write data from user application to driver:

NTSTATUS
PsdoDispatchWrite(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp
)
{
    PVOID Buf; //Buffer provided by user program
    ULONG BufLen; //Buffer length for user provided buffer
    ULONG Offset;//Buffer Offset
    PVOID DataBuf; //Buffer provided by Driver
    ULONG DataLen; //Buffer length for Driver Data Buffer
    ULONG ByteTransferred;
    PIO_STACK_LOCATION p_IO_STK;
    PDEVICE_EXTENSION p_DVCEXT;
    NTSTATUS status;

    DbgPrint("IRP_MJ_WRITE : Begin\r\n");

    //Get I/o Stack Location & Device Extension
    p_IO_STK = IoGetCurrentIrpStackLocation(Irp);
    p_DVCEXT = DeviceObject->DeviceExtension;

    //Get User Input Buffer & Length 
    Buf = MmGetSystemAddressForMdlSafe(
        Irp->MdlAddress, HighPagePriority);

    if (Buf == NULL) {
        DbgPrint("Can't get Virtual Address from MDL\r\n");
        return STATUS_INSUFFICIENT_RESOURCES;
    }

    BufLen = MmGetMdlByteCount(Irp->MdlAddress);
    Offset = MmGetMdlByteOffset(Irp->MdlAddress);

    //Get Driver Data Buffer & Length
    DataBuf = p_DVCEXT->DataBuffer;
    DataLen = 1024;

    IoAcquireRemoveLock(&p_DVCEXT->RemoveLock, Irp);

    DbgPrint("Input Buffer Length : %d\r\n", BufLen);
    DbgPrint("Offset for Buffer in the Memory Page: %d\r\n", Offset);
    DbgPrint("Driver Data Length : %d\r\n", DataLen);

    if (BufLen <= DataLen) {
        ByteTransferred = BufLen; 
    } else {
        ByteTransferred = DataLen;
    }

    ByteTransferred = BufLen;
    RtlZeroMemory(
        p_DVCEXT->DataBuffer,
        1024);

    RtlCopyMemory(
        DataBuf,
        Buf, 
        ByteTransferred);

    IoReleaseRemoveLock(&p_DVCEXT->RemoveLock, Irp);
    CompleteRequest(Irp, STATUS_SUCCESS, ByteTransferred);

    DbgPrint("IRP_MJ_WRITE : End\r\n");
    return STATUS_SUCCESS;
}

Contents of the source zip package

The zip file contains below subfolders:

  1. Application: it contains the client applications to the Pseudo Driver.
  2. bin: it contains the install/uninstall utility for Pseudo Driver.
  3. BufferedIO_PW: it is where the Pseudo Driver that employees Buffered I/O mode for read/write resides.
  4. DirectIO_PW: it is where the Pseudo Driver that employees Direct I/O Mode for read/write resides.
  5. IOCTL_PW: it is where the Pseudo Driver that simply supports user-defined I/O Control Code resides.
  6. ShareFiles: it is the common shared library for PnP, Power Management, I/O completion.
  7. Install: it contains the source code of install/uninstall utility. (Install utility is directly referenced from DDK's sample, I won't provide redundant copy of it, only the uninstall utility source code is provided in it).

How to build the Pseudo Driver?

  1. Unzip the package to some folder you'd like it to be, let's name it ROOT_OF_SOURCE.
  2. Select Start->Programs->Development Kits->Windows DDK xxxx.xxxx->Build Environments->Free Build. (This is for free release without debug information in it.)
  3. Enter ROOT_OF_SOURCE\SharedFiles subfolder, enter build -cefw, it all goes well, shared library will be generated.
  4. Enter ROOT_OF_SOURCE\BufferedIO_PW subfolder, enter build -cefw, it will create Pseudo Driver - BufferDrv.sys. Copy this file into ROOT_OF_SOURCE\BufferedIO_PW\Install if you have made add-in for any new features, the copy is for later driver install.
  5. Enter ROOT_OF_SOURCE\DirectIO_PW subfolder, enter build -cefw, it will create Pseudo Driver - DirectDrv.sys. Copy this file into ROOT_OF_SOURCE\DirectIO_PW\Install if you have made add-in for any new features, the copy is for later driver install.
  6. Enter ROOT_OF_SOURCE\IOCTL_PW subfolder, enter build -cefw, it will create Pseudo Driver - PseudoDrv.sys. Copy this file into ROOT_OF_SOURCE\IOCTL_PW\Install if you have made add-in for any new features, the copy is for later driver install.

Install Pseudo Driver into system (XP)

  1. Unzip the source file, launch DOS prompt-console.
  2. Enter into bin subfolder.
  3. Execute DevInst.bat, it will automatically install the Pseudo Driver into your system.

Uninstall Pseudo Driver from system (XP)

  1. Enter into bin subfolder.
  2. Execute DevRemove.bat, it will automatically uninstall all-driver related resources from your system.

Execute client application

You can enter into ROOT_OF_SOURCE\Application subfolder, execute bufferclient.exe, directclient.exe, and clientapp.exe to verify if the three Pseudo Drivers have been installed successfully.

Known Issues

  • The install/uninstall of Pseudo Driver won't wok on Window 2000, the root cause might be that the Setup API doesn't work on Window 2000, can't allow driver installed without a physical hardware in it. Can anybody help to resolve it? Many Thanks.
  • If you'd like to install/uninstall the Pseudo Driver in Windows 2000, you will need to launch New Hardware Wizard from within Device Manager, and select to install new hardware->Display all hardware->Install from disk->"ROOT_OF_SOURCE\BufferedIO_PW\Install", click on OK button. New Hardware Wizard will install Buffered I/O Pseudo Driver. (This is for Buffered I/O demo driver install. As for Direct I/O, please set source directory to "ROOT_OF_SOURCE\DirectIO_PW\Install").
  • Reboot is required if the driver has been reinstalled after un-installation. I don't know why this happened, I hope somebody can inform me. Many Thanks.

Future Directions for Pseudo Driver

  1. Fix above issues.
  2. WMI support in Pseudo Driver will be added-in.

History

  1. Started to create the three Pseudo Drivers on 2002/02/10, finished on 2003/12/28 (I use the rest time for it), released on 2004/10/20 after my book published.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

mjtsai
Web Developer
Taiwan Taiwan
Member
No Biography provided

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralMy vote of 5membercasa cargo10 Jul '12 - 2:02 
very good and nice and simple learn hard learnning subject , very very thanks
Questionerror in PseudoDriver codememberswetha from India2 Aug '11 - 1:21 
hi.
I'm trying to build this pseudodriver code but it will give error as
cannot open include file 'afxres.h'.
please send me the solution
GeneralMouse Driver DevelopmentmemberSabid M1 Jul '10 - 0:20 
Hi,
 
I modified the mouse driver program in WDK sample.i created mouclass.sys file.Now i want to update the mouse driver with new one.I am using Windows xp.
Sabid.M
sabid.m@gmail.com

GeneralNice article !!!memberadam george9 Dec '09 - 23:34 
mjtsai,
 
Nice article..
 
very informative..
 
very useful for to begin with driver programming..
 
N Thanx for posting this article..
 
I wud like to see more articles from u regarding device drivers..
 
Keep Up the Good Work..
 
Regards,
Mejo Koshy
GeneralProblem loading the driver: BSODmemberJMonteiro_124 Nov '09 - 8:50 
Hi,
 
I have a PCI custom board which is working correctly: i successfully written and read data to it using PCITree and windriver.
 
Now, i have to access its memory space using a user application and for that i used your DirectIO driver, since the board has none.
 
When I'm loading the driver using the "New Found Wizard", after it copies the .sys file I get a BSOD saying "IRQL_NOT_LESS_OR_EQUAL".
 
What am I missing? Can't I use this same driver functions to drive any hardware device?
 

Congratulations on the post by the way.
Best,
JM
GeneralIO stack location's Parameters returning nullmemberRKP72825 May '09 - 18:26 
I am converting a driver to make it pnp compatible.
While scanning for the resources required for the device I am getting IO stack location's "Parameters" as null.
Following is the sample code snippet:
PIRP Irp
PIO_STACK_LOCATION x;
PCM_RESOURCE_LIST y = NULL;
 
x = IoGetCurrentIrpStackLocation(Irp);
y = x->Parameters.StartDevice.AllocatedResources;
 
The device is not physical but a logical device.
I think that the pnp manager finds out which all resources the device needs and fills this stack's parameters list.
Any hint as to why I may be getting the parameters as null ?
Does this has anything to do with the device id of the device while installing the device ?
 
RKP

Generaldriver for IP cameramembersuleks25 Feb '09 - 23:07 
Hello,
 
I need to write a driver that will emulate an IP camera and connect to it to get the MJPEG stream. Any ideas how to do it ?? pleas help :(
GeneralRe: driver for IP cameramemberMember 9550752 Mar '09 - 23:39 
Maybe you can develop an user-mode driver to get it.
GeneralMany thanks for this tutorial [EOM]memberseb55916 Jan '09 - 5:13 
-
QuestionDear mjtsai:memberluixilva10 Oct '07 - 12:56 
i need to replace a printer for another computer to send the "output" of the lpt1 to a file.
 
I have some problems to read the data, status and control ports, I mean, i can't manage the busy and acknowledge in the second computer, in fact, i can't read what the first computer is sending to the printer. Could you please help me? or telling me what can i do for solve my problem?
 
I have the code for the things i am doing, if u want to see it, i will send u.
 
Thank you in advance for your attention.
 
Regards

GeneralWindows Server 2003 BSODmemberjvlake15 Sep '07 - 23:02 
All files clean compile, but when I fire the *.sys in the 'OSR Driver Loader' Kaboom! Stop Code. Using Windows DDK 3790.1830 and x86 free-build for server 2003. I have used this project before on XP without problems, any ideas? thanks
GeneralRe: Windows Server 2003 BSODmemberjvlake16 Sep '07 - 2:28 
O.K. forget about it, I see the error of my ways. I shall write 1000 times PnP is not a legacy driver. DriverObject->DriverExtension->AddDevice
GeneralNEED help:memberDharmeshC8 Aug '07 - 3:43 
Hi,
 
I want to make driver for my 6 button USB(HID) mouse for just learning aspect of windows driver .. Can you please guide me what should be my step ..
 
i also read and use your code for learning and playing with Windows Kernel and clear my some basics...thnk you very much for that,
 
Please , also tel me how your code can help me for this driver development or i have to write my own..
 

 
Ragards,Big Grin | :-D
Questionhow to write WDM filter driver modify webcam's streammemberthuong10127713 Jun '07 - 22:43 
Hi All,
 
I want write a WDM filter driver to modify webcam's stream, anybody have any ideas, think, can share me? thanks alot for help.
 
David,
QuestionInfo required about using Interrupts in WDM driversmemberFakhar Anjam13 Jun '07 - 20:50 
I am a system engineer. i worked on different hardware and software projects. currently i am working on a PCI based data acquisition hardware card. the hardware is connected to some device and it sends a byte to the PCI card after a fixed time interval. i used a timer device on the PCI card which produces an interrupt on the PCI bus so that the driver Interrupt Service Routine (ISR) is called after that specific time to get the byte sent to tha PCI card. Well that was some overview of the hardware.
 
I am writing WDM device driver for windows xp for this card. the device driver programs are written in C using Microsoft Visual C++ Professional Edition 6.0 under the free build environment of the Microsoft Driver Development kit (DDK).
 
Currently i have developed some code for the driver but it is programmed I/O, meaning that program intervention is required to transfer each unit of data. The ISR is called and it reads a byte from the card and stores it in an array in the device extention and asynchronous to that a ReadFile transfers the data array to the user mode program.
 
I got ur email from net. i found some of ur driver applications as well. these were very helpful to me. based on ur experience i want to ask u few questions. if u would help to solve me these or atleast give me some idea, i would be much much thankful.
 
1. When the ISR is called 1000 (say) times and all these bytes are stored in the device extention, it shud send a message to the user program to read the data array.
 
2. The ISR shud only get the data byte from the card if it has received a message from the user program to get the data. that is the ISR shud be capable of receiving messages from the user program at any time.
 
3. Both of these questions can be combined in this single question. that is, is there a way so that some varaibles could be accessed by both the user program and the ISR?? i mean its like using some global variables of the system accessible to both the driver ISR and the user mode program.
 
I would be much oblidged, if any one could provide me with some study materials and small codes if any doing such type of jobs.

AnswerRe: Info required about using Interrupts in WDM driversmemberDharmeshC8 Aug '07 - 18:58 
hi do you get the answer ?
 
if yes then can you please explain i also want to know it !!OMG | :OMG:
QuestionHow can you write data to pseudodriver ?memberalexnpl31 May '06 - 7:33 
Hi,
 
is there anyone know how to write data to buffered I/O driver ?
 
I have successfully installed buffered I/O driver to system device in Device Manager.
 
I wanted to test the driver and so I type BufferClient.exe to write data to the driver. Could anyone knows what is the source code in VC++6.0 that can write data to driver from user mode?
 
thx.
 
Alex
Questionhow to write a filter driver like portmonmemberJobjingjo15 Feb '06 - 23:07 
i want to write a filter driver that can attract to other devices like portmon.
ps. i don't understand about writing a (filter/device)driver so much.

Generalcapture file access eventsmemberW M Suleiman30 Jan '06 - 6:45 
hello
 
i want to capture the file access events like create read write and close, intercept this events and allow or not allow the access .
since this is something related to the file system the easyest way to do it will be the IFS kit.
but unfortunatly i'm suposed to do that without using the IFS kit. the good news is i'm allowed to use the DDK.
 
so my question is how can i capture these events without using the IFS Kit.
 
thanks in advance
 
Best Regards.
QuestionWhy query power state twice?memberodawid23 Jan '06 - 1:17 
Looking at the code I noticed that you are querying the power state twice - why?
 
Wouldn't be sufficient to pass the IRP down to 'NextDeviceObject' and skip the stack location? Or do I overlook something?
 
Oliver

GeneralPNP NotificationmemberdaDude20 Dec '05 - 16:07 
Hi,
 
Do you know if there's a way to register a callback function to Win PNP manager? This way my app knows when Win PNP manager has done installing/removing a device driver.
 
Please advice, thanks!
-Paul
Generalfloppy drivemembervasudha_verma12 Nov '05 - 18:28 
i need to build a floppy device driver.. i read your article..
will dis code be of any help to me..
i mean it does all work like reading and writing..
how should i proceed to write one??
 
vasudha
Generalwrite one?floppy drivermembervasudha_verma12 Nov '05 - 18:27 
i need to build a floppy device driver.. i read your article..
will dis code be of any help to me..
i mean it does all work like reading and writing..
how should i proceed to
Generali can't inst itmemberhorse199710 Nov '05 - 20:17 
first, this article help me a lot, thanks
 
but when i execute .\inst\Devinst.bat
it can't work well.
 
the console said that' No more data can use.... '
 
anybody can help me!
 
thanks
 

 
thank u
Questiondevice errors with XPmembergearym12 Sep '05 - 6:33 
I am developing in windows XP, I have successfully compilled and installed the pseudodriver, well at least it gives the message of a succesfull install.
 
Compare device ID: [root\mssmbios]
Compare device ID: [*BufIODvc20030801]
Compare device ID: [*DirIODvc20030804]
Compare device ID: [*PseudoDvc20030801
Found! [*PseudoDvc20030801]
Driver Installed successfully.
 

 
the problem is when I run the test programs in the application directory, i get back error messages that
 
Unable to open PSEUDODEVICE device - error 2
 
I have used the regedit to see if the driver installed and it does find them?
anyone else have this experience.
any help would be appreciated

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web04 | 2.6.130523.1 | Last Updated 26 Oct 2004
Article Copyright 2004 by mjtsai
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid