summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--LUA_API.rst4
-rw-r--r--Lua API.html3
-rw-r--r--library/LuaApi.cpp12
3 files changed, 19 insertions, 0 deletions
diff --git a/LUA_API.rst b/LUA_API.rst
index f3d26eac..1723711d 100644
--- a/LUA_API.rst
+++ b/LUA_API.rst
@@ -1168,6 +1168,10 @@ and are only documented here for completeness:
Sets the global address ``name``. Returns the value of ``getAddress`` before the change.
+* ``dfhack.internal.getVTable(name)``
+
+ Returns the pre-extracted vtable address ``name``, or *nil*.
+
* ``dfhack.internal.getBase()``
Returns the base address of the process.
diff --git a/Lua API.html b/Lua API.html
index 90e61211..f1bdd17d 100644
--- a/Lua API.html
+++ b/Lua API.html
@@ -1326,6 +1326,9 @@ global environment, persistent between calls to the script.</p>
<li><p class="first"><tt class="docutils literal">dfhack.internal.setAddress(name, value)</tt></p>
<p>Sets the global address <tt class="docutils literal">name</tt>. Returns the value of <tt class="docutils literal">getAddress</tt> before the change.</p>
</li>
+<li><p class="first"><tt class="docutils literal">dfhack.internal.getVTable(name)</tt></p>
+<p>Returns the pre-extracted vtable address <tt class="docutils literal">name</tt>, or <em>nil</em>.</p>
+</li>
<li><p class="first"><tt class="docutils literal">dfhack.internal.getBase()</tt></p>
<p>Returns the base address of the process.</p>
</li>
diff --git a/library/LuaApi.cpp b/library/LuaApi.cpp
index cdfd4789..631b3c49 100644
--- a/library/LuaApi.cpp
+++ b/library/LuaApi.cpp
@@ -1080,6 +1080,17 @@ static int internal_setAddress(lua_State *L)
return 1;
}
+static int internal_getVTable(lua_State *L)
+{
+ const char *name = luaL_checkstring(L, 1);
+ uint32_t addr = (uint32_t)Core::getInstance().vinfo->getVTable(name);
+ if (addr)
+ lua_pushnumber(L, addr);
+ else
+ lua_pushnil(L);
+ return 1;
+}
+
static int internal_getMemRanges(lua_State *L)
{
std::vector<DFHack::t_memrange> ranges;
@@ -1200,6 +1211,7 @@ static int internal_diffscan(lua_State *L)
static const luaL_Reg dfhack_internal_funcs[] = {
{ "getAddress", internal_getAddress },
{ "setAddress", internal_setAddress },
+ { "getVTable", internal_getVTable },
{ "getMemRanges", internal_getMemRanges },
{ "memmove", internal_memmove },
{ "memcmp", internal_memcmp },