Skip to content

Commit

Permalink
Don't clear password when logging in, don't login through std::async,…
Browse files Browse the repository at this point in the history
… connect CSO2MsgHandler in tierextra
  • Loading branch information
Ochii committed Feb 23, 2019
1 parent a9ba0e6 commit 3fce187
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 66 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ You **may open a CoD styled console by pressing the *~*** (*tilde*) **key**.
- ```-masterport [some port]``` - Sets the master server's port number to *some port*
- ```-decryptedfiles``` - Tell the game to consider every game file as decrypted
- ```-enablecustom``` - Enables the use of a custom directory `custom` in the root directory of your game's files
- ```-username [your name]``` - Specify user name for skip login screen, Must use with ```-password```
- ```-password [your password]``` - Specify password for skip login screen, Must use with ```-username```
- ```-username [your username]``` - Specify login user name, in order to skip the login screen. **Must** be used with ```-password```
- ```-password [your password]``` - Specify login password , in order to skip the login screen. **Must** be used with ```-username```

## Building

Expand Down
3 changes: 3 additions & 0 deletions launcher/header/tierextra.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@

#include "cdll_int.h"

class ICSO2MsgHandlerEngine;

extern IVEngineClient* g_pEngineClient;


void ConnectExtraLibraries( CreateInterfaceFn* pFactoryList,
int nFactoryCount );

Expand Down
66 changes: 22 additions & 44 deletions launcher/source/hooks/client.cpp
Original file line number Diff line number Diff line change
@@ -1,63 +1,41 @@
#include "stdafx.hpp"
#include <future>

#include "hooks.hpp"

#include "engine/cso2/icso2msgmanager.h"
#include "tier0/ICommandLine.h"

static std::unique_ptr<PLH::x86Detour> g_pInitUIHook;
static uint64_t g_InitUIOrig = NULL;

class ICSO2LoginManager
{
public:
virtual void sub_1028465() = 0;
virtual void sub_10286160() = 0;
virtual bool Login(const char *UserName, const char *Password, const char *a4, const char *a5, const char *a6) = 0;
};

extern ICSO2LoginManager *g_pCSO2LoginManager;

NOINLINE bool __fastcall hkCSO2UIManager_InitMainUI(void* ecx, void* edx)
NOINLINE bool __fastcall hkCSO2UIManager_InitMainUI( void* ecx, void* edx )
{
std::async(std::launch::async, []() {
// Delay 1s after ui loaded to avoid crash
std::this_thread::sleep_for(std::chrono::seconds(1));

const char* szUsername = CommandLine()->ParmValue("-username");
const char* szPassword = CommandLine()->ParmValue("-password");

if (szUsername && szPassword)
{
std::string Username(szUsername);
std::string Password(szPassword);

while (Username.size() > 16)
Username.pop_back();

while (Password.size() > 4)
Password.pop_back();
const char* szUsername = CommandLine()->ParmValue( "-username" );
const char* szPassword = CommandLine()->ParmValue( "-password" );

g_pCSO2LoginManager->Login(strdup(Username.c_str()), strdup(Password.c_str()), "", "", "");
}
});
if ( szUsername && szPassword )
{
g_pCSO2MsgHandler->Login( szUsername, szPassword, szUsername );
}

return PLH::FnCast(g_InitUIOrig, &hkCSO2UIManager_InitMainUI)(ecx, edx);
return PLH::FnCast( g_InitUIOrig, &hkCSO2UIManager_InitMainUI )( ecx, edx );
}

void OnClientLoaded(const uintptr_t dwClientBase)
void OnClientLoaded( const uintptr_t dwClientBase )
{
static bool bHasLoaded = false;
static bool bHasLoaded = false;

if (bHasLoaded)
{
return;
}
if ( bHasLoaded )
{
return;
}

bHasLoaded = true;
bHasLoaded = true;

PLH::CapstoneDisassembler dis(PLH::Mode::x86);
PLH::CapstoneDisassembler dis( PLH::Mode::x86 );

g_pInitUIHook = SetupDetourHook(
dwClientBase + 0xAE4610, &hkCSO2UIManager_InitMainUI, &g_InitUIOrig, dis);
g_pInitUIHook->hook();
g_pInitUIHook =
SetupDetourHook( dwClientBase + 0xAE4610, &hkCSO2UIManager_InitMainUI,
&g_InitUIOrig, dis );
g_pInitUIHook->hook();
}
30 changes: 18 additions & 12 deletions launcher/source/hooks/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ static uint64_t g_EngineWinOrig = NULL;
NOINLINE LRESULT WINAPI hkHLEngineWindowProc( HWND hWnd, UINT Msg,
WPARAM wParam, LPARAM lParam )
{
bool conRes = g_GameConsole.OnWindowCallback( hWnd, Msg, wParam, lParam );
const bool conRes = g_GameConsole.OnWindowCallback( hWnd, Msg, wParam, lParam );

if ( !conRes )
return NULL;
Expand Down Expand Up @@ -135,19 +135,30 @@ void BytePatchEngine( const uintptr_t dwEngineBase )
};
utils::WriteProtectedMemory( loginNMPatch2, dwEngineBase + 0x28499D );

