Solved How to restore field offset original value?

Status
Not open for further replies.

RazerTexz

Platinian
Original poster
May 17, 2020
36
5
8
the void
Is there a way to restore this field offset original value when the toggle is off?

Code:
bool isUnlimitedFlashbang;

void (*old_playerToolsSection)(void *instance);
void playerToolsSection(void *instance) {
    if (instance != NULL) {
        if (isUnlimitedFlashbang) {
            *(int *) ((uint32_t) instance + 0x10C) = 5;
        }
    }
    return old_playerToolsSection(instance);
}

HOOK_LIB("libil2cpp.so", "0x4631A0", playerToolsSection, old_playerToolsSection);

case 3:
    isUnlimitedFlashbang = boolean;
    break;
 

Mika Cybertron

PMT Elite Modder
Staff member
Modding-Team
Mar 24, 2017
912
65,567
1,213
24
Indonesia
well you need to get the first value before you change it's value, but i'm not sure if it works, here is the code
C++:
static int originalValue;
bool isUnlimitedFlashbang;

void (*old_playerToolsSection)(void *instance);
void playerToolsSection(void *instance) {
    if (instance != NULL) {
        if (originalValue == NULL) { // check if originalValue still NULL
            originalValue  = *(int *) ((uint32_t) instance + 0x10C); // store value to originalValue (1 times)
        }
        if (isUnlimitedFlashbang) {
            *(int *) ((uint32_t) instance + 0x10C) = 5;
        } else {
            *(int *) ((uint32_t) instance + 0x10C) = originalValue; // return to original value
        }
    }
    return old_playerToolsSection(instance);
}

HOOK_LIB("libil2cpp.so", "0x4631A0", playerToolsSection, old_playerToolsSection);

case 3:
    isUnlimitedFlashbang = boolean;
    break;
 

RazerTexz

Platinian
Original poster
May 17, 2020
36
5
8
the void
well you need to get the first value before you change it's value, but i'm not sure if it works, here is the code
C++:
static int originalValue;
bool isUnlimitedFlashbang;

void (*old_playerToolsSection)(void *instance);
void playerToolsSection(void *instance) {
    if (instance != NULL) {
        if (originalValue == NULL) { // check if originalValue still NULL
            originalValue  = *(int *) ((uint32_t) instance + 0x10C); // store value to originalValue (1 times)
        }
        if (isUnlimitedFlashbang) {
            *(int *) ((uint32_t) instance + 0x10C) = 5;
        } else {
            *(int *) ((uint32_t) instance + 0x10C) = originalValue; // return to original value
        }
    }
    return old_playerToolsSection(instance);
}

HOOK_LIB("libil2cpp.so", "0x4631A0", playerToolsSection, old_playerToolsSection);

case 3:
    isUnlimitedFlashbang = boolean;
    break;
Sorry for late reply but thanks!
 
Status
Not open for further replies.