Skip to content

Commit

Permalink
added reflection header. updated basic mods and flight mod to work wi…
Browse files Browse the repository at this point in the history
…th svn 637515.
  • Loading branch information
s0t7x committed Feb 8, 2025
1 parent 82ff9d3 commit 1639e5f
Show file tree
Hide file tree
Showing 7 changed files with 486,738 additions and 51 deletions.
65 changes: 17 additions & 48 deletions example-mods/basics_mod/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ ModMetaData metaData = {
true,
};

// Signature for GameVersion (SVN) 602428
// Signature for GameVersion (SVN) 637515
class _Mod {
public:
ModContext* modContext;
Expand Down Expand Up @@ -64,12 +64,9 @@ class NoStaminaLoss : public _Mod
{
// The modded code that will replace the original instructions at the found address.
uint8_t modCode[] = {
0x53, // push rbx
0x8B, 0x5C, 0x81, 0x08, // mov ebx, [rcx+rax*4+8]
0x89, 0x5C, 0x81, 0xFC, // mov [rcx+rax*4-4], ebx
0x5B, // pop rbx
0x8B, 0x04, 0x81, // mov eax, [rcx+rax*4]
0x89, 0x44, 0x24, 0x3C, // mov [rsp+3C], eax
0x89, 0x44, 0x24, 0x40, // mov [rsp+40], eax
0xE9, 0x00, 0x00, 0x00, 0x00 // jmp return
};

Expand All @@ -92,8 +89,8 @@ class NoFallDamage : public _Mod
NoFallDamage(ModContext* modContext) : _Mod(modContext)
{
// Pattern matching the AOB scan for the original code in the target process.
const char* pattern = "\x89\x04\x91\x48\x8D\x4D";
const char* mask = "xxxxxx";
const char* pattern = "\x89\x04\x91\x48\x8D\x4D\x08";
const char* mask = "xxxxxxx";

// Base address of the module (the game).
uintptr_t baseAddress = (uintptr_t)GetModuleHandle(NULL);
Expand All @@ -110,8 +107,8 @@ class NoFallDamage : public _Mod

// no fall damage
uint8_t modCode[] = {
0x48, 0x83, 0xC0, 0x00, // add eax, 0 (equivalent to no operation)
0x48, 0x8D, 0x4D, 0xE0, // lea rcx, [rbp-20]
0x83, 0xC0, 0x00, // add eax, 0 (equivalent to no operation)
0x48, 0x8D, 0x4D, 0x08, // lea rcx, [rbp+08]
0xE9, 0x00, 0x00, 0x00, 0x00 // jmp return (dynamic, needs to be calculated)
};

Expand All @@ -135,62 +132,35 @@ class NoFallDamage : public _Mod
class InfiniteItemUse : public _Mod
{
public:
Mem::Detour* free_ItemUseMod2 = nullptr;

InfiniteItemUse(ModContext* modContext) : _Mod(modContext)
{
// AOB patterns for the original code in the target process.
const char* pattern1 = "\x49\x89\x0E\x41\x2B"; // First AOB
const char* pattern2 = "\x45\x29\x7E\x04\x41\x2B\xEF"; // Second AOB

// Base address of the module (the game).
const char* pattern = "\x41\x29\x6E\x04";
uintptr_t baseAddress = (uintptr_t)GetModuleHandle(NULL);

// Find the patterns within the game memory (scans within 16MB).
uintptr_t address1 = Mem::FindPattern(pattern1, "xxxxx", baseAddress, 0xF0000000);
uintptr_t address2 = Mem::FindPattern(pattern2, "xxxxxxx", baseAddress, 0xF0000000);

// Check if both addresses were found.
if (address1 && address2)
uintptr_t address = Mem::FindPattern(pattern, "xxxx", baseAddress, 0xF0000000);
if (address)
{
// Allocate memory for new instructions to be injected at address1.
uint8_t modCode1[] = {
0x41, 0xBF, 0x00, 0x00, 0x00, 0x00, 0xBD, 0x00, 0x00, 0x00, 0x00, 0xE9, 0x00, 0x00, 0x00, 0x00
uint8_t modCode[] = {
0x41, 0xBF, 0x00, 0x00, 0x00, 0x00,
0xBD, 0x00, 0x00, 0x00, 0x00,
0xE9, 0x00, 0x00, 0x00, 0x00
};

// Creating the detour for the first address.
mod = new Mem::Detour(address1, modCode1, sizeof(modCode1), false, 1);
mod = new Mem::Detour(address, modCode, sizeof(modCode), false, 1);

// Calculate the jump address for the first detour.
// Calculate the jump address for detour
mod->shellcode->updateValue<uint32_t>(
sizeof(modCode1) - 4, (uint32_t)(mod->patch->data->address + mod->patch->data->size)
sizeof(modCode) - 4, (uint32_t)(mod->patch->data->address + mod->patch->data->size)
- ((uint32_t)((uintptr_t)mod->shellcode->data->address
+ mod->shellcode->data->size))
);

// Allocate memory for new instructions to be injected at address2.
uint8_t modCode2[] = {
0x41, 0xBF, 0x00, 0x00, 0x00, 0x00, 0xBD, 0x00, 0x00, 0x00, 0x00, 0xE9, 0x00, 0x00, 0x00, 0x00
};

// Creating the detour for the second address.
free_ItemUseMod2 = new Mem::Detour(address2, modCode2, sizeof(modCode2), false, 2);

// Calculate the jump address for the second detour.
free_ItemUseMod2->shellcode->updateValue<uint32_t>(
sizeof(modCode2) - 4, (uint32_t)(free_ItemUseMod2->patch->data->address + free_ItemUseMod2->patch->data->size)
- ((uint32_t)((uintptr_t)free_ItemUseMod2->shellcode->data->address
+ free_ItemUseMod2->shellcode->data->size))
);
}
}

// Activates the Infinite Item Use mod.
void activate()
{
mod->activate();
free_ItemUseMod2->activate();
active = mod->active && free_ItemUseMod2->active;
active = mod->active;
if (active)
LOG_CLASS("Activated");
else
Expand All @@ -201,7 +171,6 @@ class InfiniteItemUse : public _Mod
void deactivate()
{
mod->deactivate();
free_ItemUseMod2->deactivate();
active = false;
LOG_CLASS("Deactivated");
}
Expand Down
6 changes: 3 additions & 3 deletions example-mods/flight_mod/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ ModMetaData metaData = {
};


// Signature for GameVersion (SVN) 602428
// Signature for GameVersion (SVN) 637515
class FlightMod : public Mod
{
Mem::Detour* mod;
public:
void Load(ModContext* modContext)
{
// F3 0F 10 05 ?? ?? ?? ?? F2 0F 11 4C 24 60
const char* pattern = "\xF3\x0F\x10\x05\x00\x00\x00\x00\xF2\x0F\x11\x4C\x24\x60";
const char* mask = "xxxx????xxxxxx";
const char* pattern = "\xF3\x0F\x10\x05\x00\x00\x00\x00\xF2\x0F\x11\x4C";
const char* mask = "xxxx????xxxx";

uintptr_t baseAddress = (uintptr_t)GetModuleHandle(NULL);
uintptr_t address = Mem::FindPattern(pattern, mask, baseAddress, 0x1000000); // Scan 16MB
Expand Down
Loading

0 comments on commit 1639e5f

Please sign in to comment.