From c1e04ef0a615e2b3fb8ed5fae7052f598078fce7 Mon Sep 17 00:00:00 2001 From: Ragora Date: Tue, 5 Aug 2014 00:49:47 -0400 Subject: [PATCH] ModLoader sources didn't add? --- ModLoader | 1 - ModLoader/CoreModSystem.sln | 20 ++++ ModLoader/CoreModSystem.suo | Bin 0 -> 5120 bytes ModLoader/CoreModSystem.v11.suo | Bin 0 -> 28672 bytes ModLoader/ModLoader.vcxproj | 137 ++++++++++++++++++++++++++++ ModLoader/ModLoader.vcxproj.filters | 36 ++++++++ ModLoader/include/config.h | 7 ++ ModLoader/include/stdafx.h | 32 +++++++ ModLoader/include/t2ConCmds.h | 15 +++ ModLoader/include/t2api.h | 109 ++++++++++++++++++++++ ModLoader/source/t2ConCmds.cpp | 84 +++++++++++++++++ ModLoader/source/t2api.cpp | 89 ++++++++++++++++++ ModLoader/source/t2dll.cpp | 53 +++++++++++ 13 files changed, 582 insertions(+), 1 deletion(-) delete mode 160000 ModLoader create mode 100755 ModLoader/CoreModSystem.sln create mode 100755 ModLoader/CoreModSystem.suo create mode 100755 ModLoader/CoreModSystem.v11.suo create mode 100755 ModLoader/ModLoader.vcxproj create mode 100755 ModLoader/ModLoader.vcxproj.filters create mode 100755 ModLoader/include/config.h create mode 100755 ModLoader/include/stdafx.h create mode 100755 ModLoader/include/t2ConCmds.h create mode 100755 ModLoader/include/t2api.h create mode 100755 ModLoader/source/t2ConCmds.cpp create mode 100755 ModLoader/source/t2api.cpp create mode 100755 ModLoader/source/t2dll.cpp diff --git a/ModLoader b/ModLoader deleted file mode 160000 index 3e7e0a1..0000000 --- a/ModLoader +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 3e7e0a16cc1826031505b2d7a71e1dafa6624ca9 diff --git a/ModLoader/CoreModSystem.sln b/ModLoader/CoreModSystem.sln new file mode 100755 index 0000000..20d3fd5 --- /dev/null +++ b/ModLoader/CoreModSystem.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Express 2012 for Windows Desktop +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CoreModSystem", "ModLoader.vcxproj", "{8740E782-7AC2-4A57-85D5-592C914C5285}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {8740E782-7AC2-4A57-85D5-592C914C5285}.Debug|Win32.ActiveCfg = Debug|Win32 + {8740E782-7AC2-4A57-85D5-592C914C5285}.Debug|Win32.Build.0 = Debug|Win32 + {8740E782-7AC2-4A57-85D5-592C914C5285}.Release|Win32.ActiveCfg = Release|Win32 + {8740E782-7AC2-4A57-85D5-592C914C5285}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/ModLoader/CoreModSystem.suo b/ModLoader/CoreModSystem.suo new file mode 100755 index 0000000000000000000000000000000000000000..16edfd074f7238ff8ee396d280a5cdfe5ad848b8 GIT binary patch literal 5120 zcmeHKO-~b16g^WwVS^eIVn`s65TgqX!p?;O6$l9gBB+~j(UvOI)@eG$s0$MQ0KWki zELgH)!=ho&=MOOIiXAa-h>6s59vxC9meSaTPUlYM-S_Uj@7?!x&)nJDz42vbz5OeE z^au?&DYW29iQFow<2sB^vXergAeHK@hV&opz%w{}a_GVk-jQeVQAc@cYD3f6nMW%0 z>fOj6cWv)jS7|p;G@hhK2T6?5`)k&Q@S(ye=hbb9ocY(bpV$7m)l4z3ub~OdbJZ!# z(ZAj|m|{E1H(}=TplDZ)^&n#D-Z${QtbdL5O$Div|GrbRvL*djz5Ygyc3d1$vHMFC z_mSkv*$4l;{VUwGp5P&DJcrASC(F`?z6mkY zQeHUDY$%Qq>JrS39C8~^S$FZ4S(1Yc+sYf~Odl8b(8o8%yeh>fL7i zY2Q;8H)CayHo4a=QK}WAx;(r9AP4vA>U5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wQv3G{bJ{W!BpY85?-(x4BCDZkN~`F-A$|x+e2$aoXa9m@u5L5QF<+hXko=WxpRsOqS)%#b& zkPhtkz{p9KdlPEvbtURiXluSe`O(F{qLaQeHLaUZPt6LUC0g}!0p{{Y7u_*$+IE2w zm>10}8aDH5H^LVm6s$*vz`SYuOl?F+)QQSA>3EfK9e_f=RKVe1s!Y8cC|{7iC`!iY zQ|HMuJUK?oz4pkmGNdpj+;r0NU3rvcOW#^6;v+96n4PNq{}{AN&c6RRy(_Bn95~k% zRoPF{7yadtQTRS%{N0Ao#bQzgvRs#M#r+>S{w+i)g)iP(b0W+FsQHuyRqg-92QI7M K|Co{QfBYYMy~+vz literal 0 HcmV?d00001 diff --git a/ModLoader/ModLoader.vcxproj b/ModLoader/ModLoader.vcxproj new file mode 100755 index 0000000..ff4a3cc --- /dev/null +++ b/ModLoader/ModLoader.vcxproj @@ -0,0 +1,137 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {8740E782-7AC2-4A57-85D5-592C914C5285} + t2dll + Win32Proj + CoreModSystem + + + + DynamicLibrary + Unicode + true + + + DynamicLibrary + Unicode + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(SolutionDir)$(Configuration)\ + $(Configuration)\ + true + $(SolutionDir)$(Configuration)\ + $(Configuration)\ + false + $(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include;include\;include\bullet\; + $(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir)lib;$(FrameworkSDKDir)\lib;lib\; + $(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include;include\;include\bullet\; + $(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir)lib;$(FrameworkSDKDir)\lib;lib\; + t2dll + t2dll + + + + Disabled + C:\Documents and Settings\Linker\My Documents\Code\t2dll\lualib\include;%(AdditionalIncludeDirectories) + WIN32;BULLET_WINE;_DEBUG;_WINDOWS;_USRDLL;T2DLL_EXPORTS;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + NotUsing + Level3 + ProgramDatabase + + + %(AdditionalDependencies) + + + %(DelayLoadDLLs) + true + Windows + MachineX86 + + + + + MaxSpeed + OnlyExplicitInline + C:\Documents and Settings\Linker\My Documents\Code\t2dll\lualib\include;%(AdditionalIncludeDirectories) + WIN32;BULLET_WINE;NDEBUG;_WINDOWS;_USRDLL;T2DLL_EXPORTS;%(PreprocessorDefinitions) + MultiThreadedDLL + NotUsing + Level3 + ProgramDatabase + + + %(AdditionalDependencies) + + + + + %(DelayLoadDLLs) + true + Windows + true + true + MachineX86 + + + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ModLoader/ModLoader.vcxproj.filters b/ModLoader/ModLoader.vcxproj.filters new file mode 100755 index 0000000..0219ba4 --- /dev/null +++ b/ModLoader/ModLoader.vcxproj.filters @@ -0,0 +1,36 @@ + + + + + {47c39120-a88e-47c4-b0a8-4bf738d54a5c} + + + {9cb2992f-6959-4153-a4c4-d9ea4d86347d} + + + + + Include + + + Include + + + Include + + + Include + + + + + Source + + + Source + + + Source + + + \ No newline at end of file diff --git a/ModLoader/include/config.h b/ModLoader/include/config.h new file mode 100755 index 0000000..712656a --- /dev/null +++ b/ModLoader/include/config.h @@ -0,0 +1,7 @@ +/* + * config.h + * Contains configuration information for BulletDLL + * Copyright (c) 2013 Robert MacGregor +*/ + +#define MAXIMUM_BULLET_NODES 256 \ No newline at end of file diff --git a/ModLoader/include/stdafx.h b/ModLoader/include/stdafx.h new file mode 100755 index 0000000..5d2427f --- /dev/null +++ b/ModLoader/include/stdafx.h @@ -0,0 +1,32 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#pragma once + +// Modify the following defines if you have to target a platform prior to the ones specified below. +// Refer to MSDN for the latest info on corresponding values for different platforms. +#ifndef WINVER // Allow use of features specific to Windows XP or later. +#define WINVER 0x0501 // Change this to the appropriate value to target other versions of Windows. +#endif + +#ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later. +#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows. +#endif + +#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later. +#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. +#endif + +#ifndef _WIN32_IE // Allow use of features specific to IE 6.0 or later. +#define _WIN32_IE 0x0600 // Change this to the appropriate value to target other versions of IE. +#endif + +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +// Windows Header Files: +#include + +// TODO: reference additional headers your program requires here +#include "t2api.h" +#include "config.h" \ No newline at end of file diff --git a/ModLoader/include/t2ConCmds.h b/ModLoader/include/t2ConCmds.h new file mode 100755 index 0000000..c291122 --- /dev/null +++ b/ModLoader/include/t2ConCmds.h @@ -0,0 +1,15 @@ +/* + * t2conCmds.h + * Original code by Linker + * Modified by Robert MacGregor +*/ + +#include "stdafx.h" + +// Linker's original functions +const char* conGuiTsCtrlProject(SimObject *obj,S32 argc, const char* argv[]); +bool conNetObjectSetGhostable(SimObject *obj,S32 argc, const char* argv[]); +const char* conGetVariable(SimObject *obj,S32 argc, const char* argv[]); + +// Mod Loader Implementation +bool conLoadMod(SimObject *obj,S32 argc, const char* argv[]); \ No newline at end of file diff --git a/ModLoader/include/t2api.h b/ModLoader/include/t2api.h new file mode 100755 index 0000000..f18faec --- /dev/null +++ b/ModLoader/include/t2api.h @@ -0,0 +1,109 @@ +#pragma once + +void initT2Api(); + + +//api stuff + +typedef unsigned int U32; +typedef int S32; +typedef float F32; + +typedef unsigned int dsize_t; + +//for addvariable +#define TypeS32 1 +#define TypeBool 3 +#define TypeF32 5 + + +//dshit +inline dsize_t dStrlen(const char *str) +{ + return (dsize_t)strlen(str); +} + +class Namespace { + const char* mName; +}; + + + +class SimObject{ + SimObject* group; + const char* objectName; //04h: objectName + SimObject* nextNameObject; //8 + SimObject* nextManagerNameObject; //c + SimObject* nextIdObject; //10h: nextIdObject + U32 stuff; //14 + U32 mFlags; //18h + U32 mNotifyList; //actually a pointer + U32 mId; //20h: mId + //more stuff +}; + +class SimIdDictionary +{ + enum + { + DefaultTableSize = 4096, + TableBitMask = 4095 + }; + SimObject *table[DefaultTableSize]; +}; +extern SimIdDictionary* gIdDictionary; + +class Point3F +{ + public: + F32 x; + F32 y; + F32 z; +}; + + +//GuiTSCtrl +class GuiTSCtrl {}; +class HoverVehicle {}; +void GuiTSCtrl_project(GuiTSCtrl *obj, const Point3F &pt, Point3F *dest); //fake + + +namespace Sim { + extern SimObject* (*findObject)(U32 id); +} + + +//console + +typedef const char * (*StringCallback)(SimObject *obj, S32 argc, const char *argv[]); +typedef S32 (*IntCallback)(SimObject *obj, S32 argc, const char *argv[]); +typedef F32 (*FloatCallback)(SimObject *obj, S32 argc, const char *argv[]); +typedef void (*VoidCallback)(SimObject *obj, S32 argc, const char *argv[]); +typedef bool (*BoolCallback)(SimObject *obj, S32 argc, const char *argv[]); + + +extern void (*someTest)(void); +//functions +namespace Con{ + +extern char * (*getReturnBuffer)(U32 bufferSize); + +extern void (*addMethodB)(const char *nsName, const char *name, BoolCallback cb, const char *usage, S32 minArgs, S32 maxArgs); +extern void (*addMethodS)(const char *nsName, const char *name, StringCallback cb, const char *usage, S32 minArgs, S32 maxArgs); + +extern bool (*addVariable)(const char *name, S32 t, void *dp); + +extern void (*printf)(const char* fmt,...); +extern void (*errorf)(U32 type, const char* fmt,...); + +extern const char * (*getVariable)(const char *name); +extern const char * (*execute)(S32 argc, const char *argv[]); +extern const char * (*executef)(S32 argc, ...); +extern const char * (*executem)(SimObject *object, S32 argc, const char *argv[]); +extern const char * (*evaluate)(const char* string, bool echo, const char *fileName, bool cf); +} + +//d-util +extern int (*dSscanf)(const char *buffer, const char *format, ...); +extern int (*dSprintf)(char *buffer, dsize_t bufferSize, const char *format, ...); +extern bool (*dAtob)(const char *str); \ No newline at end of file diff --git a/ModLoader/source/t2ConCmds.cpp b/ModLoader/source/t2ConCmds.cpp new file mode 100755 index 0000000..c420585 --- /dev/null +++ b/ModLoader/source/t2ConCmds.cpp @@ -0,0 +1,84 @@ +/* + * t2ConCmds.cpp + * Original code by Linker + * Modified by Robert MacGregor +*/ + +#include + +#include "stdafx.h" +#include "t2ConCmds.h" + +// Linker's implementations +const char* conGuiTsCtrlProject(SimObject *obj,S32 argc, const char* argv[]) { + Point3F pt; + Point3F rt; + dSscanf(argv[2],"%g %g %g",&pt.x,&pt.y,&pt.z); + GuiTSCtrl_project(reinterpret_cast(obj),pt,&rt); + + char* buffer = Con::getReturnBuffer(255); + dSprintf(buffer,255,"%g %g %g",rt.x,rt.y,rt.z); + + return buffer; +} + +bool conNetObjectSetGhostable(SimObject *obj,S32 argc, const char* argv[]) { + if (dAtob(argv[2])) { + __asm { + push ecx + mov ecx, [obj] + mov eax,[ecx+40h] + or eax, 100h + mov [ecx+40h], eax + pop ecx + } + } else { + __asm { + xor eax, eax + or eax, 100h + not eax + push ecx + mov ecx,[obj] + and eax, [ecx+40h] + mov [ecx+40h],eax + push 40h + mov eax, 0x585BE0 + call eax + pop ecx + } + } + return 1; +} + +const char* conGetVariable(SimObject *obj,S32 argc, const char* argv[]) { + return Con::getVariable(argv[1]); +} + +// Mod Loader Implementation +bool conLoadMod(SimObject *obj,S32 argc, const char* argv[]) +{ + typedef void (*LPMODINIT)(void); + HINSTANCE hDLL = NULL; + LPMODINIT lpInitMod = NULL; + + std::string raw = argv[1]; + + std::wstring input(raw.begin(), raw.end()); + std::wstring modification = L"mods/"; + modification += input; + modification += L".dll"; + + hDLL = LoadLibrary(modification.c_str()); // AfxLoadLibrary is probably better. + + if (hDLL == NULL) + return false; // The DLL doesn't exist + else + lpInitMod = (LPMODINIT)GetProcAddress(hDLL, "?ModInitialize@@YAXXZ"); // Attempt to load our entry point + + if (lpInitMod == NULL) + return false; // Unable to load entry point + else + lpInitMod(); // The function was loaded, call TribesNext and move on to postTN Startup + + return true; +} \ No newline at end of file diff --git a/ModLoader/source/t2api.cpp b/ModLoader/source/t2api.cpp new file mode 100755 index 0000000..be583ab --- /dev/null +++ b/ModLoader/source/t2api.cpp @@ -0,0 +1,89 @@ +#include "stdafx.h" + +SimIdDictionary* gIdDictionary = reinterpret_cast(0x009E9194); + +//439550 +namespace Sim { + SimObject* (*findObject)(U32 id) = + (SimObject* (_cdecl *)(U32 id) ) + 0x439550; +} + +//hackey way to do member functions, .... +void GuiTSCtrl_project(GuiTSCtrl *obj, const Point3F &pt, Point3F *dest) { + typedef void (__cdecl *projFunc)(const Point3F &pt, Point3F *dest); + static projFunc p = (projFunc)0x4d0b40; + + __asm { + push dest; + push pt; + mov ecx,obj; + lea eax, p; + mov eax, [eax]; + call eax; + } +} + +void (*someTest)(void) = + (void (__cdecl *)(void)) + 0x4FD9B3; + +namespace Con { + +char* (*getReturnBuffer)(U32 bufferSize) = + (char *(__cdecl *)(U32)) + 0x42caa0; + +void (*addMethodB)(const char *nsName, const char *name, BoolCallback cb, const char *usage, S32 minArgs, S32 maxArgs) = + (void (__cdecl *)(const char *, const char *,BoolCallback,const char *,S32,S32)) + 0x426510; + +void (*addMethodS)(const char *, const char *,StringCallback, const char *, S32, S32) = + (void (__cdecl *)(const char *,const char *,StringCallback,const char *,S32,S32)) + 0x426410; + +bool (*addVariable)(const char *name, S32 t, void *dp) = + (bool (__cdecl *)(const char *name, S32 t, void *dp)) + 0x4263B0; + +const char * (*execute)(S32 argc, const char *argv[]) = + (const char * (__cdecl *)(S32 argc, const char *argv[])) + 0x4267A0; + +const char * (*executef)(S32 argc, ...) = + (const char * (__cdecl *)(S32 argc, ...)) + 0x4269E0; + +const char * (*evaluate)(const char* string, bool echo, const char *fileName, bool cf) = + (const char * (__cdecl *)(const char* string, bool echo, const char *fileName, bool cf)) + 0x426690; + +const char * (*executem)(SimObject *object, S32 argc, const char *argv[]) = + (const char * (__cdecl *)(SimObject *object, S32 argc, const char *argv[])) + 0x426800; + +const char * (*getVariable)(const char *name) = + (const char * (__cdecl *)(const char *name)) + 0x4261F0; + +void (*printf)(const char* fmt,...) = + (void (__cdecl *)(const char* fmt,...)) + 0x425F30; + +void (*errorf)(U32 type, const char* fmt,...)= + (void (__cdecl *)(U32, const char*,...)) + 0x425FB0; + +} + +int (*dSscanf)(const char *buffer, const char *format, ...) = + (int (__cdecl *)(const char *,const char *,...)) + 0x55b640; + +int (*dSprintf)(char *buffer, dsize_t bufferSize, const char *format, ...) = + (int (__cdecl *)(char *,dsize_t,const char *,...)) + 0x55b5e0; + +bool (*dAtob)(const char *str) = + (bool (__cdecl *)(const char *str)) + 0x55B490; diff --git a/ModLoader/source/t2dll.cpp b/ModLoader/source/t2dll.cpp new file mode 100755 index 0000000..94ba387 --- /dev/null +++ b/ModLoader/source/t2dll.cpp @@ -0,0 +1,53 @@ +/* + * t2dll.cpp + * Original code by Linker + * Modified by Robert MacGregor +*/ + +#include "stdafx.h" +#include "t2ConCmds.h" +#include "t2api.h" +#include + +BOOL APIENTRY DllMain( HMODULE hModule, + DWORD ul_reason_for_call, + LPVOID lpReserved + ) +{ + return true; +} + +__declspec(dllexport) void initT2Dll(void) +{ + // Run Linker's old implementations ... + Con::addMethodS("GuiTSCtrl","project",&conGuiTsCtrlProject,"projects a world space vector to on-screen position",3,3); + Con::addMethodB("NetObject","SetGhostable",&conNetObjectSetGhostable,"set or unset object to be ghostable",3,3); + Con::addMethodS(NULL,"getVariable",&conGetVariable,"Get a variable without restrictions",2,2); + + Con::addVariable("$cpuspeed",TypeS32,reinterpret_cast(0x8477F8)); //1 - S32, this is so i can set my cpu speed to 31337 or osmething =P + Con::addVariable("$GameBase::showBoundingBox",TypeBool,reinterpret_cast(0x9ECF24)); + + // Mod Loader Function + Con::addMethodB(NULL, "loadMod", &conLoadMod, "Loads a C++ modification.",2,2); + + // Load the original TribesNext DLL if available + typedef void (*LPINITT2DLL)(void); + HINSTANCE hDLL = NULL; + LPINITT2DLL lpinitT2DLL = NULL; + hDLL = LoadLibrary(L"tribesnext.dll"); // AfxLoadLibrary is probably better. + + if (hDLL == NULL) + return; // The DLL doesn't exist + else + lpinitT2DLL = (LPINITT2DLL)GetProcAddress(hDLL, "_Z9initT2Dllv"); // Attempt to load our entry point + + if (lpinitT2DLL == NULL) + return; // Unable to load entry point + else + lpinitT2DLL(); // The function was loaded, call TribesNext and move on to postTN Startup +} + +#ifdef _MANAGED +#pragma managed(pop) +#endif +