Tasty copypasta for Shamun!
Ive thought about this too and Ive come to think that it can be done if you call some of the other lua functions in the game.
Here are the right addresses for 3.0.3 (credits WoWX):
Code:
[17:39:07]: 0x0077DEF0 -> Lua_Dostring
[17:39:07]: 0x0077CD20 -> Lua_Register
[17:39:07]: 0x00401980 -> Lua_Reload
[17:39:07]: 0x007AD380 -> lua_gettop
[17:39:07]: 0x007AD7E0 -> lua_tonumber
[17:39:07]: 0x007AD820 -> lua_tointeger
[17:39:07]: 0x007AD890 -> lua_tostring
[17:39:07]: 0x007AD9C0 -> lua_touserdata
[17:39:07]: 0x007AD860 -> lua_toboolean
[17:39:07]: 0x007ADA50 -> lua_pushnumber
[17:39:08]: 0x007ADA80 -> lua_pushinteger
[17:39:08]: 0x007ADAB0 -> lua_pushstring
[17:39:08]: 0x007ADC80 -> lua_pushboolean
[17:39:08]: 0x007ADBB0 -> lua_pushcclosure
[17:39:08]: 0x007ADA30 -> lua_pushnil
[17:39:08]: 0x007AE0B0 -> lua_setfield
[17:39:08]: 0x007AF010 -> lua_getfield
[17:39:08]: 0x007AD520 -> lua_replace
I just googled some of them, gettop seems to return the size of the lua stack. The tointeger, toboolean etc functions are probably responsible for popping values off the lua stack, so thats what I would look into. Im just guessimating here, hope this helps regardless.
Edit:
Ive taken a further look, heres tointeger in IDA:
Code:
.text:007AD820 lua_tointeger proc near ; CODE XREF: sub_49C810+2Dp
.text:007AD820 ; sub_49C8B0+1Fp ...
.text:007AD820
.text:007AD820 var_1C = dword ptr -1Ch
.text:007AD820 var_C = qword ptr -0Ch
.text:007AD820 var_4 = dword ptr -4
.text:007AD820 arg_0 = dword ptr 8
.text:007AD820 arg_4 = dword ptr 0Ch
.text:007AD820
.text:007AD820 push ebp
.text:007AD821 mov ebp, esp
.text:007AD823 mov eax, [ebp+arg_4]
.text:007AD826 mov ecx, [ebp+arg_0]
.text:007AD829 sub esp, 1Ch
.text:007AD82C call sub_7AD170
.text:007AD831 cmp dword ptr [eax+8], 3
.text:007AD835 jz short loc_7AD84C ; push float to FPUstack
.text:007AD837 lea ecx, [ebp+var_1C]
.text:007AD83A push ecx
.text:007AD83B push eax
.text:007AD83C call sub_7B7AC0
.text:007AD841 add esp, 8
.text:007AD844 test eax, eax
.text:007AD846 jnz short loc_7AD84C ; push float to FPUstack
.text:007AD848 mov esp, ebp
.text:007AD84A pop ebp
.text:007AD84B retn
.text:007AD84C ; ---------------------------------------------------------------------------
.text:007AD84C
.text:007AD84C loc_7AD84C: ; CODE XREF: lua_tointeger+15j
.text:007AD84C ; lua_tointeger+26j
.text:007AD84C fld qword ptr [eax] ; push float to FPUstack
.text:007AD84E fstp [ebp+var_C] ; pop that float at epb-12
.text:007AD851 fld [ebp+var_C] ; reload the value
.text:007AD854 fistp [ebp+var_4] ; pop integer to epb-4
.text:007AD857 mov eax, [ebp+var_4] ; move said integer to eax
.text:007AD85A mov esp, ebp
.text:007AD85C pop ebp
.text:007AD85D retn ; end of story
.text:007AD85D lua_tointeger endp
What Im not sure about is how to push values to the lua stack when you call lua_dostring. Would DoString("return 1;") be enough or do you actually have to declare a variable as in DoString("bla=1;")? Maybe Ill do some testing later today.