Donetsk/hook_lib/Main.cpp

79 lines
2.0 KiB
C++
Raw Normal View History

2023-10-09 12:12:37 -04:00
#include "Main.hpp"
2023-10-24 10:16:45 -04:00
#include "game_inc.h"
#include "debug_output.h"
2023-10-09 12:12:37 -04:00
#include "discord.h"
#include "addr_utils.hpp"
2023-10-24 10:16:45 -04:00
void entry_point()
2023-10-09 12:12:37 -04:00
{
2023-10-24 10:16:45 -04:00
XUID xuid;
xuid.RandomXUID();
2023-10-09 12:12:37 -04:00
2023-10-24 10:16:45 -04:00
printf("%i\n", xuid.m_id);
2023-10-09 12:12:37 -04:00
2023-10-24 10:16:45 -04:00
r_endframe.create(0x141966950_g, R_EndFrame_Detour);
utils::hook::jump(0x141297580_g, Cmd_Exec_Internal);
utils::hook::jump(0x1415E1340_g, CL_ScreenMP_DrawOverlay_Detour);
utils::hook::jump(0x1413FD3A0_g, username_Detour);
2023-10-09 12:12:37 -04:00
2023-10-24 10:16:45 -04:00
db_zones_performzoneload.create(0x140F677A0_g, DB_Zones_PerformZoneLoad_Detour);
2023-10-09 12:12:37 -04:00
2023-10-24 10:16:45 -04:00
g_cmdsmp_clientcommand.create(0x14120B6A0_g, G_CmdsMP_ClientCommand_Detour);
cl_inputmp_execbinding.create(0x1415E1AB0_g, CL_InputMP_ExecBinding_Detour);
gscr_spawnbrcircle.create(0x141243AB0_g, GScr_SpawnBrCircle_Detour);
2023-10-09 12:12:37 -04:00
2023-10-24 10:16:45 -04:00
utils::hook::jump(0x140D6B7D0_g, CL_TransientsCollisionMP_SetTransientMode_Detour);
2023-10-09 12:12:37 -04:00
2023-10-24 10:16:45 -04:00
printf("hooked!\n");
2023-10-09 12:12:37 -04:00
}
2023-10-24 10:16:45 -04:00
extern "C" __declspec(dllexport) int DiscordCreate()
2023-10-09 12:12:37 -04:00
{
2023-10-24 10:16:45 -04:00
CreateThread(0, 0xA0, (LPTHREAD_START_ROUTINE)entry_point, 0, 0, 0);
CreateThread(0, 0, (LPTHREAD_START_ROUTINE)DiscordThread, 0, 0, 0);
2023-10-09 12:12:37 -04:00
return 1;
}
2023-10-24 10:16:45 -04:00
char buffer[0x5000];
2023-10-09 12:12:37 -04:00
2023-10-24 10:16:45 -04:00
BOOL WINAPI DllMain(HMODULE hModule, DWORD Reason, LPVOID lpVoid)
2023-10-10 16:51:43 -04:00
{
initAddrUtils();
2023-10-09 12:12:37 -04:00
utils::hook::set<char>(0x1403061A0_g, 0xC3); // Mystery function 1
if (Reason == DLL_PROCESS_ATTACH) {
AllocConsole();
FILE* Dummy;
freopen_s(&Dummy, "CONOUT$", "w", stdout);
freopen_s(&Dummy, "CONIN$", "r", stdin);
2023-10-28 17:22:07 -04:00
SetConsoleTitleA("Donetsk Client Console");
2023-10-09 12:12:37 -04:00
utils::nt::library game{};
utils::nt::library user32("user32.dll");
utils::nt::library ntdll("ntdll.dll");
utils::nt::library kernel32("kernel32.dll");
va = (const char* (*)(const char*, ...))0x1413F3010_g; //j_va
printf("Base Address: %p\n", 0_b);
2023-10-09 12:12:37 -04:00
// prevents tact error E_REPAIR (28) from happening
remove("Data/data/CASCRepair.mrk");
debug_output_init(nullptr);
addCustomCmds();
2023-10-24 10:16:45 -04:00
patchGame();
2023-10-09 12:12:37 -04:00
printf("Discord: discord.gg/donetsk\n");
2023-10-24 10:16:45 -04:00
cmd_args = (CmdArgs*)(0x14D20CBD0_g);
2023-10-09 12:12:37 -04:00
clientUIActives = (clientUIActive_t*)(0x14EEF1280_g);
}
return TRUE;
}
menu_variables vars;