Help! void

Viktorovich31

Platinian
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"));
}
 
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);
}
Thanks, I will try! Another question is how to correctly find the required update method if it is not in the class?
 
Нет, 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?
 
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);
 
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);
}
 
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!
 
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

  • Screenshot_20221227_000043_MT Manager.jpg
    Screenshot_20221227_000043_MT Manager.jpg
    94.6 KB · Views: 60
  • Screenshot_20221227_000254_MT Manager.jpg
    Screenshot_20221227_000254_MT Manager.jpg
    153.9 KB · Views: 65
  • Screenshot_20221227_000343_MT Manager.jpg
    Screenshot_20221227_000343_MT Manager.jpg
    157.4 KB · Views: 67
  • dump.zip
    dump.zip
    2.1 MB · Views: 121
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

  • Screenshot_20221227_000043_MT Manager.jpg
    Screenshot_20221227_000043_MT Manager.jpg
    94.6 KB · Views: 51
  • Screenshot_20221227_000254_MT Manager.jpg
    Screenshot_20221227_000254_MT Manager.jpg
    153.9 KB · Views: 52
  • Screenshot_20221227_000343_MT Manager.jpg
    Screenshot_20221227_000343_MT Manager.jpg
    157.4 KB · Views: 48
  • dump.zip
    dump.zip
    2.1 MB · Views: 111
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
 
Back
Top Bottom