Skip to content

Commit

Permalink
Merge pull request #8 from s0t7x/refactor
Browse files Browse the repository at this point in the history
Refactored a bit and hotfixes for svn 602428
  • Loading branch information
s0t7x authored Nov 15, 2024
2 parents 28a8188 + dc163dd commit 2b34f2a
Show file tree
Hide file tree
Showing 115 changed files with 34,218 additions and 50,729 deletions.
12 changes: 12 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[submodule "third-party/GuardDetour"]
path = third-party/GuardDetour
url = https://github.com/gravit0/GuardDetour
[submodule "third-party/funchook"]
path = third-party/funchook
url = https://github.com/kubo/funchook
[submodule "third-party/distorm"]
path = third-party/distorm
url = https://github.com/gdabah/distorm/
[submodule "third-party/nlohmann-json"]
path = third-party/nlohmann-json
url = https://github.com/nlohmann/json
1 change: 0 additions & 1 deletion build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ RD /S /Q build
mkdir build
mkdir build\x64
MSBuild "shroudtopia\shroudtopia.sln" /t:Build /p:Configuration=Release /p:OutDir="..\build\x64" /p:Platform=x64
MSBuild "winmm\winmm.sln" /t:Build /p:Configuration=Release /p:OutDir="..\build\x64" /p:Platform=x64
echo.
echo All builds completed.
echo.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<IncludePath>..\shroudtopia;$(IncludePath)</IncludePath>
<IncludePath>$(SolutionDir)\shroudtopia;$(IncludePath)</IncludePath>
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\mods\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<IncludePath>..\shroudtopia;$(IncludePath)</IncludePath>
<IncludePath>$(SolutionDir)\include;$(IncludePath)</IncludePath>
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\mods\</OutDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
Expand Down
File renamed without changes.
10 changes: 5 additions & 5 deletions basics_mod/dllmain.cpp → example-mods/basics_mod/dllmain.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "pch.h"

#include <shroudtopia.h>
#include <mem.h>
#include <memory_utils.h>

#define LOG_CLASS(msg) modContext->Log(std::string(typeid(*this).name()).append(msg).c_str())

Expand All @@ -15,7 +15,7 @@ ModMetaData metaData = {
true,
};

