diff options
Diffstat (limited to 'loader_wsock32_proxy')
-rw-r--r-- | loader_wsock32_proxy/hookutils.cpp | 54 | ||||
-rw-r--r-- | loader_wsock32_proxy/loader.cpp | 8 | ||||
-rw-r--r-- | loader_wsock32_proxy/loader_wsock32_proxy.vcxproj | 2 | ||||
-rw-r--r-- | loader_wsock32_proxy/loader_wsock32_proxy.vcxproj.filters | 9 |
4 files changed, 12 insertions, 61 deletions
diff --git a/loader_wsock32_proxy/hookutils.cpp b/loader_wsock32_proxy/hookutils.cpp deleted file mode 100644 index 7792a78e..00000000 --- a/loader_wsock32_proxy/hookutils.cpp +++ /dev/null @@ -1,54 +0,0 @@ -#include "pch.h"
-#include "../NorthstarDLL/hookutils.h"
-
-#define ERROR(...) { char err[2048]; sprintf_s(err, __VA_ARGS__); MessageBoxA(GetForegroundWindow(), err, "Northstar Wsock32 Proxy Error", 0); }
-
-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 index ab89a615..663f1f7b 100644 --- a/loader_wsock32_proxy/loader.cpp +++ b/loader_wsock32_proxy/loader.cpp @@ -1,6 +1,6 @@ #include "pch.h"
#include "loader.h"
-#include "../NorthstarDLL/hookutils.h"
+#include "include/MinHook.h"
#include <string>
#include <system_error>
#include <sstream>
@@ -84,8 +84,10 @@ bool ProvisionNorthstar() return false;
}
- HookEnabler hook;
- ENABLER_CREATEHOOK(hook, GetProcAddress(launcherHandle, "LauncherMain"), &LauncherMainHook, reinterpret_cast<LPVOID*>(&LauncherMainOriginal));
+ LPVOID pTarget = GetProcAddress(launcherHandle, "LauncherMain");
+ if (MH_CreateHook(pTarget, &LauncherMainHook, reinterpret_cast<LPVOID*>(&LauncherMainOriginal)) != MH_OK || MH_EnableHook(pTarget) != MH_OK)
+ MessageBoxA(
+ GetForegroundWindow(), "Hook creation failed for function LauncherMain.", "Northstar Wsock32 Proxy Error", 0);
return true;
}
\ No newline at end of file diff --git a/loader_wsock32_proxy/loader_wsock32_proxy.vcxproj b/loader_wsock32_proxy/loader_wsock32_proxy.vcxproj index 3fed5a8a..2b257de8 100644 --- a/loader_wsock32_proxy/loader_wsock32_proxy.vcxproj +++ b/loader_wsock32_proxy/loader_wsock32_proxy.vcxproj @@ -95,12 +95,12 @@ </Link>
</ItemDefinitionGroup>
<ItemGroup>
+ <ClInclude Include="include\MinHook.h" />
<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>
diff --git a/loader_wsock32_proxy/loader_wsock32_proxy.vcxproj.filters b/loader_wsock32_proxy/loader_wsock32_proxy.vcxproj.filters index 83ed7ac6..4c6b1ba1 100644 --- a/loader_wsock32_proxy/loader_wsock32_proxy.vcxproj.filters +++ b/loader_wsock32_proxy/loader_wsock32_proxy.vcxproj.filters @@ -13,6 +13,9 @@ <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>
+ <Filter Include="Header Files\include">
+ <UniqueIdentifier>{1b1575f7-3332-478b-9e85-9c0978249a70}</UniqueIdentifier>
+ </Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="pch.h">
@@ -21,6 +24,9 @@ <ClInclude Include="loader.h">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="include\MinHook.h">
+ <Filter>Header Files\include</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp">
@@ -32,9 +38,6 @@ <ClCompile Include="loader.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="hookutils.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
</ItemGroup>
<ItemGroup>
<MASM Include="wsock32.asm">
|