Re: Memory allocation in windows kernel driver
- From: chiara <tchiara81@xxxxxxxxx>
- Date: 7 May 2007 05:19:43 -0700
I have to hold the complete packet until I have memorized its content
in an allocated zone of memory. I can send it as soos as I have
memorized it.
I have to allocate a space of about 255 kBytes.
I think I could use the routine ExAllocatePool() with the options
NonPagedPool. Is it correct?
Thanks,
Chiara
On May 5, 1:59 pm, "Don Burn" <b...@xxxxxxxxxxxxxxxxxxxx> wrote:
First you are talking a lot of memory here depending on the NIC. Think
carefully about the design, do you really need to hold the complete packet?
If so for how long?
There is no malloc in the kernel, instead there are a number of allocation
routines the most common is ExAllocatePool. Now when you say a large
amount of memory how much? The kernel address space can be limited to 1GB
and there is a lot of things that have to fit in that space.
ExAllocatePool can allocate any size piece of memory (within the limits of
available memory and address space) there is no restriction on allocating
PAGE_SIZE or greater. PAGE_SIZE is the size of one page in the memory
management hardware, for x86 that is 4096 bytes. You probably were reading
if you want things aligned on a PAGE (for DMA purposes) you have to
allocate more that a PAGE_SIZE.
I would strongly recomend you take a class on driver development. If you
cannot, get the "Windows Internals" book by Russinovich and Solomon and
read it throughly, then read Walter Oney's "Programming the Windows Driver
Model, Second Edition", before trying to go forward with any windows driver
development.
Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Website:http://www.windrvr.com
Blog:http://msmvps.com/blogs/WinDrvr
Remove StopSpam to reply
"chiara" <tchiar...@xxxxxxxxx> wrote in message
news:1178363118.356775.216270@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
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
.
- References:
- Memory allocation in windows kernel driver
- From: chiara
- Re: Memory allocation in windows kernel driver
- From: Don Burn
- Memory allocation in windows kernel driver
- Prev by Date: Re: How to refresh the network disk directory?
- Next by Date: Microsoft Management Console Has stopped working
- Previous by thread: Re: Memory allocation in windows kernel driver
- Next by thread: Infrared testing use HCT 12.1 , about Driver verifier -NDIS , can't find ndis.sys
- Index(es):
Relevant Pages
|