1 /* mmap replacement for mingw.
3 * Copyright (C) 2011 by Daniel Gillen <gillen (dot) dan (at) pinguin (dot) lu>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation;
8 * version 2.1 of the License.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
20 #include <sys/types.h>
23 #include "hivex-internal.h"
25 /* Hack to pass the hive handle to the replacement mmap and munmap
28 #define mmap(a,b,c,d,e,f) hivex__rpl_mmap(h,(a),(b),(c),(d),(e),(f))
29 #define munmap(a,b) hivex__rpl_munmap(h,(a),(b))
31 // Supported map protections.
32 #define PROT_READ 0x1 /* Page can be read. */
34 // Supported sharing types (must choose one and only one of these).
35 #define MAP_SHARED 0x01 /* Share changes. */
37 // Value that is returned when mapping failed
38 #define MAP_FAILED NULL
41 * hivex replacement mmap
45 * void *p_addr : Preferred starting address for the mapping. Unsupported
47 * size_t len : Mapping length (From offset to offset+len-1).
48 * int prot : Flags that control what kind of access is permitted.
50 * int flags : Flags that control the nature of the map. Must be
52 * int fd : File descriptor of file to be mapped.
53 * off_t offset : Mapping offset.
56 * Map address on success or MAP_FAILED on error.
58 extern void *hivex__rpl_mmap (hive_h *h, void *p_addr, size_t len, int prot, int flags, int fd, off_t offset);
61 * hivex replacement munmap
65 * void *p_addr : Startaddress of mapping created with mmap
66 * size_t len : Lenght of mapping to be unmapped. Unsupported. The whole
67 * mapping will always be unmapped.
70 * 0 on success or -1 on error.
72 extern int hivex__rpl_munmap (hive_h *h, void *p_addr, size_t len);
74 #endif /* HIVEX_MMAP_H_ */