Skip to content

Commit c91e903

Browse files
authored
Merge pull request #5 from illusion0001/plugin-loader
Ditch patterns for syscall and read syscall pointer directly
2 parents 6683c96 + 6b24dd1 commit c91e903

File tree

4 files changed

+36
-14
lines changed

4 files changed

+36
-14
lines changed

.github/workflows/build.yml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
build:
1313
runs-on: ubuntu-latest
1414
env:
15-
zip: ps4-hen-vtx
15+
zip: ps4-hen-vtx.7z
1616
zip_glob: ps4-hen-*.bin
1717
steps:
1818
- name: Checkout repository
@@ -38,17 +38,25 @@ jobs:
3838
for VERSION in $VERSIONS; do
3939
./build.sh $VERSION
4040
done
41-
zip ${{ env.zip }}.zip ${{ env.zip_glob }}
41+
7z a -mx9 ${{ env.zip }} ${{ env.zip_glob }}
4242
4343
- name: Upload payload
44+
if: github.event_name == 'pull_request'
4445
uses: actions/upload-artifact@main
4546
with:
46-
name: ${{ env.zip }}
47+
name: ps4-hen-vtx
4748
path: ${{ env.zip_glob }}
4849

49-
- name: Release for branch Multi-HEN
50-
if: github.event_name == 'push' && github.ref == 'refs/heads/Multi-HEN'
50+
- name: Release
51+
if: github.event_name != 'pull_request'
5152
env:
5253
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5354
run: |
54-
gh release create HEN-1.0${{ github.run_number }} ps4-hen-vtx.zip --target ${{ github.sha }} -t HEN-1.0${{ github.run_number }}
55+
PRERELEASE_FLAG=""
56+
if [ "${GITHUB_REF}" != "refs/heads/Multi-HEN" ]; then
57+
PRERELEASE_FLAG="-p"
58+
fi
59+
60+
gh release create $PRERELEASE_FLAG HEN-1.0${{ github.run_number }} ${{ env.zip }} \
61+
--target ${{ github.sha }} \
62+
-t HEN-1.0${{ github.run_number }}

download_prx.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#!/bin/bash
22

33
c=$PWD
4-
cd installer/build
4+
b=installer/build
5+
mkdir -p $b
6+
cd $b
57
f=plugins.zip
68
curl -fLJO https://github.com/illusion0001/ps4-hen-plugins/releases/latest/download/$f
79
unzip $f

kpayload/source/hooks.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,12 @@ PAYLOAD_CODE void install_syscall(uint32_t n, void *func)
169169
p->sy_thrcnt = 1;
170170
}
171171

172+
PAYLOAD_CODE void *get_syscall(uint64_t n)
173+
{
174+
struct sysent *p = &SYSENT[n];
175+
return p->sy_call;
176+
}
177+
172178
int sys_proc_info_handle(struct proc *p, struct sys_proc_info_args *args)
173179
{
174180
args->pid = p->pid;
@@ -307,8 +313,7 @@ PAYLOAD_CODE int sys_dynlib_load_prx_hook(struct thread *td, struct dynlib_load_
307313
{
308314
int r = sys_dynlib_load_prx(td, args);
309315
// https://github.com/OpenOrbis/mira-project/blob/d8cc5790f08f93267354c2370eb3879edba0aa98/kernel/src/Plugins/Substitute/Substitute.cpp#L1003
310-
const char *ttemp = (const char *)((uint64_t)td->td_proc + 0x390);
311-
const char *titleid = ttemp ? ttemp : "?";
316+
const char *titleid = td->td_proc->titleid;
312317
const char *p = args->prx_path ? args->prx_path : "";
313318
printf("%s td_name %s titleid %s prx %s\n", __FUNCTION__, td->td_name, titleid, p);
314319
if (strstr(p, "/app0/sce_module/libc.prx"))
@@ -340,7 +345,6 @@ PAYLOAD_CODE int sys_dynlib_load_prx_hook(struct thread *td, struct dynlib_load_
340345
// dummy process to load server prx into
341346
else if (strstr(p, "/common/lib/libSceSysmodule.sprx") && strstr(td->td_name, "ScePartyDaemonMain"))
342347
{
343-
const int handle_out = args->handle_out ? *args->handle_out : 0;
344348
struct dynlib_load_prx_args my_args = {};
345349
int handle = 0;
346350
// TODO: Upload this file to disk
@@ -364,7 +368,7 @@ PAYLOAD_CODE int sys_dynlib_load_prx_hook(struct thread *td, struct dynlib_load_
364368
proc_rw_mem(td->td_proc, (void *)init_env_ptr, sizeof(jmp), jmp, 0, 1);
365369
proc_rw_mem(td->td_proc, (void *)(init_env_ptr + sizeof(jmp)), sizeof(plugin_load_ptr), &plugin_load_ptr, 0, 1);
366370
}
367-
printf("%s init env 0x%lx plugin load 0x%lx\n", ttemp, init_env_ptr, plugin_load_ptr);
371+
printf("%s init env 0x%lx plugin load 0x%lx\n", titleid, init_env_ptr, plugin_load_ptr);
368372
}
369373
return r;
370374
}
@@ -381,8 +385,6 @@ PAYLOAD_CODE void install_syscall_hooks()
381385
install_syscall(107, sys_proc_list);
382386
install_syscall(108, sys_proc_rw);
383387
install_syscall(109, sys_proc_cmd);
384-
printf("sys_dynlib_load_prx %p\n", sys_dynlib_load_prx);
385-
printf("sys_dynlib_dlsym %p\n", sys_dynlib_dlsym);
386388
if (sys_dynlib_load_prx && sys_dynlib_dlsym)
387389
{
388390
install_syscall(594, sys_dynlib_load_prx_hook);

kpayload/source/main.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,17 @@ static PAYLOAD_CODE uint64_t get_kernel_size(uint64_t kernel_base)
284284
return max - 0xFFFFFFFF82200000;
285285
}
286286

287-
PAYLOAD_CODE static void resolve_patterns()
287+
PAYLOAD_CODE extern void *get_syscall(uint64_t n);
288+
289+
PAYLOAD_CODE static void resolve_syscall(void)
290+
{
291+
sys_dynlib_load_prx = get_syscall(594);
292+
sys_dynlib_dlsym = get_syscall(591);
293+
}
294+
295+
PAYLOAD_CODE static void resolve_patterns(void)
288296
{
297+
return;
289298
uint64_t flags, cr0;
290299
cr0 = readCr0();
291300
writeCr0(cr0 & ~X86_CR0_WP);
@@ -370,6 +379,7 @@ PAYLOAD_CODE void my_entrypoint()
370379
{
371380
resolve_kdlsym();
372381
resolve_patterns();
382+
resolve_syscall();
373383
install_fself_hooks();
374384
install_fpkg_hooks();
375385
install_patches();

0 commit comments

Comments
 (0)