Help! void

Viktorovich31

Platinian
Original poster
Sep 16, 2022
38
0
6
42
Russian
Please tell me, am I calling the "LocalStore" class correctly, in which I need to change the field "int _coinCount; // 0x3C"?
Code:
void* LocalStore;

void (*old_update)(void* instance);
void update(void* instance){
    if(instance != NULL && LocalStore != NULL){
      *(int *)((uint64_t)LocalStore + 0x3C) = 999;
     }
     old_update(instance);
}

__attribute__((constructor))
void libhook_main() {
    do {
        sleep(1);
    } while (!isLibraryLoaded(OBFUSCATE("libil2cpp.so")));
    LOGI(OBFUSCATE("lib loaded"));
    HOOK_LIB("libil2cpp.so", "0x9A1F34", update, old_update);
    LOGI(OBFUSCATE("lib hooked"));
}
 

HekaHeka709

Solid & Active Platinian
Dec 29, 2021
57
9
8
20
Phillipines
No, LocalStore is NULL because it's not initialized. I suppose that you're trying to hook field in LocalStore through Update function outside the LocalStore class.
To fix your hook initialize LocalStore before hooking the field

void *LocalStore; //DECLARING A GLOBAL VARIABLE

void (*old_update)(void *instance);
void update(void *instance) {
if (instance != NULL) //CHECK IF INSTANCE IS NOT NULL
{
LocalStore = *(void **) ((uint64_t)instance + (LOCALSTORE OFFSET)); //INITIAZLIZING LOCALSTORE
if (LocalStore == NULL) return; //REMOVE USELESS THINGS
//THIS IS WHERE YOU CAN HOOK THE FIELD
*(int *) ((uint64_t) LocalStore + 0x3C) = 999;
LOGD("FIELD HOOKED");
}
old_update(instance);
}
 

Viktorovich31

Platinian
Original poster
Sep 16, 2022
38
0
6
42
Russian
No, LocalStore is NULL because it's not initialized. I suppose that you're trying to hook field in LocalStore through Update function outside the LocalStore class.
To fix your hook initialize LocalStore before hooking the field

void *LocalStore; //DECLARING A GLOBAL VARIABLE

void (*old_update)(void *instance);
void update(void *instance) {
if (instance != NULL) //CHECK IF INSTANCE IS NOT NULL
{
LocalStore = *(void **) ((uint64_t)instance + (LOCALSTORE OFFSET)); //INITIAZLIZING LOCALSTORE
if (LocalStore == NULL) return; //REMOVE USELESS THINGS
//THIS IS WHERE YOU CAN HOOK THE FIELD
*(int *) ((uint64_t) LocalStore + 0x3C) = 999;
LOGD("FIELD HOOKED");
}
old_update(instance);
}
Thanks, I will try! Another question is how to correctly find the required update method if it is not in the class?
 

Viktorovich31

Platinian
Original poster
Sep 16, 2022
38
0
6
42
Russian
Нет, LocalStore имеет значение NULL, потому что оно не инициализировано. Я предполагаю, что вы пытаетесь перехватить поле в LocalStore через функцию Update вне класса LocalStore.
Чтобы исправить ваш хук, инициализируйте LocalStore перед подключением поля.

недействительным *LocalStore; // ОБЪЯВЛЕНИЕ ГЛОБАЛЬНОЙ ПЕРЕМЕННОЙ

void (*old_update)(void *instance);
недействительное обновление (недействительное * экземпляр) {
if (instance != NULL) // ПРОВЕРЯЕМ, ЕСЛИ ЭКЗЕМПЛЯР НЕ NULL
{
LocalStore = *(void **) ((uint64_t)экземпляр + (LOCALSTORE OFFSET)); // ИНИЦИАЛИЗАЦИЯ LOCALSTORE
если (LocalStore == NULL) вернуть; //УДАЛЯЕМ БЕСПОЛЕЗНЫЕ ВЕЩИ
// ЗДЕСЬ ВЫ МОЖЕТЕ ПРИСОЕДИНИТЬСЯ К ПОЛЕ
*(int *) ((uint64_t) LocalStore + 0x3C) = 999;
LOGD("ПОЛЕ ПОДКЛЮЧЕНО");
}
old_update (экземпляр);
}

