Skip to content

Commit

Permalink
Implemented contitional data, fixed steam auth
Browse files Browse the repository at this point in the history
  • Loading branch information
Rex109 committed Jul 27, 2024
1 parent 9828aaa commit fccdba8
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 17 deletions.
21 changes: 13 additions & 8 deletions cod4qol/commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,21 +222,26 @@ void commands::ToggleLoadingInfoUpdate()

void commands::ToggleSteamAuthUpdate()
{
//game::cod4x_entry + 0x1A70A
//game::cod4x_entry + 0x1A717
static const DWORD steam_auth_a = offsets::GetOffset("steam_auth_a");
static const DWORD steam_auth_b = offsets::GetOffset("steam_auth_b");

static const offsets::data_t steam_auth_a_bytes = offsets::GetData("steam_auth_a");
static const offsets::data_t steam_auth_b_bytes = offsets::GetData("steam_auth_b");

static const offsets::data_t steam_auth_a_bytes_disabled = offsets::GetData("steam_auth_a_disabled");
static const offsets::data_t steam_auth_b_bytes_disabled = offsets::GetData("steam_auth_b_disabled");


/*
if (commands::qol_disable_steam_auth->current.enabled)
{
hooks::write_addr(game::cod4x_entry + 0x10982, "\x90\x90", 2);
hooks::write_addr(game::cod4x_entry + 0x1098B, "\x90\x90\x90\x90\x90\x90", 6);
hooks::write_addr(steam_auth_a, steam_auth_a_bytes.data.c_str(), steam_auth_a_bytes.size);
hooks::write_addr(steam_auth_b, steam_auth_b_bytes.data.c_str(), steam_auth_b_bytes.size);
}
else
{
hooks::write_addr(game::cod4x_entry + 0x10982, "\x75\x0D", 2);
hooks::write_addr(game::cod4x_entry + 0x1098B, "\x0F\x84\xBF\x01\x00\x00", 6);
hooks::write_addr(steam_auth_a, steam_auth_a_bytes_disabled.data.c_str(), steam_auth_a_bytes_disabled.size);
hooks::write_addr(steam_auth_b, steam_auth_b_bytes_disabled.data.c_str(), steam_auth_b_bytes_disabled.size);
}
*/
}


Expand Down
6 changes: 3 additions & 3 deletions cod4qol/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ HMODULE game::GetCurrentModule()

bool game::LoadLocalizedIWD(const char* pakfile, const char* basename, const char* gamename)
{
static const DWORD iwd_cheat_flag = offsets::GetOffset("iwd_cheat_flag");
static const DWORD iwd_flag = offsets::GetOffset("iwd_flag");

hooks::write_addr(iwd_cheat_flag, "\x01", 1);
hooks::write_addr(iwd_flag, "\x01", 1);
bool result = FS_AddSingleIwdFileForGameDirectory(pakfile, basename, gamename);
hooks::write_addr(iwd_cheat_flag, "\x00", 1);
hooks::write_addr(iwd_flag, "\x00", 1);

return result;
}
Expand Down
34 changes: 31 additions & 3 deletions cod4qol/offsets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
#include "game.hpp"
#include "defines.hpp"

std::unordered_map<std::string, offsets::offset> offset_map;
std::unordered_map<std::string, offsets::offset_set> offset_map;
std::unordered_map<std::string, offsets::data_set> data_map;

std::string current_crc32;

void offsets::InitOffsets()
Expand All @@ -19,8 +21,10 @@ void offsets::InitOffsets()

//General
AddOffset("hwnd", { {COD4QOL_COD4X_CRC32_212, (game::cod4x_entry + 0x443BA00)}, {COD4QOL_COD4X_CRC32_211, (game::cod4x_entry + 0x43FE9A0)} });
AddOffset("iwd_cheat_flag", { {COD4QOL_COD4X_CRC32_212, (game::cod4x_entry + 0x2E366)}, {COD4QOL_COD4X_CRC32_211, (game::cod4x_entry + 0x386E2)} });
AddOffset("iwd_flag", { {COD4QOL_COD4X_CRC32_212, (game::cod4x_entry + 0x2E366)}, {COD4QOL_COD4X_CRC32_211, (game::cod4x_entry + 0x386E2)} });
AddOffset("ss_switch", { {COD4QOL_COD4X_CRC32_212, (game::cod4x_entry + 0xB21FB)}, {COD4QOL_COD4X_CRC32_211, (game::cod4x_entry + 0xEA62B)} });
AddOffset("steam_auth_a", { {COD4QOL_COD4X_CRC32_212, (game::cod4x_entry + 0x10982)}, {COD4QOL_COD4X_CRC32_211, (game::cod4x_entry + 0x1A70A)} });
AddOffset("steam_auth_b", { {COD4QOL_COD4X_CRC32_212, (game::cod4x_entry + 0x1098B)}, {COD4QOL_COD4X_CRC32_211, (game::cod4x_entry + 0x1A717)} });

