Skip to content

Commit

Permalink
Fix engine.cpp and tier0.cpp compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
Ochii committed Feb 9, 2019
1 parent 0d198da commit 6e7fd50
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 85 deletions.
52 changes: 0 additions & 52 deletions launcher/header/onloadlib.hpp

This file was deleted.

64 changes: 34 additions & 30 deletions launcher/source/hooks/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,48 +36,51 @@ NOINLINE void __fastcall hkGetServerIpAddressInfo( IpAddressInfo& info )
szMasterPort ? static_cast<uint16_t>( atoi( szMasterPort ) ) : 30001;
}

HOOK_DETOUR_DECLARE( hkCanCheat );

//
// Fix sv_cheats
//
ConVar* sv_cheats = 0;
// Restore original CanCheat check
// This fixes the use of sv_cheats as a host
// Credit goes to GEEKiDoS
//
ConVar* sv_cheats = nullptr;

HOOK_DETOUR_DECLARE( hkCanCheat );

NOINLINE bool __fastcall hkCanCheat()
{
if ( !sv_cheats && g_pCVar )
sv_cheats = g_pCVar->FindVar( "sv_cheats" );
assert( g_pCVar != nullptr ); // this should be already available

if ( sv_cheats->GetBool() )
return true;
if (!sv_cheats)
{
sv_cheats = g_pCVar->FindVar( "sv_cheats" );
assert( sv_cheats != nullptr ); // this should always succeed
}

return false;
return sv_cheats->GetBool();
}


void BytePatchEngine( const uintptr_t dwEngineBase )
{
//
// don't initialize BugTrap on engine
//
// jmp short 0x3C bytes forward
const std::array<uint8_t, 5> btPatch = { 0xEB, 0x3C };
utils::WriteProtectedMemory( btPatch, ( dwEngineBase + 0x15877B ) );
utils::WriteProtectedMemory( btPatch, dwEngineBase + 0x15877B );

//
// skip nexon messenger login
//
// mov al, 1; retn 8
const std::array<uint8_t, 5> nmPatch = { 0xB0, 0x01, 0xC2, 0x08, 0x00 };
utils::WriteProtectedMemory( nmPatch, ( dwEngineBase + 0x289490 ) );
utils::WriteProtectedMemory( nmPatch, dwEngineBase + 0x289490 );

//
// copy the password instead of a null string
//
// push edi; nops
const std::array<uint8_t, 5> loginNMPatch = { 0x57, 0x90, 0x90, 0x90,
0x90 };
utils::WriteProtectedMemory( loginNMPatch, ( dwEngineBase + 0x284786 ) );
utils::WriteProtectedMemory( loginNMPatch, dwEngineBase + 0x284786 );

//
// don't null the username string
Expand All @@ -88,7 +91,7 @@ void BytePatchEngine( const uintptr_t dwEngineBase )
0x8D, 0x4C, 0x24, 0x54, // lea ecx, [esp+54]
0x90, 0x90, 0x90 // nops
};
utils::WriteProtectedMemory( loginNMPatch2, ( dwEngineBase + 0x28499D ) );
utils::WriteProtectedMemory( loginNMPatch2, dwEngineBase + 0x28499D );

//
// don't allow nexon messenger to ovewrite our password
Expand All @@ -97,36 +100,36 @@ void BytePatchEngine( const uintptr_t dwEngineBase )
const std::array<uint8_t, 10> loginNMPatch3 = {
0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90
};
utils::WriteProtectedMemory( loginNMPatch3, ( dwEngineBase + 0x284A22 ) );
utils::WriteProtectedMemory( loginNMPatch3, dwEngineBase + 0x284A22 );

//
// don't get the nexon username from NM
//
utils::WriteProtectedMemory( loginNMPatch3, ( dwEngineBase + 0x284A57 ) );
utils::WriteProtectedMemory( loginNMPatch3, dwEngineBase + 0x284A57 );

