简体   繁体   English

在DLL中使用的结构地址

[英]Struct address to use in DLL

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) 我有结构体的地址(我认为这是个好方法)0040336C我试图在要注入某些程序的DLL中使用它(该地址为)

It's really experimental because I am trying to get lua_State address. 这真的是实验性的,因为我正在尝试获取lua_State地址。

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. midaslua.exe中0x003a19e8处未处理的异常:0xC0000005:访问冲突读取位置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 . 您引用的第一个地址是DLL的数据段中struct的地址,但是您要取消引用的地址是进程内存中的地址。 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). 实际上,您尝试取消对内存的引用,而应用程序可能已存储或未存储某些数据,并将该内存视为lua_State (大多数情况下不是)。 That resulted in undefined behavior, ending up with an AV. 这导致了不确定的行为,最终导致了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. 建议另一种方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM