Help! How to hook obscuredfloat function?

You can try this method.

C++:
float GetObscuredFloat(uint64_t location){
    int cryptoKey = *(int *)location;
    intfloat encryptedValue;
    encryptedValue.f = *(float *)(location + 0x4);
    intfloat realValue;
    realValue.i = encryptedValue.i ^ cryptoKey;
    return realValue.f;
}

// this is your hook method
float hook_get_m_fireRate(void *_this) {
    if (_this != NULL){
        uint64_t location = reinterpret_cast<uint64_t>(_this);
        return GetObscuredFloat(location); 
    }
}

// hook 
DobbyHook((void*)getAbsoluteAddress("yourlibhere.so", 0x1A28AE4), (void *)hook_get_m_fireRate, (void **)&orig_get_m_fireRate);
 
C++:
#incluir <dobby.h>
#incluir <stdint.h>

// Decodifica o ObscuredFloat
float GetObscuredFloat(uint64_t localização) {
    int cryptoKey = *(int *)location; // Ler cryptoKey
    união {
        flutuar f;
        uint32_t eu;
    } valor criptografado;
    encryptedValue.f = *(float *)(location + 0x4); // Leia o valor criptografado
    união {
        flutuar f;
        uint32_t eu;
    } valorreal;
    realValue.i = encryptedValue.i ^ cryptoKey; // XOR com cryptoKey
    retornar realValue.f;
}

// Método hooked para substituir get_m_fireRate
flutuar hook_get_m_fireRate(void *_this) {
    se (_isso != NULL) {
        uint64_t localização = reinterpret_cast<uint64_t>(_this);
        
        // Aqui, você precisa ajustar o deslocamento ou a lógica para localizar corretamente `m_fireRate`
        // Assumindo que `location` já é o objeto e `m_fireRate` está no deslocamento esperado
        return GetObscuredFloat(location + 0x10); // Ajustar deslocamento (exemplo)
    }
    return 0.0f; // Retorna um valor padrão se _this for NULL
}

// Função para enganchar
void hookFunction() {
    // Endereço absoluto para o método get_m_fireRate na biblioteca carregada
    void* targetFunction = (void*)getAbsoluteAddress("suabiblioteca.so", 0x1A28AE4);
    
    // Conecte a função usando Dobby
    DobbyHook(targetFunction, (void*)hook_get_m_fireRate, (void**)&orig_get_m_fireRate);
}

// Este é o ponto de entrada, que pode estar no seu código principal ou de inicialização
vazio initHook() {
    hookFunction();
}
[/CÓDIGO]
 
Back
Top Bottom