summaryrefslogtreecommitdiff
path: root/loader/server
diff options
context:
space:
mode:
Diffstat (limited to 'loader/server')
-rw-r--r--loader/server/client.cpp201
-rw-r--r--loader/server/client.hpp67
-rw-r--r--loader/server/message.hpp8
-rw-r--r--loader/server/server.cpp48
-rw-r--r--loader/server/server.hpp34
-rw-r--r--loader/server/server.vcxproj248
-rw-r--r--loader/server/server.vcxproj.filters14
-rw-r--r--loader/server/server_windows.cpp40
-rw-r--r--loader/server/util.hpp25
9 files changed, 685 insertions, 0 deletions
diff --git a/loader/server/client.cpp b/loader/server/client.cpp
new file mode 100644
index 0000000..8e7d3d3
--- /dev/null
+++ b/loader/server/client.cpp
@@ -0,0 +1,201 @@
+#include "client.hpp"
+#include "server.hpp"
+
+/*
+std::vector< byte > server::c_client::receive_message( ) {
+ std::vector< uint8_t > ret;
+ char buffer[ BUFFER_SIZE ]{ };
+ int received = 0;
+
+ while( true ) {
+ received = recv( m_socket, buffer, BUFFER_SIZE, 0 );
+ if( received < 0 )
+ break;
+
+ for( int i{ }; i < received; ++i )
+ ret.push_back( buffer[ i ] );
+
+ if( received < BUFFER_SIZE )
+ break;
+ }
+
+ if( ret.size( ) ) {
+ decode_buffer( ret.data( ), ret.size( ) );
+ ret.push_back( 0 );
+ ret.erase( ret.begin( ) );
+ }
+
+ return ret;
+}
+*/
+
+void server::c_client::kill( ) {
+ closesocket( m_socket );
+ printf( "%s disconnected\n", get_ip( ) );
+}
+
+std::string server::c_client::get_msg( ) {
+ std::string ret{ };
+ char buffer[ BUFFER_SIZE ]{ };
+ int received = 0;
+
+ while ( true ) {
+ received = recv( m_socket, buffer, BUFFER_SIZE, 0 );
+ if ( received < 0 )
+ break;
+
+ for ( int i{ }; i < received; ++i )
+ ret.push_back( buffer[ i ] );
+
+ if ( received < BUFFER_SIZE )
+ break;
+ }
+
+ if ( ret.size( ) ) {
+ decode_buffer( ( uint8_t* )ret.data( ), ret.size( ) );
+ // ret.push_back( 0 ); somehow broke things :/
+ ret.erase( ret.begin( ) );
+ }
+
+ return ret;
+}
+
+bool server::c_client::send_msg( byte* msg, size_t length ) {
+ auto buffer = std::make_unique< uint8_t[ ] >( length + 1 );
+ uint8_t key = util::random_number( 0, 255 ) & 0xff;
+
+ buffer[ 0 ] = key;
+ memcpy( buffer.get( ) + 1,
+ msg,
+ length );
+
+ for( size_t i = 1; i <= length; ++i ) {
+ buffer[ i ] ^= key;
+ }
+
+ int result = send( m_socket, ( char* )buffer.get( ), length + 1, 0 );
+ if( result == -1 ) {
+#if WIN64
+ printf( "error sending message to %s: %d\n",
+ get_ip( ), WSAGetLastError( ) );
+#else
+ printf( "error sending message to %s\n",
+ get_ip( ) );
+#endif
+ return false;
+ }
+
+ return true;
+}
+
+bool server::c_client::send_msg( const char* msg ) {
+ auto length = strlen( msg );
+ auto buffer = std::make_unique< uint8_t[ ] >( length + 1 );
+ uint8_t key = util::random_number( 0, 255 ) & 0xff;
+
+ memset( buffer.get( ), 0, length+1 );
+
+ buffer[ 0 ] = key;
+ memcpy( buffer.get( ) + 1,
+ msg,
+ length );
+
+ for ( size_t i = 1; i <= length; ++i ) {
+ buffer[ i ] ^= key;
+ }
+
+ int result = send( m_socket, ( char* )buffer.get( ), length + 1, 0 );
+ if ( result == -1 ) {
+#if WIN64
+ printf( "error sending message to %s: %d\n",
+ get_ip( ), WSAGetLastError( ) );
+#else
+ printf( "error sending message to %s\n",
+ get_ip( ) );
+#endif
+ return false;
+ }
+
+ return true;
+}
+
+bool server::c_client::handle( ) {
+ /*
+ ALL TEST CODE BELOW.
+ */
+ auto hello_msg = get_msg( );
+ printf( "%s\n", hello_msg.c_str( ) );
+
+ if ( hello_msg != "hello" )
+ return false;
+
+ auto username = get_msg( );
+ if ( username != "friendly" )
+ return false;
+
+ printf( "correct username\n" );
+ send_msg( "correct username" );
+
+ auto password = get_msg( );
+ if ( password != "nigger" )
+ return false;
+
+ printf( "correct password\n" );
+ send_msg( "correct password" );
+
+ const char* games_list =
+R"(games:
+1: CSGO
+2: CSGO (test)
+3: Garry's Mod
+)";
+
+ send_msg( games_list );
+
+ auto game_id = get_msg( );
+
+ if ( game_id== "1" ) {
+ printf( "csgo\n" );
+ send_msg( "csgo.exe" );
+ }
+ else if ( game_id == "2" ) {
+ printf( "csgo test\n" );
+ send_msg( "csgo.exe" );
+ }
+ else if ( game_id == "3" ) {
+ printf( "gmod\n" );
+ send_msg( "hl2.exe" );
+ }
+ else {
+ printf( "invalid\n" );
+ return false;
+ }
+
+ auto found = get_msg( );
+ if ( found != "found" )
+ return false;
+
+ printf( "process found\n" );
+
+ if ( game_id == "3" ) {
+ // test. make sure the file is in ur directory
+ auto file = std::ifstream( "gmod.dll", std::ifstream::binary );
+ if ( file.is_open( ) ) {
+ file.seekg( 0, file.end );
+
+ auto size = ( int )file.tellg( );
+ auto buffer = std::make_unique< char[ ] >( size );
+
+ memset( buffer.get( ), 0, size );
+
+ file.seekg( 0, file.beg );
+ file.read( buffer.get( ), size );
+
+ send_msg( ( uint8_t* )buffer.get( ), size );
+
+ file.close( );
+ }
+ }
+
+ return true;
+}
diff --git a/loader/server/client.hpp b/loader/server/client.hpp
new file mode 100644
index 0000000..1f577c7
--- /dev/null
+++ b/loader/server/client.hpp
@@ -0,0 +1,67 @@
+#pragma once
+
+#ifdef WIN64
+#include <Windows.h>
+#pragma comment(lib, "ws2_32.lib")
+#else
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <netinet/in.h>
+#endif
+
+
+#include <cstdio>
+#include <cstdlib>
+#include <string>
+#include <fstream>
+#include <memory>
+#include <thread>
+
+
+#include "util.hpp"
+
+constexpr auto PORT_NUM = 6969;
+constexpr auto BUFFER_SIZE = 255;
+
+namespace server
+{
+ class c_client {
+ SOCKET m_socket{ };
+ in_addr m_address{ };
+ ulong_t m_hwid{ };
+ public:
+ c_client( SOCKET socket, in_addr& address ) :
+ m_socket( socket ),
+ m_address( address )
+ { }
+
+ ~c_client( ) {
+ kill( );
+ }
+
+
+ void decode_buffer( uint8_t* buf, size_t length ) {
+ auto key = buf[ 0 ];
+ for( size_t i{ 1 }; i < length; ++i )
+ buf[ i ] ^= key;
+ }
+
+ auto get_ip( ) {
+ return inet_ntoa( m_address );
+ }
+
+ void kill( );
+
+ //std::vector< byte > receive_message( );
+ std::string get_msg( );
+ bool send_msg( byte* msg, size_t length );
+ bool send_msg( const char* );
+
+ //handles messages, hwid etc
+ void handle_buffer( byte* msg );
+ virtual bool handle( );
+ };
+} \ No newline at end of file
diff --git a/loader/server/message.hpp b/loader/server/message.hpp
new file mode 100644
index 0000000..bf67389
--- /dev/null
+++ b/loader/server/message.hpp
@@ -0,0 +1,8 @@
+#pragma once
+
+enum MessageType_t {
+ MSG_HELLO = 'h',
+ MSG_READY = 'r',
+ MSG_BAN = 'q',
+ MSG_IMPORT = 'i'
+}; \ No newline at end of file
diff --git a/loader/server/server.cpp b/loader/server/server.cpp
new file mode 100644
index 0000000..e12e691
--- /dev/null
+++ b/loader/server/server.cpp
@@ -0,0 +1,48 @@
+#include "server.hpp"
+
+int server::c_server::init( ) {
+#if WIN64
+ if( WSAStartup( MAKEWORD( 2, 2 ), &m_sock_data ) ) // windows
+ return 1;
+#endif
+
+ m_socket = socket( AF_INET, SOCK_STREAM, 0 );
+ if( m_socket == INVALID_SOCKET )
+ return 2;
+
+ sockaddr_in server_address{ };
+ server_address.sin_addr.s_addr = INADDR_ANY;
+ server_address.sin_port = htons( PORT_NUM );
+ server_address.sin_family = AF_INET;
+
+ auto result = ::bind( m_socket, ( sockaddr* )( &server_address ), sizeof( server_address ) );
+ return result != -1 ? 0 : 3;
+}
+
+void server::c_server::listen( ) {
+ ::listen( m_socket, 5 );
+
+ sockaddr_in client_address{ };
+
+ // not needed, this is set in accept, values are input.
+ // client_address.sin_port = htons( PORT_NUM );
+ int len = sizeof( client_address );
+
+ SOCKET result = accept( m_socket, ( sockaddr* )( &client_address ), &len );
+ if( result == INVALID_SOCKET ) {
+ printf( "socket error accepting a connection\n" );
+ return;
+ }
+
+ printf( "incoming connection from: %s\n", inet_ntoa( client_address.sin_addr ) );
+
+ // connection established.
+ auto client = std::make_shared< c_client >( result, client_address.sin_addr );
+
+ // handshake.
+ client->send_msg( "hello" );
+
+ // surprised it even works with shared_ptr.
+ std::thread thread{ &c_client::handle, client };
+ thread.detach( );
+}
diff --git a/loader/server/server.hpp b/loader/server/server.hpp
new file mode 100644
index 0000000..5ac8393
--- /dev/null
+++ b/loader/server/server.hpp
@@ -0,0 +1,34 @@
+#pragma once
+#include <vector>
+#include <memory>
+#include <mutex>
+#include <thread>
+
+#include "client.hpp"
+
+
+//since this will be running on our vps we dont need string encryption or protection for anything
+//which is cool, i guess
+
+namespace server
+{
+ class c_server {
+ // not sure if even needed.
+ std::mutex m_mutex;
+ private:
+ WSADATA m_sock_data{ };
+ SOCKET m_socket{ };
+
+ public:
+ ~c_server( ) {
+ if ( m_socket )
+ closesocket( m_socket );
+ }
+
+ int init( );
+ void listen( );
+ void client_loop( );
+ };
+}
+
+extern server::c_server g_server; \ No newline at end of file
diff --git a/loader/server/server.vcxproj b/loader/server/server.vcxproj
new file mode 100644
index 0000000..543a42f
--- /dev/null
+++ b/loader/server/server.vcxproj
@@ -0,0 +1,248 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="D_LinuxServer|Win32">
+ <Configuration>D_LinuxServer</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="D_LinuxServer|x64">
+ <Configuration>D_LinuxServer</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release_Windows|Win32">
+ <Configuration>Release_Windows</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release_Windows|x64">
+ <Configuration>Release_Windows</Configuration>
+ <Platform>x64</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="client.hpp" />
+ <ClInclude Include="message.hpp" />
+ <ClInclude Include="server.hpp" />
+ <ClInclude Include="util.hpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="client.cpp" />
+ <ClCompile Include="server.cpp" />
+ <ClCompile Include="server_windows.cpp" />
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <VCProjectVersion>15.0</VCProjectVersion>
+ <ProjectGuid>{A6D4FCB9-F886-424C-8493-758A15CCD7A9}</ProjectGuid>
+ <RootNamespace>server</RootNamespace>
+ <WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v141</PlatformToolset>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='D_LinuxServer|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v141</PlatformToolset>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v141</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_Windows|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v141</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v141</PlatformToolset>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='D_LinuxServer|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v141</PlatformToolset>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v141</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_Windows|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v141</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>MultiByte</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 Condition="'$(Configuration)|$(Platform)'=='D_LinuxServer|Win32'" Label="PropertySheets">
+ <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 Condition="'$(Configuration)|$(Platform)'=='Release_Windows|Win32'" Label="PropertySheets">
+ <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 Condition="'$(Configuration)|$(Platform)'=='D_LinuxServer|x64'" Label="PropertySheets">
+ <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>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release_Windows|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup />
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <SDLCheck>true</SDLCheck>
+ <ConformanceMode>true</ConformanceMode>
+ </ClCompile>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='D_LinuxServer|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <SDLCheck>true</SDLCheck>
+ <ConformanceMode>true</ConformanceMode>
+ </ClCompile>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <WarningLevel>Level4</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <SDLCheck>true</SDLCheck>
+ <ConformanceMode>true</ConformanceMode>
+ <EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
+ <RuntimeTypeInfo>false</RuntimeTypeInfo>
+ <LanguageStandard>stdcpplatest</LanguageStandard>
+ <CallingConvention>FastCall</CallingConvention>
+ <PreprocessorDefinitions>WIN64;VC_EXTRALEAN;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='D_LinuxServer|x64'">
+ <ClCompile>
+ <WarningLevel>Level4</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <SDLCheck>true</SDLCheck>
+ <ConformanceMode>true</ConformanceMode>
+ <EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
+ <RuntimeTypeInfo>false</RuntimeTypeInfo>
+ <LanguageStandard>stdcpplatest</LanguageStandard>
+ <CallingConvention>FastCall</CallingConvention>
+ <PreprocessorDefinitions>VC_EXTRALEAN;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <SDLCheck>true</SDLCheck>
+ <ConformanceMode>true</ConformanceMode>
+ </ClCompile>
+ <Link>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_Windows|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <SDLCheck>true</SDLCheck>
+ <ConformanceMode>true</ConformanceMode>
+ </ClCompile>
+ <Link>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <WarningLevel>Level4</WarningLevel>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <SDLCheck>true</SDLCheck>
+ <ConformanceMode>true</ConformanceMode>
+ <EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
+ <RuntimeTypeInfo>false</RuntimeTypeInfo>
+ <LanguageStandard>stdcpplatest</LanguageStandard>
+ <CallingConvention>FastCall</CallingConvention>
+ </ClCompile>
+ <Link>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_Windows|x64'">
+ <ClCompile>
+ <WarningLevel>Level4</WarningLevel>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <SDLCheck>true</SDLCheck>
+ <ConformanceMode>true</ConformanceMode>
+ <EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
+ <RuntimeTypeInfo>false</RuntimeTypeInfo>
+ <LanguageStandard>stdcpplatest</LanguageStandard>
+ <CallingConvention>FastCall</CallingConvention>
+ <PreprocessorDefinitions>WIN64;VC_EXTRALEAN;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <Link>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ </Link>
+ </ItemDefinitionGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/loader/server/server.vcxproj.filters b/loader/server/server.vcxproj.filters
new file mode 100644
index 0000000..5ef28fc
--- /dev/null
+++ b/loader/server/server.vcxproj.filters
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <ClInclude Include="message.hpp" />
+ <ClInclude Include="server.hpp" />
+ <ClInclude Include="util.hpp" />
+ <ClInclude Include="client.hpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="server.cpp" />
+ <ClCompile Include="server_windows.cpp" />
+ <ClCompile Include="client.cpp" />
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/loader/server/server_windows.cpp b/loader/server/server_windows.cpp
new file mode 100644
index 0000000..cdc6ac4
--- /dev/null
+++ b/loader/server/server_windows.cpp
@@ -0,0 +1,40 @@
+#ifdef WIN64
+#include <Windows.h>
+#pragma comment(lib, "ws2_32.lib")
+#else
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <netinet/in.h>
+#endif
+
+#include <cstdio>
+#include <cstdlib>
+#include <string>
+#include <fstream>
+#include <thread>
+#include "server.hpp"
+
+server::c_server g_server;
+
+int main( ) {
+ std::thread listen_thread;
+
+ int result = g_server.init( );
+ if( !result ) {
+ //listen_thread = std::thread( [ ]( ) { while( 1 ) { g_server.listen( ); } } );
+ //listen_thread.detach( );
+
+ while( true ) {
+ g_server.listen( );
+ //Sleep( 1 );
+ }
+ }
+ else
+ printf( "server init error (%d)\n", result );
+
+ system( "pause" );
+ return 0;
+}
diff --git a/loader/server/util.hpp b/loader/server/util.hpp
new file mode 100644
index 0000000..1d408e0
--- /dev/null
+++ b/loader/server/util.hpp
@@ -0,0 +1,25 @@
+#pragma once
+#include <random>
+
+using ulong_t = unsigned long;
+
+namespace util
+{
+ namespace {
+ //make a random generator and seed it with a p random number
+ static std::random_device rd;
+ static std::mt19937 gen( rd( ) );
+ }
+
+ template < typename t >
+ __forceinline t random_number( t min, t max ) {
+ if constexpr( !std::is_integral_v< t > ) {
+ std::uniform_real_distribution< t > dist( min, max );
+ return dist( gen );
+ }
+ else {
+ std::uniform_int_distribution< t > dist( min, max );
+ return dist( gen );
+ }
+ }
+} \ No newline at end of file