diff options
| author | Alexander Gavrilov | 2012-08-17 14:32:04 +0400 |
|---|---|---|
| committer | Alexander Gavrilov | 2012-08-17 15:07:48 +0400 |
| commit | bcc41c081a43a68042c4757a6569cb690098d9b8 (patch) | |
| tree | 583f40741778c0e0634fd50610cf6c6f4d979a05 /library/LuaApi.cpp | |
| parent | 509d9570908e1befa537d10285942006d148b3a3 (diff) | |
| download | dfhack-bcc41c081a43a68042c4757a6569cb690098d9b8.tar.gz dfhack-bcc41c081a43a68042c4757a6569cb690098d9b8.tar.bz2 dfhack-bcc41c081a43a68042c4757a6569cb690098d9b8.tar.xz | |
Add a utility function for patching read-only memory.
Diffstat (limited to 'library/LuaApi.cpp')
| -rw-r--r-- | library/LuaApi.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/library/LuaApi.cpp b/library/LuaApi.cpp index b0a085ec..108dba88 100644 --- a/library/LuaApi.cpp +++ b/library/LuaApi.cpp @@ -1124,6 +1124,17 @@ static int internal_getMemRanges(lua_State *L) return 1; } +static int internal_patchMemory(lua_State *L) +{ + void *dest = checkaddr(L, 1); + void *src = checkaddr(L, 2); + int size = luaL_checkint(L, 3); + if (size < 0) luaL_argerror(L, 1, "negative size"); + bool ok = Core::getInstance().p->patchMemory(dest, src, size); + lua_pushboolean(L, ok); + return 1; +} + static int internal_memmove(lua_State *L) { void *dest = checkaddr(L, 1); @@ -1214,6 +1225,7 @@ static const luaL_Reg dfhack_internal_funcs[] = { { "setAddress", internal_setAddress }, { "getVTable", internal_getVTable }, { "getMemRanges", internal_getMemRanges }, + { "patchMemory", internal_patchMemory }, { "memmove", internal_memmove }, { "memcmp", internal_memcmp }, { "memscan", internal_memscan }, |
