Re: Memory allocation in windows kernel driver




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


.



Relevant Pages

  • Re: non-paged memory inside a kernel driver
    ... Windows 2k/XP/2k3 Filesystem and Driver Consulting ... With their stuff running I cannot allocate 10 MB 's on a XP system. ... so I need 100MB of non-paged memory inside my driver. ...
    (microsoft.public.development.device.drivers)
  • Re: Memory fragmentation issue in kernel mode
    ... Also, on the Performance tab, watch the Kernel Memory section. ... fragmentation, which is actually fragmentation of the system virtual ... A user level application doesn't allocate and even access the ... I have my driver that uses direct IO to perform data transfer ...
    (microsoft.public.development.device.drivers)
  • Re: non-paged memory inside a kernel driver
    ... I've seen kernel memory leaks up to full memory exaustion when Symantec AV ... Windows 2k/XP/2k3 Filesystem and Driver Consulting ... With their stuff running I cannot allocate 10 MB 's on a XP system. ...
    (microsoft.public.development.device.drivers)
  • Re: non-paged memory inside a kernel driver
    ... With their stuff running I cannot allocate 10 MB 's on a XP system. ... disk and one flash. ... so I need 100MB of non-paged memory inside my driver. ...
    (microsoft.public.development.device.drivers)
  • PROBLEM: Memory leak in -test9?
    ... There seems to be a memory leak in 2.6.0-test9. ... 0cf8-0cff: PCI conf1 ... 16 nodes reported by PnP BIOS; 16 recorded by driver ... ide0 at 0x1f0-0x1f7,0x3f6 on irq 14 ...
    (Linux-Kernel)