[/ЦИТИРОВАТЬ]
No, LocalStore is NULL because it's not initialized. I suppose that you're trying to hook field in LocalStore through Update function outside the LocalStore class.
To fix your hook initialize LocalStore before hooking the field

void *LocalStore; //DECLARING A GLOBAL VARIABLE

void (*old_update)(void *instance);
void update(void *instance) {
if (instance != NULL) //CHECK IF INSTANCE IS NOT NULL
{
LocalStore = *(void **) ((uint64_t)instance + (LOCALSTORE OFFSET)); //INITIAZLIZING LOCALSTORE
if (LocalStore == NULL) return; //REMOVE USELESS THINGS
//THIS IS WHERE YOU CAN HOOK THE FIELD
*(int *) ((uint64_t) LocalStore + 0x3C) = 999;
LOGD("FIELD HOOKED");
}
old_update(instance);
}
No, LocalStore is NULL because it's not initialized. I suppose that you're trying to hook field in LocalStore through Update function outside the LocalStore class.
To fix your hook initialize LocalStore before hooking the field

void *LocalStore; //DECLARING A GLOBAL VARIABLE

void (*old_update)(void *instance);
void update(void *instance) {
if (instance != NULL) //CHECK IF INSTANCE IS NOT NULL
{
LocalStore = *(void **) ((uint64_t)instance + (LOCALSTORE OFFSET)); //INITIAZLIZING LOCALSTORE
if (LocalStore == NULL) return; //REMOVE USELESS THINGS
//THIS IS WHERE YOU CAN HOOK THE FIELD
*(int *) ((uint64_t) LocalStore + 0x3C) = 999;
LOGD("FIELD HOOKED");
}
old_update(instance);
}
Please look, did I do it right?
No, LocalStore is NULL because it's not initialized. I suppose that you're trying to hook field in LocalStore through Update function outside the LocalStore class.
To fix your hook initialize LocalStore before hooking the field

void *LocalStore; //DECLARING A GLOBAL VARIABLE

void (*old_update)(void *instance);
void update(void *instance) {
if (instance != NULL) //CHECK IF INSTANCE IS NOT NULL
{
LocalStore = *(void **) ((uint64_t)instance + (LOCALSTORE OFFSET)); //INITIAZLIZING LOCALSTORE
if (LocalStore == NULL) return; //REMOVE USELESS THINGS
//THIS IS WHERE YOU CAN HOOK THE FIELD
*(int *) ((uint64_t) LocalStore + 0x3C) = 999;
LOGD("FIELD HOOKED");
}
old_update(instance);
}
void *LocalStore;

void (*old_update)(void *instance);
void update(void *instance) {
if (instance != NULL)
{
LocalStore = *(void **) ((uint64_t)instance + (0x3C));
if (LocalStore == NULL) return;
*(int *) ((uint64_t) LocalStore + 0x3C) = 999;
LOGD("FIELD HOOKED");
}
old_update(instance);
}
Please look, did I do it right?
No, LocalStore is NULL because it's not initialized. I suppose that you're trying to hook field in LocalStore through Update function outside the LocalStore class.
To fix your hook initialize LocalStore before hooking the field

void *LocalStore; //DECLARING A GLOBAL VARIABLE

void (*old_update)(void *instance);
void update(void *instance) {
if (instance != NULL) //CHECK IF INSTANCE IS NOT NULL
{
LocalStore = *(void **) ((uint64_t)instance + (LOCALSTORE OFFSET)); //INITIAZLIZING LOCALSTORE
if (LocalStore == NULL) return; //REMOVE USELESS THINGS
//THIS IS WHERE YOU CAN HOOK THE FIELD
*(int *) ((uint64_t) LocalStore + 0x3C) = 999;
LOGD("FIELD HOOKED");
}
old_update(instance);
}
void *LocalStore;