//Functions
AddOffset("Cmd_AddCommand_fnc", { {COD4QOL_COD4X_CRC32_212, (game::cod4x_entry + 0x639B0)}, {COD4QOL_COD4X_CRC32_211, (game::cod4x_entry + 0x2116C)} });
Expand All @@ -29,9 +33,15 @@ void offsets::InitOffsets()
AddOffset("Cvar_RegisterEnum", { {COD4QOL_COD4X_CRC32_212, (game::cod4x_entry + 0x60640)}, {COD4QOL_COD4X_CRC32_211, (game::cod4x_entry + 0x2DCAF)} });
AddOffset("Cvar_RegisterString", { {COD4QOL_COD4X_CRC32_212, (game::cod4x_entry + 0x60960)}, {COD4QOL_COD4X_CRC32_211, (game::cod4x_entry + 0x2D87D)} });
AddOffset("FS_AddSingleIwdFileForGameDirectory", { {COD4QOL_COD4X_CRC32_212, (game::cod4x_entry + 0x2E310)}, {COD4QOL_COD4X_CRC32_211, (game::cod4x_entry + 0x3867C)} });

//Strings
AddData("steam_auth_a", { {COD4QOL_COD4X_CRC32_212, {"\x90\x90", 2}}, {COD4QOL_COD4X_CRC32_211, {"\x90\x90\x90\x90\x90\x90", 6}} });
AddData("steam_auth_b", { {COD4QOL_COD4X_CRC32_212, {"\xE9\xC0\x01\x00\x00\x90", 6}}, {COD4QOL_COD4X_CRC32_211, {"\x90\x90\x90\x90\x90\x90", 6}} });
AddData("steam_auth_a_disabled", { {COD4QOL_COD4X_CRC32_212, {"\x75\x0D", 2}}, {COD4QOL_COD4X_CRC32_211, {"\x0F\x85\xDB\x00\x00\x00", 6}} });
AddData("steam_auth_b_disabled", { {COD4QOL_COD4X_CRC32_212, {"\x0F\x84\xBF\x01\x00\x00", 6}}, {COD4QOL_COD4X_CRC32_211, {"\x0F\x85\xCE\x00\x00\x00", 6}} });
}

void offsets::AddOffset(std::string id, offsets::offset offset)
void offsets::AddOffset(std::string id, offsets::offset_set offset)
{
assert(offset_map.find(id) == offset_map.end());

Expand All @@ -50,6 +60,24 @@ DWORD offsets::GetOffset(std::string id)
return offset;
}

void offsets::AddData(std::string id, offsets::data_set data)
{
assert(data_map.find(id) == data_map.end());

data_map[id] = data;
}

offsets::data_t offsets::GetData(std::string id)
{
assert(data_map.find(id) != data_map.end());

offsets::data_t data = data_map[id][current_crc32];

std::cout << "Requested data for " << id << std::endl;

return data;
}

void offsets::SetCRC32(std::string crc32)
{
assert(std::find(supported_cod4x_crc32.begin(), supported_cod4x_crc32.end(), crc32) != supported_cod4x_crc32.end());
Expand Down
16 changes: 13 additions & 3 deletions cod4qol/offsets.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,20 @@

namespace offsets
{
typedef std::unordered_map<std::string, DWORD> offset;
typedef std::unordered_map<std::string, DWORD> offset_set;

typedef struct
{
std::string data;
size_t size;
}data_t;

typedef std::unordered_map<std::string, data_t> data_set;

void InitOffsets();
void AddOffset(std::string name, offsets::offset offset);
DWORD GetOffset(std::string name);
void AddOffset(std::string id, offset_set offset);
DWORD GetOffset(std::string id);
void AddData(std::string id, data_set data);
data_t GetData(std::string id);
void SetCRC32(std::string crc32);
}

0 comments on commit fccdba8

Please sign in to comment.