| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. | 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 #include <process.h> | 7 #include <process.h> |
| 8 #include <stdio.h> | 8 #include <stdio.h> |
| 9 #include <stdlib.h> | 9 #include <stdlib.h> |
| 10 #include <windows.h> | 10 #include <windows.h> |
| 11 | 11 |
| 12 #include <exception> | 12 #include <exception> |
| 13 | 13 |
| 14 #include "native_client/src/include/nacl_compiler_annotations.h" |
| 14 #include "native_client/src/shared/platform/nacl_log.h" | 15 #include "native_client/src/shared/platform/nacl_log.h" |
| 15 #include "native_client/src/trusted/debug_stub/abi.h" | 16 #include "native_client/src/trusted/debug_stub/abi.h" |
| 16 #include "native_client/src/trusted/debug_stub/platform.h" | 17 #include "native_client/src/trusted/debug_stub/platform.h" |
| 17 | 18 |
| 18 /* | 19 /* |
| 19 * Define the OS specific portions of IPlatform interface. | 20 * Define the OS specific portions of IPlatform interface. |
| 20 */ | 21 */ |
| 21 | 22 |
| 22 static DWORD Reprotect(void *ptr, uint32_t len, DWORD newflags) { | 23 static DWORD Reprotect(void *ptr, uint32_t len, DWORD newflags) { |
| 23 DWORD oldflags; | 24 DWORD oldflags; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 40 uint32_t oldFlags = Reprotect(reinterpret_cast<void*>(virt), | 41 uint32_t oldFlags = Reprotect(reinterpret_cast<void*>(virt), |
| 41 len, PAGE_EXECUTE_READWRITE); | 42 len, PAGE_EXECUTE_READWRITE); |
| 42 | 43 |
| 43 if (oldFlags == -1) return false; | 44 if (oldFlags == -1) return false; |
| 44 | 45 |
| 45 memcpy(dst, reinterpret_cast<void*>(virt), len); | 46 memcpy(dst, reinterpret_cast<void*>(virt), len); |
| 46 (void) Reprotect(reinterpret_cast<void*>(virt), len, oldFlags); | 47 (void) Reprotect(reinterpret_cast<void*>(virt), len, oldFlags); |
| 47 return true; | 48 return true; |
| 48 } | 49 } |
| 49 | 50 |
| 50 bool IPlatform::SetMemory(uint64_t virt, uint32_t len, void *src) { | 51 bool IPlatform::SetMemory(struct NaClApp *nap, uint64_t virt, uint32_t len, |
| 52 void *src) { |
| 53 UNREFERENCED_PARAMETER(nap); |
| 51 uint32_t oldFlags = Reprotect(reinterpret_cast<void*>(virt), | 54 uint32_t oldFlags = Reprotect(reinterpret_cast<void*>(virt), |
| 52 len, PAGE_EXECUTE_READWRITE); | 55 len, PAGE_EXECUTE_READWRITE); |
| 53 | 56 |
| 54 if (oldFlags == -1) return false; | 57 if (oldFlags == -1) return false; |
| 55 | 58 |
| 56 memcpy(reinterpret_cast<void*>(virt), src, len); | 59 memcpy(reinterpret_cast<void*>(virt), src, len); |
| 57 FlushInstructionCache(GetCurrentProcess(), | 60 FlushInstructionCache(GetCurrentProcess(), |
| 58 reinterpret_cast<void*>(virt), len); | 61 reinterpret_cast<void*>(virt), len); |
| 59 (void) Reprotect(reinterpret_cast<void*>(virt), len, oldFlags); | 62 (void) Reprotect(reinterpret_cast<void*>(virt), len, oldFlags); |
| 60 return true; | 63 return true; |
| 61 } | 64 } |
| 62 | 65 |
| 63 } // End of port namespace | 66 } // End of port namespace |
| 64 | 67 |
| OLD | NEW |