summaryrefslogtreecommitdiff
path: root/csgo-loader/csgo-client/Client.cpp
blob: dc08da2f975f8202d4ad081fe3f2d45ee4f0bb5e (plain)
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 <Networking/TCPClient.hpp>
#include <Login/RemoteLogin.hpp>
#include <Security/SyscallManager.hpp>
#include <Security/FnvHash.hpp>
#include <UserExperience/UserInterface.hpp>
#include <RemoteCode/RemoteProcess.hpp>

#define LOCAL_IP    0x0100007F // '127.0.0.1'
#define SERVER_IP   0xE53CA523 // Hexadecimal representation of the server IP, obtained by inet_addr()
#define SERVER_PORT 0xF2C      // Hexadecimal representation of the server port.

// hey nave just wanna let u know u r epic
// yea
#if 0
void hhahahaha()
{
	std::thread WindowThread([]
	{
		if(!UserInterface->Start())
			ERROR_ASSERT("[000F:00001B00] Failed to initialize. Please contact an administrator.");

		UserInterface->RunUiFrame();
	}); WindowThread.detach();

	UserInterface->m_Data.m_ExecutionState = UserExperience::EXECUTION_LOG_IN;

	while(UserInterface->m_Data.m_ExecutionState != UserExperience::EXECUTION_WAITING)
		Sleep(1);

	Login::RemoteLoginTransaction Transaction;
	Transaction.Start(UserInterface->m_Data.m_Username, UserInterface->m_Data.m_Password);

	ByteArray RawLoginHeader = Transaction.GetHeader();
	Client.SendBytes(RawLoginHeader);

	ByteArray RawServerResponse = Client.ReceiveBytes();
	if(!Transaction.TranslateResponse(RawServerResponse))
	{
		UserInterface->m_Data.m_ExecutionState = UserExperience::EXECUTION_ERROR;
	}
	else
	{
		UserInterface->m_Data.m_ExecutionState = UserExperience::EXECUTION_CHOOSE;
	}
}
#endif

// is this loss/
__forceinline void OpenConsole()
{
#ifdef DEBUG
	// ;ddDDDDdDDDd
	AllocConsole();

	// yo dude
	// get this handles
	FILE *file;
	freopen_s(&file, "CONOUT$", "w", stdout);
#endif // DEBUG
}

int __stdcall WinMain(HINSTANCE inst, HINSTANCE prev, char* str, int cmdshow)
{
	OpenConsole();

	Networking::TCPClient Client;

	// Initialize the syscall manager.
	if(!Syscalls->Start())
		ERROR_ASSERT("[000F:00001A00] Failed to initialize. Please contact an administrator.");
	
	// Wait for connection.
	UserInterface->m_Data.m_ExecutionState = UserExperience::EXECUTION_WAITING;

	// Create a thread to handle UI.
	std::thread WindowThread([]
	{
		// Create a window, initialise DirectX context.
		if(!UserInterface->Start())
			ERROR_ASSERT("[000F:00001B00] Failed to initialize. Please contact an administrator.");

		// Create a loop to draw our UI.
		UserInterface->RunUiFrame();
	}); WindowThread.detach();

	// Attempt to connect to the remote server.
	if(!Client.Start(LOCAL_IP, SERVER_PORT))
		ERROR_ASSERT("[000F:0002A000] Server did not accept the connection.");
	// Allow the user to input their log-in data.
	UserInterface->m_Data.m_ExecutionState = UserExperience::EXECUTION_LOG_IN;

	// TODO: Add game selection.

	while(1) { if(GetAsyncKeyState(VK_END) & 0x8000) break; Sleep(1); }
}