[英]Calling function from DLL injected into process and changing the addresses of the pointer functions
Hello I'm having this problem; 您好,我遇到了这个问题; I want to call functions from a process with my injected DLL, but I'd like to be able to change the address of the function since the addresses differ from each program version.
我想从使用注入的DLL的进程中调用函数,但是我希望能够更改函数的地址,因为每个程序版本的地址都不相同。
Basically I got DllMain resulting into making a new Thread which does the same as in this main example. 基本上,我得到了DllMain并产生了一个新的Thread,其作用与此主要示例相同。
typedef void (*func_t)();
func_t func = (func_t)0x2000; //as an example
int main(int argc, char* argv[]) {
int type = 1;
if(type == 0) {
*func = 0x2001; //altough *(int*)func = 0x2001; works but it doesn't change it
}
func(); //func will do the same in each version of the program except the addresses change so you can e.g change the type with cin >> type; and that'll it work
}
I get this: error: assignment of read-only location '* func 我得到这个:错误:只读位置'* func的赋值
Thanks 谢谢
*func = 0x2001;
You probably want to do the opposite. 您可能想做相反的事情。 change
func
instead of *func
to the address of the function. 将
func
而不是*func
更改为*func
的地址。 For example this will work: 例如,这将起作用:
func = (func_t)0x2001;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.