2017-02-25 09:32:15 -05:00
|
|
|
#include "STDInclude.hpp"
|
|
|
|
#undef getch
|
2017-03-30 08:05:37 -04:00
|
|
|
#undef ungetch
|
2017-02-25 09:32:15 -05:00
|
|
|
#include <conio.h>
|
|
|
|
|
|
|
|
namespace Components
|
|
|
|
{
|
|
|
|
bool Monitor::IsEnabled()
|
|
|
|
{
|
2017-06-13 09:35:12 -04:00
|
|
|
static std::optional<bool> flag;
|
2017-02-25 09:32:15 -05:00
|
|
|
|
2017-06-13 09:35:12 -04:00
|
|
|
if (!flag.has_value())
|
2017-02-25 09:32:15 -05:00
|
|
|
{
|
2017-06-13 09:35:12 -04:00
|
|
|
flag.emplace(Flags::HasFlag("monitor"));
|
2017-02-25 09:32:15 -05:00
|
|
|
}
|
|
|
|
|
2017-06-13 09:35:12 -04:00
|
|
|
return flag.value();
|
2017-02-25 09:32:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int __stdcall Monitor::EntryPoint(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPSTR /*lpCmdLine*/, int /*nShowCmd*/)
|
|
|
|
{
|
|
|
|
Utils::Hook::Call<void()>(0x4D8220)(); // Dvar_Init
|
|
|
|
Utils::Hook::Call<void()>(0x4D2280)(); // SL_Init
|
|
|
|
Utils::Hook::Call<void()>(0x47F390)(); // Swap_Init
|
|
|
|
Utils::Hook::Call<void()>(0x60AD10)(); // Com_InitDvars
|
|
|
|
Utils::Hook::Call<void()>(0x420830)(); // Com_InitHunkMemory
|
|
|
|
Utils::Hook::Call<void()>(0x4A62A0)(); // LargeLocalInit
|
|
|
|
Utils::Hook::Call<void(unsigned int)>(0x502580)(static_cast<unsigned int>(__rdtsc())); // Netchan_Init
|
|
|
|
Game::NET_Init();
|
|
|
|
|
|
|
|
Utils::Time::Interval interval;
|
2017-06-14 06:06:04 -04:00
|
|
|
while (!interval.elapsed(15s))
|
2017-02-25 09:32:15 -05:00
|
|
|
{
|
2017-02-25 09:58:43 -05:00
|
|
|
Utils::Hook::Call<void()>(0x49F0B0)(); // Com_ClientPacketEvent
|
2017-07-02 07:13:06 -04:00
|
|
|
//Session::RunFrame();
|
2017-09-02 12:16:56 -04:00
|
|
|
DHT::RunFrame();
|
2017-02-25 09:32:15 -05:00
|
|
|
ServerList::Frame();
|
|
|
|
|
|
|
|
std::this_thread::sleep_for(10ms);
|
|
|
|
}
|
|
|
|
|
|
|
|
auto list = ServerList::GetList();
|
|
|
|
if (!list)
|
|
|
|
{
|
2017-02-25 12:52:53 -05:00
|
|
|
printf("1 IW4x player=0|server=0 Returned list was null\n");
|
2017-02-25 09:32:15 -05:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int servers = list->size();
|
|
|
|
int players = 0;
|
|
|
|
|
2017-06-14 06:06:04 -04:00
|
|
|
for (unsigned int i = 0; i < list->size(); ++i)
|
2017-02-25 09:32:15 -05:00
|
|
|
{
|
|
|
|
players += list->at(i).clients;
|
|
|
|
}
|
|
|
|
|
2017-02-25 12:52:53 -05:00
|
|
|
printf("0 IW4x player=%d|server=%d Servers successfully parsed\n", players, servers);
|
2017-02-25 09:32:15 -05:00
|
|
|
|
|
|
|
Utils::Hook::Call<void()>(0x430630)(); // LargeLocalReset
|
|
|
|
Utils::Hook::Call<void()>(0x4A0460)(); // Hunk_ClearTempMemory
|
|
|
|
Utils::Hook::Call<void()>(0x4AB3A0)(); // Hunk_ClearTempMemoryHigh
|
|
|
|
Utils::Hook::Call<void()>(0x4B3AD0)(); // SL_Shutdown
|
|
|
|
Utils::Hook::Call<void()>(0x502C50)(); // Dvar_Shutdown
|
|
|
|
|
|
|
|
if (*Game::ip_socket && *Game::ip_socket != INVALID_SOCKET)
|
|
|
|
{
|
|
|
|
closesocket(*Game::ip_socket);
|
|
|
|
}
|
|
|
|
|
|
|
|
WSACleanup();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
Monitor::Monitor()
|
|
|
|
{
|
|
|
|
if (!Monitor::IsEnabled()) return;
|
|
|
|
|
|
|
|
Utils::Hook(0x4513DA, Monitor::EntryPoint, HOOK_JUMP).install()->quick();
|
|
|
|
}
|
|
|
|
}
|