2021-12-25 22:36:38 +01:00
|
|
|
#pragma once
|
2023-03-18 09:08:29 +01:00
|
|
|
#if defined(_DEBUG) || defined(_PROFILE)
|
|
|
|
#pragma message ("Profiling is turned on; do not release this binary!\n")
|
|
|
|
#endif // _DEBUG || _PROFILE
|
|
|
|
|
2021-12-25 22:36:38 +01:00
|
|
|
#define WIN32_LEAN_AND_MEAN // Prevent winsock2 redefinition.
|
|
|
|
#include <windows.h>
|
|
|
|
#include <WinSock2.h>
|
2023-01-26 20:06:48 +01:00
|
|
|
#include <Ws2tcpip.h>
|
|
|
|
#include <bcrypt.h>
|
2022-03-04 12:22:17 +01:00
|
|
|
#include <comdef.h>
|
2023-03-18 13:34:43 +01:00
|
|
|
#include <direct.h>
|
2022-05-24 02:23:37 +02:00
|
|
|
#include <gdiplus.h>
|
2023-04-08 16:09:23 +02:00
|
|
|
#include <dbghelp.h>
|
2022-07-06 21:11:32 +02:00
|
|
|
#include <timeapi.h>
|
2022-05-24 02:23:37 +02:00
|
|
|
#include <shellapi.h>
|
|
|
|
#include <Psapi.h>
|
2022-04-12 02:48:46 +02:00
|
|
|
#include <setjmp.h>
|
2022-03-21 23:13:03 +01:00
|
|
|
#include <tchar.h>
|
2021-12-25 22:36:38 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <shlobj.h>
|
|
|
|
#include <objbase.h>
|
2022-03-21 23:13:03 +01:00
|
|
|
#include <intrin.h>
|
2021-12-25 22:36:38 +01:00
|
|
|
#include <emmintrin.h>
|
|
|
|
#include <cmath>
|
2022-04-10 19:59:34 +02:00
|
|
|
#include <regex>
|
2021-12-25 22:36:38 +01:00
|
|
|
#include <thread>
|
2022-03-21 23:13:03 +01:00
|
|
|
#include <vector>
|
2021-12-25 22:36:38 +01:00
|
|
|
#include <string>
|
|
|
|
#include <sstream>
|
|
|
|
#include <fstream>
|
|
|
|
#include <iostream>
|
|
|
|
#include <iomanip>
|
|
|
|
#include <cassert>
|
|
|
|
#include <filesystem>
|
2023-03-20 00:10:49 +01:00
|
|
|
#include <set>
|
2022-11-27 15:01:55 +01:00
|
|
|
#include <unordered_set>
|
2021-12-25 22:36:38 +01:00
|
|
|
|
2023-04-01 22:19:30 +02:00
|
|
|
#include <smmintrin.h>
|
|
|
|
|
2023-03-20 00:10:49 +01:00
|
|
|
// Windows specifics.
|
|
|
|
#ifndef FILE_SUPPORTS_GHOSTING
|
|
|
|
#define FILE_SUPPORTS_GHOSTING 0x40000000 // winnt
|
|
|
|
#endif
|
|
|
|
#ifndef ENABLE_VIRTUAL_TERMINAL_PROCESSING
|
|
|
|
#define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004
|
|
|
|
#endif
|
|
|
|
|
2022-08-21 00:59:55 +02:00
|
|
|
#if !defined(DEDICATED) && !defined(SDKLAUNCHER) && !defined (NETCONSOLE) && !defined(PLUGINSDK)
|
2021-12-25 22:36:38 +01:00
|
|
|
#include <d3d11.h>
|
2022-08-21 00:59:55 +02:00
|
|
|
#endif // !DEDICATED && !SDKLAUNCHER && !NETCONSOLE && !PLUGINSDK
|
2021-12-25 22:36:38 +01:00
|
|
|
|
2022-05-03 17:28:17 +02:00
|
|
|
#include "thirdparty/nlohmann/json.hpp"
|
|
|
|
|
2021-12-25 22:36:38 +01:00
|
|
|
#include "thirdparty/detours/include/detours.h"
|
|
|
|
#include "thirdparty/detours/include/idetour.h"
|
|
|
|
|
2022-05-24 02:23:37 +02:00
|
|
|
#if defined(SDKLAUNCHER)
|
|
|
|
#include "thirdparty/cppnet/cppkore/Kore.h"
|
|
|
|
#include "thirdparty/cppnet/cppkore/UIXTheme.h"
|
|
|
|
#include "thirdparty/cppnet/cppkore/UIXLabel.h"
|
|
|
|
#include "thirdparty/cppnet/cppkore/UIXListView.h"
|
|
|
|
#include "thirdparty/cppnet/cppkore/UIXCheckBox.h"
|
|
|
|
#include "thirdparty/cppnet/cppkore/UIXComboBox.h"
|
|
|
|
#include "thirdparty/cppnet/cppkore/UIXTextBox.h"
|
|
|
|
#include "thirdparty/cppnet/cppkore/UIXGroupBox.h"
|
|
|
|
#include "thirdparty/cppnet/cppkore/UIXButton.h"
|
|
|
|
#include "thirdparty/cppnet/cppkore/UIXRadioButton.h"
|
|
|
|
#include "thirdparty/cppnet/cppkore/KoreTheme.h"
|
2022-06-06 01:31:20 +02:00
|
|
|
|
|
|
|
#include "launcher/launcherdefs.h"
|
2022-05-24 02:23:37 +02:00
|
|
|
#endif // SDKLAUNCHER
|
|
|
|
|
2022-08-21 00:59:55 +02:00
|
|
|
#if !defined(DEDICATED) && !defined(SDKLAUNCHER) && !defined (NETCONSOLE) && !defined(PLUGINSDK)
|
2023-03-29 00:19:19 +02:00
|
|
|
#include "thirdparty/imgui/imgui.h"
|
|
|
|
#include "thirdparty/imgui/imgui_internal.h"
|
|
|
|
#include "thirdparty/imgui/misc/imgui_logger.h"
|
|
|
|
#include "thirdparty/imgui/misc/imgui_editor.h"
|
|
|
|
#include "thirdparty/imgui/misc/imgui_utility.h"
|
|
|
|
#include "thirdparty/imgui/misc/cpp/imgui_stdlib.h"
|
|
|
|
#include "thirdparty/imgui/backends/imgui_impl_dx11.h"
|
|
|
|
#include "thirdparty/imgui/backends/imgui_impl_win32.h"
|
2022-08-21 00:59:55 +02:00
|
|
|
#endif // !DEDICATED && !SDKLAUNCHER && !NETCONSOLE && !PLUGINSDK
|
2021-12-25 22:36:38 +01:00
|
|
|
|
2022-08-21 00:59:55 +02:00
|
|
|
#if !defined(SDKLAUNCHER) && !defined (NETCONSOLE) && !defined(PLUGINSDK)
|
2022-01-06 15:08:39 +01:00
|
|
|
#include "thirdparty/lzham/include/lzham_types.h"
|
|
|
|
#include "thirdparty/lzham/include/lzham.h"
|
2022-08-21 00:59:55 +02:00
|
|
|
#endif // !SDKLAUNCHER && !NETCONSOLE && !PLUGINSDK
|
2022-01-06 15:08:39 +01:00
|
|
|
|
2023-03-18 13:34:43 +01:00
|
|
|
#include "thirdparty/spdlog/spdlog.h"
|
|
|
|
#include "thirdparty/spdlog/async.h"
|
|
|
|
#include "thirdparty/spdlog/sinks/ostream_sink.h"
|
|
|
|
#include "thirdparty/spdlog/sinks/basic_file_sink.h"
|
|
|
|
#include "thirdparty/spdlog/sinks/stdout_sinks.h"
|
|
|
|
#include "thirdparty/spdlog/sinks/stdout_color_sinks.h"
|
|
|
|
#include "thirdparty/spdlog/sinks/ansicolor_sink.h"
|
|
|
|
#include "thirdparty/spdlog/sinks/rotating_file_sink.h"
|
2022-01-14 15:38:48 +01:00
|
|
|
|
2023-01-26 20:06:48 +01:00
|
|
|
#include "thirdparty/curl/include/curl/curl.h"
|
|
|
|
|
2023-03-20 00:17:29 +01:00
|
|
|
#include "common/experimental.h"
|
2022-04-10 19:59:34 +02:00
|
|
|
#include "common/pseudodefs.h"
|
|
|
|
#include "common/x86defs.h"
|
|
|
|
#include "common/sdkdefs.h"
|
|
|
|
|
2022-08-09 17:18:07 +02:00
|
|
|
#include "public/utility/utility.h"
|
|
|
|
#include "public/utility/memaddr.h"
|
|
|
|
#include "public/utility/module.h"
|
|
|
|
#include "public/utility/vdf_parser.h"
|
2021-12-25 22:36:38 +01:00
|
|
|
|
2022-01-14 15:38:48 +01:00
|
|
|
#include "core/assert.h"
|
2022-01-26 23:48:52 +01:00
|
|
|
#include "core/termutil.h"
|
2022-01-16 01:18:36 +01:00
|
|
|
#include "tier0/basetypes.h"
|
2022-03-21 23:13:03 +01:00
|
|
|
#include "tier0/platform.h"
|
2023-03-17 00:00:37 +01:00
|
|
|
#include "tier0/annotations.h"
|
2022-05-28 16:15:39 +02:00
|
|
|
#include "tier0/commonmacros.h"
|
2023-01-29 15:24:24 +01:00
|
|
|
#if !defined(SDKLAUNCHER) && !defined(PLUGINSDK)
|
2022-05-25 14:18:29 +02:00
|
|
|
#include "tier0/dbg.h"
|
2022-08-21 00:59:55 +02:00
|
|
|
#endif // !SDKLAUNCHER && !NETCONSOLE && !PLUGINSDK
|
2022-04-02 02:48:54 +02:00
|
|
|
|
2022-08-21 00:59:55 +02:00
|
|
|
#if !defined(SDKLAUNCHER) && !defined (NETCONSOLE) && !defined(PLUGINSDK)
|
2022-01-14 15:38:48 +01:00
|
|
|
#if !defined (DEDICATED)
|
2022-08-09 03:02:00 +02:00
|
|
|
inline CModule g_GameDll = CModule("r5apex.exe");
|
|
|
|
inline CModule g_RadVideoToolsDll = CModule("bink2w64.dll");
|
|
|
|
inline CModule g_RadAudioDecoderDll = CModule("binkawin64.dll");
|
|
|
|
inline CModule g_RadAudioSystemDll = CModule("mileswin64.dll");
|
2022-12-26 23:35:41 +01:00
|
|
|
#if !defined (CLIENT_DLL)
|
|
|
|
inline CModule g_SDKDll = CModule("gamesdk.dll");
|
|
|
|
#else // This dll is loaded from 'bin/x64_retail//'
|
|
|
|
inline CModule g_SDKDll = CModule("client.dll");
|
|
|
|
#endif // !CLIENT_DLL
|
2022-02-23 21:03:06 +01:00
|
|
|
#else // No DirectX and Miles imports.
|
2022-08-09 03:02:00 +02:00
|
|
|
inline CModule g_GameDll = CModule("r5apex_ds.exe");
|
2022-12-26 23:35:41 +01:00
|
|
|
inline CModule g_SDKDll = CModule("dedicated.dll");
|
2022-02-23 21:03:06 +01:00
|
|
|
#endif // !DEDICATED
|
2023-04-08 16:11:25 +02:00
|
|
|
inline const string g_ProcessTimestamp = CreateTimedFileName();
|
2022-04-09 02:18:57 +02:00
|
|
|
|
2022-04-09 00:59:42 +02:00
|
|
|
#define VAR_NAME(varName) #varName
|
2022-01-23 18:26:48 +01:00
|
|
|
|
2022-02-06 16:48:52 +01:00
|
|
|
#define MEMBER_AT_OFFSET(varType, varName, offset) \
|
|
|
|
varType& varName() \
|
|
|
|
{ \
|
|
|
|
static int _##varName = offset; \
|
2022-01-23 18:26:48 +01:00
|
|
|
return *(varType*)((std::uintptr_t)this + _##varName); \
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename ReturnType, typename ...Args>
|
|
|
|
ReturnType CallVFunc(int index, void* thisPtr, Args... args)
|
|
|
|
{
|
|
|
|
return (*reinterpret_cast<ReturnType(__fastcall***)(void*, Args...)>(thisPtr))[index](thisPtr, args...);
|
2022-02-06 16:48:52 +01:00
|
|
|
}
|
2023-01-25 02:26:52 +01:00
|
|
|
|
|
|
|
inline void LogFunAdr(const char* szFun, uintptr_t nAdr) // Logging function addresses.
|
|
|
|
{
|
2023-02-11 17:44:16 +01:00
|
|
|
spdlog::debug("| {:s}: {:42s}: {:#18x} |\n", "FUN", szFun, nAdr);
|
2023-01-25 02:26:52 +01:00
|
|
|
}
|
|
|
|
inline void LogVarAdr(const char* szVar, uintptr_t nAdr) // Logging variable addresses.
|
|
|
|
{
|
2023-02-11 17:44:16 +01:00
|
|
|
spdlog::debug("| {:s}: {:42s}: {:#18x} |\n", "VAR", szVar, nAdr);
|
2023-01-25 02:26:52 +01:00
|
|
|
}
|
|
|
|
inline void LogConAdr(const char* szCon, uintptr_t nAdr) // Logging constant addresses.
|
|
|
|
{
|
2023-02-11 17:44:16 +01:00
|
|
|
spdlog::debug("| {:s}: {:42s}: {:#18x} |\n", "CON", szCon, nAdr);
|
2023-01-25 02:26:52 +01:00
|
|
|
}
|
2022-08-21 00:59:55 +02:00
|
|
|
#endif // !SDKLAUNCHER && !NETCONSOLE && !PLUGINSDK
|