-
Notifications
You must be signed in to change notification settings - Fork 0
/
EntryPoint.cpp
89 lines (68 loc) · 1.99 KB
/
EntryPoint.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
#include "Common.hpp"
#include "GlobalVars.hpp"
#include "D3D.hpp"
#include "SDK.hpp"
DWORD WINAPI MainThread( PVOID pModule )
{
if ( MH_Initialize( ) != MH_OK )
return 0ul;
AllocConsole( );
freopen_s( ( FILE** )stdin, "conin$", "r", stdin );
freopen_s( ( FILE** )stdout, "conout$", "w", stdout );
freopen_s( ( FILE** )stderr, "conout$", "w", stderr );
SetConsoleTitleA( "DX9-Cheat-Base by Valee1337" );
SDK::FindOffsets( );
printf_s( "Scanned for offsets.\n" );
if ( !D3D::AtttachHooks( ) )
{
printf_s( "Failed D3D::AtttachHooks( ).\n" );
return 0ul;
}
return 1ul;
}
DWORD WINAPI UnloadThread( PVOID pModule )
{
while ( !GetAsyncKeyState( VK_END ) )
std::this_thread::sleep_for( 1s );
printf_s( "Goodbye!\n" );
std::this_thread::sleep_for( 1s );
g_bUnloading = true;
if ( g_pDefaultFont != nullptr )
{
g_pDefaultFont->Release( );
g_pDefaultFont = nullptr;
}
// This will take care of all hooks instead of doing it for each one
MH_DisableHook( MH_ALL_HOOKS );
MH_RemoveHook( MH_ALL_HOOKS );
MH_Uninitialize( );
FreeConsole( );
fclose( stdin );
fclose( stdout );
fclose( stderr );
Beep( 200, 200 );
FreeLibraryAndExitThread( ( HMODULE )pModule, 1ul );
return 1ul;
}
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD dwReason,
LPVOID lpReserved
)
{
if ( dwReason == DLL_PROCESS_ATTACH )
{
Beep( 200, 200 );
DisableThreadLibraryCalls( hModule );
const HANDLE hMainThread = CreateThread( nullptr, NULL, MainThread, hModule, NULL, nullptr );
if ( hMainThread != nullptr )
{
CloseHandle( hMainThread );
}
const HANDLE hUnloadThread = CreateThread( nullptr, NULL, UnloadThread, hModule, NULL, nullptr );
if ( hUnloadThread != nullptr )
{
CloseHandle( hUnloadThread );
}
}
return TRUE;
}