Search code examples
lualua-tablerobloxmetatable

Lua getmetatable() a locked table


In the lua programming language, I know that you can lock the metatable of userdata with the metamethod __metatable so that no-one can view the userdata's metatable with the getmetatable() function. But, I still want to access that metatable after its been locked. So, my question is, after the userdata's metatable is locked, is it still possible (maybe through some backdoor) to still get the metatable of the locked userdata, or is it just not possible (if so, then for what reasons)?

EDIT #1: My motivation for wanting to know this is because I am trying to find a backdoor into Roblox's API so that I can more effectively script my games.


Solution

  • This applies at least to lua 5.3

    In lua you can use the debug library method debug.getmetatable. That should return the original metatable regardless of the __metatable metamethod. In C you can use the function lua_getmetatable for same purpose.

    Also you could always make a variable somewhere to where you store the metatable and can access it later through that variable later.

    Also if you used luaL_newmetatable, then you can still find the metatable in the registery with the metatable name you used.