Add an api function to get vtable address from version info.

develop
Alexander Gavrilov 2012-06-17 14:26:27 +04:00
parent 67536da2fe
commit fa41a27f26
3 changed files with 19 additions and 0 deletions

@ -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.

@ -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>

@ -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 },