MCPcopy Create free account
hub / github.com/DFHack/dfhack / internal_setAddress

Function internal_setAddress

library/LuaApi.cpp:3747–3772  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3745}
3746
3747static int internal_setAddress(lua_State *L)
3748{
3749 string name = luaL_checkstring(L, 1);
3750 uintptr_t addr = (uintptr_t)checkaddr(L, 2, true);
3751 internal_getAddress(L);
3752
3753 // Set the address
3754 Core::getInstance().vinfo->setAddress(name, addr);
3755
3756 auto fields = df::global::_identity.getFields();
3757
3758 for (int i = 0; fields && fields[i].mode != struct_field_info::END; ++i)
3759 {
3760 if (fields[i].name != name)
3761 continue;
3762
3763 *(void**)fields[i].offset = (void*)addr;
3764 }
3765
3766 // Print via printerr, so that it is definitely logged to stderr.log.
3767 uintptr_t iaddr = addr - Core::getInstance().vinfo->getRebaseDelta();
3768 fmt::print(stderr, "Setting global '{}' to {} ({})\n", name, (addr), (void*)iaddr);
3769 fflush(stderr);
3770
3771 return 1;
3772}
3773
3774static int internal_getVTable(lua_State *L)
3775{

Callers

nothing calls this directly

Calls 3

checkaddrFunction · 0.85
internal_getAddressFunction · 0.85
printFunction · 0.50

Tested by

no test coverage detected