View Single Post
  #4  
Old March 13th 12, 11:02 AM posted to alt.windows7.general
Paul
external usenet poster
 
Posts: 18,275
Default How to allocate physically contiguous memory in user mode onwindows 7

rsyed wrote:
Paul wrote on 03/12/2012 13:39 ET :
rsyed wrote:
Hello,

I want to allocate non paged physically contiguous memory in system memory in
"user mode". Can any one suggest me the API through which we can
achieve this, or the way we can achieve this.

FYI,
I know that we can achieve this in kernel mode using the API
"MmAllocateContiguousMemory".

Regards,
Rahim.



We have a requirement to allocate a pinned memory(non swappable physical
page memory) in user mode of windows 7, can someone suggest how this can be
achieved in user mode, which are the windows API's available.
Little explanation and Links to the documents would be helpful.

Regards,
Rahim.


http://blogs.technet.com/b/markrussi...7/3155406.aspx

Keyword is virtualalloc.

*******

This answer doesn't seem to be right. The problem is, the virtual memory system
consists of the amount of physical memory in the system, plus the paging file.
Virtualalloc, by the nature of its name, would not be distinguishing between
those kinds of memory.

My guess is, a slightly different means will be needed.

http://www.windows-api.com/microsoft...ser-space.aspx

"VirtualAlloc can let you do this if you have the correct privilege enabled."

*******

This thread has a few suggestions.

http://social.msdn.microsoft.com/For...6-4df5e7a4d924

This one makes more sense. "AllocateUserPhysicalPages". That acquires physical
memory, but without virtual addresses being allocated for them. They still need
a virtual mapping, before being used.

http://msdn.microsoft.com/en-us/libr...28(VS.85).aspx

There is a code example here, linked from the previous page.

http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx

Article on AWE Extensions.

http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx

AWE relies on PAE mode, which is enabled on WinXP SP2 or SP3 as far
as I know. And probably on later OSes. Even if a machine has less
than 4GB of memory installed, PAE would still be enabled, because
on WinXP it is used for NX protection (No Execute). NX prevents
certain kinds of malware attacks.

http://en.wikipedia.org/wiki/Address...ing_Extensions

*******

So it can be done, but it isn't the simplest thing in the world.
As the user space program needs the privilege granted for
that function (SeLockMemoryPrivilege).

There is a claim here, that 7ZIP is setting that privilege :-)
And it requires a reboot, to take effect. That implies to me,
that if you had access to the source code of 7ZIP, you might
find a worked example of such a memory allocation.

http://sourceforge.net/projects/seve.../topic/4609502

And another example here for setting SeLockMemoryPrivilege.

http://www.tek-tips.com/viewthread.cfm?qid=1020893

I'm not a software programmer. You should consult a Windows
programming group, for the language you intend to use,
for a real answer.

Just a guess,
Paul
Ads