winelib: Remapping and utilizing reserved low memory area

Open forum for end-user questions about Wine. Before asking questions, check out the Wiki as a first step.
Forum Rules
Locked
haxar
Newbie
Newbie
Posts: 2
Joined: Wed Jun 27, 2012 2:09 pm

winelib: Remapping and utilizing reserved low memory area

Post by haxar »

I need to utilize some virtual memory at 0x10000 for an emulator requiring the Windows layer. Unfortunately, I could not find any documentation on the virtual memory utilized by Wine between 0x10000 and 0x20000000 other than being reserved for DOS.

Low memory map of a Wine process:

Code: Select all

00010000-00120000 rw-p 00000000 00:00 0 
00120000-00220000 ---p 00000000 00:00 0 
00220000-00223000 rw-p 00000000 00:00 0 
00223000-00224000 ---p 00000000 00:00 0 
00224000-00230000 ---p 00000000 00:00 0 
00230000-00232000 ---p 00000000 00:00 0 
00232000-00330000 rw-p 00000000 00:00 0 
00330000-20000000 ---p 00000000 00:00 0 
I can undo reserve_dos_area() from libs/wine/mmap.c but the area when accessed by ntdll page faults with:

Code: Select all

wine: Unhandled page fault on read access to 0x00110acc at address 0x7ef7e5f9 (thread 0025), starting debugger...
err:seh:raise_exception Unhandled exception code c0000005 flags 0 addr 0x7ef76890
This is reproducible with:

Code: Select all

/* winegcc -m32 -Wall -Wextra -g -O0 loader.c -o loader */

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/mman.h>

#include <wine/library.h>

int
main(int argc, char **argv) {
    (void)argc, (void)argv;
    int fd;

    fd = open("/dev/zero", O_RDONLY);
    wine_mmap_remove_reserved_area(NULL, 0x232000, 1);
    mmap((void *)0x10000, 0x232000 - 0x10000, PROT_NONE, MAP_PRIVATE | MAP_FIXED | MAP_NORESERVE, fd, 0);
    wine_mmap_add_reserved_area(NULL, 0x232000);

    return 0;
}
haxar
Newbie
Newbie
Posts: 2
Joined: Wed Jun 27, 2012 2:09 pm

Post by haxar »

kevlarman in #winehq suggested to use VirtualAlloc instead.
Locked