Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Vista Drivers > WDM driver for WinXP writefile and readfile error

Reply
Thread Tools Display Modes

WDM driver for WinXP writefile and readfile error

 
 
Felisberto Coimbra
Guest
Posts: n/a

 
      10-12-2004
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
error.
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 |
GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
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());
}
 
Reply With Quote
 
 
 
 
Tim Roberts
Guest
Posts: n/a

 
      10-14-2004
(Felisberto Coimbra) wrote:
>
>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
>error.
>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?


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,
Providenza & Boekelheide, Inc.
 
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
IoCall Driver on WinXP Manohara.K Windows Vista Drivers 1 08-25-2004 05:08 PM
ReadFile problem Harry Windows Vista Drivers 0 05-26-2004 10:41 AM
switch display driver in WinXP Ananth Windows Vista Drivers 4 05-15-2004 03:35 PM
Device Driver loading error on 2nd PCI card, WinXP SP1 Curtis Rubel Windows Vista Drivers 3 05-13-2004 01:51 AM
what difference is the driver under win2000 and winxp? tomlee Windows Vista Drivers 0 08-29-2003 05:27 AM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59