// Signature for GameVersion (SVN) 55812
// Signature for GameVersion (SVN) 602428
class _Mod {
public:
ModContext* modContext;
Expand Down Expand Up @@ -66,7 +66,7 @@ class NoStaminaLoss : public _Mod
uint8_t modCode[] = {
0x53, // push rbx
0x8B, 0x5C, 0x81, 0x08, // mov ebx, [rcx+rax*4+8]
0x89, 0x1C, 0x81, // mov [rcx+rax*4], ebx
0x89, 0x5C, 0x81, 0xFC, // mov [rcx+rax*4-4], ebx
0x5B, // pop rbx
0x8B, 0x04, 0x81, // mov eax, [rcx+rax*4]
0x89, 0x44, 0x24, 0x3C, // mov [rsp+3C], eax
Expand All @@ -92,8 +92,8 @@ class NoFallDamage : public _Mod
NoFallDamage(ModContext* modContext) : _Mod(modContext)
{
// Pattern matching the AOB scan for the original code in the target process.
const char* pattern = "\x89\x04\x91\x48\x8D\x4D\xE0";
const char* mask = "xxxxxxx";
const char* pattern = "\x89\x04\x91\x48\x8D\x4D";
const char* mask = "xxxxxx";

// Base address of the module (the game).
uintptr_t baseAddress = (uintptr_t)GetModuleHandle(NULL);
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -21,36 +21,36 @@
<PropertyGroup Label="Globals">
<VCProjectVersion>17.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{e267db7b-5024-432f-93e9-f5e942f8508e}</ProjectGuid>
<RootNamespace>shroudtopiagui</RootNamespace>
<ProjectGuid>{dd54476d-eeab-49d8-8baa-48edb8429493}</ProjectGuid>
<RootNamespace>buildcam</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
Expand All @@ -70,16 +70,27 @@
<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'">
<IncludePath>$(SolutionDir)\shroudtopia;$(IncludePath)</IncludePath>
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\mods\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<IncludePath>$(SolutionDir)\include;$(IncludePath)</IncludePath>
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\mods\</OutDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_DEBUG;BUILDCAM_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
Expand All @@ -88,27 +99,33 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;NDEBUG;BUILDCAM_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_DEBUG;BUILDCAM_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
Expand All @@ -117,32 +134,34 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>NDEBUG;BUILDCAM_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="framework.h" />
<ClInclude Include="nlohmannjson.hpp" />
<ClInclude Include="Resource.h" />
<ClInclude Include="shroudtopia_gui.h" />
<ClInclude Include="targetver.h" />
<ClInclude Include="pch.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="shroudtopia_gui.cpp" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="shroudtopia_gui.rc" />
<ClCompile Include="dllmain.cpp" />
<ClCompile Include="pch.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Image Include="icon.ico" />
<None Include="..\first_person_view\first_person_view.vcxproj" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,19 @@
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="framework.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="targetver.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="Resource.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="shroudtopia_gui.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="nlohmannjson.hpp">
<ClInclude Include="pch.h">
<Filter>Headerdateien</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="shroudtopia_gui.cpp">
<ClCompile Include="dllmain.cpp">
<Filter>Quelldateien</Filter>
</ClCompile>
<ClCompile Include="pch.cpp">
<Filter>Quelldateien</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="shroudtopia_gui.rc">
<Filter>Ressourcendateien</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<Image Include="icon.ico">
<Filter>Ressourcendateien</Filter>
</Image>
<None Include="..\first_person_view\first_person_view.vcxproj" />
</ItemGroup>
</Project>
84 changes: 84 additions & 0 deletions example-mods/build_cam/dllmain.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#include "pch.h"

#include <shroudtopia.h>
#include <memory_utils.h>

ModMetaData metaData = {
"BuildCam",
"Enables build cam. (Client only)",
"1.0",
"s0T7x",
"0.0.1",
true,
false
};


// Signature for GameVersion (SVN) 55812
class BuildCam : public Mod
{
Mem::Detour* mod;
public:
void Load(ModContext* modContext)
{
const char* pattern = "\xF3\x0F\x11\x9F\x2C\x07\x00\x00";
const char* mask = "xxxxxxxx";

uintptr_t baseAddress = (uintptr_t)GetModuleHandle(NULL);
uintptr_t address = Mem::FindPattern(pattern, mask, baseAddress, 0x1000000); // Scan 16MB

if (address)
{
uint8_t modCode[] = {
0xF3,0x0F,0x11,0x9F,0x2C,0x07,0x00,0x00,
0xC7,0x87,0x2C,0x07,0x00,0x00,0x00,0x00,0x00,0x00,
0xC7,0x87,0x30,0x07,0x00,0x00,0x00,0x00,0x80,0xBF,
0xE9,0x00,0x00,0x00,0x00
};
mod = new Mem::Detour(address, modCode, sizeof(modCode), false, 3);
mod->shellcode->updateValue<uint32_t>(sizeof(modCode) - 4, (uint32_t)(mod->patch->data->address + mod->patch->data->size) - ((uint32_t)((uintptr_t)mod->shellcode->data->address + mod->shellcode->data->size)));
}
}

void Unload(ModContext* modContext) {
if (mod) delete mod;
}

void Activate(ModContext* modContext) {
active = mod->activate();
modContext->Log(std::string().append(metaData.name).append(" activated").c_str());
}

void Deactivate(ModContext* modContext) {
mod->deactivate();
active = false;
modContext->Log(std::string().append(metaData.name).append(" deactivated").c_str());
}

void Update(ModContext* modContext) { }

ModMetaData GetMetaData() {
return metaData;
}
};

extern "C" __declspec(dllexport) Mod* CreateModInstance() {
return new BuildCam();
}

BOOL APIENTRY DllMain(HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}

File renamed without changes.
File renamed without changes.
File renamed without changes
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "pch.h"

#include <shroudtopia.h>
#include <mem.h>
#include <memory_utils.h>

ModMetaData metaData = {
"FirstPersonView",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\mods\</OutDir>
<IncludePath>..\shroudtopia;$(IncludePath)</IncludePath>
<IncludePath>$(SolutionDir)\shroudtopia;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\mods\</OutDir>
<IncludePath>..\shroudtopia;$(IncludePath)</IncludePath>
<IncludePath>$(SolutionDir)\include;$(IncludePath)</IncludePath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
Expand Down
5 changes: 5 additions & 0 deletions example-mods/first_person_view/pch.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// pch.cpp: Quelldatei, die dem vorkompilierten Header entspricht

#include "pch.h"

// Bei der Verwendung vorkompilierter Header ist diese Quelldatei für eine erfolgreiche Kompilierung erforderlich.
13 changes: 13 additions & 0 deletions example-mods/first_person_view/pch.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// pch.h: Dies ist eine vorkompilierte Headerdatei.
// Die unten aufgeführten Dateien werden nur einmal kompiliert, um die Buildleistung für zukünftige Builds zu verbessern.
// Dies wirkt sich auch auf die IntelliSense-Leistung aus, Codevervollständigung und viele Features zum Durchsuchen von Code eingeschlossen.
// Die hier aufgeführten Dateien werden jedoch ALLE neu kompiliert, wenn mindestens eine davon zwischen den Builds aktualisiert wird.
// Fügen Sie hier keine Dateien hinzu, die häufig aktualisiert werden sollen, da sich so der Leistungsvorteil ins Gegenteil verkehrt.

#ifndef PCH_H
#define PCH_H

#define WIN32_LEAN_AND_MEAN
#include <windows.h>

#endif //PCH_H
File renamed without changes
Loading

0 comments on commit 2b34f2a

Please sign in to comment.