Skip to content

Commit

Permalink
Final update tested with old and current kernel builds
Browse files Browse the repository at this point in the history
  • Loading branch information
Ste1io committed Apr 29, 2021
1 parent 8b31f3c commit f6de8b8
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 19 deletions.
11 changes: 5 additions & 6 deletions AuroraCrashPatcher/Common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ BOOL TrayOpen() {
memset(msg, 0x0, 0x10);
memcpy(resp, msg, 0x10);
msg[0] = 0xA;
///((void(*)(LPVOID, LPVOID))ResolveFunction("xboxkrnl.xex", 0x29))(msg, resp); //0x80067F48
HalSendSMCMessage(msg, resp);
if (resp[1] == 0x60)
return TRUE;
Expand All @@ -53,7 +52,7 @@ BOOL TrayOpen() {
BOOL critSecInit = FALSE;
CRITICAL_SECTION writeLock;

void DbgLog(BOOL printToConsole, const char * fmt, ...) {
VOID DbgLog(bool printToConsole, const char * fmt, ...) {
CHAR buf[0x512];
va_list va;
va_start(va, fmt);
Expand Down Expand Up @@ -91,7 +90,7 @@ BOOL SelfDestruct(HANDLE hModule) {
auto len = wcstombs(chName, wchName, 260);
chName[len] = '\0';

skDbgPrint("[sk] Attempting to delete file: %s\n", chName);
DbgLog(TRUE, "Attempting to delete file: %s", chName);

char chPath[260];
int i = strlen(chName) - 1;
Expand All @@ -100,15 +99,15 @@ BOOL SelfDestruct(HANDLE hModule) {
strcat(chPath, &chName[i]);

if (!FileExists(chPath)) {
skDbgPrint("[sk] Error finding file: %s\n", chPath);
DbgLog(TRUE, "Error finding file: %s", chPath);
return FALSE;
}

if (!DeleteFileA(chPath)) {
skDbgPrint("[sk] Error deleting file: %s\n", chPath);
DbgLog(TRUE, "Error deleting file: %s", chPath);
return FALSE;
}

skDbgPrint("[sk] Successfully deleted file: %s\n", chName);
DbgLog(TRUE, "Successfully deleted file: %s", chName);
return TRUE;
}
2 changes: 1 addition & 1 deletion AuroraCrashPatcher/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,5 +152,5 @@ SK_INLINE uint32_t ByteSwap(uint32_t value) {
BOOL MountSysDrives();
BOOL FileExists(const char * fileName);
BOOL TrayOpen();
VOID DbgLog(BOOL printToConsole, const char * fmt, ...);
VOID DbgLog(bool printToConsole, const char * fmt, ...);
BOOL SelfDestruct(HANDLE hModule);
12 changes: 8 additions & 4 deletions AuroraCrashPatcher/Compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ void DbgLog(bool printToConsole, const char * fmt, ...);
#define SK_INLINE __inline
#define SK_FORCE_INLINE __forceinline

#define HDD "\\Device\\Harddisk0\\Partition1"
#define USB "\\Device\\Mass0"
#define SKMOUNT "SK_ACP:\\"

#ifndef NDEBUG
#define skDbgPrint DbgPrint
#define skDbgLog DbgLog
Expand All @@ -16,10 +20,10 @@ void DbgLog(bool printToConsole, const char * fmt, ...);
#define skDbgLog
#endif

#define SK_VERSION "1.2"

#define HDD "\\Device\\Harddisk0\\Partition1"
#define USB "\\Device\\Mass0"
#define SKMOUNT "SK_ACP:\\"
//
// Config
//

#define SK_VERSION "1.2"
#define SK_LOGPATH SKMOUNT "AuroraCrashPatcher.log"
22 changes: 14 additions & 8 deletions AuroraCrashPatcher/DllMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,28 @@ INT HookProc(INT x, PCHAR h, HANDLE e, XNDNS **s) {
}

DWORD WINAPI MainThread(LPVOID lpParameter) {
skDbgLog(TRUE, "AuroraCrashPatcher " __FUNCTION__ " started");

auto Run = [] (uint32_t t) -> bool
{
static uint32_t p = 0;
if (g_flag < 2) {
if (t != p) {
skDbgLog(TRUE, "Title changed: 0x%08X -> 0x%08X", p, t);
if ((!t || t == 0xFFFE07D1 || t == 0xF5D20000) && MmIsAddressValid((PVOID)0x82000000)) {
if (*(uint16_t*)0x82000000 != 0x4D5A)
return true;
skDbgLog(TRUE, "Checking if patch is needed with this version of Aurora/FSD...");
g_flag = ByteSwap(*(uint32_t*)(0x82000008 + ByteSwap(*(uint32_t*)0x8200003C))) > 0x607F951E;
if (!g_flag && !origHook.Addr) {
skDbgLog(TRUE, "Setting up hook...");
if (origHook.SetupDetour(ResolveFunction("xam.xex", 0x43), HookProc)) { //0x81741150
skDbgLog(TRUE, "AuroraCrashPatcher v" SK_VERSION ": ENABLED [flag: 0x%X]", &g_flag);
}
}
} else if (!p || p == 0xFFFE07D1 || p == 0xF5D20000) {
if (origHook.Addr) {
skDbgLog(TRUE, "Taking down hook...");
origHook.TakeDownDetour();
skDbgLog(TRUE, "AuroraCrashPatcher v" SK_VERSION ": DISABLED");
g_flag = 0;
Expand All @@ -79,7 +85,7 @@ DWORD WINAPI MainThread(LPVOID lpParameter) {
}
};

while (Run(((uint32_t(*)())0x816E03B8)())) {
while (Run(((uint32_t(*)())ResolveFunction("xam.xex", 0x1CF))())) {
Sleep(100);
}

Expand All @@ -90,30 +96,30 @@ DWORD WINAPI MainThread(LPVOID lpParameter) {
}

BOOL Init() {
skDbgLog(TRUE, "AuroraCrashPatcher initializing");
skDbgLog(TRUE, "AuroraCrashPatcher v" SK_VERSION ": LOADING");
skDbgLog(TRUE, "- Author: Stelio Kontos");
skDbgLog(TRUE, "- Github: https://github.com/StelioKontosXBL/AuroraCrashPatcher");
skDbgLog(TRUE, "initializing...");

if (!MountSysDrives()) {
DbgPrint("[sk] Failed to mount system drives\n");
skDbgPrint("[sk] Failed to mount system drives\n");
} else { skDbgLog(TRUE, "System drives mounted"); }

if (XboxKrnlVersion->Build < 0x4497) {
DbgLog(TRUE, "Kernel build %i detected...you really should update", XboxKrnlVersion->Build);
} else { skDbgLog(TRUE, "Kernel build %i detected", XboxKrnlVersion->Build); }

if (TrayOpen()) {
DbgLog(TRUE, "Tray open...AuroraCrashPatcher aborting");
skDbgLog(TRUE, "Tray open...AuroraCrashPatcher aborting");
return FALSE;
} else { skDbgLog(TRUE, "Tray closed"); }

skDbgLog(TRUE, "AuroraCrashPatcher init success");
skDbgLog(TRUE, "Initialization complete");
return TRUE;
}

BOOL APIENTRY DllMain(HANDLE hModule, DWORD dwReason, LPVOID lpReserved) {
if (dwReason == DLL_PROCESS_ATTACH) {
skDbgLog(TRUE, "AuroraCrashPatcher v" SK_VERSION ": LOADING");
skDbgLog(TRUE, "- Author: Stelio Kontos");
skDbgLog(TRUE, "- Github: https://github.com/StelioKontosXBL/AuroraCrashPatcher");
if (Init()) {
g_hModule = hModule;
ExCreateThread(&g_hThread, 0, 0, (PVOID)XapiThreadStartup, (LPTHREAD_START_ROUTINE)MainThread, 0, 0x2 | 0x1);
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 f6de8b8

Please sign in to comment.