Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Before Posting...
Please check out the Community Guidelines in the Announcements and Administration Category.

RE: Ntstatus in DeviceIoControl

Don_Burn_1Don_Burn_1 Member Posts: 4,311
Use ZwDeviceIoControl in user space to get the NTSTATUS, if you use
DeviceIoControl the value is translated into a Win32 error code you can
get from GetLastError if the DeviceIoControl returns zero.


Don Burn (MVP, Windows DKD)
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr




> -----Original Message-----
> From: xxxxx@gmail.com [mailto:xxxxx@gmail.com]
> Posted At: Friday, May 07, 2010 2:27 PM
> Posted To: ntdev
> Conversation: Ntstatus in DeviceIoControl.
> Subject: Ntstatus in DeviceIoControl.
>
> Hi,
>
> I am sending an IOCTL to my driver from a user mode program using
> DeviceIoControl. In the driver I return various NTSTATUS codes in
> WdfRequestComplete.
>
> My question is how do I get the returned NTSTATUS value in the user
mode
> program?
>
> Thanks,
>
> Kevin.
>
>
> __________ Information from ESET Smart Security, version of virus
signature
> database 5095 (20100507) __________
>
> The message was checked by ESET Smart Security.
>
> http://www.eset.com
>

Comments

  • Don_Burn_1Don_Burn_1 Member Posts: 4,311
    An alternative to the custom bit trick is to use NtDeviceIoControl from
    user space and get the result directly as the return value.


    Don Burn (MVP, Windows DKD)
    Windows Filesystem and Driver Consulting
    Website: http://www.windrvr.com
    Blog: http://msmvps.com/blogs/WinDrvr



    > -----Original Message-----
    > From: Tim Roberts [mailto:xxxxx@probo.com]
    > Posted At: Tuesday, May 11, 2010 7:51 PM
    > Posted To: ntdev
    > Conversation: Ntstatus in DeviceIoControl.
    > Subject: Re: Ntstatus in DeviceIoControl.
    >
    > xxxxx@gmail.com wrote:
    > > 1. I am sending an IOCTL to my driver from a user mode program using
    > DeviceIoControl.
    > > 2. In the driver I return various NTSTATUS codes in
    WdfRequestComplete.
    > > 3. In the user mode program I do:
    > >
    >
    > In your WAIT_OBJECT_0+0 case,call GetOverlappedResult. If that
    returns non-
    > zero, then you had STATUS_SUCCESS. If that returns zero, only then
    should you
    > call GetLastError. That will return the NSTATUS, although it will
    have gone
    > through the DDK -> SDK error code translation process that converts
    STATUS_xxx
    > to the equivalent ERROR_xxx codes.
    >
    > If you want to return a value unscathed, set the "custom" bit in the
    NTSTATUS
    > value (which means in the range 0xE0000000 to 0xFFFFFFFF).
    >
    > --
    > Tim Roberts, xxxxx@probo.com
    > Providenza & Boekelheide, Inc.
    >
    >
    >
    > __________ Information from ESET Smart Security, version of virus
    signature
    > database 5106 (20100511) __________
    >
    > The message was checked by ESET Smart Security.
    >
    > http://www.eset.com
    >
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Upcoming OSR Seminars
Writing WDF Drivers 25 Feb 2019 OSR Seminar Space
Developing Minifilters 8 April 2019 OSR Seminar Space