If you are talking about a getting a constant address/offset like methods etc, then no. Instance/objects are dynamically allocated and each time their address will be entirely different.
You can still pass the inst pointer to your function pointer and it will work, but the original function have to be called at least once beforehand
[
Like what i just did? But i think it'll be useless but thank youIf you are talking about a getting a constant address/offset like methods etc, then no. Instance/objects are dynamically allocated and each time their address will be entirely different.
You can still pass the inst pointer to your function pointer and it will work, but the original function have to be called at least once beforehand
void* instptr;
void (*_addMoney)(void* instance, int amount);
void addMoney(void* instance, int amount){
if(instance != NULL)
instptr = instance;
_addMoney(instance, amount);
}
}
// A function pointer to addMoney function
void (*addMoneyPtr)(void* instance, int amount);
//Now you can call it anywhere, for example inside an update function like so
void (*_update)(void* instance);
void update(void* instance){
if(instance != NULL && instptr != NULL){
addMoneyPtr(instptr, <your amount>);
}
_update(instance);
}
Unfortunately i didnt find any update function i also tried finding a function that is called every time addmoney is called and i had bo luck. Is it possible that the instance cant be in the dump?
It's fine now i found a function that is called every time something happens in the game in the same class as addMoney and the hook look like thisAnyways, putting this particular function inside an update makes no sense. You wouldn't want the money getting increased on every frame.
The point was to help you understand about your particular question and how instance/this pointer works
Теперь все в порядке, я нашел функцию, которая поднималась каждый раз, когда в игре что-то происходит в том же классе, что и addMoney, и хук выглядит так
недействующим *Inst;
AddMoneyExample(void *instance, целое количество);
void (*ExampleFunction)(void *instance, int param); // ФУНКЦИЯ, КОТОРАЯ ВЫЗЫВАЕТСЯ КАЖДЫЙ РАЗ
void _ExampleFunction (void * instance, int param) {
если (экземпляр != NULL) {
ЛОГД("ПОЛУЧЕНИЕ ЭКЗЕМПЛЯРА");
Инст = экземпляр;
ЛОГД("ГОТОВО");
}
ExampleFunction(экземпляр, параметр);
}
и я не хочу, чтобы каждый раз, когда функция подъема, деньги добавлялись, поэтому я рекомендую указывать функцию в учете
дело 115:
если (Inst != NULL) {
AddMoneyExample(Inst, 99999);
LOGD("ДЕНЬГИ ЗАЧИСЛЕНЫ");
}
ломать;
Работает как шарм
[/ЦИТИРОВАТЬ]
Здравствуйте! Может показать весь код (Main.cpp)
We use cookies to personalize content and ads, to provide social media features and to analyse our traffic. We also share necessary information with our advertising and analytics partners to optimize your experience on our site.
Learn more about cookies
We use cookies to personalize content and ads, to provide social media features and to analyse our traffic. We also share necessary information with our advertising and analytics partners to optimize your experience on our site.
Learn more about cookies