WDFMEMORY is undefined

I’m following the toaster example though keep getting the error ‘WDFMEMORY is undefined’ when I try to define a local variable memory of type WDFMEMORY, I have wdf.h and ntddk.h included as header files and other framework data types seem to work.

Do other wdf handle types work?

d

Bent from my phone


From: xxxxx@edu.salford.ac.ukmailto:xxxxx
Sent: ?12/?17/?2014 2:34 PM
To: Windows System Software Devs Interest Listmailto:xxxxx
Subject: [ntdev] WDFMEMORY is undefined

I’m following the toaster example though keep getting the error ‘WDFMEMORY is undefined’ when I try to define a local variable memory of type WDFMEMORY, I have wdf.h and ntddk.h included as header files and other framework data types seem to work.


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

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</mailto:xxxxx></mailto:xxxxx>

Yes others like WDFDRIVER, WDFDEVICE, WDFQUEUE work.

Two guesses
1 you missed a ; on the previous local var decl right above
2 you are using C and declaring a local in the middle of code, not at the start of the block

d

Bent from my phone

-----Original Message-----
From: “xxxxx@edu.salford.ac.uk
Sent: ‎12/‎17/‎2014 3:31 PM
To: “Windows System Software Devs Interest List”
Subject: RE:[ntdev] WDFMEMORY is undefined

Yes others like WDFDRIVER, WDFDEVICE, WDFQUEUE work.


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

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

All WDF handles are declared in wdftypes.h which wdf.h includes. Take a look in there and search for DECLARE_HANDLE( WDFMEMORY ) as a sanity check. Also, could you please post a snippet of your code?

VOID ToasterEvtIoRead(WDFQUEUE Queue, WDFREQUEST Request, size_t Length)  
{  
 WDFMEMORY memory;  
 NTSTATUS status;  
 ULONG_PTR bytesCopied = 0;  
  
UNREFERENCED_PARAMETER(Queue);  
 UNREFERENCED_PARAMETER(Length);  
  
PAGED_CODE();  
 status = WdfRequestRetrieveOutputMemory(Request, memory);  
  
}  

You are missing an indirect on memory

WdfRequestRetrieveOutputMemory(Request, &memory);

d

Bent from my phone


From: xxxxx@edu.salford.ac.ukmailto:xxxxx
Sent: ?12/?17/?2014 3:58 PM
To: Windows System Software Devs Interest Listmailto:xxxxx
Subject: RE:[ntdev] WDFMEMORY is undefined

<br>VOID ToasterEvtIoRead(WDFQUEUE Queue, WDFREQUEST Request, size_t Length)<br>{<br> WDFMEMORY memory;<br> NTSTATUS status;<br> ULONG_PTR bytesCopied = 0;<br><br>UNREFERENCED_PARAMETER(Queue);<br> UNREFERENCED_PARAMETER(Length);<br><br>PAGED_CODE();<br> status = WdfRequestRetrieveOutputMemory(Request, memory);<br><br>}<br>


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

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</mailto:xxxxx></mailto:xxxxx>

Thanks but that’s not the error. For some reason WDFMemory is not being recognized as a valid data type.

I also looked in wdftypes.h and found DECLARE_HANDLE( WDFMEMORY ) so it’s strange. I tried including wdtypes.h alongside wdf.h though still get the problem. Maybe something to do with VisualStudio. Do you guys knows where I can go from here?

Can you use the type in another source file?

d

Bent from my phone

-----Original Message-----
From: “xxxxx@edu.salford.ac.uk
Sent: ‎12/‎17/‎2014 5:11 PM
To: “Windows System Software Devs Interest List”
Subject: RE:[ntdev] WDFMEMORY is undefined

I also looked in wdftypes.h and found DECLARE_HANDLE( WDFMEMORY ) so it’s strange. I tried including wdtypes.h alongside wdf.h though still get the problem. Maybe something to do with VisualStudio. Do you guys knows where I can go from here?


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

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

Thanks I just manually put DECLARE_HANDLE(WDFMEMORY) at the top of my c file and I’m not receiving any errors. Not sure why it was not included within wdf.h. Thanks for helping

WdfRequestRetrieveOutputMemory takes a pointer to a WDFMEMORY handle and in your code below you’re passing the handle as a value. Try WdfRequestRetrieveOutputMemory(Request, &memory) instead.

VOID ToasterEvtIoRead(WDFQUEUE Queue, WDFREQUEST Request, size_t Length)  
{  
 WDFMEMORY memory;  
 NTSTATUS status;  
 ULONG_PTR bytesCopied = 0;  
  
UNREFERENCED_PARAMETER(Queue);  
 UNREFERENCED_PARAMETER(Length);  
  
PAGED_CODE();  
 status = WdfRequestRetrieveOutputMemory(Request, memory);  
  
}  

(re-posting due to bad formatting)

WdfRequestRetrieveOutputMemory takes a pointer to a WDFMEMORY handle and in your code you’re passing the handle as a value. Try WdfRequestRetrieveOutputMemory(Request, &memory) instead.

There are multiple copies of the wdf headers in the wdk, make sure you are looking at the right version. Not that it should matter, this should work out of the box. My last guess is you accidently changed the header with a manual edit

d

Bent from my phone


From: xxxxx@edu.salford.ac.ukmailto:xxxxx
Sent: ?12/?17/?2014 5:40 PM
To: Windows System Software Devs Interest Listmailto:xxxxx
Subject: RE:[ntdev] WDFMEMORY is undefined

Thanks I just manually put DECLARE_HANDLE(WDFMEMORY) at the top of my c file and I’m not receiving any errors. Not sure why it was not included within wdf.h. Thanks for helping


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

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</mailto:xxxxx></mailto:xxxxx>

Cosmic rays. They’re *always* the culprit in situations like this.

Or, perhaps, his header file has been hacked by the North Koreans.

Peter
OSR
@OSRDrivers

(All kidding aside: OP, it’s always frustrating when stuff like this happens – Try building the driver on another system. Try removing and re-installing the WDK. It only takes a few minutes and it’s beter than randomly defining data types in your source code)