sharing memory between two drivers with static lib

Hi,

I have to drivers and a static lib. Both drivers are linked to this lib. The
lib is responsible for all memory operations (free, realloc, etc). I am
allocating the memory from inside the library, but when one of the drivers
tries to write something the memory appears to be NULL.

Can you please suggest the best design for this issue? Two drivers and a
library for working with memory? I saw the previous discussion about sending
IOCTL from one driver to another. Is this really necessary knowing that all
drivers and kernel libs share the same address space?

Regards,

Dmitry.

The problem is rather simple:
I have a mini-filter driver and an ndis miniport-protocol driver (passthru
modification).
Both collect events and write them to a nonpaged cyclic queue. My practical
question is how and where to allocate
the queue for it to be visible to both drivers. I also have a static library
which is responsible for different memory operations.

Thanks a lot, Dmitry.

“Dmitry Geskin” wrote in message news:xxxxx@ntfsd…
> Hi,
>
> I have to drivers and a static lib. Both drivers are linked to this lib.
> The lib is responsible for all memory operations (free, realloc, etc). I
> am allocating the memory from inside the library, but when one of the
> drivers tries to write something the memory appears to be NULL.
>
> Can you please suggest the best design for this issue? Two drivers and a
> library for working with memory? I saw the previous discussion about
> sending IOCTL from one driver to another. Is this really necessary knowing
> that all drivers and kernel libs share the same address space?
>
>
>
> Regards,
>
> Dmitry.
>
>
>

Linking to a static lib means that each driver gets their own copy of the
code and data in the library. If you want them to share the same set of code

  • data then you need a dynamic library or some exchange mechanism (IOCTL,
    etc) to pass a blob from one driver to the other.

-scott


Scott Noone
Consulting Associate
OSR Open Systems Resources, Inc.
http://www.osronline.com

“Dmitry Geskin” wrote in message news:xxxxx@ntfsd…
> Hi,
>
> I have to drivers and a static lib. Both drivers are linked to this lib.
> The lib is responsible for all memory operations (free, realloc, etc). I
> am allocating the memory from inside the library, but when one of the
> drivers tries to write something the memory appears to be NULL.
>
> Can you please suggest the best design for this issue? Two drivers and a
> library for working with memory? I saw the previous discussion about
> sending IOCTL from one driver to another. Is this really necessary knowing
> that all drivers and kernel libs share the same address space?
>
>
>
> Regards,
>
> Dmitry.
>
>
>

A static lib is not shared between both drivers, each driver has its own
copy of the library both code and data. So if your goal was to allocate
memory in one driver then have the second driver reference through a
pointer stored in the library you are out of luck.

You do not need to do IOCTL’s there are a number of techniques depending
on what your overall goal is. You can do an IOCTL that returns a set of
pointers to calls you want to share from the other driver, you can use a
PnP device interface to do the same thing with the advantage you can be
notified when the interface is available, and the reference count means
you have some control over the other driver going away. Finally, you
can use a kernel mode DLL which does display the sharing you were
expecting.

So tell the list what your reasoning is behind the library and two
driver design, and we can help you select a good solution.

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

-----Original Message-----
From: Dmitry Geskin [mailto:xxxxx@gmail.com]
Posted At: Thursday, July 08, 2010 9:21 AM
Posted To: ntfsd
Conversation: sharing memory between two drivers with static lib
Subject: sharing memory between two drivers with static lib

Hi,

I have to drivers and a static lib. Both drivers are linked to this
lib. The
lib is responsible for all memory operations (free, realloc, etc). I
am
allocating the memory from inside the library, but when one of the
drivers
tries to write something the memory appears to be NULL.

Can you please suggest the best design for this issue? Two drivers and
a
library for working with memory? I saw the previous discussion about
sending
IOCTL from one driver to another. Is this really necessary knowing
that all
drivers and kernel libs share the same address space?

Regards,

Dmitry.

__________ Information from ESET Smart Security, version of virus
signature
database 5262 (20100708) __________

The message was checked by ESET Smart Security.

http://www.eset.com

> Both collect events and write them to a nonpaged cyclic queue. My practical

question is how and where to allocate
the queue for it to be visible to both drivers.

I would use 2 queues.


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