non-paged memory under windows

John Checco checco at
Wed Apr 7 15:03:04 CEST 2004

just to re-iterate your point, I've worked on a project that needed
non-paged memory to pass to a frame-grabber pci board... We found out the
hard way that none of the retail functions ever guaranteed memory was not
paged -- we ended up creating our own memory device driver, including
creation of SGLs and IRPs and using ExAllocatePool... needless to say, true
non-paged access is really difficult to implement under Windows.

----- Original Message ----- 
From: "Peter Gutmann" <pgut001 at>
To: <gnupg-devel at>; <wk at>
Sent: Wednesday, April 07, 2004 7:22 AM
Subject: Re: GPG random data gathering

> Werner Koch <wk at> writes:
> >On Wed, 07 Apr 2004 02:45:01 -0500, J Vender said:
> >>Does GnuPG lock the memory where the passphrase is stored, like PGP
> >
> >It does thi on systems wehere it is possible It is not possible under
> >without installing a special driver to support unswappable memory - there
> >exists no such free driver.  All Windows functions claiming to lock the
> >memory don't do what you would expect them to do.
> Actually there's a lot of confusion about VirtualLock, with contradicting
> claims about what it really does.  After I did my analysis of it (and
> unfortunately too late to make it into the book), an MS security person
had a
> close look at it and was unable to get VirtualLock()'ed memory paged out
> matter what he did.  He also checked with someone who had worked on
> VirtualLock who said that it did indeed prevent the memory from being
> The problem is that there have been instances in the past where an MS
> developer has believed that his code did X when in fact it did Y, since
> have been reports from other sources that it does result in data being
> my best guess is that it did this under NT and perhaps early Win2K, but
> been changed in newer Win2K and XP.  It may also be that since
> has per-page granularity, some of the people who reported data being
> experienced this because they'd VirtualUnlock()'ed adjacent data on the
> page.  My code goes to some lengths to ensure that it never
> anything on the same page, although if your keys happen to share a page
> data that something else VirtualUnlock()'s then that guarantee is gone.
To in
> turn get around *that*, you can use VirtualAlloc() in place of malloc(),
> specifying memory blocks in 4K increments.  This kinda wastes memory (and
> means you have to do additional work to handle thread-safety), but it does
> mean you can completely control the memory you're getting.
> You can also get nonpageable memory using AWE (Address Windowing
> but the interface to that is clunky to say the least.
> Peter.
> _______________________________________________
> Gnupg-devel mailing list
> Gnupg-devel at

More information about the Gnupg-devel mailing list