summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReiko Asakura2021-03-01 00:36:56 -0500
committerReiko Asakura2021-03-01 00:36:56 -0500
commite900ac06bf5c724f37809870612e23b8a1886682 (patch)
tree98b9c53f74f60c6b9c16ef75fcc410bb474a5e29
parentRefactor hook and inject functions (diff)
downloadmusicpremium-e900ac06bf5c724f37809870612e23b8a1886682.tar.gz
Fix compiler warnings
1. Strict aliasing violation 2. Arithmetics on void pointer 3. Goto bypasses variable initialisation
-rw-r--r--CMakeLists.txt2
-rw-r--r--musicpremium.c24
2 files changed, 13 insertions, 13 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9fb76f5..8e9fe19 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -23,7 +23,7 @@ link_directories(
)
add_compile_options(
- -Xdiag=2
+ -Xdiag=2 -Xquit=2
)
add_link_options(
diff --git a/musicpremium.c b/musicpremium.c
index bcafc4c..e1178d1 100644
--- a/musicpremium.c
+++ b/musicpremium.c
@@ -24,10 +24,6 @@
if ((x) < 0) { return (x); }\
} while(0)
-#define RNE(x, k) do {\
- if ((x) != (k)) { return -1; }\
-} while(0)
-
#define STREQ(s1, s2) (strncmp(s1, s2, sizeof(s1)) == 0)
SceUID bgm_port_priority_patch_id = -1;
@@ -39,23 +35,25 @@ tai_hook_ref_t sceAppMgrAcquireBgmPort_impl_hook_ref;
static int (*sceAppMgrAcquireBgmPortWithPriority)(int priority);
static int (*sceAppMgrReleaseBgmPort)(void);
-static int get_addr(void **inject_addr, void **hook_addr) {
+static int get_addr(uint16_t **inject_addr, uint16_t **hook_addr) {
// get sceAppMgrAcquireBgmPort addr
- void *sceAppMgrAcquireBgmPort;
+ uint16_t *sceAppMgrAcquireBgmPort;
RLZ(GET_EXPORT("SceAppMgr", 0x8AF17416, 0xAFCEAB96, (void *)&sceAppMgrAcquireBgmPort));
// clear Thumb bit
- sceAppMgrAcquireBgmPort = (void*)((int)sceAppMgrAcquireBgmPort & ~0x1);
+ sceAppMgrAcquireBgmPort = (uint16_t *)((uintptr_t)sceAppMgrAcquireBgmPort & ~0x1);
// get sceAppMgrAcquireBgmPort impl func addr
- RLZ(get_addr_bl((uint16_t *)sceAppMgrAcquireBgmPort + 1, (void *)hook_addr));
+ RLZ(get_addr_bl(sceAppMgrAcquireBgmPort + 1, hook_addr));
// get inject addr
- *inject_addr = *hook_addr + 0xE2;
- RNE(**(int**)inject_addr, 0x7380F44F);
+ *inject_addr = *hook_addr + 0xE2/2;
+ if ((*inject_addr)[0] != 0xF44F || (*inject_addr)[1] != 0x7380) {
+ return -1;
+ }
// set Thumb bit
- *hook_addr = (void*)((int)*hook_addr | 0x1);
+ *hook_addr = (uint16_t *)((uintptr_t)*hook_addr | 0x1);
return 0;
}
@@ -109,12 +107,14 @@ static void cleanup(void) {
int module_start(SceSize argc, const void *argv) { (void)argc; (void)argv;
+ uint16_t *inject_addr = NULL;
+ uint16_t *hook_addr = NULL;
+
// get SceAppMgr exports
GLZ(GET_EXPORT("SceAppMgr", 0x8AF17416, 0xAAED7419, (void *)&sceAppMgrAcquireBgmPortWithPriority));
GLZ(GET_EXPORT("SceAppMgr", 0x8AF17416, 0xF3717E37, (void *)&sceAppMgrReleaseBgmPort));
// firmware independent way of getting absolute address
- void *inject_addr = 0, *hook_addr = 0;
GLZ(get_addr(&inject_addr, &hook_addr));
// mov.w r3, #0x78