Skip to content

Commit

Permalink
Major update for 21.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Rex109 committed Jul 22, 2024
1 parent 836cf4d commit 6bd7f9a
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 24 deletions.
11 changes: 7 additions & 4 deletions cod4qol/commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,15 +220,18 @@ void commands::ToggleLoadingInfoUpdate()

void commands::ToggleSteamAuthUpdate()
{
//game::cod4x_entry + 0x1A70A
//game::cod4x_entry + 0x1A717

if (commands::qol_disable_steam_auth->current.enabled)
{
hooks::write_addr(game::cod4x_entry + 0x1A70A, "\x90\x90\x90\x90\x90\x90", 6);
hooks::write_addr(game::cod4x_entry + 0x1A717, "\x90\x90\x90\x90\x90\x90", 6);
hooks::write_addr(game::cod4x_entry + 0x10982, "\x90\x90", 2);
hooks::write_addr(game::cod4x_entry + 0x1098B, "\x90\x90\x90\x90\x90\x90", 6);
}
else
{
hooks::write_addr(game::cod4x_entry + 0x1A70A, "\x0F\x85\xDB\x00\x00\x00", 6);
hooks::write_addr(game::cod4x_entry + 0x1A717, "\x0F\x85\xCE\x00\x00\x00", 6);
hooks::write_addr(game::cod4x_entry + 0x10982, "\x75\x0D", 2);
hooks::write_addr(game::cod4x_entry + 0x1098B, "\x0F\x84\xBF\x01\x00\x00", 6);
}
}

Expand Down
2 changes: 1 addition & 1 deletion cod4qol/defines.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
#define COD4QOL_GITHUB_URL "https://api.github.com/repos/Rex109/CoD4QOL/releases/latest"
#define COD4QOL_FILE_NAME "download/cod4qol.zip"

#define COD4QOL_SUPPORTEDVERSIONS "21.1"
#define COD4QOL_SUPPORTEDVERSIONS "21.2"
4 changes: 2 additions & 2 deletions cod4qol/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ void Initialize()
if (!iw3mp)
return;

if (!game::cod4x_entry)
if (!game::cod4x_entry || strcmp(reinterpret_cast<const char*>(game::cod4x_entry + 0x22551A), "CoD4 MP 21.2") != 0)
{
MessageBox(NULL, "CoD4X version mismatch, CoD4QOL unloaded.\nYou need to have CoD4X version " COD4QOL_SUPPORTEDVERSIONS " installed.", "CoD4QOL", MB_ICONERROR);
MessageBox(NULL, "CoD4X version mismatch, CoD4QOL has been unloaded.\nYou need to have CoD4X version " COD4QOL_SUPPORTEDVERSIONS " installed.\n\nYou may need to update your game or manually download a newer version of CoD4QOL, otherwise you will have to wait for a new version of CoD4QOL and manually update it later." , "CoD4QOL", MB_ICONWARNING);
return;
}

Expand Down
8 changes: 4 additions & 4 deletions cod4qol/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ HMODULE game::GetCurrentModule()

bool game::LoadLocalizedIWD(const char* pakfile, const char* basename, const char* gamename)
{
hooks::write_addr((game::cod4x_entry + 0x386E2), "\x01", 1);
hooks::write_addr(game::cod4x_entry + 0x2E366, "\x01", 1);
bool result = FS_AddSingleIwdFileForGameDirectory(pakfile, basename, gamename);
hooks::write_addr((game::cod4x_entry + 0x386E2), "\x00", 1);
hooks::write_addr(game::cod4x_entry + 0x2E366, "\x00", 1);

return result;
}
Expand Down Expand Up @@ -175,9 +175,9 @@ int game::hookedScreenshotRequest(int a1, int a2)
commands::iPrintLnBold("[^3CoD4QOL^7]: ^1You are currently being screenshotted");

if (commands::qol_getss->current.integer == 2)
hooks::write_addr(game::cod4x_entry + 0xEA62B, "\xEB", 1);
hooks::write_addr(game::cod4x_entry + 0xB21FB, "\xEB", 1);
else
hooks::write_addr(game::cod4x_entry + 0xEA62B, "\x74", 1);
hooks::write_addr(game::cod4x_entry + 0xB21FB, "\x74", 1);

return pScreenshotRequest(a1, a2);
}
Expand Down
17 changes: 9 additions & 8 deletions cod4qol/game.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "defines.hpp"
#include <d3d9.h>
#include <filesystem>
#include "hooks.hpp"

