Driver Problems? Questions? Issues?
Put OSR's experience to work for you! Contact us for assistance with:
  • Creating the right design for your requirements
  • Reviewing your existing driver code
  • Analyzing driver reliability/performance issues
  • Custom training mixed with consulting and focused directly on your specific areas of interest/concern.
Check us out. OSR, the Windows driver experts.

Upcoming OSR Seminars:
Writing WDF Drivers: Core Concepts Lab, Boston/Waltham, MA 22-26 September, 2014
Windows Internals & Software Drivers Lab, Dulles/Sterling, VA, 20-24 October, 2014
Developing File Systems for Windows, Seattle, WA 4-7 November, 2014


Go Back   OSR Online Lists > ntdev
Welcome, Guest
You must login to post to this list
  Message 1 of 10  
07 May 10 14:25
Kevin Dalpatadu
xxxxxx@gmail.com
Join Date: 10 Feb 2009
Posts To This List: 104
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.
  Message 2 of 10  
07 May 10 14:28
Fernando Roberto
xxxxxx@driverentry.com.br
Join Date: 14 Jan 2008
Posts To This List: 21
Ntstatus in DeviceIoControl.

Actually you didn't. NTSTATUS code is converted to a Win32 error code when the request finish. Regards, -- Fernando Roberto da Silva DriverEntry Kernel Development http://www.driverentry.com.br
  Message 3 of 10  
07 May 10 14:39
ntdev member 43772
xxxxxx@gmail.com
Join Date:
Posts To This List: 8
Ntstatus in DeviceIoControl.

You can also use the IRP Tracker to see the status of your requests. Best Regards, Ismael On Fri, May 7, 2010 at 3:26 PM, <xxxxx@gmail.com> wrote: > 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, <...excess quoted lines suppressed...> --
  Message 4 of 10  
07 May 10 14:44
Maxim S. Shatskih
xxxxxx@storagecraft.com
Join Date: 20 Feb 2003
Posts To This List: 9373
Ntstatus in DeviceIoControl.

> My question is how do I get the returned NTSTATUS value in the user mode program? From GetLastError after DeviceIoControl returned FALSE, or from GetOverlappedResult. They will be converted to Win32 errors, the conversion table is described somewhere on MS's site - google for "Mapping NTSTATUS Win32 error". -- Maxim S. Shatskih Windows DDK MVP xxxxx@storagecraft.com http://www.storagecraft.com
  Message 5 of 10  
07 May 10 15:13
Kevin Dalpatadu
xxxxxx@gmail.com
Join Date: 10 Feb 2009
Posts To This List: 104
Ntstatus in DeviceIoControl.

Thanks for the answers. Kevin.
  Message 6 of 10  
07 May 10 15:37
Scott Noone
xxxxxx@osr.com
Join Date:
Posts To This List: 1025
List Moderator
Ntstatus in DeviceIoControl.

>They will be converted to Win32 errors, the conversion table is described >somewhere on MS's site - google for "Mapping >NTSTATUS Win32 error". Winerror.exe in the WDK is pretty handy, it lets you translate between Win32 and NTSTATUS values. -scott -- Scott Noone Consulting Associate OSR Open Systems Resources, Inc. http://www.osronline.com "Maxim S. Shatskih" <xxxxx@storagecraft.com> wrote in message news:142694@ntdev... >> My question is how do I get the returned NTSTATUS value in the user mode >> program? > > From GetLastError after DeviceIoControl returned FALSE, or from > GetOverlappedResult. > > They will be converted to Win32 errors, the conversion table is described > somewhere on MS's site - google for "Mapping NTSTATUS Win32 error". > > -- <...excess quoted lines suppressed...>
  Message 7 of 10  
07 May 10 15:51
Gary Little
xxxxxx@comcast.net
Join Date: 08 Apr 2009
Posts To This List: 980
Ntstatus in DeviceIoControl.

You can define your own error messages using the Message compiler (*.mc) and adding it to your SOURCES file SOURCES section. Gary G. Little H (952) 223-1349 C (952) 454-4629 xxxxx@comcast.net -----Original Message----- From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com Sent: Friday, May 07, 2010 1:27 PM To: Windows System Software Devs Interest List Subject: [ntdev] 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. --- 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 __________ Information from ESET Smart Security, version of virus signature database 5095 (20100507) __________ The message was checked by ESET Smart Security. http://www.eset.com __________ Information from ESET Smart Security, version of virus signature database 5096 (20100507) __________ The message was checked by ESET Smart Security. http://www.eset.com
  Message 8 of 10  
08 May 10 19:10
Pavel A
xxxxxx@fastmail.fm
Join Date: 21 Jul 2008
Posts To This List: 2083
Ntstatus in DeviceIoControl.

<xxxxx@gmail.com> wrote in message news:142688@ntdev... > 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? Just set the "custom" bit in your status values. GetLastError will return these values without any conversion. Regards, --pa
  Message 9 of 10  
11 May 10 19:27
Kevin Dalpatadu
xxxxxx@gmail.com
Join Date: 10 Feb 2009
Posts To This List: 104
Ntstatus in DeviceIoControl.

Hi, 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: BOOL status = DeviceIoControl(Driver, Ioctl, Buffer, BufferSize, Buffer, BufferSize, BytesRead, &Overlapped); error = GetLastError(); if (!status) { // if port driver returns a pending message if (error == ERROR_IO_PENDING) { HANDLE hEvents[2]; hEvents[0] = Overlapped.hEvent; hEvents[1] = evtExit; // wait for irp complete or stop process events DWORD WaitValue = WaitForMultipleObjects(2, hEvents, FALSE, INFINITE); switch (WaitValue) { case WAIT_OBJECT_0 + 0: error = GetLastError(); break; case WAIT_OBJECT_0 + 1: ::CancelIo(Driver); break; case WAIT_ABANDONED_0 + 0: break; case WAIT_ABANDONED_0 + 1: break; case WAIT_TIMEOUT: break; case WAIT_FAILED: break; default: break; } } } CloseHandle(hEvent); } My question is how do I get the returned NTSTATUS value in the user mode program? Thanks, Kevin.
  Message 10 of 10  
11 May 10 19:51
Tim Roberts
xxxxxx@probo.com
Join Date: 28 Jan 2005
Posts To This List: 9355
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.
Posting Rules  
You may not post new threads
You may not post replies
You may not post attachments
You must login to OSR Online AND be a member of the ntdev list to be able to post.

All times are GMT -5. The time now is 09:21.


Copyright ©2014, OSR Open Systems Resources, Inc.
Based on vBulletin Copyright ©2000 - 2005, Jelsoft Enterprises Ltd.
Modified under license