WDM driver for WinXP writefile and readfile error

Discussion in 'Windows Vista Drivers' started by Felisberto Coimbra, Oct 12, 2004.

  1. Hello all,

    Well I´m learning how wdm drivers work and reading Walter Oney´s book,
    I was testing the driver and I can create a handle to the driver
    normaly but when I try to read or to write to the driver I receive an
    an the getlasterror function returns me 1 (Incorrect function).
    I have already added the driver into the system with the inf file.
    What it is missing? or what could be the mistake?

    HANDLE hdevice = CreateFile("\\\\.\\piofake"/, GENERIC_READ |
    if (hdevice == INVALID_HANDLE_VALUE)
    printf("Can't open PIOFAKE device - %d\n", GetLastError());
    return 1;

    // Read what's left in buffer
    DWORD TxdBytes;
    char *Rvalue;
    Rvalue = new char[10];
    if( !ReadFile(hdevice, &Rvalue, 3, &TxdBytes, NULL) )
    printf("Could not read value %d\n", GetLastError());
    Felisberto Coimbra, Oct 12, 2004
    1. Advertisements

  2. Felisberto Coimbra

    Tim Roberts Guest

    ReadFile goes almost directly to the IRP_MJ_READ handler in your driver.

    Have you implemented such a handler? Many sample drivers only implement an
    ioctl handler.

    I believe user-mode error 1 maps to an NTSTATUS of
    STATUS_INVALID_PARAMETER. Does your ReadFile function validate its
    parameters in any way? Does it ever return STATUS_INVALID_PARAMETER?
    Tim Roberts, Oct 14, 2004
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.