Global pointer to buffer

Hello,

I have a buffer in one of the .c files in a driver. Now i want to use this buffer also in another .c file of the same driver. What is the best way to do this? Declare an extern pointer in a .h file?

PE

Stuff a pointer to the buffer in the extension of the device object and
access it that way. Read the WDK/KMDF documentation? Look at the WDK
samples. There are many examples of doing this there.

The personal opinion of
Gary G. Little

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@greefa.nl
Sent: Monday, June 08, 2009 7:51 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Global pointer to buffer

Hello,

I have a buffer in one of the .c files in a driver. Now i want to use this
buffer also in another .c file of the same driver. What is the best way to
do this? Declare an extern pointer in a .h file?

PE


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

Declaring the extern works, so does __declspec(selectany) and putting the actual declaration in a shared header. But, why do you have a global in the first place? This is something that probably should be allocated and put into the device extension so that each devobj in your driver has its own and you do not have cross devobj sync issues

d

Sent from my phone with no t9, all spilling mistakes are not intentional.

-----Original Message-----
From: xxxxx@greefa.nl
Sent: Monday, June 08, 2009 5:54 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Global pointer to buffer

Hello,

I have a buffer in one of the .c files in a driver. Now i want to use this buffer also in another .c file of the same driver. What is the best way to do this? Declare an extern pointer in a .h file?

PE


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

Hi Gary G. and Doron

Thanks for the reactions. While I’m new to driver programming I did not realise I could do it in the device extension. I asked this because I simply was not happy with the global pointer.

PE