1 | // Licensed to the .NET Foundation under one or more agreements. |
---|---|
2 | // The .NET Foundation licenses this file to you under the MIT license. |
3 | // See the LICENSE file in the project root for more information. |
4 | |
5 | /*++ |
6 | |
7 | |
8 | |
9 | Module Name: |
10 | |
11 | common.c |
12 | |
13 | Abstract: |
14 | |
15 | Implementation of the common mapping functions. |
16 | |
17 | |
18 | |
19 | --*/ |
20 | |
21 | #include "pal/palinternal.h" |
22 | #include "pal/dbgmsg.h" |
23 | |
24 | #include "common.h" |
25 | |
26 | #include <sys/mman.h> |
27 | |
28 | SET_DEFAULT_DEBUG_CHANNEL(VIRTUAL); |
29 | |
30 | /***** |
31 | * |
32 | * W32toUnixAccessControl( DWORD ) - Maps Win32 to Unix memory access controls . |
33 | * |
34 | */ |
35 | INT W32toUnixAccessControl( IN DWORD flProtect ) |
36 | { |
37 | INT MemAccessControl = 0; |
38 | |
39 | switch ( flProtect & 0xff ) |
40 | { |
41 | case PAGE_READONLY : |
42 | MemAccessControl = PROT_READ; |
43 | break; |
44 | case PAGE_READWRITE : |
45 | MemAccessControl = PROT_READ | PROT_WRITE; |
46 | break; |
47 | case PAGE_EXECUTE_READWRITE: |
48 | MemAccessControl = PROT_EXEC | PROT_READ | PROT_WRITE; |
49 | break; |
50 | case PAGE_EXECUTE : |
51 | MemAccessControl = PROT_EXEC; |
52 | break; |
53 | case PAGE_EXECUTE_READ : |
54 | MemAccessControl = PROT_EXEC | PROT_READ; |
55 | break; |
56 | case PAGE_NOACCESS : |
57 | MemAccessControl = PROT_NONE; |
58 | break; |
59 | |
60 | default: |
61 | MemAccessControl = 0; |
62 | ERROR( "Incorrect or no protection flags specified.\n"); |
63 | break; |
64 | } |
65 | return MemAccessControl; |
66 | } |
67 |