mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
commit
1b65803073
28
apex.sln
28
apex.sln
@ -11,28 +11,56 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "r5dedicated", "r5dedicated\
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Minhook", "external\minhook\libMinHook.vcxproj", "{F142A341-5EE0-442D-A15F-98AE9B48DBAE}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Minhook", "external\minhook\libMinHook.vcxproj", "{F142A341-5EE0-442D-A15F-98AE9B48DBAE}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "r5net", "r5net\r5net.vcxproj", "{F04BE619-0326-4FF1-B06B-FBE882E04D5E}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|x64 = Debug|x64
|
Debug|x64 = Debug|x64
|
||||||
|
Debug|x86 = Debug|x86
|
||||||
Release|x64 = Release|x64
|
Release|x64 = Release|x64
|
||||||
|
Release|x86 = Release|x86
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
{18F8C75E-3844-4AA6-AB93-980A08253519}.Debug|x64.ActiveCfg = Debug|x64
|
{18F8C75E-3844-4AA6-AB93-980A08253519}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
{18F8C75E-3844-4AA6-AB93-980A08253519}.Debug|x64.Build.0 = Debug|x64
|
{18F8C75E-3844-4AA6-AB93-980A08253519}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{18F8C75E-3844-4AA6-AB93-980A08253519}.Debug|x86.ActiveCfg = Debug|Win32
|
||||||
|
{18F8C75E-3844-4AA6-AB93-980A08253519}.Debug|x86.Build.0 = Debug|Win32
|
||||||
{18F8C75E-3844-4AA6-AB93-980A08253519}.Release|x64.ActiveCfg = Release|x64
|
{18F8C75E-3844-4AA6-AB93-980A08253519}.Release|x64.ActiveCfg = Release|x64
|
||||||
{18F8C75E-3844-4AA6-AB93-980A08253519}.Release|x64.Build.0 = Release|x64
|
{18F8C75E-3844-4AA6-AB93-980A08253519}.Release|x64.Build.0 = Release|x64
|
||||||
|
{18F8C75E-3844-4AA6-AB93-980A08253519}.Release|x86.ActiveCfg = Release|Win32
|
||||||
|
{18F8C75E-3844-4AA6-AB93-980A08253519}.Release|x86.Build.0 = Release|Win32
|
||||||
{28CC6B4F-7A95-4933-ADA9-65E38D48516D}.Debug|x64.ActiveCfg = Debug|x64
|
{28CC6B4F-7A95-4933-ADA9-65E38D48516D}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
{28CC6B4F-7A95-4933-ADA9-65E38D48516D}.Debug|x64.Build.0 = Debug|x64
|
{28CC6B4F-7A95-4933-ADA9-65E38D48516D}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{28CC6B4F-7A95-4933-ADA9-65E38D48516D}.Debug|x86.ActiveCfg = Debug|Win32
|
||||||
|
{28CC6B4F-7A95-4933-ADA9-65E38D48516D}.Debug|x86.Build.0 = Debug|Win32
|
||||||
{28CC6B4F-7A95-4933-ADA9-65E38D48516D}.Release|x64.ActiveCfg = Release|x64
|
{28CC6B4F-7A95-4933-ADA9-65E38D48516D}.Release|x64.ActiveCfg = Release|x64
|
||||||
{28CC6B4F-7A95-4933-ADA9-65E38D48516D}.Release|x64.Build.0 = Release|x64
|
{28CC6B4F-7A95-4933-ADA9-65E38D48516D}.Release|x64.Build.0 = Release|x64
|
||||||
|
{28CC6B4F-7A95-4933-ADA9-65E38D48516D}.Release|x86.ActiveCfg = Release|Win32
|
||||||
|
{28CC6B4F-7A95-4933-ADA9-65E38D48516D}.Release|x86.Build.0 = Release|Win32
|
||||||
{71988D92-343C-49AB-B52B-0AE0E83B0401}.Debug|x64.ActiveCfg = Debug|x64
|
{71988D92-343C-49AB-B52B-0AE0E83B0401}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
{71988D92-343C-49AB-B52B-0AE0E83B0401}.Debug|x64.Build.0 = Debug|x64
|
{71988D92-343C-49AB-B52B-0AE0E83B0401}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{71988D92-343C-49AB-B52B-0AE0E83B0401}.Debug|x86.ActiveCfg = Debug|Win32
|
||||||
|
{71988D92-343C-49AB-B52B-0AE0E83B0401}.Debug|x86.Build.0 = Debug|Win32
|
||||||
{71988D92-343C-49AB-B52B-0AE0E83B0401}.Release|x64.ActiveCfg = Release|x64
|
{71988D92-343C-49AB-B52B-0AE0E83B0401}.Release|x64.ActiveCfg = Release|x64
|
||||||
{71988D92-343C-49AB-B52B-0AE0E83B0401}.Release|x64.Build.0 = Release|x64
|
{71988D92-343C-49AB-B52B-0AE0E83B0401}.Release|x64.Build.0 = Release|x64
|
||||||
|
{71988D92-343C-49AB-B52B-0AE0E83B0401}.Release|x86.ActiveCfg = Release|Win32
|
||||||
|
{71988D92-343C-49AB-B52B-0AE0E83B0401}.Release|x86.Build.0 = Release|Win32
|
||||||
{F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Debug|x64.ActiveCfg = Debug|x64
|
{F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
{F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Debug|x64.Build.0 = Debug|x64
|
{F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Debug|x86.ActiveCfg = Debug|Win32
|
||||||
|
{F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Debug|x86.Build.0 = Debug|Win32
|
||||||
{F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Release|x64.ActiveCfg = Release|x64
|
{F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Release|x64.ActiveCfg = Release|x64
|
||||||
{F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Release|x64.Build.0 = Release|x64
|
{F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Release|x64.Build.0 = Release|x64
|
||||||
|
{F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Release|x86.ActiveCfg = Release|Win32
|
||||||
|
{F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Release|x86.Build.0 = Release|Win32
|
||||||
|
{F04BE619-0326-4FF1-B06B-FBE882E04D5E}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{F04BE619-0326-4FF1-B06B-FBE882E04D5E}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{F04BE619-0326-4FF1-B06B-FBE882E04D5E}.Debug|x86.ActiveCfg = Debug|Win32
|
||||||
|
{F04BE619-0326-4FF1-B06B-FBE882E04D5E}.Debug|x86.Build.0 = Debug|Win32
|
||||||
|
{F04BE619-0326-4FF1-B06B-FBE882E04D5E}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{F04BE619-0326-4FF1-B06B-FBE882E04D5E}.Release|x64.Build.0 = Release|x64
|
||||||
|
{F04BE619-0326-4FF1-B06B-FBE882E04D5E}.Release|x86.ActiveCfg = Release|Win32
|
||||||
|
{F04BE619-0326-4FF1-B06B-FBE882E04D5E}.Release|x86.Build.0 = Release|Win32
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
59
r5dev/BuildVersion.rc
Normal file
59
r5dev/BuildVersion.rc
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
// Microsoft Visual C++ generated resource script.
|
||||||
|
//
|
||||||
|
#include "resource.h"
|
||||||
|
|
||||||
|
#define APSTUDIO_READONLY_SYMBOLS
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Generated from the TEXTINCLUDE 2 resource.
|
||||||
|
//
|
||||||
|
#include "winres.h"
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
#undef APSTUDIO_READONLY_SYMBOLS
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// English (United States) resources
|
||||||
|
|
||||||
|
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||||
|
LANGUAGE 9, 1
|
||||||
|
|
||||||
|
#ifdef APSTUDIO_INVOKED
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// TEXTINCLUDE
|
||||||
|
//
|
||||||
|
|
||||||
|
1 TEXTINCLUDE
|
||||||
|
BEGIN
|
||||||
|
"resource.h\0"
|
||||||
|
END
|
||||||
|
|
||||||
|
2 TEXTINCLUDE
|
||||||
|
BEGIN
|
||||||
|
"#include ""winres.h""\r\n"
|
||||||
|
"\0"
|
||||||
|
END
|
||||||
|
|
||||||
|
3 TEXTINCLUDE
|
||||||
|
BEGIN
|
||||||
|
"\r\n"
|
||||||
|
"\0"
|
||||||
|
END
|
||||||
|
|
||||||
|
#endif // APSTUDIO_INVOKED
|
||||||
|
|
||||||
|
#endif // English (United States) resources
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef APSTUDIO_INVOKED
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Generated from the TEXTINCLUDE 3 resource.
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
#endif // not APSTUDIO_INVOKED
|
@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "serverlisting.h"
|
#include "serverlisting.h"
|
||||||
#include "gui_utility.h"
|
#include "gui_utility.h"
|
||||||
|
#include "r5net.h"
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// Initialization
|
// Initialization
|
||||||
@ -13,6 +14,7 @@ private:
|
|||||||
public:
|
public:
|
||||||
CCompanion();
|
CCompanion();
|
||||||
|
|
||||||
|
|
||||||
////////////////////
|
////////////////////
|
||||||
// Enums //
|
// Enums //
|
||||||
////////////////////
|
////////////////////
|
||||||
@ -32,15 +34,17 @@ public:
|
|||||||
////////////////////
|
////////////////////
|
||||||
// Server Browser //
|
// Server Browser //
|
||||||
////////////////////
|
////////////////////
|
||||||
ImVector<ServerListing*> ServerList;
|
|
||||||
ServerListing* SelectedServer;
|
R5Net::Client r5net;
|
||||||
|
|
||||||
|
std::vector<ServerListing> ServerList;
|
||||||
ImGuiTextFilter ServerBrowserFilter;
|
ImGuiTextFilter ServerBrowserFilter;
|
||||||
char ServerConnStringBuffer[256] = { 0 };
|
char ServerConnStringBuffer[256] = { 0 };
|
||||||
|
|
||||||
////////////////////
|
////////////////////
|
||||||
// Settings //
|
// Settings //
|
||||||
////////////////////
|
////////////////////
|
||||||
char MatchmakingServerStringBuffer[256] = { 0 };
|
std::string MatchmakingServerStringBuffer;
|
||||||
|
|
||||||
////////////////////
|
////////////////////
|
||||||
// Host Server //
|
// Host Server //
|
||||||
@ -135,7 +139,6 @@ public:
|
|||||||
|
|
||||||
void RefreshServerList();
|
void RefreshServerList();
|
||||||
void SendHostingPostRequest();
|
void SendHostingPostRequest();
|
||||||
const nlohmann::json SendGetServerByTokenRequest(const std::string &token, const std::string &password);
|
|
||||||
void CompMenu();
|
void CompMenu();
|
||||||
void ServerBrowserSection();
|
void ServerBrowserSection();
|
||||||
void SettingsSection();
|
void SettingsSection();
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
class ServerListing
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
ServerListing() = default;
|
|
||||||
|
|
||||||
ServerListing(std::string name, std::string map, std::string ip, std::string port) : name(name), map(map), ip(ip), port(port)
|
|
||||||
{
|
|
||||||
// for future constructor use.
|
|
||||||
}
|
|
||||||
|
|
||||||
void Select();
|
|
||||||
|
|
||||||
std::string name;
|
|
||||||
std::string map;
|
|
||||||
std::string ip;
|
|
||||||
std::string port;
|
|
||||||
std::string password;
|
|
||||||
};
|
|
||||||
|
|
@ -82,16 +82,16 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
<LinkIncremental>true</LinkIncremental>
|
<LinkIncremental>true</LinkIncremental>
|
||||||
<IncludePath>$(SolutionDir)external\minhook\include;$(SolutionDir)external\imgui\include;$(SolutionDir)external\spdlog\include;$(SolutionDir)shared\include;$(SolutionDir)r5dev\include;$(IncludePath)</IncludePath>
|
<IncludePath>$(SolutionDir)r5net\include\r5;$(SolutionDir)external\minhook\include;$(SolutionDir)external\imgui\include;$(SolutionDir)external\spdlog\include;$(SolutionDir)shared\include;$(SolutionDir)r5dev\include;$(IncludePath)</IncludePath>
|
||||||
<LibraryPath>$(SolutionDir)external\minhook\lib\$(Configuration);$(LibraryPath)</LibraryPath>
|
<LibraryPath>$(SolutionDir)external\minhook\lib\$(Configuration);$(SolutionDir)r5net\lib\$(Configuration);$(LibraryPath)</LibraryPath>
|
||||||
<OutDir>$(SolutionDir)bin\$(Configuration)\</OutDir>
|
<OutDir>$(SolutionDir)bin\$(Configuration)\</OutDir>
|
||||||
<TargetName>r5detours</TargetName>
|
<TargetName>r5detours</TargetName>
|
||||||
<IntDir>$(SolutionDir)build\$(ProjectName)\$(Configuration)\</IntDir>
|
<IntDir>$(SolutionDir)build\$(ProjectName)\$(Configuration)\</IntDir>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<LinkIncremental>false</LinkIncremental>
|
<LinkIncremental>false</LinkIncremental>
|
||||||
<IncludePath>$(SolutionDir)external\minhook\include;$(SolutionDir)external\imgui\include;$(SolutionDir)external\spdlog\include;$(SolutionDir)shared\include;$(SolutionDir)r5dev\include;$(IncludePath)</IncludePath>
|
<IncludePath>$(SolutionDir)r5net\include\r5;$(SolutionDir)external\minhook\include;$(SolutionDir)external\imgui\include;$(SolutionDir)external\spdlog\include;$(SolutionDir)shared\include;$(SolutionDir)r5dev\include;$(IncludePath)</IncludePath>
|
||||||
<LibraryPath>$(SolutionDir)external\minhook\lib\$(Configuration);$(LibraryPath)</LibraryPath>
|
<LibraryPath>$(SolutionDir)external\minhook\lib\$(Configuration);$(SolutionDir)r5net\lib\$(Configuration);$(LibraryPath)</LibraryPath>
|
||||||
<OutDir>$(SolutionDir)bin\$(Configuration)\</OutDir>
|
<OutDir>$(SolutionDir)bin\$(Configuration)\</OutDir>
|
||||||
<IntDir>$(SolutionDir)build\$(ProjectName)\$(Configuration)\</IntDir>
|
<IntDir>$(SolutionDir)build\$(ProjectName)\$(Configuration)\</IntDir>
|
||||||
<TargetName>r5detours</TargetName>
|
<TargetName>r5detours</TargetName>
|
||||||
@ -148,7 +148,7 @@
|
|||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<EnableUAC>false</EnableUAC>
|
<EnableUAC>false</EnableUAC>
|
||||||
<ModuleDefinitionFile>r5dev.def</ModuleDefinitionFile>
|
<ModuleDefinitionFile>r5dev.def</ModuleDefinitionFile>
|
||||||
<AdditionalDependencies>Minhook.x64.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>Minhook.x64.lib;r5net.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
<PostBuildEvent>
|
<PostBuildEvent>
|
||||||
<Command>
|
<Command>
|
||||||
@ -157,7 +157,11 @@
|
|||||||
<PreBuildEvent>
|
<PreBuildEvent>
|
||||||
<Command>if not EXIST $(SolutionDir)external\minhook\lib\$(Configuration)\Minhook.x64.lib (
|
<Command>if not EXIST $(SolutionDir)external\minhook\lib\$(Configuration)\Minhook.x64.lib (
|
||||||
"$(DevEnvDir)devenv" "$(SolutionDir)apex.sln" /Rebuild $(Configuration) /project "$(SolutionDir)external\minhook\libMinHook.vcxproj"
|
"$(DevEnvDir)devenv" "$(SolutionDir)apex.sln" /Rebuild $(Configuration) /project "$(SolutionDir)external\minhook\libMinHook.vcxproj"
|
||||||
)</Command>
|
);
|
||||||
|
|
||||||
|
if not EXIST $(SolutionDir)r5net\lib\$(Configuration)\r5net.lib (
|
||||||
|
"$(DevEnvDir)devenv" "$(SolutionDir)apex.sln" /Rebuild $(Configuration) /project "$(SolutionDir)r5net\r5net.vcxproj"
|
||||||
|
);</Command>
|
||||||
</PreBuildEvent>
|
</PreBuildEvent>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
@ -185,7 +189,7 @@
|
|||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<EnableUAC>false</EnableUAC>
|
<EnableUAC>false</EnableUAC>
|
||||||
<ModuleDefinitionFile>r5dev.def</ModuleDefinitionFile>
|
<ModuleDefinitionFile>r5dev.def</ModuleDefinitionFile>
|
||||||
<AdditionalDependencies>Minhook.x64.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>Minhook.x64.lib;r5net.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
<PostBuildEvent>
|
<PostBuildEvent>
|
||||||
<Command>
|
<Command>
|
||||||
@ -194,7 +198,11 @@
|
|||||||
<PreBuildEvent>
|
<PreBuildEvent>
|
||||||
<Command>if not EXIST $(SolutionDir)external\minhook\lib\$(Configuration)\Minhook.x64.lib (
|
<Command>if not EXIST $(SolutionDir)external\minhook\lib\$(Configuration)\Minhook.x64.lib (
|
||||||
"$(DevEnvDir)devenv" "$(SolutionDir)apex.sln" /Rebuild $(Configuration) /project "$(SolutionDir)external\minhook\libMinHook.vcxproj"
|
"$(DevEnvDir)devenv" "$(SolutionDir)apex.sln" /Rebuild $(Configuration) /project "$(SolutionDir)external\minhook\libMinHook.vcxproj"
|
||||||
)</Command>
|
);
|
||||||
|
|
||||||
|
if not EXIST $(SolutionDir)r5net\lib\$(Configuration)\r5net.lib (
|
||||||
|
"$(DevEnvDir)devenv" "$(SolutionDir)apex.sln" /Rebuild $(Configuration) /project "$(SolutionDir)r5net\r5net.vcxproj"
|
||||||
|
);</Command>
|
||||||
</PreBuildEvent>
|
</PreBuildEvent>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@ -319,8 +327,8 @@
|
|||||||
<ClInclude Include="include\patterns.h" />
|
<ClInclude Include="include\patterns.h" />
|
||||||
<ClInclude Include="include\pch.h" />
|
<ClInclude Include="include\pch.h" />
|
||||||
<ClInclude Include="include\r5dev.h" />
|
<ClInclude Include="include\r5dev.h" />
|
||||||
<ClInclude Include="include\serverlisting.h" />
|
|
||||||
<ClInclude Include="include\structs.h" />
|
<ClInclude Include="include\structs.h" />
|
||||||
|
<ClInclude Include="resource.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="..\external\imgui\src\imgui.cpp">
|
<ClCompile Include="..\external\imgui\src\imgui.cpp">
|
||||||
@ -401,14 +409,15 @@
|
|||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
|
||||||
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">pch.h</PrecompiledHeaderFile>
|
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">pch.h</PrecompiledHeaderFile>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\serverlisting.cpp">
|
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Use</PrecompiledHeader>
|
|
||||||
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|x64'">pch.h</PrecompiledHeaderFile>
|
|
||||||
</ClCompile>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="r5dev.def" />
|
<None Include="r5dev.def" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\r5net\r5net.vcxproj">
|
||||||
|
<Project>{f04be619-0326-4ff1-b06b-fbe882e04d5e}</Project>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
|
@ -180,9 +180,6 @@
|
|||||||
<ClCompile Include="src\CGameConsole.cpp">
|
<ClCompile Include="src\CGameConsole.cpp">
|
||||||
<Filter>gui\interface</Filter>
|
<Filter>gui\interface</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\serverlisting.cpp">
|
|
||||||
<Filter>gui</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="src\id3dx.cpp">
|
<ClCompile Include="src\id3dx.cpp">
|
||||||
<Filter>gui</Filter>
|
<Filter>gui</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
@ -527,9 +524,6 @@
|
|||||||
<ClInclude Include="include\CGameConsole.h">
|
<ClInclude Include="include\CGameConsole.h">
|
||||||
<Filter>gui\include</Filter>
|
<Filter>gui\include</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="include\serverlisting.h">
|
|
||||||
<Filter>gui\include</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="include\gameclasses.h">
|
<ClInclude Include="include\gameclasses.h">
|
||||||
<Filter>r5-sdk\include</Filter>
|
<Filter>r5-sdk\include</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
@ -563,6 +557,7 @@
|
|||||||
<ClInclude Include="include\gui_utility.h">
|
<ClInclude Include="include\gui_utility.h">
|
||||||
<Filter>gui\include</Filter>
|
<Filter>gui\include</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="resource.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="r5dev.def">
|
<None Include="r5dev.def">
|
||||||
|
14
r5dev/resource.h
Normal file
14
r5dev/resource.h
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
//{{NO_DEPENDENCIES}}
|
||||||
|
// Microsoft Visual C++ generated include file.
|
||||||
|
// Used by BuildVersion.rc
|
||||||
|
|
||||||
|
// Next default values for new objects
|
||||||
|
//
|
||||||
|
#ifdef APSTUDIO_INVOKED
|
||||||
|
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||||
|
#define _APS_NEXT_RESOURCE_VALUE 101
|
||||||
|
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||||
|
#define _APS_NEXT_CONTROL_VALUE 1001
|
||||||
|
#define _APS_NEXT_SYMED_VALUE 101
|
||||||
|
#endif
|
||||||
|
#endif
|
@ -5,6 +5,7 @@
|
|||||||
#include "patterns.h"
|
#include "patterns.h"
|
||||||
#include "gameclasses.h"
|
#include "gameclasses.h"
|
||||||
#include "CCompanion.h"
|
#include "CCompanion.h"
|
||||||
|
#include "r5net.h"
|
||||||
|
|
||||||
#define OVERLAY_DEBUG
|
#define OVERLAY_DEBUG
|
||||||
|
|
||||||
@ -14,11 +15,9 @@ CCompanion* g_ServerBrowser = nullptr;
|
|||||||
* _ccompanion.cpp
|
* _ccompanion.cpp
|
||||||
*-----------------------------------------------------------------------------*/
|
*-----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
CCompanion::CCompanion()
|
CCompanion::CCompanion() : MatchmakingServerStringBuffer("r5a-comp-sv.herokuapp.com"), r5net(R5Net::Client("r5a-comp-sv.herokuapp.com"))
|
||||||
{
|
{
|
||||||
memset(MatchmakingServerStringBuffer, 0, sizeof(MatchmakingServerStringBuffer));
|
|
||||||
memset(ServerConnStringBuffer, 0, sizeof(ServerConnStringBuffer));
|
memset(ServerConnStringBuffer, 0, sizeof(ServerConnStringBuffer));
|
||||||
strcpy_s(MatchmakingServerStringBuffer, "r5a-comp-sv.herokuapp.com");
|
|
||||||
|
|
||||||
std::string path = "stbsp";
|
std::string path = "stbsp";
|
||||||
for (const auto& entry : std::filesystem::directory_iterator(path))
|
for (const auto& entry : std::filesystem::directory_iterator(path))
|
||||||
@ -87,19 +86,7 @@ void CCompanion::RefreshServerList()
|
|||||||
std::cout << " [+CCompanion+] Refreshing server list with string " << MatchmakingServerStringBuffer << "\n";
|
std::cout << " [+CCompanion+] Refreshing server list with string " << MatchmakingServerStringBuffer << "\n";
|
||||||
#endif
|
#endif
|
||||||
bThreadLocked = true;
|
bThreadLocked = true;
|
||||||
httplib::Client client(MatchmakingServerStringBuffer);
|
ServerList = r5net.GetServersList();
|
||||||
client.set_connection_timeout(10);
|
|
||||||
auto res = client.Get("/servers");
|
|
||||||
if (res)
|
|
||||||
{
|
|
||||||
nlohmann::json root = nlohmann::json::parse(res->body);
|
|
||||||
for (auto obj : root["servers"])
|
|
||||||
{
|
|
||||||
ServerList.push_back(
|
|
||||||
new ServerListing(obj["name"].get<std::string>(), obj["map"].get<std::string>(), obj["ip"].get<std::string>(), obj["port"].get<std::string>())
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
bThreadLocked = false;
|
bThreadLocked = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -109,76 +96,27 @@ void CCompanion::RefreshServerList()
|
|||||||
|
|
||||||
void CCompanion::SendHostingPostRequest()
|
void CCompanion::SendHostingPostRequest()
|
||||||
{
|
{
|
||||||
httplib::Client client(MatchmakingServerStringBuffer);
|
HostToken = "";
|
||||||
client.set_connection_timeout(10);
|
bool result = r5net.PostServerHost(HostRequestMessage, HostToken, ServerListing{ MyServer.name, std::string(GameGlobals::HostState->m_levelName), "", GameGlobals::Cvar->FindVar("hostport")->m_pzsCurrentValue, MyServer.password});
|
||||||
|
|
||||||
// send a post request to "/servers/add" with a json body
|
|
||||||
nlohmann::json body = nlohmann::json::object();
|
|
||||||
body["name"] = MyServer.name;
|
|
||||||
body["map"] = std::string(GameGlobals::HostState->m_levelName);
|
|
||||||
static ConVar* hostport = GameGlobals::Cvar->FindVar("hostport"); // static since it won't move memory locations.
|
|
||||||
body["port"] = hostport->m_pzsCurrentValue; //body["port"] = MyServer.port;
|
|
||||||
body["password"] = MyServer.password;
|
|
||||||
|
|
||||||
std::string body_str = body.dump();
|
|
||||||
|
|
||||||
#ifdef OVERLAY_DEBUG
|
|
||||||
std::cout << " [+CCompanion+] Sending request now, Body: " << body_str << "\n";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
httplib::Result result = client.Post("/servers/add", body_str.c_str(), body_str.length(), "application/json");
|
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
#ifdef OVERLAY_DEBUG
|
HostRequestMessageColor = ImVec4(0.00f, 1.00f, 0.00f, 1.00f);
|
||||||
std::cout << " [+CCompanion+] Request Result: " << result->body << "\n";
|
|
||||||
#endif
|
|
||||||
nlohmann::json res = nlohmann::json::parse(result->body);
|
|
||||||
if (!res["success"] && !res["err"].is_null())
|
|
||||||
{
|
|
||||||
HostRequestMessage = res["err"].get<std::string>();
|
|
||||||
HostRequestMessageColor = ImVec4(1.00f, 0.00f, 0.00f, 1.00f);
|
|
||||||
}
|
|
||||||
else if (res["success"].get<bool>() == true)
|
|
||||||
{
|
|
||||||
std::stringstream msg;
|
std::stringstream msg;
|
||||||
msg << "Broadcasting! ";
|
msg << "Broadcasting! ";
|
||||||
HostToken = "";
|
if (!HostToken.empty())
|
||||||
if (res["token"].is_string())
|
|
||||||
{
|
{
|
||||||
msg << "Share the following token for people to connect: ";
|
msg << "Share the following token for people to connect: ";
|
||||||
HostToken = res["token"].get<std::string>();
|
|
||||||
}
|
}
|
||||||
HostRequestMessage = msg.str().c_str();
|
HostRequestMessage = msg.str().c_str();
|
||||||
HostRequestMessageColor = ImVec4(0.00f, 1.00f, 0.00f, 1.00f);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
HostRequestMessage = "";
|
HostRequestMessageColor = ImVec4(1.00f, 0.00f, 0.00f, 1.00f);
|
||||||
HostRequestMessageColor = ImVec4(1.00f, 1.00f, 1.00f, 1.00f);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const nlohmann::json CCompanion::SendGetServerByTokenRequest(const std::string &token, const std::string &password)
|
|
||||||
{
|
|
||||||
httplib::Client client(MatchmakingServerStringBuffer);
|
|
||||||
client.set_connection_timeout(10);
|
|
||||||
|
|
||||||
nlohmann::json reqBody = nlohmann::json::object();
|
|
||||||
|
|
||||||
reqBody["token"] = token;
|
|
||||||
reqBody["password"] = password;
|
|
||||||
|
|
||||||
std::string reqBody_str = reqBody.dump();
|
|
||||||
|
|
||||||
httplib::Result res = client.Post("/server/byToken", reqBody_str.c_str(), reqBody_str.length(), "application/json");
|
|
||||||
if (res && !res->body.empty())
|
|
||||||
{
|
|
||||||
return nlohmann::json::parse(res->body);
|
|
||||||
}
|
|
||||||
|
|
||||||
return nlohmann::json::object();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CCompanion::CompMenu()
|
void CCompanion::CompMenu()
|
||||||
{
|
{
|
||||||
@ -212,7 +150,6 @@ void CCompanion::ServerBrowserSection()
|
|||||||
|
|
||||||
const float FooterHeight = ImGui::GetStyle().ItemSpacing.y + ImGui::GetFrameHeightWithSpacing();
|
const float FooterHeight = ImGui::GetStyle().ItemSpacing.y + ImGui::GetFrameHeightWithSpacing();
|
||||||
ImGui::BeginChild("ServerListChild", { 0, -FooterHeight }, true, ImGuiWindowFlags_AlwaysVerticalScrollbar);
|
ImGui::BeginChild("ServerListChild", { 0, -FooterHeight }, true, ImGuiWindowFlags_AlwaysVerticalScrollbar);
|
||||||
{
|
|
||||||
if (ImGui::BeginTable("##ServerBrowser_ServerList", 4, ImGuiTableFlags_Resizable))
|
if (ImGui::BeginTable("##ServerBrowser_ServerList", 4, ImGuiTableFlags_Resizable))
|
||||||
{
|
{
|
||||||
ImGui::TableSetupColumn("Name", ImGuiTableColumnFlags_WidthStretch, 35);
|
ImGui::TableSetupColumn("Name", ImGuiTableColumnFlags_WidthStretch, 35);
|
||||||
@ -221,11 +158,11 @@ void CCompanion::ServerBrowserSection()
|
|||||||
ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthStretch, 8);
|
ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthStretch, 8);
|
||||||
ImGui::TableHeadersRow();
|
ImGui::TableHeadersRow();
|
||||||
|
|
||||||
for (ServerListing* server : ServerList)
|
for (ServerListing& server : ServerList)
|
||||||
{
|
{
|
||||||
const char* name = server->name.c_str();
|
const char* name = server.name.c_str();
|
||||||
const char* map = server->map.c_str();
|
const char* map = server.map.c_str();
|
||||||
const char* port = server->port.c_str();
|
const char* port = server.port.c_str();
|
||||||
|
|
||||||
if (ServerBrowserFilter.PassFilter(name)
|
if (ServerBrowserFilter.PassFilter(name)
|
||||||
|| ServerBrowserFilter.PassFilter(map)
|
|| ServerBrowserFilter.PassFilter(map)
|
||||||
@ -242,18 +179,17 @@ void CCompanion::ServerBrowserSection()
|
|||||||
|
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
std::string selectButtonText = "Connect##";
|
std::string selectButtonText = "Connect##";
|
||||||
selectButtonText += (server->name + server->ip + server->map);
|
selectButtonText += (server.name + server.ip + server.map);
|
||||||
|
|
||||||
if (ImGui::Button(selectButtonText.c_str()))
|
if (ImGui::Button(selectButtonText.c_str()))
|
||||||
{
|
{
|
||||||
SelectedServer = server;
|
ConnectToServer(server.ip, server.port);
|
||||||
server->Select();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
ImGui::EndTable();
|
ImGui::EndTable();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
|
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
@ -262,7 +198,7 @@ void CCompanion::ServerBrowserSection()
|
|||||||
|
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
|
|
||||||
if (ImGui::Button("Connect", ImVec2(ImGui::GetWindowContentRegionWidth() * (1.f / 3.f /2.f), 19)))
|
if (ImGui::Button("Connect##ServerBrowser_ConnectByIp", ImVec2(ImGui::GetWindowContentRegionWidth() * (1.f / 3.f / 2.f), 19)))
|
||||||
{
|
{
|
||||||
//const char* replace = ""; // For history pos soon
|
//const char* replace = ""; // For history pos soon
|
||||||
std::stringstream cmd;
|
std::stringstream cmd;
|
||||||
@ -335,7 +271,6 @@ void CCompanion::ServerBrowserSection()
|
|||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
|
||||||
};
|
};
|
||||||
// ^^^^
|
// ^^^^
|
||||||
// this definitely wont reach the final commit lmao
|
// this definitely wont reach the final commit lmao
|
||||||
@ -370,30 +305,21 @@ void CCompanion::ServerBrowserSection()
|
|||||||
|
|
||||||
if (ImGui::Button("Connect##PrivateServersConnectModal_ConnectButton", ImVec2(ImGui::GetWindowContentRegionWidth() / 2.f, 19)))
|
if (ImGui::Button("Connect##PrivateServersConnectModal_ConnectButton", ImVec2(ImGui::GetWindowContentRegionWidth() / 2.f, 19)))
|
||||||
{
|
{
|
||||||
nlohmann::json response = SendGetServerByTokenRequest(PrivateServerToken, PrivateServerPassword); // Send token connect request.
|
PrivateServerRequestMessage = "";
|
||||||
if (response["success"].get<bool>()) // Was the response successful?
|
ServerListing server;
|
||||||
|
bool result = r5net.GetServerByToken(server, PrivateServerRequestMessage, PrivateServerToken, PrivateServerPassword); // Send token connect request.
|
||||||
|
if (!server.name.empty())
|
||||||
{
|
{
|
||||||
nlohmann::json server = response["server"].get<nlohmann::json>(); // Get server field.
|
ConnectToServer(server.ip, server.port); // Connect to the server
|
||||||
|
PrivateServerRequestMessage = "Found Server: " + server.name;
|
||||||
if (server["ip"].is_string() && server["port"].is_string()) // Check if both field are a string.
|
|
||||||
{
|
|
||||||
std::string name = server["name"].get<std::string>(); // Please do this if you grab values from the response.
|
|
||||||
std::string ip = server["ip"].get<std::string>();
|
|
||||||
std::string port = server["port"].get<std::string>();
|
|
||||||
|
|
||||||
ConnectToServer(ip, port); // Connect to the server
|
|
||||||
PrivateServerRequestMessage = "Found Server: " + name;
|
|
||||||
PrivateServerMessageColor = ImVec4(0.00f, 1.00f, 0.00f, 1.00f);
|
PrivateServerMessageColor = ImVec4(0.00f, 1.00f, 0.00f, 1.00f);
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::string err = response["err"].get<std::string>();
|
PrivateServerRequestMessage = "Error: " + PrivateServerRequestMessage;
|
||||||
PrivateServerRequestMessage = "Error: " + err;
|
|
||||||
PrivateServerMessageColor = ImVec4(1.00f, 0.00f, 0.00f, 1.00f);
|
PrivateServerMessageColor = ImVec4(1.00f, 0.00f, 0.00f, 1.00f);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
@ -494,7 +420,8 @@ void CCompanion::HostServerSection()
|
|||||||
|
|
||||||
void CCompanion::SettingsSection()
|
void CCompanion::SettingsSection()
|
||||||
{
|
{
|
||||||
ImGui::InputText("Matchmaking Server String", MatchmakingServerStringBuffer, IM_ARRAYSIZE(MatchmakingServerStringBuffer), 0);
|
ImGui::Text("In renovation");
|
||||||
|
//ImGui::InputText("Matchmaking Server String", MatchmakingServerStringBuffer, IM_ARRAYSIZE(MatchmakingServerStringBuffer), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCompanion::Draw(const char* title)
|
void CCompanion::Draw(const char* title)
|
||||||
|
@ -47,14 +47,12 @@ void Hooks::InstallHooks()
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// Hook WinAPI
|
// Hook WinAPI
|
||||||
HMODULE user32dll = GetModuleHandleA("user32.dll");
|
if (Module user32dll = Module("user32.dll"); user32dll.GetModuleBase()) // Is user32.dll valid?
|
||||||
|
|
||||||
if (user32dll)
|
|
||||||
{
|
{
|
||||||
void* SetCursorPosPtr = GetProcAddress(user32dll, "SetCursorPos");
|
void* SetCursorPosPtr = user32dll.GetExportedFunction("SetCursorPos");
|
||||||
void* ClipCursorPtr = GetProcAddress(user32dll, "ClipCursor");
|
void* ClipCursorPtr = user32dll.GetExportedFunction("ClipCursor");
|
||||||
void* GetCursorPosPtr = GetProcAddress(user32dll, "GetCursorPos");
|
void* GetCursorPosPtr = user32dll.GetExportedFunction("GetCursorPos");
|
||||||
void* ShowCursorPtr = GetProcAddress(user32dll, "ShowCursor");
|
void* ShowCursorPtr = user32dll.GetExportedFunction("ShowCursor");
|
||||||
|
|
||||||
MH_CreateHook(SetCursorPosPtr, &Hooks::SetCursorPos, reinterpret_cast<void**>(&originalSetCursorPos));
|
MH_CreateHook(SetCursorPosPtr, &Hooks::SetCursorPos, reinterpret_cast<void**>(&originalSetCursorPos));
|
||||||
MH_CreateHook(ClipCursorPtr, &Hooks::ClipCursor, reinterpret_cast<void**>(&originalClipCursor));
|
MH_CreateHook(ClipCursorPtr, &Hooks::ClipCursor, reinterpret_cast<void**>(&originalClipCursor));
|
||||||
@ -124,14 +122,12 @@ void Hooks::RemoveHooks()
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// Unhook WinAPI
|
// Unhook WinAPI
|
||||||
HMODULE user32dll = GetModuleHandleA("user32.dll");
|
if (Module user32dll = Module("user32.dll"); user32dll.GetModuleBase()) // Is user32.dll valid?
|
||||||
|
|
||||||
if (user32dll)
|
|
||||||
{
|
{
|
||||||
void* SetCursorPosPtr = GetProcAddress(user32dll, "SetCursorPos");
|
void* SetCursorPosPtr = user32dll.GetExportedFunction("SetCursorPos");
|
||||||
void* ClipCursorPtr = GetProcAddress(user32dll, "ClipCursor");
|
void* ClipCursorPtr = user32dll.GetExportedFunction("ClipCursor");
|
||||||
void* GetCursorPosPtr = GetProcAddress(user32dll, "GetCursorPos");
|
void* GetCursorPosPtr = user32dll.GetExportedFunction("GetCursorPos");
|
||||||
void* ShowCursorPtr = GetProcAddress(user32dll, "ShowCursor");
|
void* ShowCursorPtr = user32dll.GetExportedFunction("ShowCursor");
|
||||||
|
|
||||||
MH_RemoveHook(SetCursorPosPtr);
|
MH_RemoveHook(SetCursorPosPtr);
|
||||||
MH_RemoveHook(ClipCursorPtr);
|
MH_RemoveHook(ClipCursorPtr);
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
#include "CCompanion.h"
|
#include "CCompanion.h"
|
||||||
#include "CGameConsole.h"
|
#include "CGameConsole.h"
|
||||||
|
|
||||||
|
|
||||||
#pragma comment(lib, "d3d11.lib")
|
#pragma comment(lib, "d3d11.lib")
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------
|
/*---------------------------------------------------------------------------------
|
||||||
@ -29,7 +28,6 @@ extern BOOL g_bShowConsole = false;
|
|||||||
extern BOOL g_bShowBrowser = false;
|
extern BOOL g_bShowBrowser = false;
|
||||||
static BOOL g_bInitMenu = false;
|
static BOOL g_bInitMenu = false;
|
||||||
static BOOL g_bInitialized = false;
|
static BOOL g_bInitialized = false;
|
||||||
static BOOL g_bPresentHooked = false;
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
static WNDPROC g_oWndProc = NULL;
|
static WNDPROC g_oWndProc = NULL;
|
||||||
@ -227,18 +225,12 @@ void GetPresent()
|
|||||||
pDeviceVTable = (DWORD_PTR*)pDevice;
|
pDeviceVTable = (DWORD_PTR*)pDevice;
|
||||||
pDeviceVTable = (DWORD_PTR*)pDeviceVTable[0];
|
pDeviceVTable = (DWORD_PTR*)pDeviceVTable[0];
|
||||||
|
|
||||||
int pIDX = (int)DXGISwapChainVTbl::Present;
|
g_fnIDXGISwapChainPresent = (IDXGISwapChainPresent)(DWORD_PTR)pSwapChainVtable[(int)DXGISwapChainVTbl::Present];
|
||||||
int rIDX = (int)DXGISwapChainVTbl::ResizeBuffers;
|
g_oResizeBuffers = (IDXGIResizeBuffers)(DWORD_PTR)pSwapChainVtable[(int)DXGISwapChainVTbl::ResizeBuffers];
|
||||||
|
|
||||||
g_fnIDXGISwapChainPresent = (IDXGISwapChainPresent)(DWORD_PTR)pSwapChainVtable[pIDX];
|
|
||||||
g_oResizeBuffers = (IDXGIResizeBuffers)(DWORD_PTR)pSwapChainVtable[rIDX];
|
|
||||||
|
|
||||||
pSwapChain->Release();
|
pSwapChain->Release();
|
||||||
pContext->Release();
|
pContext->Release();
|
||||||
pDevice->Release();
|
pDevice->Release();
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
g_bPresentHooked = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//#################################################################################
|
//#################################################################################
|
||||||
@ -316,7 +308,7 @@ void CreateRenderTarget(IDXGISwapChain* pSwapChain)
|
|||||||
|
|
||||||
void DestroyRenderTarget()
|
void DestroyRenderTarget()
|
||||||
{
|
{
|
||||||
if (nullptr != g_pRenderTargetView)
|
if (g_pRenderTargetView)
|
||||||
{
|
{
|
||||||
g_pRenderTargetView->Release();
|
g_pRenderTargetView->Release();
|
||||||
g_pRenderTargetView = nullptr;
|
g_pRenderTargetView = nullptr;
|
||||||
@ -348,7 +340,6 @@ HRESULT __stdcall GetResizeBuffers(IDXGISwapChain* pSwapChain, UINT nBufferCount
|
|||||||
g_bShowConsole = false;
|
g_bShowConsole = false;
|
||||||
g_bShowBrowser = false;
|
g_bShowBrowser = false;
|
||||||
g_bInitialized = false;
|
g_bInitialized = false;
|
||||||
g_bPresentHooked = false;
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@ -448,19 +439,6 @@ bool LoadTextureFromByteArray(unsigned char* image_data, const int& image_width,
|
|||||||
|
|
||||||
void InstallDXHooks()
|
void InstallDXHooks()
|
||||||
{
|
{
|
||||||
HMODULE user32dll = GetModuleHandleA("user32.dll");
|
|
||||||
|
|
||||||
if (user32dll)
|
|
||||||
{
|
|
||||||
IPostMessageA PostMessageA = (IPostMessageA)GetProcAddress(user32dll, "PostMessageA");
|
|
||||||
IPostMessageW PostMessageW = (IPostMessageW)GetProcAddress(user32dll, "PostMessageW");
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Hook PostMessage
|
|
||||||
MH_CreateHook(PostMessageA, &HPostMessageA, reinterpret_cast<void**>(&g_oPostMessageA));
|
|
||||||
MH_CreateHook(PostMessageW, &HPostMessageW, reinterpret_cast<void**>(&g_oPostMessageW));
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// Hook SwapChain
|
// Hook SwapChain
|
||||||
MH_CreateHook(g_fnIDXGISwapChainPresent, &Present, reinterpret_cast<void**>(&originalPresent));
|
MH_CreateHook(g_fnIDXGISwapChainPresent, &Present, reinterpret_cast<void**>(&originalPresent));
|
||||||
@ -468,26 +446,36 @@ void InstallDXHooks()
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// Enable hooks
|
// Enable hooks
|
||||||
MH_EnableHook(PostMessageA);
|
|
||||||
MH_EnableHook(PostMessageW);
|
|
||||||
MH_EnableHook(g_fnIDXGISwapChainPresent);
|
MH_EnableHook(g_fnIDXGISwapChainPresent);
|
||||||
MH_EnableHook(g_oResizeBuffers);
|
MH_EnableHook(g_oResizeBuffers);
|
||||||
|
|
||||||
|
if (Module user32dll = Module("user32.dll"); user32dll.GetModuleBase()) // Is user32.dll valid?
|
||||||
|
{
|
||||||
|
IPostMessageA PostMessageA = user32dll.GetExportedFunction("PostMessageA").RCast<IPostMessageA>();
|
||||||
|
IPostMessageW PostMessageW = user32dll.GetExportedFunction("PostMessageW").RCast<IPostMessageW>();
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Hook PostMessage
|
||||||
|
MH_CreateHook(PostMessageA, &HPostMessageA, reinterpret_cast<void**>(&g_oPostMessageA));
|
||||||
|
MH_CreateHook(PostMessageW, &HPostMessageW, reinterpret_cast<void**>(&g_oPostMessageW));
|
||||||
|
|
||||||
|
MH_EnableHook(PostMessageA);
|
||||||
|
MH_EnableHook(PostMessageW);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemoveDXHooks()
|
void RemoveDXHooks()
|
||||||
{
|
{
|
||||||
HMODULE user32dll = GetModuleHandleA("user32.dll");
|
|
||||||
|
|
||||||
if (user32dll)
|
|
||||||
{
|
|
||||||
IPostMessageA PostMessageA = (IPostMessageA)GetProcAddress(user32dll, "PostMessageA");
|
|
||||||
IPostMessageW PostMessageW = (IPostMessageW)GetProcAddress(user32dll, "PostMessageW");
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// Unhook PostMessage
|
// Unhook PostMessage
|
||||||
|
if (Module user32dll = Module("user32.dll"); user32dll.GetModuleBase()) // Is user32.dll valid?
|
||||||
|
{
|
||||||
|
IPostMessageA PostMessageA = user32dll.GetExportedFunction("PostMessageA").RCast<IPostMessageA>();
|
||||||
|
IPostMessageW PostMessageW = user32dll.GetExportedFunction("PostMessageW").RCast<IPostMessageW>();
|
||||||
|
|
||||||
MH_RemoveHook(PostMessageA);
|
MH_RemoveHook(PostMessageA);
|
||||||
MH_RemoveHook(PostMessageW);
|
MH_RemoveHook(PostMessageW);
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// Unhook SwapChain
|
// Unhook SwapChain
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
#include "pch.h"
|
|
||||||
#include "serverlisting.h"
|
|
||||||
#include "CCompanion.h"
|
|
||||||
|
|
||||||
void ServerListing::Select()
|
|
||||||
{
|
|
||||||
std::stringstream cmd;
|
|
||||||
cmd << "connect " << this->ip << ":" << this->port;
|
|
||||||
g_ServerBrowser->ProcessCommand(cmd.str().c_str());
|
|
||||||
}
|
|
26
r5net/include/netpch.h
Normal file
26
r5net/include/netpch.h
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#pragma once
|
||||||
|
#pragma message("Precompiling r5net headers.\n")
|
||||||
|
|
||||||
|
#define WIN32_LEAN_AND_MEAN
|
||||||
|
#include <windows.h>
|
||||||
|
#include <thread>
|
||||||
|
#include <fstream>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <filesystem>
|
||||||
|
#include <sstream>
|
||||||
|
#include <shlobj.h>
|
||||||
|
#include <objbase.h>
|
||||||
|
#include <cassert>
|
||||||
|
#include <iomanip>
|
||||||
|
#include <iostream>
|
||||||
|
#include <d3d11.h>
|
||||||
|
#include <string>
|
||||||
|
#include <Psapi.h>
|
||||||
|
#include <vector>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
///
|
||||||
|
|
||||||
|
|
||||||
|
#include "httplib.h"
|
||||||
|
#include "json.hpp"
|
27
r5net/include/r5/r5net.h
Normal file
27
r5net/include/r5/r5net.h
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "serverlisting.h"
|
||||||
|
|
||||||
|
namespace R5Net
|
||||||
|
{
|
||||||
|
struct Config
|
||||||
|
{
|
||||||
|
std::string MOTD;
|
||||||
|
int SERVER_TTL;
|
||||||
|
int MIN_REQUIRED_VERSION;
|
||||||
|
};
|
||||||
|
class Client
|
||||||
|
{
|
||||||
|
httplib::Client m_HttpClient;
|
||||||
|
|
||||||
|
public:
|
||||||
|
Client(std::string serverString) : m_HttpClient(serverString.c_str())
|
||||||
|
{
|
||||||
|
m_HttpClient.set_connection_timeout(10);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<ServerListing> GetServersList();
|
||||||
|
bool PostServerHost(std::string& outMessage, std::string& outToken, const ServerListing& serverListing);
|
||||||
|
bool GetServerByToken(ServerListing& outServer, std::string& outError, const std::string& token, const std::string& password = "");
|
||||||
|
};
|
||||||
|
}
|
11
r5net/include/r5/serverlisting.h
Normal file
11
r5net/include/r5/serverlisting.h
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
struct ServerListing
|
||||||
|
{
|
||||||
|
std::string name;
|
||||||
|
std::string map;
|
||||||
|
std::string ip;
|
||||||
|
std::string port;
|
||||||
|
std::string password;
|
||||||
|
};
|
||||||
|
|
177
r5net/r5net.vcxproj
Normal file
177
r5net/r5net.vcxproj
Normal file
@ -0,0 +1,177 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="include\netpch.h" />
|
||||||
|
<ClInclude Include="include\r5\r5net.h" />
|
||||||
|
<ClInclude Include="include\serverlisting.h" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="src\netpch.cpp">
|
||||||
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
|
||||||
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\r5net.cpp" />
|
||||||
|
<ClCompile Include="src\serverlisting.cpp" />
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<VCProjectVersion>16.0</VCProjectVersion>
|
||||||
|
<Keyword>Win32Proj</Keyword>
|
||||||
|
<ProjectGuid>{f04be619-0326-4ff1-b06b-fbe882e04d5e}</ProjectGuid>
|
||||||
|
<RootNamespace>r5net</RootNamespace>
|
||||||
|
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="Shared">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
<OutDir>$(ProjectDir)lib\$(Configuration)\</OutDir>
|
||||||
|
<IntDir>$(SolutionDir)build\$(ProjectName)\$(Configuration)\</IntDir>
|
||||||
|
<IncludePath>$(SolutionDir)shared\include;$(ProjectDir)include;$(IncludePath)</IncludePath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
<OutDir>$(ProjectDir)lib\$(Configuration)\</OutDir>
|
||||||
|
<IntDir>$(SolutionDir)build\$(ProjectName)\$(Configuration)\</IntDir>
|
||||||
|
<IncludePath>$(SolutionDir)shared\include;$(ProjectDir)include;$(IncludePath)</IncludePath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||||
|
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>
|
||||||
|
</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||||
|
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>
|
||||||
|
</SubSystem>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||||
|
<PrecompiledHeaderFile>netpch.h</PrecompiledHeaderFile>
|
||||||
|
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>
|
||||||
|
</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||||
|
<PrecompiledHeaderFile>netpch.h</PrecompiledHeaderFile>
|
||||||
|
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>
|
||||||
|
</SubSystem>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
33
r5net/r5net.vcxproj.filters
Normal file
33
r5net/r5net.vcxproj.filters
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup>
|
||||||
|
<Filter Include="include">
|
||||||
|
<UniqueIdentifier>{676c0758-86e4-4159-8aaf-17969db2d381}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="src">
|
||||||
|
<UniqueIdentifier>{a3728292-4416-44be-a05c-5642a99dbbad}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="include\serverlisting.h">
|
||||||
|
<Filter>include</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="include\netpch.h">
|
||||||
|
<Filter>include</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="include\r5\r5net.h">
|
||||||
|
<Filter>include</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="src\r5net.cpp">
|
||||||
|
<Filter>src</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\serverlisting.cpp">
|
||||||
|
<Filter>src</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\netpch.cpp">
|
||||||
|
<Filter>src</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
2
r5net/src/netpch.cpp
Normal file
2
r5net/src/netpch.cpp
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "netpch.h"
|
96
r5net/src/r5net.cpp
Normal file
96
r5net/src/r5net.cpp
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
// r5net.cpp : Defines the functions for the static library.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "netpch.h"
|
||||||
|
#include "r5\r5net.h"
|
||||||
|
|
||||||
|
std::vector<ServerListing> R5Net::Client::GetServersList()
|
||||||
|
{
|
||||||
|
std::vector<ServerListing> list{ };
|
||||||
|
|
||||||
|
auto res = m_HttpClient.Get("/servers");
|
||||||
|
|
||||||
|
if (res)
|
||||||
|
{
|
||||||
|
nlohmann::json root = nlohmann::json::parse(res->body);
|
||||||
|
for (auto obj : root["servers"])
|
||||||
|
{
|
||||||
|
list.push_back(
|
||||||
|
ServerListing{ obj["name"].get<std::string>(), obj["map"].get<std::string>(), obj["ip"].get<std::string>(), obj["port"].get<std::string>() }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool R5Net::Client::PostServerHost(std::string& outMessage, std::string& outToken, const ServerListing& serverListing)
|
||||||
|
{
|
||||||
|
nlohmann::json reqBody = nlohmann::json::object();
|
||||||
|
reqBody["name"] = serverListing.name;
|
||||||
|
reqBody["map"] = serverListing.map;
|
||||||
|
reqBody["port"] = serverListing.port;
|
||||||
|
reqBody["password"] = serverListing.password;
|
||||||
|
|
||||||
|
std::string reqBodyStr = reqBody.dump();
|
||||||
|
|
||||||
|
auto res = m_HttpClient.Post("/servers/add", reqBodyStr.c_str(), reqBodyStr.length(), "application/json");
|
||||||
|
|
||||||
|
|
||||||
|
nlohmann::json resBody = nlohmann::json::parse(res->body);
|
||||||
|
if (res && resBody["success"].is_boolean() && resBody["success"])
|
||||||
|
{
|
||||||
|
outMessage = "Broadcasting!";
|
||||||
|
|
||||||
|
if (resBody["token"].is_string())
|
||||||
|
outToken = resBody["token"].get<std::string>();
|
||||||
|
else
|
||||||
|
outToken = "";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (resBody["err"].is_string())
|
||||||
|
outMessage = resBody["err"].get<std::string>();
|
||||||
|
else
|
||||||
|
outMessage = "An unknown error occured!";
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool R5Net::Client::GetServerByToken(ServerListing& outServer, std::string& outError, const std::string& token, const std::string& password)
|
||||||
|
{
|
||||||
|
nlohmann::json reqBody = nlohmann::json::object();
|
||||||
|
|
||||||
|
reqBody["token"] = token;
|
||||||
|
reqBody["password"] = password;
|
||||||
|
|
||||||
|
httplib::Result res = m_HttpClient.Post("/server/byToken", reqBody.dump().c_str(), reqBody.dump().length(), "application/json");
|
||||||
|
|
||||||
|
std::cout << "YEEEEEEEEEEEEEE" << res->body << "\n";
|
||||||
|
nlohmann::json resBody = nlohmann::json::parse(res->body);
|
||||||
|
|
||||||
|
if (res && resBody["success"].is_boolean() && resBody["success"])
|
||||||
|
{
|
||||||
|
outServer = ServerListing{
|
||||||
|
resBody["server"]["name"].get<std::string>(),
|
||||||
|
resBody["server"]["map"].get<std::string>(),
|
||||||
|
resBody["server"]["ip"].get<std::string>(),
|
||||||
|
resBody["server"]["port"].get<std::string>()
|
||||||
|
};
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (resBody["err"].is_string())
|
||||||
|
outError = resBody["err"].get<std::string>();
|
||||||
|
else
|
||||||
|
outError = "";
|
||||||
|
|
||||||
|
outServer = ServerListing{};
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
3
r5net/src/serverlisting.cpp
Normal file
3
r5net/src/serverlisting.cpp
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#include "netpch.h"
|
||||||
|
|
||||||
|
#include "r5\serverlisting.h"
|
@ -343,7 +343,7 @@ public:
|
|||||||
{
|
{
|
||||||
for (ModuleSections& currentSection : moduleSections)
|
for (ModuleSections& currentSection : moduleSections)
|
||||||
{
|
{
|
||||||
printf(" [+Module: %s+]%s, %p\n", moduleName.c_str(), currentSection.sectionName.c_str(), currentSection.sectionStartAddress);
|
printf(" [+Module: %s+]%s, %p\n", moduleName.c_str(), currentSection.sectionName.c_str(), reinterpret_cast<void*>(currentSection.sectionStartAddress));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -437,6 +437,52 @@ public:
|
|||||||
return MemoryAddress(latestOccurence);
|
return MemoryAddress(latestOccurence);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MemoryAddress GetExportedFunction(const std::string functionName)
|
||||||
|
{
|
||||||
|
if (!dosHeader || dosHeader->e_magic != IMAGE_DOS_SIGNATURE) // Is dosHeader valid?
|
||||||
|
return MemoryAddress();
|
||||||
|
|
||||||
|
if (!ntHeaders || ntHeaders->Signature != IMAGE_NT_SIGNATURE) // Is ntHeader valid?
|
||||||
|
return MemoryAddress();
|
||||||
|
|
||||||
|
// Get the location of IMAGE_EXPORT_DIRECTORY for this module by adding the IMAGE_DIRECTORY_ENTRY_EXPORT relative virtual address onto our module base address.
|
||||||
|
IMAGE_EXPORT_DIRECTORY* ImageExportDirectory = reinterpret_cast<IMAGE_EXPORT_DIRECTORY*>(moduleBase + ntHeaders->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress);
|
||||||
|
if (!ImageExportDirectory)
|
||||||
|
return MemoryAddress();
|
||||||
|
|
||||||
|
// Are there any exported functions?
|
||||||
|
if (!ImageExportDirectory->NumberOfFunctions)
|
||||||
|
return MemoryAddress();
|
||||||
|
|
||||||
|
// Get the location of the functions via adding the relative virtual address from the struct into our module base address.
|
||||||
|
DWORD* AddressOfFunctionsPtr = reinterpret_cast<DWORD*>(moduleBase + ImageExportDirectory->AddressOfFunctions);
|
||||||
|
if (!AddressOfFunctionsPtr)
|
||||||
|
return MemoryAddress();
|
||||||
|
|
||||||
|
// Get the names of the functions via adding the relative virtual address from the struct into our module base address.
|
||||||
|
DWORD* AddressOfNamePtr = reinterpret_cast<DWORD*>(moduleBase + ImageExportDirectory->AddressOfNames);
|
||||||
|
if (!AddressOfNamePtr)
|
||||||
|
return MemoryAddress();
|
||||||
|
|
||||||
|
// Get the ordinals of the functions via adding the relative virtual address from the struct into our module base address.
|
||||||
|
DWORD* AddressOfOrdinalsPtr = reinterpret_cast<DWORD*>(moduleBase + ImageExportDirectory->AddressOfNameOrdinals);
|
||||||
|
if (!AddressOfOrdinalsPtr)
|
||||||
|
return MemoryAddress();
|
||||||
|
|
||||||
|
for (std::size_t i = 0; i < ImageExportDirectory->NumberOfFunctions; i++) // Iterate through all the functions.
|
||||||
|
{
|
||||||
|
// Get virtual relative address of the function name. Then add module base address to get the actual location.
|
||||||
|
std::string ExportFunctionName = reinterpret_cast<char*>(reinterpret_cast<DWORD*>(moduleBase + AddressOfNamePtr[i]));
|
||||||
|
|
||||||
|
if (ExportFunctionName.compare(functionName) == 0) // Is this our wanted exported function?
|
||||||
|
{
|
||||||
|
// Get the function ordinal. Then grab the relative virtual address of our wanted function. Then add module base address so we get the actual location.
|
||||||
|
return MemoryAddress(moduleBase + AddressOfFunctionsPtr[reinterpret_cast<WORD*>(AddressOfOrdinalsPtr)[i]]); // Return as MemoryAddress class.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return MemoryAddress();
|
||||||
|
}
|
||||||
|
|
||||||
MemoryAddress FindAddressForString(const std::string string, bool nullTerminator)
|
MemoryAddress FindAddressForString(const std::string string, bool nullTerminator)
|
||||||
{
|
{
|
||||||
static auto StringToBytes = [](const std::string string, bool nullTerminator)
|
static auto StringToBytes = [](const std::string string, bool nullTerminator)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user