namespace game
{
Expand Down Expand Up @@ -431,7 +432,7 @@ namespace game
inline bool startup = true;

const static DWORD cod4x_entry = (DWORD)GetModuleHandleA("cod4x_021.dll");
const static HWND* hwnd = reinterpret_cast<HWND*>(game::cod4x_entry + 0x43FE9A0);
const static HWND* hwnd = reinterpret_cast<HWND*>(game::cod4x_entry + 0x443BA00);
const static char* prefix = COD4QOL_CONSOLE_PREFIX;
const static char* localization = *reinterpret_cast<const char**>(0xCC147D4);

Expand Down Expand Up @@ -538,20 +539,20 @@ namespace game
typedef bool(*FS_AddSingleIwdFileForGameDirectory_t)(const char* pakfile, const char* basename, const char* gamename);
extern FS_AddSingleIwdFileForGameDirectory_t FS_AddSingleIwdFileForGameDirectory;

inline void* Cmd_AddCommand_fnc = (void*)(cod4x_entry + 0x2116C);
inline void* Cmd_AddCommand_fnc = (void*)(cod4x_entry + 0x639B0); //cod4x_entry + 0x2116C
inline game::CmdArgs* cmd_args = reinterpret_cast<game::CmdArgs*>(0x1410B40);
inline game::gclient_s* g_clients = reinterpret_cast<game::gclient_s*>(0x13255A8);

inline game::Cmd_ExecuteSingleCommand_t Cmd_ExecuteSingleCommand = Cmd_ExecuteSingleCommand_t(0x4F9AB0);
inline game::Com_PrintMessage_t Com_PrintMessage = game::Com_PrintMessage_t(0x4FCA50);
inline game::DB_LoadXAssets_t DB_LoadXAssets = DB_LoadXAssets_t(0x48A2B0);
inline game::Sys_CreateConsole_t Sys_CreateConsole = Sys_CreateConsole_t(cod4x_entry + 0x7F503);
inline game::Sys_CreateConsole_t Sys_CreateConsole = Sys_CreateConsole_t(cod4x_entry + 0x7F160); //cod4x_entry + 0x7F503

inline game::Cvar_RegisterBool_t Cvar_RegisterBool = Cvar_RegisterBool_t(cod4x_entry + 0x2D8F2);
inline game::Cvar_RegisterEnum_t Cvar_RegisterEnum = Cvar_RegisterEnum_t(cod4x_entry + 0x2DCAF);
inline game::Cvar_RegisterString_t Cvar_RegisterString = Cvar_RegisterString_t(cod4x_entry + 0x2D87D);
inline game::Cvar_RegisterBool_t Cvar_RegisterBool = Cvar_RegisterBool_t(cod4x_entry + 0x60BE0); //cod4x_entry + 0x2D8F2
inline game::Cvar_RegisterEnum_t Cvar_RegisterEnum = Cvar_RegisterEnum_t(cod4x_entry + 0x60640); //cod4x_entry + 0x2DCAF
inline game::Cvar_RegisterString_t Cvar_RegisterString = Cvar_RegisterString_t(cod4x_entry + 0x60960); //cod4x_entry + 0x2D87D

inline game::FS_AddSingleIwdFileForGameDirectory_t FS_AddSingleIwdFileForGameDirectory = FS_AddSingleIwdFileForGameDirectory_t(cod4x_entry + 0x3867C);
inline game::FS_AddSingleIwdFileForGameDirectory_t FS_AddSingleIwdFileForGameDirectory = FS_AddSingleIwdFileForGameDirectory_t(cod4x_entry + 0x2E310); //cod4x_entry + 0x3867C

inline game::dvar_s* fs_game = game::Find("fs_game");
inline game::dvar_s* fs_homepath = game::Find("fs_homepath");
Expand All @@ -561,4 +562,4 @@ namespace game
inline int* modIndex = reinterpret_cast<int*>(0xCAF7558);
inline const char** modName = reinterpret_cast<const char**>(0xCAF7354);
inline const char** modDesc = reinterpret_cast<const char**>(0xCAF7358);
}
}
17 changes: 12 additions & 5 deletions cod4qol/hooks.cpp
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
#include "hooks.hpp"
#include "game.hpp"
#include <psapi.h>
#include <cassert>

void hooks::InitializeHooks()
{
std::cout << "Initializing hooks..." << std::endl;

//Removing cod4x safechecks
hooks::write_addr((game::cod4x_entry + 0x43580), "\xC3", 1);
//(game::cod4x_entry + 0x43580)
hooks::write_addr((game::cod4x_entry + 0x82E40), "\xC3", 1);

//Fast startup
hooks::write_addr((game::cod4x_entry + 0x3AA7C), "\xC3", 1);
//(game::cod4x_entry + 0x3AA7C)
hooks::write_addr((game::cod4x_entry + 0x30F00), "\xC3", 1);

//Console name
game::pCon_LinePrefix = (game::Con_LinePrefix)(0x460613);
hooks::install(&(PVOID&)game::pCon_LinePrefix, (PBYTE)game::hookedCon_LinePrefix);

//Game start
game::pDB_LoadXZoneFromGfxConfig = (game::DB_LoadXZoneFromGfxConfig)(game::cod4x_entry + 0x8327E);
//(game::cod4x_entry + 0x8327E)
game::pDB_LoadXZoneFromGfxConfig = (game::DB_LoadXZoneFromGfxConfig)(game::cod4x_entry + 0x3C180);
hooks::install(&(PVOID&)game::pDB_LoadXZoneFromGfxConfig, (PBYTE)game::hookedDB_LoadXZoneFromGfxConfig);

//Return to main menu
Expand All @@ -32,15 +37,17 @@ void hooks::InitializeHooks()
hooks::install(&(PVOID&)game::pCL_RegisterDvars, (PBYTE)game::hookedCL_RegisterDvars);

//Respawn
game::pCG_Respawn = (game::CG_Respawn)(game::cod4x_entry + 0x3B45);
//(game::cod4x_entry + 0x3B45)
game::pCG_Respawn = (game::CG_Respawn)(game::cod4x_entry + 0x3DF00);
hooks::install(&(PVOID&)game::pCG_Respawn, (PBYTE)game::hookedCG_Respawn);

//VSTR
game::pCmd_Vstr_f = (game::Cmd_Vstr_f)(0x4F9550);
hooks::install(&(PVOID&)game::pCmd_Vstr_f, (PBYTE)game::hookedCmd_Vstr_f);

//ScreenshotRequest
game::pScreenshotRequest = (game::ScreenshotRequest)(game::cod4x_entry + 0xEA610);
//(game::cod4x_entry + 0xEA610)
game::pScreenshotRequest = (game::ScreenshotRequest)(game::cod4x_entry + 0xB21E0);
hooks::install(&(PVOID&)game::pScreenshotRequest, (PBYTE)game::hookedScreenshotRequest);

//R_SetViewParmsForScene
Expand Down

0 comments on commit 6bd7f9a

Please sign in to comment.