aboutsummaryrefslogtreecommitdiff
path: root/loader_wsock32_proxy
diff options
context:
space:
mode:
authorBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2022-01-02 22:32:36 +0000
committerGitHub <noreply@github.com>2022-01-02 22:32:36 +0000
commit3f629680f71b4694bd4eb78726537a91e10a2352 (patch)
tree137e44e28bbe372adeb616e3f20156ba23c08655 /loader_wsock32_proxy
parentff875c0551c54bb187b5320b81029f8fe7f010fb (diff)
parentf7b96d1048acddc343244ddec87a996ebaf7cb5b (diff)
downloadNorthstarLauncher-3f629680f71b4694bd4eb78726537a91e10a2352.tar.gz
NorthstarLauncher-3f629680f71b4694bd4eb78726537a91e10a2352.zip
Merge pull request #19 from p0358/main
Big refactor of launching process
Diffstat (limited to 'loader_wsock32_proxy')
-rw-r--r--loader_wsock32_proxy/dllmain.cpp137
-rw-r--r--loader_wsock32_proxy/hookutils.cpp71
-rw-r--r--loader_wsock32_proxy/loader.cpp86
-rw-r--r--loader_wsock32_proxy/loader.h8
-rw-r--r--loader_wsock32_proxy/loader_wsock32_proxy.vcxproj120
-rw-r--r--loader_wsock32_proxy/loader_wsock32_proxy.vcxproj.filters49
-rw-r--r--loader_wsock32_proxy/pch.cpp5
-rw-r--r--loader_wsock32_proxy/pch.h16
-rw-r--r--loader_wsock32_proxy/wsock32.asm7
-rw-r--r--loader_wsock32_proxy/wsock32.def78
10 files changed, 577 insertions, 0 deletions
diff --git a/loader_wsock32_proxy/dllmain.cpp b/loader_wsock32_proxy/dllmain.cpp
new file mode 100644
index 00000000..0b518dbe
--- /dev/null
+++ b/loader_wsock32_proxy/dllmain.cpp
@@ -0,0 +1,137 @@
+#include "pch.h"
+#include "loader.h"
+
+#include <Shlwapi.h>
+#include <filesystem>
+
+HINSTANCE hLThis = 0;
+FARPROC p[857];
+HINSTANCE hL = 0;
+
+bool GetExePathWide(wchar_t* dest, DWORD destSize)
+{
+ if (!dest) return NULL;
+ if (destSize < MAX_PATH) return NULL;
+
+ DWORD length = GetModuleFileNameW(NULL, dest, destSize);
+ return length && PathRemoveFileSpecW(dest);
+}
+
+wchar_t exePath[4096];
+wchar_t dllPath[8192];
+wchar_t dllPath2[4096];
+
+BOOL WINAPI DllMain(HINSTANCE hInst, DWORD reason, LPVOID)
+{
+ if (reason == DLL_PROCESS_ATTACH)
+ {
+ hLThis = hInst;
+
+ if (!GetExePathWide(exePath, 4096))
+ {
+ MessageBoxA(GetForegroundWindow(), "Failed getting game directory.\nThe game cannot continue and has to exit.", "Northstar Wsock32 Proxy Error", 0);
+ return 1;
+ }
+
+ if (!ProvisionNorthstar()) // does not call InitialiseNorthstar yet, will do it on LauncherMain hook
+ return 1;
+
+ // copy the original library for system to our local directory, with changed name so that we can load it
+ swprintf_s(dllPath, L"%s\\bin\\x64_retail\\wsock32.org.dll", exePath);
+ GetSystemDirectoryW(dllPath2, 4096);
+ swprintf_s(dllPath2, L"%s\\wsock32.dll", dllPath2);
+ try
+ {
+ std::filesystem::copy_file(dllPath2, dllPath);
+ }
+ catch (const std::exception& e)
+ {
+ if (!std::filesystem::exists(dllPath))
+ {
+ swprintf_s(dllPath, L"Failed copying wsock32.dll from system32 to \"%s\"\n\n%S", dllPath, e.what());
+ MessageBoxW(GetForegroundWindow(), dllPath, L"Northstar Wsock32 Proxy Error", 0);
+ }
+ }
+ hL = LoadLibraryExW(dllPath, 0, LOAD_WITH_ALTERED_SEARCH_PATH);
+ if (!hL) return false;
+
+ // load the functions to proxy
+ // it's only some of them, because in case of wsock32 most of the functions can actually be natively redirected
+ // (see wsock32.def and https://source.winehq.org/WineAPI/wsock32.html)
+ p[1] = GetProcAddress(hL, "EnumProtocolsA");
+ p[2] = GetProcAddress(hL, "EnumProtocolsW");
+ p[4] = GetProcAddress(hL, "GetAddressByNameA");
+ p[5] = GetProcAddress(hL, "GetAddressByNameW");
+ p[17] = GetProcAddress(hL, "WEP");
+ p[30] = GetProcAddress(hL, "WSARecvEx");
+ p[36] = GetProcAddress(hL, "__WSAFDIsSet");
+ p[45] = GetProcAddress(hL, "getnetbyname");
+ p[52] = GetProcAddress(hL, "getsockopt");
+ p[56] = GetProcAddress(hL, "inet_network");
+ p[67] = GetProcAddress(hL, "s_perror");
+ p[72] = GetProcAddress(hL, "setsockopt");
+ }
+
+ if (reason == DLL_PROCESS_DETACH)
+ {
+ FreeLibrary(hL);
+ return 1;
+ }
+
+ return 1;
+}
+
+extern "C"
+{
+ FARPROC PA = NULL;
+ int RunASM();
+
+ void PROXY_EnumProtocolsA() {
+ PA = p[1];
+ RunASM();
+ }
+ void PROXY_EnumProtocolsW() {
+ PA = p[2];
+ RunASM();
+ }
+ void PROXY_GetAddressByNameA() {
+ PA = p[4];
+ RunASM();
+ }
+ void PROXY_GetAddressByNameW() {
+ PA = p[5];
+ RunASM();
+ }
+ void PROXY_WEP() {
+ PA = p[17];
+ RunASM();
+ }
+ void PROXY_WSARecvEx() {
+ PA = p[30];
+ RunASM();
+ }
+ void PROXY___WSAFDIsSet() {
+ PA = p[36];
+ RunASM();
+ }
+ void PROXY_getnetbyname() {
+ PA = p[45];
+ RunASM();
+ }
+ void PROXY_getsockopt() {
+ PA = p[52];
+ RunASM();
+ }
+ void PROXY_inet_network() {
+ PA = p[56];
+ RunASM();
+ }
+ void PROXY_s_perror() {
+ PA = p[67];
+ RunASM();
+ }
+ void PROXY_setsockopt() {
+ PA = p[72];
+ RunASM();
+ }
+} \ No newline at end of file
diff --git a/loader_wsock32_proxy/hookutils.cpp b/loader_wsock32_proxy/hookutils.cpp
new file mode 100644
index 00000000..8603cb35
--- /dev/null
+++ b/loader_wsock32_proxy/hookutils.cpp
@@ -0,0 +1,71 @@
+#include "pch.h"
+#include "../NorthstarDedicatedTest/hookutils.h"
+
+#define ERROR(...) { char err[2048]; sprintf_s(err, __VA_ARGS__); MessageBoxA(GetForegroundWindow(), err, "Northstar Wsock32 Proxy Error", 0); }
+
+TempReadWrite::TempReadWrite(void* ptr)
+{
+ m_ptr = ptr;
+ MEMORY_BASIC_INFORMATION mbi;
+ VirtualQuery(m_ptr, &mbi, sizeof(mbi));
+ VirtualProtect(mbi.BaseAddress, mbi.RegionSize, PAGE_EXECUTE_READWRITE, &mbi.Protect);
+ m_origProtection = mbi.Protect;
+}
+
+TempReadWrite::~TempReadWrite()
+{
+ MEMORY_BASIC_INFORMATION mbi;
+ VirtualQuery(m_ptr, &mbi, sizeof(mbi));
+ VirtualProtect(mbi.BaseAddress, mbi.RegionSize, m_origProtection, &mbi.Protect);
+}
+
+
+void HookEnabler::CreateHook(LPVOID ppTarget, LPVOID ppDetour, LPVOID* ppOriginal, const char* targetName)
+{
+ // the macro for this uses ppTarget's name as targetName, and this typically starts with &
+ // targetname is used for debug stuff and debug output is nicer if we don't have this
+ if (*targetName == '&')
+ targetName++;
+
+ if (MH_CreateHook(ppTarget, ppDetour, ppOriginal) == MH_OK)
+ {
+ HookTarget* target = new HookTarget;
+ target->targetAddress = ppTarget;
+ target->targetName = (char*)targetName;
+
+ m_hookTargets.push_back(target);
+ }
+ else
+ {
+ if (targetName != nullptr)
+ {
+ ERROR("MH_CreateHook failed for function %s", targetName);
+ }
+ else
+ {
+ ERROR("MH_CreateHook failed for unknown function");
+ }
+ }
+}
+
+HookEnabler::~HookEnabler()
+{
+ for (auto& hook : m_hookTargets)
+ {
+ if (MH_EnableHook(hook->targetAddress) != MH_OK)
+ {
+ if (hook->targetName != nullptr)
+ {
+ ERROR("MH_EnableHook failed for function %s", hook->targetName);
+ }
+ else
+ {
+ ERROR("MH_EnableHook failed for unknown function");
+ }
+ }
+ else
+ {
+ //ERROR("Enabling hook %s", hook->targetName);
+ }
+ }
+} \ No newline at end of file
diff --git a/loader_wsock32_proxy/loader.cpp b/loader_wsock32_proxy/loader.cpp
new file mode 100644
index 00000000..907caa9d
--- /dev/null
+++ b/loader_wsock32_proxy/loader.cpp
@@ -0,0 +1,86 @@
+#include "pch.h"
+#include "loader.h"
+#include "../NorthstarDedicatedTest/hookutils.h"
+#include <string>
+#include <system_error>
+#include <sstream>
+#include <fstream>
+
+void LibraryLoadError(DWORD dwMessageId, const wchar_t* libName, const wchar_t* location)
+{
+ char text[2048];
+ std::string message = std::system_category().message(dwMessageId);
+ sprintf_s(text, "Failed to load the %ls at \"%ls\" (%lu):\n\n%hs", libName, location, dwMessageId, message.c_str());
+ MessageBoxA(GetForegroundWindow(), text, "Northstar Wsock32 Proxy Error", 0);
+}
+
+bool ShouldLoadNorthstar()
+{
+ bool loadNorthstar = strstr(GetCommandLineA(), "-northstar");
+
+ if (loadNorthstar)
+ return loadNorthstar;
+
+ auto runNorthstarFile = std::ifstream("run_northstar.txt");
+ if (runNorthstarFile)
+ {
+ std::stringstream runNorthstarFileBuffer;
+ runNorthstarFileBuffer << runNorthstarFile.rdbuf();
+ runNorthstarFile.close();
+ if (!runNorthstarFileBuffer.str()._Starts_with("0"))
+ loadNorthstar = true;
+ }
+ return loadNorthstar;
+}
+
+bool LoadNorthstar()
+{
+ FARPROC Hook_Init = nullptr;
+ {
+ swprintf_s(dllPath, L"%s\\Northstar.dll", exePath);
+ auto hHookModule = LoadLibraryExW(dllPath, 0, LOAD_WITH_ALTERED_SEARCH_PATH);
+ if (hHookModule) Hook_Init = GetProcAddress(hHookModule, "InitialiseNorthstar");
+ if (!hHookModule || Hook_Init == nullptr)
+ {
+ LibraryLoadError(GetLastError(), L"Northstar.dll", dllPath);
+ return false;
+ }
+ }
+
+ ((bool (*)()) Hook_Init)();
+ return true;
+}
+
+typedef int(*LauncherMainType)(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow);
+LauncherMainType LauncherMainOriginal;
+
+int LauncherMainHook(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
+{
+ if (ShouldLoadNorthstar())
+ LoadNorthstar();
+ return LauncherMainOriginal(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
+}
+
+bool ProvisionNorthstar()
+{
+ if (!ShouldLoadNorthstar())
+ return true;
+
+ if (MH_Initialize() != MH_OK)
+ {
+ MessageBoxA(GetForegroundWindow(), "MH_Initialize failed\nThe game cannot continue and has to exit.", "Northstar Wsock32 Proxy Error", 0);
+ return false;
+ }
+
+ auto launcherHandle = GetModuleHandleA("launcher.dll");
+ if (!launcherHandle)
+ {
+ MessageBoxA(GetForegroundWindow(), "Launcher isn't loaded yet.\nThe game cannot continue and has to exit.", "Northstar Wsock32 Proxy Error", 0);
+ return false;
+ }
+
+ HookEnabler hook;
+ ENABLER_CREATEHOOK(hook, GetProcAddress(launcherHandle, "LauncherMain"), &LauncherMainHook, reinterpret_cast<LPVOID*>(&LauncherMainOriginal));
+
+ return true;
+} \ No newline at end of file
diff --git a/loader_wsock32_proxy/loader.h b/loader_wsock32_proxy/loader.h
new file mode 100644
index 00000000..9a14b2e7
--- /dev/null
+++ b/loader_wsock32_proxy/loader.h
@@ -0,0 +1,8 @@
+#pragma once
+
+extern wchar_t exePath[4096];
+extern wchar_t dllPath[8192];
+extern wchar_t dllPath2[4096];
+
+bool ShouldLoadNorthstar();
+bool ProvisionNorthstar();
diff --git a/loader_wsock32_proxy/loader_wsock32_proxy.vcxproj b/loader_wsock32_proxy/loader_wsock32_proxy.vcxproj
new file mode 100644
index 00000000..9866d368
--- /dev/null
+++ b/loader_wsock32_proxy/loader_wsock32_proxy.vcxproj
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <VCProjectVersion>16.0</VCProjectVersion>
+ <Keyword>Win32Proj</Keyword>
+ <ProjectGuid>{cf55f3b5-f348-450a-9ccb-c269f21d629d}</ProjectGuid>
+ <RootNamespace>loaderwsock32proxy</RootNamespace>
+ <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v143</PlatformToolset>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v143</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ <Import Project="$(VCTargetsPath)\BuildCustomizations\masm.props" />
+ </ImportGroup>
+ <ImportGroup Label="Shared">
+ </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|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <TargetName>wsock32</TargetName>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <TargetName>wsock32</TargetName>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <SDLCheck>true</SDLCheck>
+ <PreprocessorDefinitions>_DEBUG;LOADERWSOCK32PROXY_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ConformanceMode>true</ConformanceMode>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
+ <LanguageStandard>stdcpp17</LanguageStandard>
+ <AdditionalIncludeDirectories>..\NorthstarDedicatedTest\</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableUAC>false</EnableUAC>
+ <ModuleDefinitionFile>wsock32.def</ModuleDefinitionFile>
+ <AdditionalDependencies>..\NorthstarDedicatedTest\include\MinHook.x64.lib;mswsock.lib;ws2_32.lib;Shlwapi.lib;imagehlp.lib;dbghelp.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <SDLCheck>true</SDLCheck>
+ <PreprocessorDefinitions>NDEBUG;LOADERWSOCK32PROXY_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ConformanceMode>true</ConformanceMode>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
+ <AdditionalIncludeDirectories>..\NorthstarDedicatedTest\</AdditionalIncludeDirectories>
+ <LanguageStandard>stdcpp17</LanguageStandard>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableUAC>false</EnableUAC>
+ <ModuleDefinitionFile>wsock32.def</ModuleDefinitionFile>
+ <AdditionalDependencies>..\NorthstarDedicatedTest\include\MinHook.x64.lib;mswsock.lib;ws2_32.lib;Shlwapi.lib;imagehlp.lib;dbghelp.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;wsock32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClInclude Include="loader.h" />
+ <ClInclude Include="pch.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="dllmain.cpp" />
+ <ClCompile Include="hookutils.cpp" />
+ <ClCompile Include="loader.cpp" />
+ <ClCompile Include="pch.cpp">
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <MASM Include="wsock32.asm" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="wsock32.def" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ <Import Project="$(VCTargetsPath)\BuildCustomizations\masm.targets" />
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/loader_wsock32_proxy/loader_wsock32_proxy.vcxproj.filters b/loader_wsock32_proxy/loader_wsock32_proxy.vcxproj.filters
new file mode 100644
index 00000000..6d131e5b
--- /dev/null
+++ b/loader_wsock32_proxy/loader_wsock32_proxy.vcxproj.filters
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+ <Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+ <Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
+ </Filter>
+ <Filter Include="Resource Files">
+ <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
+ <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="pch.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="loader.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="dllmain.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="pch.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="loader.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="hookutils.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <MASM Include="wsock32.asm">
+ <Filter>Source Files</Filter>
+ </MASM>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="wsock32.def">
+ <Filter>Source Files</Filter>
+ </None>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/loader_wsock32_proxy/pch.cpp b/loader_wsock32_proxy/pch.cpp
new file mode 100644
index 00000000..64b7eef6
--- /dev/null
+++ b/loader_wsock32_proxy/pch.cpp
@@ -0,0 +1,5 @@
+// pch.cpp: source file corresponding to the pre-compiled header
+
+#include "pch.h"
+
+// When you are using pre-compiled headers, this source file is necessary for compilation to succeed.
diff --git a/loader_wsock32_proxy/pch.h b/loader_wsock32_proxy/pch.h
new file mode 100644
index 00000000..0103ff59
--- /dev/null
+++ b/loader_wsock32_proxy/pch.h
@@ -0,0 +1,16 @@
+// pch.h: This is a precompiled header file.
+// Files listed below are compiled only once, improving build performance for future builds.
+// This also affects IntelliSense performance, including code completion and many code browsing features.
+// However, files listed here are ALL re-compiled if any one of them is updated between builds.
+// Do not add files here that you will be updating frequently as this negates the performance advantage.
+
+#ifndef PCH_H
+#define PCH_H
+
+#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
+// Windows Header Files
+#include <windows.h>
+
+#include "include/MinHook.h"
+
+#endif //PCH_H
diff --git a/loader_wsock32_proxy/wsock32.asm b/loader_wsock32_proxy/wsock32.asm
new file mode 100644
index 00000000..22a9c384
--- /dev/null
+++ b/loader_wsock32_proxy/wsock32.asm
@@ -0,0 +1,7 @@
+.data
+extern PA : qword
+.code
+RunASM proc
+jmp qword ptr [PA]
+RunASM endp
+end
diff --git a/loader_wsock32_proxy/wsock32.def b/loader_wsock32_proxy/wsock32.def
new file mode 100644
index 00000000..448440b4
--- /dev/null
+++ b/loader_wsock32_proxy/wsock32.def
@@ -0,0 +1,78 @@
+LIBRARY wsock32
+EXPORTS
+ AcceptEx=mswsock.AcceptEx
+ EnumProtocolsA=PROXY_EnumProtocolsA
+ EnumProtocolsW=PROXY_EnumProtocolsW
+ GetAcceptExSockaddrs=mswsock.GetAcceptExSockaddrs
+ GetAddressByNameA=PROXY_GetAddressByNameA
+ GetAddressByNameW=PROXY_GetAddressByNameW
+ GetNameByTypeA=ws2_32.GetNameByTypeA
+ GetNameByTypeW=ws2_32.GetNameByTypeW
+ GetServiceA=ws2_32.GetServiceA
+ GetServiceW=ws2_32.GetServiceW
+ GetTypeByNameA=ws2_32.GetTypeByNameA
+ GetTypeByNameW=ws2_32.GetTypeByNameW
+ MigrateWinsockConfiguration=ws2_32.MigrateWinsockConfiguration
+ NPLoadNameSpaces=ws2_32.NPLoadNameSpaces
+ SetServiceA=ws2_32.SetServiceA
+ SetServiceW=ws2_32.SetServiceW
+ TransmitFile=mswsock.TransmitFile
+ WEP=PROXY_WEP
+ WSAAsyncGetHostByAddr=ws2_32.WSAAsyncGetHostByAddr
+ WSAAsyncGetHostByName=ws2_32.WSAAsyncGetHostByName
+ WSAAsyncGetProtoByName=ws2_32.WSAAsyncGetProtoByName
+ WSAAsyncGetProtoByNumber=ws2_32.WSAAsyncGetProtoByNumber
+ WSAAsyncGetServByName=ws2_32.WSAAsyncGetServByName
+ WSAAsyncGetServByPort=ws2_32.WSAAsyncGetServByPort
+ WSAAsyncSelect=ws2_32.WSAAsyncSelect
+ WSACancelAsyncRequest=ws2_32.WSACancelAsyncRequest
+ WSACancelBlockingCall=ws2_32.WSACancelBlockingCall
+ WSACleanup=ws2_32.WSACleanup @116
+ WSAGetLastError=ws2_32.WSAGetLastError @111
+ WSAIsBlocking=ws2_32.WSAIsBlocking
+ WSARecvEx=PROXY_WSARecvEx
+ WSASetBlockingHook=ws2_32.WSASetBlockingHook
+ WSASetLastError=ws2_32.WSASetLastError @112
+ WSAStartup=ws2_32.WSAStartup @115
+ WSAUnhookBlockingHook=ws2_32.WSAUnhookBlockingHook
+ WSApSetPostRoutine=ws2_32.WSApSetPostRoutine
+ __WSAFDIsSet=PROXY___WSAFDIsSet @151
+ accept=ws2_32.accept @1
+ bind=ws2_32.bind @2
+ closesocket=ws2_32.closesocket @3
+ connect=ws2_32.connect @4
+ dn_expand=ws2_32.dn_expand @1106
+ gethostbyaddr=ws2_32.gethostbyaddr
+ gethostbyname=ws2_32.gethostbyname @52
+ gethostname=ws2_32.gethostname @57
+ getnetbyname=PROXY_getnetbyname @ 1101
+ getpeername=ws2_32.getpeername @5
+ getprotobyname=ws2_32.getprotobyname
+ getprotobynumber=ws2_32.getprotobynumber
+ getservbyname=ws2_32.getservbyname
+ getservbyport=ws2_32.getservbyport
+ getsockname=ws2_32.getsockname @6
+ getsockopt=PROXY_getsockopt @7
+ htonl=ws2_32.htonl
+ htons=ws2_32.htons @9
+ inet_addr=ws2_32.inet_addr
+ inet_network=PROXY_inet_network
+ inet_ntoa=ws2_32.inet_ntoa
+ ioctlsocket=ws2_32.ioctlsocket @12
+ listen=ws2_32.listen @13
+ ntohl=ws2_32.ntohl
+ ntohs=ws2_32.ntohs @15
+ rcmd=ws2_32.rcmd
+ recv=ws2_32.recv @16
+ recvfrom=ws2_32.recvfrom @17
+ rexec=ws2_32.rexec
+ rresvport=ws2_32.rresvport
+ s_perror=PROXY_s_perror
+ select=ws2_32.select @18
+ select=ws2_32.select @18
+ send=ws2_32.send @19
+ sendto=ws2_32.sendto @20
+ sethostname=ws2_32.sethostname
+ setsockopt=PROXY_setsockopt @21
+ shutdown=ws2_32.shutdown @22
+ socket=ws2_32.socket @23