//
// reenable UDP info packet
//
const std::array<uint8_t, 6> netPacketPatch = {
0x89, 0xB0, 0x28, 0x01, 0x00, 0x00
}; // mov [eax+128h], esi
utils::WriteProtectedMemory( netPacketPatch, ( dwEngineBase + 0x283604 ) );
utils::WriteProtectedMemory( netPacketPatch, dwEngineBase + 0x283604 );

//
// force direct UDP connection instead of relay connection
//
// mov dword ptr [eax], 2
const std::array<uint8_t, 6> relayPatch = { 0xC7, 0x00, 0x02,
0x00, 0x00, 0x00 };
utils::WriteProtectedMemory( relayPatch, ( dwEngineBase + 0x2BE552 ) );
utils::WriteProtectedMemory( relayPatch, dwEngineBase + 0x2BE552 );
// mov dword ptr [eax+8], 2
const std::array<uint8_t, 7> relayPatch2 = { 0xC7, 0x40, 0x08, 0x02,
0x00, 0x00, 0x00 };
utils::WriteProtectedMemory( relayPatch2, ( dwEngineBase + 0x2BE56C ) );
utils::WriteProtectedMemory( relayPatch2, dwEngineBase + 0x2BE56C );
// mov dword ptr [eax+4], 2
const std::array<uint8_t, 7> relayPatch3 = { 0xC7, 0x40, 0x04, 0x02,
0x00, 0x00, 0x00 };
utils::WriteProtectedMemory( relayPatch3, ( dwEngineBase + 0x2BE587 ) );
utils::WriteProtectedMemory( relayPatch3, dwEngineBase + 0x2BE587 );

//
// don't send the filesystem hash
Expand All @@ -137,26 +140,27 @@ void BytePatchEngine( const uintptr_t dwEngineBase )
const std::array<uint8_t, 11> hashGenPatch = {
0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90,
};
utils::WriteProtectedMemory( hashGenPatch, ( dwEngineBase + 0x2BC50D ) );
utils::WriteProtectedMemory( hashGenPatch, dwEngineBase + 0x2BC50D );

//
// always return true when checking if the user is over 18
//
// mov al, 01
// ret
const std::array<uint8_t, 11> isAdultPatch = { 0xB0, 0x01, 0xC3 };
utils::WriteProtectedMemory( isAdultPatch, ( dwEngineBase + 0x288FF0 ) );
utils::WriteProtectedMemory( isAdultPatch, dwEngineBase + 0x288FF0 );

//
// Patch CanCheat traps
//
// nops
const std::array<uint8_t, 6> canCheatPatch1 = { 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 };
WriteProtectedMemory( canCheatPatch1, ( dwEngineBase + 0x1EFEF6 ) );
// Patch CanCheat traps
//
// nops
const std::array<uint8_t, 6> canCheatPatch1 = { 0x90, 0x90, 0x90,
0x90, 0x90, 0x90 };
utils::WriteProtectedMemory( canCheatPatch1, dwEngineBase + 0x1EFEF6 );

// jmp
const std::array<uint8_t, 1> canCheatPatch2 = { 0xEB };
WriteProtectedMemory( canCheatPatch2, ( dwEngineBase + 0x19F4D2 ) );
utils::WriteProtectedMemory( canCheatPatch2, dwEngineBase + 0x19F4D2 );
}

extern void ConsoleThread();
Expand Down
4 changes: 2 additions & 2 deletions launcher/source/hooks/tier0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ void BytePatchTier( const uintptr_t dwTierBase )
//
// jmp near 0x1D8 bytes forward
const std::array<uint8_t, 5> addArgPatch = { 0xE9, 0xD8, 0x01, 0x00, 0x00 };
WriteProtectedMemory( addArgPatch, ( dwTierBase + 0x1D63 ) );
utils::WriteProtectedMemory( addArgPatch, ( dwTierBase + 0x1D63 ) );
}

void HookTier0()
{
const uintptr_t dwTierBase = g_ModuleList.Get( "tier0.dll" );
const uintptr_t dwTierBase = utils::GetModuleBase( "tier0.dll" );
BytePatchTier( dwTierBase );

// only hook COM_TimestampedLog if we are actually going to use it
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2.1
0.2.2

0 comments on commit 6e7fd50

Please sign in to comment.