Skip to content

Commit

Permalink
Merge pull request #3 from StelioKontosXBL/base-addr-tests
Browse files Browse the repository at this point in the history
Bug fix for users without stealth server which broke the original detection method for when FSD/Aurora were active.
  • Loading branch information
Ste1io authored Apr 25, 2021
2 parents 6690d98 + f5d8ae7 commit 1212205
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 31 deletions.
27 changes: 17 additions & 10 deletions AuroraCrashPatcher/AuroraCrashPatcher.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,17 @@
<ProgramDatabaseFile>$(OutDir)$(ProjectName).pdb</ProgramDatabaseFile>
<AdditionalDependencies>xapilibd.lib;d3d9d.lib;d3dx9d.lib;xgraphicsd.lib;xboxkrnl.lib;xnetd.lib;xaudiod2.lib;xactd3.lib;x3daudiod.lib;xmcored.lib;xbdm.lib;vcompd.lib;xhttp.lib;</AdditionalDependencies>
<AdditionalOptions>/dll /ALIGN:128,4096 %(AdditionalOptions)</AdditionalOptions>
<BaseAddress>0x910E0000</BaseAddress>
<BaseAddress>0x90D00000</BaseAddress>
<GenerateMapFile>true</GenerateMapFile>
<MapFileName>$(OutDir)$(ProjectName).map</MapFileName>
<MapExports>true</MapExports>
</Link>
<ImageXex>
<ConfigurationFile>xex.xml</ConfigurationFile>
</ImageXex>
<PostBuildEvent>
<Command>copy /Y "$(ImageXexOutput)" "$(SolutionDir)Dist\$(ImageName)-$(ConfigurationName).xex"</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='CodeAnalysis|Xbox 360'">
<ClCompile>
Expand All @@ -148,7 +151,7 @@
<ProgramDatabaseFile>$(OutDir)$(ProjectName).pdb</ProgramDatabaseFile>
<AdditionalDependencies>xapilibd.lib;d3d9d.lib;d3dx9d.lib;xgraphicsd.lib;xboxkrnl.lib;xnetd.lib;xaudiod2.lib;xactd3.lib;x3daudiod.lib;xmcored.lib;xbdm.lib;vcompd.lib;xhttp.lib;</AdditionalDependencies>
<AdditionalOptions>/dll /ALIGN:128,4096 %(AdditionalOptions)</AdditionalOptions>
<BaseAddress>0x910E0000</BaseAddress>
<BaseAddress>0x90D00000</BaseAddress>
<GenerateMapFile>true</GenerateMapFile>
<MapFileName>$(OutDir)$(ProjectName).map</MapFileName>
<MapExports>true</MapExports>
Expand Down Expand Up @@ -184,7 +187,7 @@
<SetChecksum>true</SetChecksum>
<AdditionalDependencies>xapilibi.lib;d3d9i.lib;d3dx9.lib;xgraphics.lib;xboxkrnl.lib;xnet.lib;xaudio2.lib;xact3i.lib;x3daudioi.lib;xmcorei.lib;xbdm.lib;vcomp.lib;xhttp.lib;</AdditionalDependencies>
<AdditionalOptions>/dll /ALIGN:128,4096 %(AdditionalOptions)</AdditionalOptions>
<BaseAddress>0x910E0000</BaseAddress>
<BaseAddress>0x90D00000</BaseAddress>
<GenerateMapFile>true</GenerateMapFile>
<MapFileName>$(OutDir)$(ProjectName).map</MapFileName>
<MapExports>true</MapExports>
Expand Down Expand Up @@ -219,7 +222,7 @@
<SetChecksum>true</SetChecksum>
<AdditionalDependencies>xapilib.lib;d3d9.lib;d3dx9.lib;xgraphics.lib;xboxkrnl.lib;xnet.lib;xaudio2.lib;xact3.lib;x3daudio.lib;xmcore.lib;vcomp.lib;xbdm.lib;xhttp.lib;</AdditionalDependencies>
<AdditionalOptions>/dll /ALIGN:128,4096 %(AdditionalOptions)</AdditionalOptions>
<BaseAddress>0x910E0000</BaseAddress>
<BaseAddress>0x90D00000</BaseAddress>
<GenerateMapFile>true</GenerateMapFile>
<MapFileName>$(OutDir)$(ProjectName).map</MapFileName>
<MapExports>true</MapExports>
Expand Down Expand Up @@ -253,7 +256,7 @@
<SetChecksum>true</SetChecksum>
<AdditionalDependencies>xapilib.lib;d3d9.lib;d3dx9.lib;xgraphics.lib;xboxkrnl.lib;xnet.lib;xaudio2.lib;xact3.lib;x3daudio.lib;xmcore.lib;vcomp.lib;xhttp.lib;</AdditionalDependencies>
<AdditionalOptions>/dll /ALIGN:128,4096 %(AdditionalOptions)</AdditionalOptions>
<BaseAddress>0x910E0000</BaseAddress>
<BaseAddress>0x90D00000</BaseAddress>
<GenerateMapFile>true</GenerateMapFile>
<MapFileName>$(OutDir)$(ProjectName).map</MapFileName>
<MapExports>true</MapExports>
Expand All @@ -268,7 +271,7 @@
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>Full</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<StringPooling>false</StringPooling>
<StringPooling>true</StringPooling>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<FavorSizeOrSpeed>Neither</FavorSizeOrSpeed>
<ExceptionHandling>false</ExceptionHandling>
Expand All @@ -282,21 +285,25 @@
<AssemblerOutput>All</AssemblerOutput>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<GenerateDebugInformation>false</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<ProgramDatabaseFile>$(OutDir)$(ProjectName).pdb</ProgramDatabaseFile>
<ProgramDatabaseFile>
</ProgramDatabaseFile>
<SetChecksum>true</SetChecksum>
<AdditionalDependencies>xapilib.lib;d3d9ltcg.lib;d3dx9.lib;xgraphics.lib;xboxkrnl.lib;xnet.lib;xaudio2.lib;xact3ltcg.lib;x3daudioltcg.lib;xmcoreltcg.lib;vcomp.lib;xhttp.lib;</AdditionalDependencies>
<AdditionalOptions>/dll /ALIGN:128,4096 %(AdditionalOptions)</AdditionalOptions>
<BaseAddress>0x910E0000</BaseAddress>
<BaseAddress>0x90D00000</BaseAddress>
<GenerateMapFile>true</GenerateMapFile>
<MapFileName>$(OutDir)$(ProjectName).map</MapFileName>
<MapExports>true</MapExports>
</Link>
<ImageXex>
<ConfigurationFile>xex.xml</ConfigurationFile>
</ImageXex>
<PostBuildEvent>
<Command>copy /Y "$(ImageXexOutput)" "$(SolutionDir)Dist\$(ImageFileName)"</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="Common.h" />
Expand All @@ -323,4 +330,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
5 changes: 3 additions & 2 deletions AuroraCrashPatcher/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ typedef struct _LDR_DATA_TABLE_ENTRY {
extern "C" {
#endif
VOID XapiThreadStartup(void(__cdecl *)(void*), void *, DWORD);
HANDLE CreateThread(LPVOID, DWORD, LPTHREAD_START_ROUTINE, LPVOID, DWORD, LPDWORD);
DWORD ExCreateThread(PHANDLE, DWORD, LPDWORD, PVOID, LPTHREAD_START_ROUTINE, LPVOID, DWORD);
LONG XexGetModuleHandle(PCHAR, PHANDLE);
LONG XexGetProcedureAddress(HANDLE, DWORD, PVOID);
Expand Down Expand Up @@ -142,8 +143,8 @@ SK_INLINE DWORD ResolveFunction(PCHAR moduleName, DWORD ordinal) {

SK_INLINE uint32_t ByteSwap(uint32_t value) {
return (value & 0x000000FF) << 0x18
| (value & 0x0000FF00) << 0x08
| (value & 0x00FF0000) >> 0x08
| (value & 0x0000FF00) << 0x08
| (value & 0x00FF0000) >> 0x08
| (value & 0xFF000000) >> 0x18;
}

Expand Down
2 changes: 1 addition & 1 deletion AuroraCrashPatcher/Compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ extern "C" unsigned long __cdecl DbgPrint(char *, ...);
#define skDbgPrint
#endif

#define SK_VERSION "1.0"
#define SK_VERSION "1.1"

#define HDD "\\Device\\Harddisk0\\Partition1"
#define USB "\\Device\\Mass0"
Expand Down
42 changes: 25 additions & 17 deletions AuroraCrashPatcher/DllMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
* v0.4-beta: 04/21/2021
* - Changed killswitch method for Aurora devs to use once official patch is released.
* v1.0: 04/22/2021
* v1.1: 04/25/2021
* - Fixed bug causing patch to not load for users not using a stealth server
* (props to rubensyama for helping track this down).
*/

#include "stdafx.h"
Expand All @@ -38,31 +41,36 @@ INT HookProc(INT x, PCHAR h, HANDLE e, XNDNS **s) {
}

DWORD WINAPI MainThread(LPVOID lpParameter) {
auto Run = [] (uint32_t title) -> bool
auto Run = [] (uint32_t t) -> bool
{
static uint32_t last = 0;
static uint32_t p = 0;
if (g_flag < 2) {
if (title != last) {
if (title == 0xFFFE07D1 && ((uint32_t(*)(PVOID))0x800819D0)((PVOID)0x82000000)) {
if (t != p) {
if (!t && !((uint32_t(*)(PVOID))0x800819D0)((PVOID)0x82000000))
return true;
if ((!t || t == 0xFFFE07D1 || t == 0xF5D20000) && ((uint32_t(*)(PVOID))0x800819D0)((PVOID)0x82000000)) {
if (*(uint16_t*)0x82000000 != 0x4D5A)
return true;
g_flag = ByteSwap(*(uint32_t*)(0x82000008 + ByteSwap(*(uint32_t*)0x8200003C))) > 0x607F951E;
DbgPrint("[sk] AuroraCrashPatcher v" SK_VERSION " by Stelio Kontos: %s. [flag: 0x%X]\n", !g_flag ? "ENABLED" : "DISABLED", &g_flag);
if (!g_flag)
origHook.SetupDetour(0x81741150, HookProc);
} else if (last == 0xFFFE07D1) {
origHook.TakeDownDetour();
g_flag = 0;
if (!g_flag) {
if (origHook.SetupDetour(0x81741150, HookProc)) {
DbgPrint("[sk] AuroraCrashPatcher v" SK_VERSION " by Stelio Kontos: ENABLED. [flag: 0x%X]\n", &g_flag);
}
}
} else if (!p || p == 0xFFFE07D1 || p == 0xF5D20000) {
if (origHook.Addr) {
origHook.TakeDownDetour();
DbgPrint("[sk] AuroraCrashPatcher v" SK_VERSION " DISABLED");
g_flag = 0;
}
}
last = title;
p = t;
}
return true;
} else {
origHook.TakeDownDetour();
if (g_flag == 0xDEADC0DE) {
DbgPrint("[sk] Received self-destruct command from host process...wiping patch file. :)\n");
if (SelfDestruct(g_hModule)) {
DbgPrint("[sk] Self-terminate successful.\n");
}
}
if (g_flag == 0xDEADC0DE)
SelfDestruct(g_hModule);
return false;
}
};
Expand Down
1 change: 0 additions & 1 deletion AuroraCrashPatcher/xex.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<xex>
<baseaddr addr="0x910E0000"/>
<sysdll/>
<format>
<compressed/>
Expand Down
Binary file modified Dist/AuroraCrashPatcher-Debug.xex
Binary file not shown.
Binary file modified Dist/AuroraCrashPatcher.xex
Binary file not shown.

0 comments on commit 1212205

Please sign in to comment.