Yes your problem is annoying
So just to be absolutely clear about this: DeviceIoControl returns false and
GetLastError returns zero, right? That actually makes very little sense.
Also what is the point in your crappy driver routine
MyCrappyDriverDeviceControl of the “IO_STATUS_BLOCK ioStatus” variable? Is
there any possiblity that your pseudo code has glossed over an error here?
Like your real code is setting ioStatus rather than Irp->IoStatus?
Finally, last resort, (or maybe first resort) turn on driver verifier and
run this mess on a checked build kernel.
=====================
Mark Roddy
Windows .NET/XP/2000 Consulting
Hollis Technology Solutions 603-321-1032
www.hollistech.com
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Fred
Sent: Wednesday, April 13, 2005 7:26 PM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] Error return translation from driver to win32
This bug is really anoying me. I’m sure this will turn out to be
something really silly. So, now, I created a simple IOCTL that simply fails
all requests with STATUS_NO_MEMORY but my user-mode app still receives 0x00
for GetLastError().
Any Ideas? Here’s the actual code I’m using…
Here’s my driver code:
NTSTATUS MyCrappyDriverDeviceControl(PDEVICE_OBJECT
DeviceObject,PIRP Irp)
{
PDEVICE_EXTENSION deviceExtension = DeviceObject->DeviceExtension;
PIO_STACK_LOCATION currentIrpStack =
IoGetCurrentIrpStackLocation(Irp);
NTSTATUS status;
IO_STATUS_BLOCK ioStatus;
DebugPrint((2, “MyCrappyDriverDeviceControl: DeviceObject %X Irp
%X\n”, DeviceObject, Irp));
switch (currentIrpStack->Parameters.DeviceIoControl.IoControlCode)
{
case IOCTL_MYCRAPPYIOCTL:
{
status = STATUS_NO_MEMORY;
Irp->IoStatus.Information = 0;
Irp->IoStatus.Status = status;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return status;
}
… handle other stuff here (removed for readability) …
}
And here’s my user-mode code:
if (!DeviceIoControl(hHandle, IOCTL_MYCRAPPYIOCTL, ReadTarget,
sizeof(READ_TARGET), ReadTarget, ReadTarget->BufferSize, &bytes, NULL))
{
LastError = GetLastError();
printf(“\nIOCTL_MYCRAPPYIOCTL device request failed: 0x%x\n”,
LastError);
}
So, how can GetLastError() possibly return 0x00 and not not
STATUS_NO_MEMORY??? User a debugger showed that my driver was called
correctly and returned STATUS_NO_MEMORY.
“Doron Holan” mailto:xxxxx > wrote in message news:xxxxx@ntdev
news:xxxxx …
I hope you are calling IoCompleteRequest after setting the status in
the
Irp. If not, that is probably your problem.
d
-----Original Message-----
From: xxxxx@lists.osr.com
mailto:xxxxx
[mailto:xxxxx@lists.osr.com] On Behalf Of Fred
Sent: Tuesday, April 12, 2005 1:59 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Error return translation from driver to win32
I’m sending an ioctl to my driver via IoDeviceControl(). If I fail
the
ioctl with STATUS_NON_MEMORY then I expect that this will result in
IoDeviceControl() returning 0 as well as GetLastError() returning
‘no
memory’ error. But GetLastError() actually returns 0.
I’m setting :
Irp->IoStatus.Information = 0;
Irp->IoStatus.Status = STATUS_NO_MEMORY;
return STATUS_NO_MEMORY;
in my driver.
Shouldn’t the Win32 GetLastError() call get the error returned in
Irp->IoStatus.Status?
Thanks.
—
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
http:
You are currently subscribed to ntdev as:
xxxxx@windows.microsoft.com mailto:xxxxx
To unsubscribe send a blank email to xxxxx@lists.osr.com
mailto:xxxxx
—
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as: unknown lmsubst tag
argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com</mailto:xxxxx></mailto:xxxxx></http:></mailto:xxxxx></news:xxxxx></mailto:xxxxx>