ruby: Add unit test for new RLenValue type
[hivex.git] / lib / mmap.h
1 /* mmap replacement for mingw.
2  *
3  * Copyright (C) 2011 by Daniel Gillen <gillen (dot) dan (at) pinguin (dot) lu>
4  *
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.
9  *
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.
14  */
15
16 #ifndef HIVEX_MMAP_H_
17 #define HIVEX_MMAP_H_
18
19 #include <stdlib.h>
20 #include <sys/types.h>
21
22 #include "hivex.h"
23 #include "hivex-internal.h"
24
25 /* Hack to pass the hive handle to the replacement mmap and munmap
26  * functions. XXX
27  */
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))
30
31 // Supported map protections.
32 #define PROT_READ   0x1  /* Page can be read.  */
33
34 // Supported sharing types (must choose one and only one of these).
35 #define MAP_SHARED  0x01 /* Share changes.  */
36
37 // Value that is returned when mapping failed
38 #define MAP_FAILED  NULL
39
40 /*
41  * hivex replacement mmap
42  *
43  * Parameters:
44  *   h                : Hive handle
45  *   void *p_addr     : Preferred starting address for the mapping. Unsupported
46  *                      and must be NULL.
47  *   size_t len       : Mapping length (From offset to offset+len-1).
48  *   int prot         : Flags that control what kind of access is permitted.
49  *                      Must be PROT_READ.
50  *   int flags        : Flags that control the nature of the map. Must be
51  *                      MAP_SHARED.
52  *   int fd           : File descriptor of file to be mapped.
53  *   off_t offset     : Mapping offset.
54  *
55  * Returns:
56  *   Map address on success or MAP_FAILED on error.
57  */
58 extern void *hivex__rpl_mmap (hive_h *h, void *p_addr, size_t len, int prot, int flags, int fd, off_t offset);
59
60 /*
61  * hivex replacement munmap
62  *
63  * Parameters:
64  *   h               : Hive handle
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.
68  *
69  * Returns:
70  *   0 on success or -1 on error.
71  */
72 extern int hivex__rpl_munmap (hive_h *h, void *p_addr, size_t len);
73
74 #endif /* HIVEX_MMAP_H_ */