Click here to Skip to main content
16,004,678 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralHere's a good one! .cram files! Pin
steve333317-May-05 4:02
steve333317-May-05 4:02 
QuestionHow to load bitmap, which is located in Access, on a FormView (MFC) Pin
chinook7517-May-05 3:43
chinook7517-May-05 3:43 
GeneralGetting command line parameters of a running process Pin
rocky_pulley17-May-05 3:36
rocky_pulley17-May-05 3:36 
GeneralRe: Getting command line parameters of a running process Pin
«_Superman_»17-May-05 4:26
professional«_Superman_»17-May-05 4:26 
GeneralRe: Getting command line parameters of a running process Pin
rocky_pulley17-May-05 4:41
rocky_pulley17-May-05 4:41 
GeneralRe: Getting command line parameters of a running process Pin
David Crow17-May-05 5:53
David Crow17-May-05 5:53 
GeneralRe: Getting command line parameters of a running process Pin
David Crow17-May-05 4:43
David Crow17-May-05 4:43 
GeneralAllocating very large memory Pin
Orkun GEDiK17-May-05 3:35
Orkun GEDiK17-May-05 3:35 
Hello,

I am facing with a problem while trying to allocate very large memory by AWE APIs on Windows 2003 Advanced Server. I developed following code in order to allocate large memory portion, but I couldn't allocate it;

#include "stdafx.h"
#define _WIN32_WINNT 0x0500
#include <windows.h>
#include <stdio.h>
#define MEM_ALLOC 1024 * 1024 * 1024 * 4 // allocate physical memory

int _tmain(int argc, _TCHAR* argv[])
{
struct {
DWORD count;
LUID_AND_ATTRIBUTES privilege[1];
} info;

HANDLE token=0x0;
BOOL result=FALSE;
int iPageCount=0x0;
int PFNarraysize=0x0;
ULONG_PTR NumberOfPages=0x0;
ULONG_PTR* PFNarraylist=0x0;
SYSTEM_INFO sys_info;
PVOID lpMemoryWindow=0x0;

// get system page size
GetSystemInfo(&sys_info);

// calculate how many pages required
iPageCount = MEM_ALLOC / sys_info.dwPageSize;

// PFN requested size
PFNarraysize = iPageCount * sizeof(ULONG_PTR);

// allocate array for PFN array
PFNarraylist = (ULONG_PTR*)HeapAlloc(GetProcessHeap(), 0, PFNarraysize);

// ------------------------------------------------------------- //
// check user privileges in order to lock memory on the system
result = OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &token);
// set privilege attributes
info.privilege[0].Attributes = SE_PRIVILEGE_ENABLED;
// lookup user privileges
result = LookupPrivilegeValue(NULL, SE_LOCK_MEMORY_NAME, &(info.privilege[0].Luid));
// info count
info.count=0x1;
// retrieve user privilege
result = AdjustTokenPrivileges(token, FALSE, (PTOKEN_PRIVILEGES)&info, 0, NULL, NULL);
// close token handle
CloseHandle(token);
// ------------------------------------------------------------- //

// create memory window
lpMemoryWindow=VirtualAlloc(NULL, MEM_ALLOC, MEM_RESERVE | MEM_PHYSICAL, PAGE_READWRITE);
NumberOfPages = iPageCount;

// allocate physical memory - I
result = AllocateUserPhysicalPages(GetCurrentProcess(), &NumberOfPages, PFNarraylist);

// map user physical page to the window - I
result = MapUserPhysicalPages(lpMemoryWindow, iPageCount, PFNarraylist);

// use memory
lstrcpy((LPSTR)lpMemoryWindow, TEXT("OGED"));
}

In the example that I wrote above can allocate 2 gb or less memory but not more and I am sure that I have 16 Gb physical memory.

How can I allocate and use more than 4 Gb memory? Can anybody give an example about AWE?

PS: I am aware about MSDN AWE and MSDJ - 99 examples, but they are not a solution for my case.

Regards,

Orkun GEDiK
SAP R/3 Software & System Support Specialist
ASTRON
GeneralRe: Allocating very large memory Pin
James R. Twine17-May-05 3:41
James R. Twine17-May-05 3:41 
GeneralRe: Allocating very large memory Pin
Orkun GEDiK17-May-05 8:26
Orkun GEDiK17-May-05 8:26 
GeneralProperty Pages and CTreeCtrl Updates Pin
jamesrgoodwin17-May-05 3:19
jamesrgoodwin17-May-05 3:19 
GeneralRe: Property Pages and CTreeCtrl Updates Pin
Jack Puppy17-May-05 4:11
Jack Puppy17-May-05 4:11 
GeneralRe: Property Pages and CTreeCtrl Updates Pin
jamesrgoodwin17-May-05 4:24
jamesrgoodwin17-May-05 4:24 
GeneralRegarding the value that appears in the first two bytes of a bmp image Pin
MoQuisha17-May-05 2:22
MoQuisha17-May-05 2:22 
GeneralRe: Regarding the value that appears in the first two bytes of a bmp image Pin
Priyank Bolia17-May-05 2:27
Priyank Bolia17-May-05 2:27 
GeneralRe: Regarding the value that appears in the first two bytes of a bmp image Pin
Bob Stanneveld17-May-05 2:42
Bob Stanneveld17-May-05 2:42 
GeneralRe: Regarding the value that appears in the first two bytes of a bmp image Pin
Chris Losinger17-May-05 7:17
professionalChris Losinger17-May-05 7:17 
Question#define ?? Pin
Bob Stanneveld17-May-05 2:18
Bob Stanneveld17-May-05 2:18 
AnswerRe: #define ?? Pin
toxcct17-May-05 2:21
toxcct17-May-05 2:21 
GeneralRe: #define ?? Pin
Bob Stanneveld17-May-05 2:23
Bob Stanneveld17-May-05 2:23 
AnswerRe: #define ?? Pin
ThatsAlok17-May-05 2:23
ThatsAlok17-May-05 2:23 
GeneralRe: #define ?? Pin
Bob Stanneveld17-May-05 2:24
Bob Stanneveld17-May-05 2:24 
AnswerAlmost solved! Pin
Bob Stanneveld17-May-05 2:59
Bob Stanneveld17-May-05 2:59 
AnswerRe: #define ?? Pin
Tim Smith17-May-05 3:20
Tim Smith17-May-05 3:20 
QuestionUser script or other technique? Pin
lynchspawn17-May-05 2:14
lynchspawn17-May-05 2:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.