COVERAGE SUMMARY
FILE SUMMARY
NameExecutedRoutines%ExecutedLines%Unexecuted
/home/matt/eu/rds/include/std/memconst.e55100.00%4343100.00%0
ROUTINE SUMMARY
RoutineExecutedLinesUnexecuted
test_exec()33100.00%0
test_read()33100.00%0
test_write()33100.00%0
valid_memory_protection_constant()22100.00%0
valid_wordsize()22100.00%0
LINE COVERAGE DETAIL
#Executed
1
namespace memconst
2
3
--****
4
-- === Microsoft Windows Memory Protection Constants === @[microsoftsmemoryprotectionconstants]
5
-- These constant names are taken right from Microsoft's Memory Protection constants.
6
7101
ifdef WIN32 then
8
--**
9
-- You may run the data in this page
10
public constant PAGE_EXECUTE = #10
11
12
--**
13
-- You may read or run the data
14
public constant PAGE_EXECUTE_READ = #20
15
16
--**
17
-- You may run, read or write in this page
18
public constant PAGE_EXECUTE_READWRITE = #40
19
20
--**
21
-- You may run or write in this page
22
public constant PAGE_EXECUTE_WRITECOPY = #80
23
24
--**
25
-- You may write to this page.
26
public constant PAGE_WRITECOPY = #08
27
28
--**
29
-- You may read or write in this page.
30
public constant PAGE_READWRITE = #04
31
32
--**
33
-- You may only read data in this page
34
public constant PAGE_READONLY = #02
35
36
--**
37
-- You have no access to this page
38
public constant PAGE_NOACCESS = #01
39
40
41
elsedef
42
43
constant
44101
PROT_EXEC = 4,
45101
PROT_READ = 1,
46101
PROT_WRITE = 2,
47101
PROT_NONE = 0
48
49101
public constant PAGE_EXECUTE = PROT_EXEC,
50101
PAGE_EXECUTE_READ = or_bits( PROT_READ, PROT_EXEC ),
51101
PAGE_EXECUTE_READWRITE = or_bits( PROT_READ, or_bits( PROT_EXEC, PROT_WRITE ) ),
52101
PAGE_EXECUTE_WRITECOPY = or_bits( PROT_READ, or_bits( PROT_EXEC, PROT_WRITE ) ),
53101
PAGE_WRITECOPY = or_bits( PROT_READ, PROT_WRITE ),
54101
PAGE_READWRITE = or_bits( PROT_READ, PROT_WRITE ),
55101
PAGE_READONLY = PROT_READ,
56101
PAGE_NOACCESS = PROT_NONE
57
58
end ifdef
59
60
--****
61
-- === Standard Library Memory Protection Constants === @[stardardlibrarymemoryprotectionconstants]
62
--
63
--
64
-- Memory Protection Constants are the same constants names and meaning
65
-- across all platforms yet possibly of different numeric value.
66
-- They are only necessary for [[:allocate_protect]]
67
--
68
-- The constant names are created like this: You have four aspects of protection
69
-- READ, WRITE, EXECUTE and COPY.
70
-- You take the word PAGE and you concatonate an underscore and the aspect
71
-- in the order above. For example: PAGE_WRITE_EXECUTE
72
-- The sole exception to this nomenclature is when you will have no acesss to the page the
73
-- constant is called PAGE_NOACCESS.
74
75
--**
76
-- You have no access to this page
77
-- An alias to PAGE_NOACCESS
78101
public constant PAGE_NONE = PAGE_NOACCESS
79
80
--**
81
-- You may read or run the data
82
-- An alias to PAGE_EXECUTE_READ
83101
public constant PAGE_READ_EXECUTE = PAGE_EXECUTE_READ
84
85
--**
86
-- You may read or write to this page
87
-- An alias to PAGE_READWRITE
88101
public constant PAGE_READ_WRITE = PAGE_READWRITE
89
90
--**
91
-- You may only read to this page
92
-- An alias to PAGE_READONLY
93101
public constant PAGE_READ = PAGE_READONLY
94
95
--**
96
-- You may run, read or write in this page
97
-- An alias to PAGE_EXECUTE_READWRITE
98101
public constant PAGE_READ_WRITE_EXECUTE = PAGE_EXECUTE_READWRITE
99
100
--**
101
-- You may run or write to this page. Data
102
-- will copied for use with other processes when
103
-- you first write to it.
104101
public constant PAGE_WRITE_EXECUTE_COPY = PAGE_EXECUTE_WRITECOPY
105
106
--**
107
-- You may write to this page. Data
108
-- will copied for use with other processes when
109
-- you first write to it.
110101
public constant PAGE_WRITE_COPY = PAGE_WRITECOPY
111
112
113
114
115101
export constant MEMORY_PROTECTION = {
116
PAGE_EXECUTE,
117
PAGE_EXECUTE_READ,
118
PAGE_EXECUTE_READWRITE,
119
PAGE_EXECUTE_WRITECOPY,
120
PAGE_WRITECOPY,
121
PAGE_READWRITE,
122
PAGE_READONLY,
123
PAGE_NOACCESS
124
}
125
126130
127130
return 0 != find( x, MEMORY_PROTECTION )
128
end type
129
130
13130
132
-- does this protection allow for reading?
13330
ifdef UNIX then
134
-- take advantage of the use of bit fields in UNIX for protections
13530
return and_bits(PROT_READ,protection) != 0
136
elsedef
137
return find( protection, { PAGE_EXECUTE_READ, PAGE_EXECUTE_READWRITE,
138
PAGE_READWRITE, PAGE_READONLY } )
139
end ifdef
140
end function
141
142
14330
144
-- does this protection allow for writing?
14530
ifdef UNIX then
146
-- take advantage of the use of bit fields in UNIX for protections
14730
return and_bits(PROT_WRITE,protection) != 0
148
elsedef
149
return find( protection, { PAGE_EXECUTE_READWRITE,
150
PAGE_EXECUTE_WRITECOPY,
151
PAGE_WRITECOPY,
152
PAGE_READWRITE})
153
end ifdef
154
end function
155
15612
157
-- does this protection allow for executing?
15812
ifdef UNIX then
159
-- take advantage of the use of bit fields in UNIX for protections
16012
return and_bits(PROT_EXEC,protection) != 0
161
elsedef
162
return find(protection,{PAGE_EXECUTE,
163
PAGE_EXECUTE_READ,
164
PAGE_EXECUTE_READWRITE,
165
PAGE_EXECUTE_WRITECOPY})
166
end ifdef
167
end function
168
169
17023
17123
return find(i, {1,2,4})!=0
172
end type
173
174101
export integer DEP_really_works = 0
175101
export integer use_DEP = 1
176
177
-- Windows constants
178101
export constant MEM_COMMIT = #1000,
179101
MEM_RESERVE = #2000,
180101
MEM_RESET = #80000,
181101
MEM_RELEASE = #8000
182
183
export integer FREE_RID
184
185101
public enum A_READ = 1, A_WRITE = 2, A_EXECUTE = 3
186
187
export constant
188101
M_ALLOC = 16,
189101
M_FREE = 17
190
191
export atom kernel_dll, memDLL_id,
192
VirtualAlloc_rid, VirtualLock_rid, VirtualUnlock_rid,
193
VirtualProtect_rid, GetLastError_rid, GetSystemInfo_rid