Log in

View Full Version : RE : /me asks stupid mem allocation question


kill3xx
June 5th, 2001, 10:28
Hi +Tsehp,

...quoting by hand (donno why u've locked the msg =)
Quote:

a big dilemna; I need to allocate some mem above the 0x7fffffff wall on win9x to
write a global "fault" handler.
I have two choices :
1-the vmm services way : _pageAllocate, etc... and I'm too lazy to take this a first choice
2-the api way, so here's my question : is there a way to allocate + have a handle to allocate such mem, even if I normally should use some ring0 code for those purposes.


1) using the undocumented VirtualAlloc 0x80000000 flag
#define MEM_SHARED_ARENA 0x80000000
PVOID pt = VirtualAlloc( 0, 0x1000, MEM_COMMIT + MEM_SHARED_ARENA,
PAGE_READWRITE );

2) using MMF - win9x MM map the pages for a MMF to the shared arena - side effect: a MMF lays _always_ at
the same linear address in _all_ memory contexts despite the process map it or not

HANDLE hFileMap = CreateFileMapping( INVALID_HANDLE_VALUE, 0,
PAGE_READWRITE, 0, 0x1000, 0 );
if ( hFileMapping )
{
PVOID pt = MapViewOfFile(hFileMapping, FILE_MAP_WRITE, 0, 0, 0x1000);
}

3) more esotic :
emulating kernel32 behaviour using (via K32!ORD_1) the VMM win32 vxd services
_PageReserve(PR_SHARED) and _PageCommit (PC_USER + PC_WRITEABLE)


Best Regards,

kill3xx

tsehp
June 7th, 2001, 02:11
thanks for your reply, the msg was locked by error, I just tried to delete it, now its done.
I only used a mappedfile to have this, auto made in high mem.

thanks for the other interesting tricks.

tsehp
June 7th, 2001, 07:18
btw,
if someone knows an easy solution for this :
I'm writing a small asm program that is called from any process running in win9x, so it's copied inside this mappedfile I have, just above the 7fffffff limit.
But I need to access a variable that was previously declared in the code that copied this small code into the mappedfile, this variable resides in low mem, but when the code is copied into the mappedfile, the variable can't be accessed anymore if the code is called from another process. So I'm just looking for a way to have a variable that directly resides in high mem and declared in c++, not assembly.
tia

+Tsehp