2 * reactos memory areas emulation of libcaptive
3 * Copyright (C) 2002 Jan Kratochvil <project-captive@jankratochvil.net>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; exactly version 2 of June 1991 is required
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "captive/mm.h" /* self, for captive_flProtect_to_mmap_prot() */
23 #include "reactos/internal/mm.h" /* self */
24 #include "reactos/ntos/types.h" /* for PVOID etc. */
25 #include <glib/gmessages.h>
26 #include <sys/mman.h> /* for PROT_NONE etc. */
31 * @Length: Length (in bytes) of the area to allocate. Does not have to be page
32 * aligned. Value 0 is forbidden.
34 * Allocates @Length area with %PAGE_READWRITE flags.
36 * Returns: Allocated address space if the allocation was successful.
38 PVOID STDCALL MmAllocateSection(IN ULONG Length)
40 int mmap_prot=captive_flProtect_to_mmap_prot(PAGE_READWRITE);
43 g_return_val_if_fail(Length>0,NULL);
45 Length=(Length|(PAGE_SIZE-1))+1; /* round up to PAGE_SIZE */
51 MAP_PRIVATE|MAP_ANONYMOUS, /* flags */
52 -1, /* fd; ignored due to MAP_ANONYMOUS */
53 0); /* offset; ignored due to MAP_ANONYMOUS */
54 g_return_val_if_fail(r!=NULL,NULL);
56 captive_mmap_map_new(r,Length,mmap_prot);