From a1043024680750056d87102107df2952dd30a741 Mon Sep 17 00:00:00 2001 From: Robert MacGregor Date: Sat, 13 Jul 2019 17:54:20 -0700 Subject: [PATCH] * Correct serverProcessReplacement code. * Remove the python.lib dependency from TSExtension. --- CommonAPI/Common/Common.vcxproj | 2 + .../TSExtension/source/dllmain.cpp | 56 +++++++++---------- ModLoader/Modloader/source/modLoader.cpp | 2 - ModLoader/Modloader/source/t2dll.cpp | 21 +++---- 4 files changed, 39 insertions(+), 42 deletions(-) diff --git a/CommonAPI/Common/Common.vcxproj b/CommonAPI/Common/Common.vcxproj index d6b751e..2159dfb 100644 --- a/CommonAPI/Common/Common.vcxproj +++ b/CommonAPI/Common/Common.vcxproj @@ -20,12 +20,14 @@ StaticLibrary true Unicode + v142 StaticLibrary false true Unicode + v142 diff --git a/Mod Sources/TSExtension/TSExtension/source/dllmain.cpp b/Mod Sources/TSExtension/TSExtension/source/dllmain.cpp index fb8919d..3923a09 100644 --- a/Mod Sources/TSExtension/TSExtension/source/dllmain.cpp +++ b/Mod Sources/TSExtension/TSExtension/source/dllmain.cpp @@ -1430,15 +1430,15 @@ __declspec(dllexport) void ServerProcess(unsigned int deltaTime) } static unsigned int gboaptr =(unsigned int ) &GameBaseOnAddHook; -extern "C" -{ - TSEXTENSION_API unsigned int getModLoaderVersion(void) - { - return 0; - } - - TSEXTENSION_API void ModInitialize(void) - { +extern "C" +{ + TSEXTENSION_API unsigned int getModLoaderVersion(void) + { + return 0; + } + + TSEXTENSION_API void ModInitialize(void) + { // Init WSA WSADATA wsadata; WSAStartup(0x0202, &wsadata); @@ -1457,8 +1457,8 @@ extern "C" //Con::addMethodB(NULL,"setAITrigger", &consetTrigger, "setAITrigger(%aicon,triggerid,value);",2,6); Con::addMethodS("GrenadeProjectile", "getposition", &conGrenadeProjectileGetPosition,"Accurately gets the position of the GrenadeProjectile", 2, 2); Con::addMethodS("GrenadeProjectile", "getvelocity", &conGrenadeProjectileGetVelocity,"Gets the velocity of the GrenadeProjectile", 2, 2); - Con::addMethodB("Projectile", "makeNerf", &conProjectileMakeNerf,"Makes the Projectile deal no damage", 2, 2); - + Con::addMethodB("Projectile", "makeNerf", &conProjectileMakeNerf,"Makes the Projectile deal no damage", 2, 2); + // TCPObject #ifdef ENABLE_TCPOBJECT /* @@ -1540,22 +1540,22 @@ extern "C" DX::memPatch(0x438415,(unsigned char *)dbpatch3,7); DX::memPatch(0x5E29F0,(unsigned char *)gboaonadd,7); #endif - - - return; - } - - TSEXTENSION_API const char* getManagementName(void) - { - return "TSExtension"; - } - - TSEXTENSION_API ModLoader::ModLoaderCallables* getModCallables(void) - { - ModLoader::ModLoaderCallables* result = new ModLoader::ModLoaderCallables(); - result->mInitializeModPointer = ModInitialize; - result->mGetManagementName = getManagementName; - return result; - } + + + return; + } + + TSEXTENSION_API const char* getManagementName(void) + { + return "TSExtension"; + } + + TSEXTENSION_API ModLoader::ModLoaderCallables* getModCallables(void) + { + ModLoader::ModLoaderCallables* result = new ModLoader::ModLoaderCallables(); + result->mInitializeModPointer = ModInitialize; + result->mGetManagementName = getManagementName; + return result; + } } diff --git a/ModLoader/Modloader/source/modLoader.cpp b/ModLoader/Modloader/source/modLoader.cpp index 919caf0..5d5ed29 100644 --- a/ModLoader/Modloader/source/modLoader.cpp +++ b/ModLoader/Modloader/source/modLoader.cpp @@ -23,8 +23,6 @@ void serverProcessReplacement(unsigned int timeDelta) currentCallables->mServerProcessPointer(timeDelta); } - Con::errorf(0, "Bla -bla blallaaa"); - __asm { mov ecx,serverthisptr diff --git a/ModLoader/Modloader/source/t2dll.cpp b/ModLoader/Modloader/source/t2dll.cpp index 1efc84f..c609583 100644 --- a/ModLoader/Modloader/source/t2dll.cpp +++ b/ModLoader/Modloader/source/t2dll.cpp @@ -67,8 +67,8 @@ const char* congetInterpreterAddr(Linker::SimObject *obj, S32 argc, const char * void initializeHooks() { // Replicates: - // memPatch("5BBBDC",getServPAddr()); - // sprintf(test2,"B8 FFD089EC5DC3",endian(spr)); + // memPatch("5240FD", "B00190"); + // memPatch("5BBBDC", getServPAddr()); unsigned char serverProcessBytes[] = { 0xB8, @@ -91,6 +91,13 @@ void initializeHooks() unsigned int* serverProcessOffset = reinterpret_cast(&serverProcessBytes[1]); *serverProcessOffset = reinterpret_cast(*serverProcessReplacement); + unsigned char addressBytes[] = { + 0xB0, + 0x01, + 0x90 + }; + + DX::memPatch(0x5240FD, addressBytes, sizeof(addressBytes)); DX::memPatch(0x5BBBDC, serverProcessBytes, sizeof(serverProcessBytes)); } @@ -125,16 +132,6 @@ class CImmDevice LPINITT2DLL lpinitT2DLL = NULL; hDLL = LoadLibrary(L"tribesnext.dll"); // AfxLoadLibrary is probably better. - if (hDLL == NULL) - return 0; // The DLL doesn't exist - else - lpinitT2DLL = (LPINITT2DLL)GetProcAddress(hDLL, "_Z9initT2Dllv"); // Attempt to load our entry point - - if (lpinitT2DLL == NULL) - return 0; // Unable to load entry point - else - lpinitT2DLL(); // The function was loaded, call TribesNext and move on to postTN Startup - // Initialize all engine hooks initializeHooks();