void (*old_update)(void *instance);
void update(void *instance) {
if (instance != NULL)
{
LocalStore = *(void **) ((uint64_t)instance + (0x3C));
if (LocalStore == NULL) return;
*(int *) ((uint64_t) LocalStore + 0x3C) = 999;
LOGD("FIELD HOOKED");
}
old_update(instance);
}
Please look, did I do it right?
 

Smiley3rd

Platinian
Oct 4, 2020
28
132
28
23
Indonesia
Please look, did I do it right?

void *LocalStore;

void (*old_update)(void *instance);
void update(void *instance) {
if (instance != NULL)
{
LocalStore = *(void **) ((uint64_t)instance + (0x3C));
if (LocalStore == NULL) return;
*(int *) ((uint64_t) LocalStore + 0x3C) = 999;
LOGD("FIELD HOOKED");
}
old_update(instance);
}
Please look, did I do it right?

No, remove the brackets like this

LocalStore = *(void **) ((uint64_t)instance + 0x3C);
 

Smiley3rd

Platinian
Oct 4, 2020
28
132
28
23
Indonesia
Thank you! But it doesn't work in both cases.
When you said it dosen't work, could you be more specific?
It doesn't work when building or the hook doesn't work?

If the hook doesn't work, try to check if 'LocalStore' is null

what it should look like:


void (*old_update)(void *instance);
void update(void *instance) {
if (instance != NULL)
{
LocalStore = *(void **) ((uint64_t)instance + 0x3C);
if (LocalStore != NULL)
{
*(int *) ((uint64_t) LocalStore + 0x3C) = 999;
LOGD("FIELD HOOKED");
old_update(instance);
}
}
old_update(instance);
}
 

Viktorovich31

Platinian
Original poster
Sep 16, 2022
38
0
6
42
Russian
When you said it dosen't work, could you be more specific?
It doesn't work when building or the hook doesn't work?

If the hook doesn't work, try to check if 'LocalStore' is null

what it should look like:


void (*old_update)(void *instance);
void update(void *instance) {
if (instance != NULL)
{
LocalStore = *(void **) ((uint64_t)instance + 0x3C);
if (LocalStore != NULL)
{
*(int *) ((uint64_t) LocalStore + 0x3C) = 999;
LOGD("FIELD HOOKED");
old_update(instance);
}
}
old_update(instance);
}
Thank you!
 

Viktorovich31

Platinian
Original poster
Sep 16, 2022
38
0
6
42
Russian
When you said it dosen't work, could you be more specific?
It doesn't work when building or the hook doesn't work?

If the hook doesn't work, try to check if 'LocalStore' is null

what it should look like:


void (*old_update)(void *instance);
void update(void *instance) {
if (instance != NULL)
{
LocalStore = *(void **) ((uint64_t)instance + 0x3C);
if (LocalStore != NULL)
{
*(int *) ((uint64_t) LocalStore + 0x3C) = 999;
LOGD("FIELD HOOKED");
old_update(instance);
}
}
old_update(instance);
}
Hello! Please help, I'm completely confused. Did I do right? The hook doesn't work! And how to correctly find the update method in the dump? I used any, probably it's not correct.
 

Attachments

Smiley3rd

Platinian
Oct 4, 2020
28
132
28
23
Indonesia
Hello! Please help, I'm completely confused. Did I do right? The hook doesn't work! And how to correctly find the update method in the dump? I used any, probably it's not correct.
I don't know why it still doesn't work but maybe because of how you hooked the field? try to set to true or false not number
 

Raebydett

Awesome Active Platinian
Jan 20, 2020
171
60
28
G
It didnt work bcs u using wrong update method, also theres no instance on that class pointing to class usersavedata

void* UserSaveData = *(void **) ((uint64_t) instance + 0x9); <--- your offset doesnt point to anything
 

Viktorovich31

Platinian
Original poster
Sep 16, 2022
38
0
6
42
Russian
It didnt work bcs u using wrong update method, also theres no instance on that class pointing to class usersavedata

void* UserSaveData = *(void **) ((uint64_t) instance + 0x9); <--- your offset doesnt point to anything
Help me please! How to do it right?