//
// don't clear password string
// TODO: this is DANGEROUS! find a better way to fix this!
//
// nops
const std::array<uint8_t, 14> loginNMPatch3 = { 0x90, 0x90, 0x90, 0x90,
0x90, 0x90, 0x90, 0x90,
0x90, 0x90, 0x90, 0x90,
0x90, 0x90 };
utils::WriteProtectedMemory( loginNMPatch3, dwEngineBase + 0x2849CB );

//
// don't allow nexon messenger to ovewrite our password
//
// nops
const std::array<uint8_t, 10> loginNMPatch3 = {
const std::array<uint8_t, 10> loginNMPatch4 = {
0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90
};
utils::WriteProtectedMemory( loginNMPatch3, dwEngineBase + 0x284A22 );
utils::WriteProtectedMemory( loginNMPatch4, dwEngineBase + 0x284A22 );

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

//
// reenable UDP info packet
Expand Down Expand Up @@ -205,9 +216,6 @@ void BytePatchEngine( const uintptr_t dwEngineBase )
utils::WriteProtectedMemory( canCheatPatch2, dwEngineBase + 0x19F4D2 );
}

class ICSO2LoginManager;
ICSO2LoginManager* g_pCSO2LoginManager;

void OnEngineLoaded( const uintptr_t dwEngineBase )
{
static bool bHasLoaded = false;
Expand All @@ -219,7 +227,7 @@ void OnEngineLoaded( const uintptr_t dwEngineBase )

bHasLoaded = true;

// setup engine interfaces
// setup engine library interfaces
CreateInterfaceFn pEngineFactory = Sys_GetFactory( "engine.dll" );
ConnectExtraLibraries( &pEngineFactory, 1 );

Expand All @@ -229,15 +237,13 @@ void OnEngineLoaded( const uintptr_t dwEngineBase )

g_pServerAddrHook = SetupDetourHook(
dwEngineBase + 0x285FE0, &hkGetServerInfo, &g_ServerAddrOrig, dis );
g_pCanCheatHook = SetupDetourHook(
dwEngineBase + 0xCE8B0, &hkCanCheat, &g_CanCheatOrig, dis );
g_pCanCheatHook = SetupDetourHook( dwEngineBase + 0xCE8B0, &hkCanCheat,
&g_CanCheatOrig, dis );
g_pEngineWinHook = SetupDetourHook(
dwEngineBase + 0x15EAF0, &hkHLEngineWindowProc, &g_EngineWinOrig, dis );
g_pColorPrintHook = SetupDetourHook(
dwEngineBase + 0x1C4B40, &hkCon_ColorPrint, &g_ColorPrintOrig, dis );

g_pCSO2LoginManager = (ICSO2LoginManager*)(dwEngineBase + 0xAA8190);

g_pServerAddrHook->hook();
g_pCanCheatHook->hook();
g_pEngineWinHook->hook();
Expand Down
21 changes: 14 additions & 7 deletions launcher/source/tierextra.cpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
#include "stdafx.hpp"

#include "tierextra.hpp"
#include "tier0/dbg.h"

#include "engine/cso2/icso2msgmanager.h"

IVEngineClient* g_pEngineClient = nullptr;
ICSO2MsgHandlerEngine* g_pCSO2MsgHandler = nullptr;

//-----------------------------------------------------------------------------
// Call this to connect to all tier 3 libraries.
// It's up to the caller to check the globals it cares about to see if ones are
// missing
//-----------------------------------------------------------------------------
//
// link additional library interfaces needed by us
//
void ConnectExtraLibraries( CreateInterfaceFn* pFactoryList, int nFactoryCount )
{
// Don't connect twice..
Assert( g_pEngineClient == nullptr );
assert( g_pEngineClient == nullptr );

for ( int i = 0; i < nFactoryCount; ++i )
{
Expand All @@ -22,10 +22,17 @@ void ConnectExtraLibraries( CreateInterfaceFn* pFactoryList, int nFactoryCount )
g_pEngineClient = reinterpret_cast<IVEngineClient*>(
pFactoryList[i]( VENGINE_CLIENT_INTERFACE_VERSION, nullptr ) );
}

if ( !g_pCSO2MsgHandler )
{
g_pCSO2MsgHandler = reinterpret_cast<ICSO2MsgHandlerEngine*>(
pFactoryList[i]( CSO2_MSGHANDLER_ENGINE_VERSION, nullptr ) );
}
}
}

void DisconnectExtraLibraries()
{
g_pEngineClient = nullptr;
g_pCSO2MsgHandler = nullptr;
}
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.3.2
0.4.0

0 comments on commit 3fce187

Please sign in to comment.