Dear Team,
For the custom device, I modified and loaded usb-umdf-osrfx2 sample driver.
While performing read, write operations through the applications,
OnCompletion routine in readwritequeue.cpp is called after the operation is
completed.
The wdf request is completed as :
WdfRequest->CompleteWithInformation(Params->GetCompletionStatus(),
Params->GetInformation() );
Application uses generic ReadFile, WriteFile routines with overlapped
structures.
In the case of any error in the data transfer, I noticed that
Params->GetCompletionStatus has values of 0xd00000b5, 0xd0000120, etc.
In normal case it is 0x0000000.
Params->GetInformation has non zero values in normal conditions and zero
value in the case of error. I am able to see these values using traceview.
Coming to the application, whenever ReadFile or WriteFile fails, I call
GetLastError which shows the values as:
0x79 Semaphore timeout expiry,
0x1f attached device is not working, etc.
Can somebody point to the way through which I can populate the exact driver
errors to the calling application.
I am into this situation because I need to perform the data transfer to the
device depending on the previous state of the device.
Regards.
These values are NTSTATUS values converted to an HRESULT.
So 0xd00000b5 is NTSTATUS 0xC00000b5 (STATUS_IO_TIMEOUT),
0xd0000120 is NTSTATUS 0xC0000120 (STATUS_CANCELLED)
The first one seems to map to Windows error 0x79 Semaphore timeout expiry.
The second one should have mapped to 0x3E3 (ERROR_OPERATION_ABORTED). Did you get (0x1f attached device is not working) for this one?
In general, the mapping should be automatic as long as you pick the right NTSTATUS code (from ntstatus.h) or Windows error code (from winerror.h).
In general, UMDF drivers should be using Windows error code converted to HRESULT. UMDF I/O target completion routines currently return NTSTATUS (because the underlying completion port API returns NTSTATUS). Both should work and automatically get translated to windows error for the application correctly.
If you want to send a custom error code to the application you can use NTSTATUS with customer code flag set, and it should go through un-translated to the application.
HTH,
Praveen
Thanks for the pointer. In the second case as you guessed 0x1f was the
error. Can you suggest the procedure to set the customer control flag.
On Feb 4, 2008 11:52 AM, Praveen Rao wrote:
> These values are NTSTATUS values converted to an HRESULT.
>
> So 0xd00000b5 is NTSTATUS 0xC00000b5 (STATUS_IO_TIMEOUT),
> 0xd0000120 is NTSTATUS 0xC0000120 (STATUS_CANCELLED)
>
> The first one seems to map to Windows error 0x79 Semaphore timeout expiry.
> The second one should have mapped to 0x3E3 (ERROR_OPERATION_ABORTED). Did
> you get (0x1f attached device is not working) for this one?
>
> In general, the mapping should be automatic as long as you pick the right
> NTSTATUS code (from ntstatus.h) or Windows error code (from winerror.h).
>
> In general, UMDF drivers should be using Windows error code converted to
> HRESULT. UMDF I/O target completion routines currently return NTSTATUS
> (because the underlying completion port API returns NTSTATUS). Both should
> work and automatically get translated to windows error for the application
> correctly.
>
> If you want to send a custom error code to the application you can use
> NTSTATUS with customer code flag set, and it should go through un-translated
> to the application.
>
> HTH,
> Praveen
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>
I am not sure why you get 0x1f corresponding to STATUS_CANCELLED. That shouldn’t happen. Are the device and device stack working when you get this error code. Would you please do !gle in the debugger to see what’s the last winerror and ntstatus set?
For customer bit please check the WDK docs for NTSTATUS. It is the 29th bit (0-based count).
Praveen