Skip to content

Commit

Permalink
fixed random crash
Browse files Browse the repository at this point in the history
  • Loading branch information
Rex109 committed Jul 2, 2023
1 parent 01f1f3c commit 3d78ba2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions cod4qol/cod4qol.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<TargetExt>.asi</TargetExt>
<LibraryPath>$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(SolutionDir)lib</LibraryPath>
<TargetName>$(SolutionName)</TargetName>
<TargetName>cod4qol</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<TargetExt>.asi</TargetExt>
<LibraryPath>$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(SolutionDir)lib</LibraryPath>
<TargetName>$(SolutionName)</TargetName>
<TargetName>cod4qol</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
Expand Down
12 changes: 6 additions & 6 deletions cod4qol/dllmain.cpp
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
#include <Windows.h>
#include <cstdio>
#include "hooks.hpp"
#include <iostream>

void Initialize();

HMODULE s_hModule;
HMODULE dummy;

BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
s_hModule = hModule;
DisableThreadLibraryCalls(hModule);

#ifdef _DEBUG
FILE* _con;
AllocConsole();
freopen_s(&_con, "CONOUT$", "w", stdout);
#endif

//THIS IS FUCKING NECESSARY
GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_PIN, "cod4qol.asi", &dummy);

Initialize();
break;
case DLL_THREAD_ATTACH:
Expand All @@ -34,11 +38,7 @@ void Initialize()
const HMODULE iw3mp = GetModuleHandleA("iw3mp.exe");

if (!iw3mp)
{
FreeConsole();
FreeLibraryAndExitThread(s_hModule, 0);
return;
}

hooks::InitializeHooks();
}
2 changes: 1 addition & 1 deletion cod4qol/hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
void hooks::InitializeHooks()
{
//Cod4x safe checks
hooks::write_addr(game::cod4x_entry + 0x1E7EC, "\xEB", 1);
//hooks::write_addr(21101250, "\xEB", 1);

//Game start
game::pDB_LoadXZoneFromGfxConfig = (game::DB_LoadXZoneFromGfxConfig)(game::cod4x_entry + 0x8327E);
Expand Down

0 comments on commit 3d78ba2

Please sign in to comment.