Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I am not sure if a module exists for this, but ... I am testing a SNMP agent function and want to allocate 100 meg out of the Windows non-paged memory pool, using the equivallent of ExAllocatePoolWithQuotaTag() or AllocateCommonBuffer(). Has anyone done this before?
  • Comment on Windows Non-Paged Pool Memory Allocation

Replies are listed 'Best First'.
Re: Windows Non-Paged Pool Memory Allocation
by BrowserUk (Patriarch) on Oct 31, 2006 at 12:44 UTC

    Are you (attempting to) writing a device driver in Perl?

    If so, you're probably into a world of grief

    If not, why do you want to use non-paged memory from an application?


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      This is meant to test the allocation. We have a few kernal leaks and want to detect the problem via an SNMP trap. I need to test that the trap will fire. So I need to run a program that will eat up a ton of non-paged windows memory to force the trap. I would rather not purchase a C compiler to run the test ... so I want to see if a perl module has already incorporated this OS specific function. Make sense?

        Okay, but you are going to be out of luck. According to the docs, both those apis need to be called from code running at an IRQ level:

        Callers of ExAllocatePoolWithQuotaTag must be running at IRQL <= APC_L +EVEL. Callers of AllocateCommonBuffer must be running at IRQL = PASSIVE_LEVE +L.

        If you knew (or search) to locate the dll they are exported from, the you could attempt to call them using Win32::API, but unless you know a way to cause your Perl script to be called by the kernel as an IRQ handler, it isn't going to to work.


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.
        Umm, you can download many C or C++ compilers gratis.

        Even MS its self makes a free version of Visual C++ 2005 (which will compile C code also) though obviously you would not be getting source code there