Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(331)

Side by Side Diff: runtime/vm/virtual_memory_win.cc

Issue 10830045: - Add the ability to protect VirtualMemory. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/virtual_memory_macos.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/virtual_memory.h" 5 #include "vm/virtual_memory.h"
6 6
7 #include "platform/assert.h" 7 #include "platform/assert.h"
8 8
9 namespace dart { 9 namespace dart {
10 10
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 bool VirtualMemory::Commit(uword addr, intptr_t size, bool executable) { 52 bool VirtualMemory::Commit(uword addr, intptr_t size, bool executable) {
53 ASSERT(Contains(addr)); 53 ASSERT(Contains(addr));
54 ASSERT(Contains(addr + size) || (addr + size == end())); 54 ASSERT(Contains(addr + size) || (addr + size == end()));
55 int prot = executable ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE; 55 int prot = executable ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE;
56 if (VirtualAlloc(address(), size, MEM_COMMIT, prot) == NULL) { 56 if (VirtualAlloc(address(), size, MEM_COMMIT, prot) == NULL) {
57 return false; 57 return false;
58 } 58 }
59 return true; 59 return true;
60 } 60 }
61 61
62
63 bool VirtualMemory::Protect(Protection mode) {
64 int prot = 0;
65 switch (mode) {
66 case kNoAccess:
67 prot = PAGE_NOACCESS;
68 break;
69 case kReadOnly:
70 prot = PAGE_READONLY;
71 break;
72 case kReadWrite:
73 prot = PAGE_READWRITE;
74 break;
75 case kReadExecute:
76 prot = PAGE_EXECUTE_READ;
77 break;
78 case kReadWriteExecute:
79 prot = PAGE_EXECUTE_READWRITE;
80 break;
81 }
82 int old_prot = 0;
83 return VirtualProtect(address(), size(), prot, &old_prot);
84 }
85
62 } // namespace dart 86 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/virtual_memory_macos.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698