I've got the address of struct(I think it is good one) 0040336C I tried to use it in the DLL I am injecting into some program(where the address is)
It's really experimental because I am trying to get lua_State address.
data:0040336C ?L@@3PAUlua_State@@A dd ? ; DATA XREF: _main+Cw
lua_State* L = (lua_State*)0x0040336C;
I tried this way but program crashes just after I inject it.
(What debugger says)
Unhandled exception at 0x003a19e8 in midaslua.exe: 0xC0000005: Access violation reading location 0x443de713.
The first address you cited is an address of struct inside a DLL's data section , but the address you are trying to dereference is an address in the process's memory . These two addresses are not of the same kind, so it is impossible to use them like you did.
Effectively, you tried to dereference a piece of memory, where application might or might not have stored some data and treated this piece of memory as a lua_State
(which, mostly probably, it is not). That resulted in undefined behavior, ending up with an AV.
It's hard (maybe even impossible) to locate a place in memory, where this variable is stored in process's memory. Another approach is advised.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.