-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.cpp
95 lines (73 loc) · 2.05 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#include <windows.h>
#include <thread>
#include "context.h"
#include "l4d2.h"
#include "netvar.h"
#include "cheat.h"
c_context g_ctx;
c_l4d2 g_l4d2;
c_cheat g_cheat;
void load( )
{
DELETE_START( 0 );
// initialize lava lamps for pRandomNumberGenerator
time_t t;
time( &t );
srand( static_cast<uint32_t>( t ) );
// find and load configs
CreateFile( "./default.cfg", GENERIC_READ | GENERIC_WRITE, 0, 0, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0 );
util::get_all_files( g_ctx.m_cfg_list, "./" );
// l4d2 specific, the game does not load client.dll until all the intro videos are either finished or manually skipped
while ( !GetModuleHandleA( xors( "client.dll" ) ) )
std::this_thread::sleep_for( std::chrono::milliseconds( 100 ) );
// give it a bit more time to be ready
std::this_thread::sleep_for( std::chrono::milliseconds( 2000 ) );
// grab interfaces
g_l4d2.grab_interfaces( );
// dump netvars
g_netvar.dump_netvars( g_l4d2.client->GetAllClasses( ) );
// hook funcs
g_l4d2.hook_functions( );
DELETE_END( 0 );
}
void unload( )
{
// free the allocated console
fclose( stdout );
FreeConsole( );
// unhook all functions and restore vmt
g_l4d2.unload( );
// wait for shit to unload
std::this_thread::sleep_for( std::chrono::milliseconds( 500 ) );
// exit
FreeLibraryAndExitThread( g_ctx.instance, 0 );
}
void main_thread( HINSTANCE instance )
{
g_ctx.instance = instance;
// allocate a console
AllocConsole( );
SetConsoleTitleA( xors( "979 Strassenbande" ) );
freopen( xors( "CON" ), xors( "w" ), stdout );
// load the cheat
load( );
// wait until we want to unload the cheat
while ( !g_ctx.panic )
{
if ( GetAsyncKeyState( VK_DELETE ) )
g_ctx.panic = true;
// zzzzzzzzzzz
std::this_thread::sleep_for( std::chrono::milliseconds( 100 ) );
}
// unload
unload( );
}
BOOL APIENTRY DllMain( HINSTANCE instance, DWORD reason, LPVOID lpReserved )
{
if ( reason == DLL_PROCESS_ATTACH )
{
DisableThreadLibraryCalls( instance );
CreateThread( nullptr, 0, (LPTHREAD_START_ROUTINE)( main_thread ), instance, 0, nullptr );
}
return 1;
}