STATUS_NO_MEMORY

At this time my driver returns “STATUS_NO_MEMORY” if a memory region was not allocated. I unfortunately don’t know any way to force this to happen but would still like to handle it appropriately. If this value is returned should I expect an error using GetLastError after opening the driver? If so, what error? I see no STATUS_NO_MEMORY in the system error codes.

Tim

I just discovered that maybe “STATUS_INSUFFICIENT_RESOURCES” would be more appropriate but I still don’t know how or if this shows up after a CreateFile( ) call. Not sure if this results in an invalid handle or an error message in GetLastError. If so which one?

If CreateFile fails it will return INVALID_HANDLE_VALUE and the error value
will be returned by GetLastError().

Bill Wandel

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com]
On Behalf Of xxxxx@gmail.com
Sent: Tuesday, May 25, 2010 6:18 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] STATUS_NO_MEMORY

I just discovered that maybe “STATUS_INSUFFICIENT_RESOURCES” would be more
appropriate but I still don’t know how or if this shows up after a
CreateFile( ) call. Not sure if this results in an invalid handle or an
error message in GetLastError. If so which one?


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 just don’t know if it indeed returns INVALID_HANDLE_VALUE if the driver function returns STATUS_INSUFFICIENT_RESOURCES. When I return STATUS_NO_MEMORY I do get a valid handle. unfortunately I have no idea my resources were not allocated. When I attempt a driver access it crashes. I am now unable to recreate this scenario though so I can’t just try it by changing the return value to STATUS_INSUFFICIENT_RESOURCES and hope that it results in an invalid handle. I have no idea when the error may arise again and would prefer to handle it correctly no rather than hope to reproduce it continually.

STATUS_INSUFFICIENT_RESOURCES is an error return and if your driver
correctly returns it from your IRP_MJ_CREATE call then CreateFile will
return INVALID_HANDLE_VALUE anf GetLastError() will return the WIN32 version
of STATUS_INSUFFICIENT_RESOURCE.
Are you setting the error in the IO_STATUS field when you complete the IRP?

Bill Wandel

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com]
On Behalf Of xxxxx@gmail.com
Sent: Tuesday, May 25, 2010 6:47 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] STATUS_NO_MEMORY

I just don’t know if it indeed returns INVALID_HANDLE_VALUE if the driver
function returns STATUS_INSUFFICIENT_RESOURCES. When I return
STATUS_NO_MEMORY I do get a valid handle. unfortunately I have no idea my
resources were not allocated. When I attempt a driver access it crashes. I
am now unable to recreate this scenario though so I can’t just try it by
changing the return value to STATUS_INSUFFICIENT_RESOURCES and hope that it
results in an invalid handle. I have no idea when the error may arise again
and would prefer to handle it correctly no rather than hope to reproduce it
continually.


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

xxxxx@gmail.com wrote:

At this time my driver returns “STATUS_NO_MEMORY” if a memory region was not allocated. I unfortunately don’t know any way to force this to happen but would still like to handle it appropriately. If this value is returned should I expect an error using GetLastError after opening the driver? If so, what error? I see no STATUS_NO_MEMORY in the system error codes.

STATUS_NO_MEMORY maps to ERROR_NOT_ENOUGH_MEMORY.

Save a bookmark to this very useful list:
http://support.microsoft.com/kb/113996


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

> At this time my driver returns “STATUS_NO_MEMORY” if a memory region was not allocated. I

unfortunately don’t know any way to force this to happen but would still like to handle it appropriately.

Low Resources Simulation in Verifier

If this value is returned should I expect an error using GetLastError after opening the driver?

Yes.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com