From b058056f88d2807cd11ea2c927e50b2904e5a66b Mon Sep 17 00:00:00 2001
From: TheSola10 <me@thesola.io>
Date: Fri, 4 Apr 2025 21:26:58 +0200
Subject: [PATCH] cleanup, add umdiff magic

---
 main.c              | 7 ++++++-
 umdiff/umdiff.magic | 6 ++++++
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 umdiff/umdiff.magic

diff --git a/main.c b/main.c
index feff3d0..1f821cd 100644
--- a/main.c
+++ b/main.c
@@ -70,6 +70,8 @@ int lp_catchUmdCallback(int cbid)
     Kprintf("Caught request to register UMD callback 0x%08x\n", cbid);
     vshCallbackId = cbid;
     sceKernelNotifyCallback(cbid, PSP_UMD_NOT_PRESENT);
+
+    return 0;
 }
 
 /**
@@ -120,8 +122,9 @@ int lp_discChangeWatcher(SceSize argc, void *argp)
         REDIRECT_FUNCTION(fn_RegisterUmdCallback, lp_catchUmdCallback);
     }
 
-
     sceKernelSleepThreadCB();
+
+    return 1; // This should be unreachable
 }
 
 int module_start(SceSize argc, void *argp)
@@ -164,6 +167,8 @@ int module_stop(void)
     sceUmdUnRegisterUMDCallBack(umdCallbackId);
     sceKernelDeleteCallback(umdCallbackId);
 
+    sceKernelDeleteThread(umdCallbackThread);
+
     // put things back where we found them
     _sw((u32) &reserveRegisterUmdCallback, fn_RegisterUmdCallback);
     _sw((u32) &reserveRegisterUmdCallback + 4, fn_RegisterUmdCallback + 4);
diff --git a/umdiff/umdiff.magic b/umdiff/umdiff.magic
new file mode 100644
index 0000000..73c56ff
--- /dev/null
+++ b/umdiff/umdiff.magic
@@ -0,0 +1,6 @@
+# umdiff:  file(1) magic for UMDiff format
+# URL:          https://github.com/thesola10/umd-livepatch
+0       string  \x7fUMDiff  UMDiff patch file
+>0x07   byte    0           v0,
+>>0x08  belong  x           %d commands,
+>>0x0c  belong  x           data starts at offset %d