Memory allocation in windows kernel driver

C

chiara

Hi all, I'm approaching in the development of windows drivers and I'm
trying to modify the passthru driver provided in the Windows Driver
Development Kit.

In particular I have some problems in memory allocation. I have to
memorize into the passthru driver packets received from driver
Tcpip.sys before sending them through the NIC. Once I have memorized
the bytes of the packets I can send them, but I have also to operate
into the allocated zone of memory modifying its content.

I don't know if I can use the function malloc() to allocate a zone of
memory into the driver because I try to use it but when I build the
driver I have the error unresoved external symbol _imp_malloc
It is possible to create a pointer to an array of pointers to memorize
the packets before sending it? If yes, can I use the function malloc()
to allocate memory?

I read also that the routine ExAllocatePool() is used to allocate pool
memory in windows drivers. Can I use it to memorize a large quantity
of bytes before sending it through the NIC? If yes, what is the
type of pool memory I have to allocate, non paged or paged? I read
that the system can only allocate buffers larger than PAGE_SIZE from
nonpaged pool in multiples of PAGE_SIZE but I don't understand what is
the value of PAGE_SIZE.

Is there anyone that can help me?

Thank you,

Chiara
 
D

Doron Holan [MSFT]

the equivalent of malloc is ExAllocatePool. I would guess you will need
NonPagedPool. As for what you can allocate, you can do wahtever you want, it
is just C after all. You can allocate any size pointer you want from
NonPagedPool. If you don't know what a page is or what PAGE_SIZE means, you
really should educate yourself before you ever step foot into kernel mode.

d
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top