Help! Byte offset

Jan Skokan

Platinian
Original poster
Apr 29, 2023
9
0
1
German
Hi, can someone please help me? I found an offset for double coins for the game HCR (Hill Climb Racing) and found out an unpleasant news. Offset works only in the lua script, but not in the mod menu. Offset is in byte format or I don't know what exactly it is, and in GG (Game Guardian) it supports byte. Can someone please tell me how to make this offset work even in the lgl mod menu?
2023-05-24-17-26-22-182~2.jpg
Screenshot_20230524-183239_Hill_Climb_Racing.png
 
Last edited:

NotALegitGuy

Solid & Active Platinian
Sep 24, 2018
69
67
18
Costa Rica
Just dereference it, gonna assume you want to set it to a number.
Should work.

C++:
*reinterpret_cast<int*>(getAbsoluteAddress(0x69BD50)) = 1000000;
 
  • Like
Reactions: ekajeel

Jan Skokan

Platinian
Original poster
Apr 29, 2023
9
0
1
German
Just dereference it, gonna assume you want to set it to a number.
Should work.

C++:
*reinterpret_cast<int*>(getAbsoluteAddress(0x69BD50)) = 1000000;
This is how it looks in my lua script
C++:
function HackFunction(ToF)
  if Hack == "A" then
    if ToF == true then
      setHexMemory("libgame.so", 0x69BD50, "20 00 80 D2 C0 03 5F D6")
      gg.toast("✅")
    else
      setHexMemory("libgame.so", 0x69BD50, "00 00 00 00 00 00 00 00")
      gg.toast("❌")
    end
20 00 80 D2 C0 03 5F D6 = 1

And this is how it looks in my mod menu

C++:
struct My_Patches {
    DoubleCoins;

} hexPatches;

bool feature1 = false;

hexPatches.DoubleCoins = MemoryPatch::createWithHex("libgame.so",0x69BD50, "20 00 80 D2 C0 03 5F D6");

switch (featNum) {
        case 0:
            feature1 = boolean;
            if (feature1) {
                hexPatches.DoubleCoins.Modify();
            } else {
                hexPatches.DoubleCoins.Restore();
            }
           break;
    }
}
Yes, the code is abbreviated, but that's the point. And it still doesn't work. I would like to say that you sent me the code, so I don't know exactly how to correctly put it in main.cpp, I'm not that experienced in hook. Could you please tell me what I should put in switch (featNum) { when I want to use the getAbsoluteAddress method?
 

Jan Skokan

Platinian
Original poster
Apr 29, 2023
9
0
1
German
Now I did it.. But the double coins hack only works when I start the game.. When I quit the game and go back to the garage and start the game again, double coins doesn't work anymore.. I have to complete start the game again.. I need the hook to return after shutdown value to 0 because even the lua script must be switched off and on again for it to work. Can you please help me with the hook? I need the hook to return 0 after the function is turned off

Screenshot_20230527-204307_Hill Climb Racing.png


C++:
bool AddCoins;

void (*old_coins)(void *instance, int value);
void coins(void *instance, int value) {
    if (instance != NULL) {
        if (AddCoins) {
            old_coins(instance, 1);
            return;
        }
    }
    old_coins(instance, value);
}


HOOK_LIB("libgame.so", "0x5182BC", coins, old_coins);


switch (featNum) {
        case 0:
         AddCoins = boolean;
         break;