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.
Basically I got DllMain resulting into making a new Thread which does the same as in this main example.
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
Thanks
*func = 0x2001;
You probably want to do the opposite. change func
instead of *func
to the address of the function. For example this will work:
func = (func_t)0x2001;
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.