Solved How to restore field offset original value?

Status
Not open for further replies.

RazerTexz

Platinian
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;
 
Solution
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...
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;
 
Solution
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.
Back
Top Bottom