Skip to content

Commit 9afe46c

Browse files
committed
- fix lua_touserdata causing crash
1 parent 4192256 commit 9afe46c

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

DriverLuaShim/DriverLuaShim.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ static uintptr_t kluaIndex2adrAddr = 0x005E91C0; // for some reason it crashes g
4444
static uintptr_t kluaToLStringAddr = 0x005F2D20;
4545
static uintptr_t kluaVToNumberAddr = 0x005ED760;
4646
static uintptr_t kluaToBooleanAddr = 0x005E94E0;
47+
static uintptr_t kluaToUserdataAddr = 0x005E9540;
4748
static uintptr_t kluaCreateTableAddr = 0x005F2EA0;
4849
static uintptr_t kluaRawSetAddr = 0x005EDA20;
4950

@@ -429,12 +430,9 @@ LUA_API const TValue* luaV_tonumber(const TValue* obj, TValue* n)
429430
// direct reimpl
430431
LUA_API void* lua_touserdata(lua_State* L, int idx)
431432
{
432-
StkId o = index2adr(L, idx);
433-
switch (ttype(o)) {
434-
case LUA_TUSERDATA: return (rawuvalue(o) + 1);
435-
case LUA_TLIGHTUSERDATA: return pvalue(o);
436-
default: return NULL;
437-
}
433+
typedef void* (*lua_touserdata_t)(lua_State*, int);
434+
return ((lua_touserdata_t)kluaToUserdataAddr)(L, idx);
435+
438436
}
439437

440438
// direct reimpl

0 commit comments

Comments
 (0)