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());
}