Skip to content

Commit 60a31e4

Browse files
committed
fixed kernel run example (helps to reverse stuff ..)
1 parent cbef208 commit 60a31e4

File tree

3 files changed

+17
-16
lines changed

3 files changed

+17
-16
lines changed

kernel/hook/source/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ int hook1(void *td, Ps4KernFunctionHookArgument *uap)
3434

3535
int hook2(void *td, Ps4KernFunctionHookArgument *uap)
3636
{
37-
// unroot
37+
// Blocks hooks added after this one
3838
uap->arguments->rax = 0; // return OK
3939
return PS4_KERN_FUNCTION_HOOK_RETURN; // intercept call
4040
}

kernel/kernel_run/source/kmain.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,18 @@ int kmain(struct thread *td, void *uap)
3838

3939
free(kmoo, mt);
4040

41-
RunnableInt sceSblACMgrIsVideoplayerProcess = (RunnableInt)ps4KernelDlSym("sceSblACMgrIsVideoplayerProcess");
41+
RunnableInt sceSblACMgrIsVideoplayerProcess = (RunnableInt)ps4KernDlSym("sceSblACMgrIsVideoplayerProcess");
4242

43-
//ps4KernThreadSetReturn0(td, sceSblACMgrIsVideoplayerProcess()); //see kmain2's content & return
44-
return 0;
43+
ps4KernThreadSetReturn0(td, sceSblACMgrIsVideoplayerProcess(td)); //see kmain2's content & return
44+
return EINVAL;
4545
}
4646

4747
int kmain2(struct thread *td, void *uap)
4848
{
4949
RunnableInt sceSblACMgrIsVideoplayerProcess = (RunnableInt)ps4KernelDlSym("sceSblACMgrIsVideoplayerProcess");
5050
ps4KernelFunctionPatchToReturn((void *)sceSblACMgrIsVideoplayerProcess, 0);
51-
//size_t s = 0;
52-
//int r = ps4KernelAssemblerInstructionNext(sceSblACMgrIsVideoplayerProcess, &s);
53-
//ps4KernThreadSetReturn0(td, sceSblACMgrIsVideoplayerProcess()); // important notice from kernel!
51+
52+
ps4KernThreadSetReturn0(td, sceSblACMgrIsVideoplayerProcess(td)); // important notice from kernel!
5453
return 0;
5554
}
5655

@@ -60,6 +59,6 @@ int kmain3(struct thread *td, void *uap)
6059
void *sceSblACMgrIsShellcoreProcess = ps4KernelDlSym("sceSblACMgrIsShellcoreProcess");
6160
ps4KernelFunctionPatchToJump((void *)sceSblACMgrIsVideoplayerProcess, sceSblACMgrIsShellcoreProcess);
6261

63-
//ps4KernThreadSetReturn0(td, sceSblACMgrIsVideoplayerProcess());
62+
ps4KernThreadSetReturn0(td, sceSblACMgrIsVideoplayerProcess(td));
6463
return 0;
6564
}

kernel/kernel_run/source/main.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,22 @@
55
#include <stdlib.h>
66
#include <stdio.h>
77
#include <string.h>
8+
#include <stdint.h>
9+
#include <inttypes.h>
10+
811
#include <unistd.h>
12+
913
#include <sys/syscall.h>
1014

1115
#include <ps4/kernel.h>
1216

1317
#include "kmain.h"
1418

15-
1619
int main(int argc, char **argv)
1720
{
1821
char *moo = malloc(32); // A moo!! :D
1922
int i;
20-
uint64_t ret;
23+
int64_t ret;
2124

2225
printf("uid: %zu\n", getuid());
2326
// this syscall returns 0 after the first ps4KernelRunMain (see in a rerun process)
@@ -28,8 +31,7 @@ int main(int argc, char **argv)
2831
strcpy(moo, "Hmm ... ? *yum, grass*");
2932
// I will also add a ps4KernelRun(Syscall?) that uses the syscall interface instead
3033
int r = ps4KernelExecute((void *)kmain, moo, &ret, NULL);
31-
printf("r (sceSblACMgrIsVideoplayerProcess): %i\n", r);
32-
printf("return (sceSblACMgrIsVideoplayerProcess): %i\n", ret);
34+
printf("return (sceSblACMgrIsVideoplayerProcess): %i %"PRId64"\n", r, ret);
3335
printf("moo: %s\n", moo);
3436
printf("moo: %p\n", moo);
3537

@@ -53,16 +55,16 @@ int main(int argc, char **argv)
5355
printf("%02X", ((unsigned char *)moo)[i]);
5456
printf("\n");
5557

56-
r = ps4KernelExecute((void *)kmain2, moo, NULL, NULL);
57-
printf("return2 (sceSblACMgrIsVideoplayerProcess): %i\n", r);
58+
r = ps4KernelExecute((void *)kmain2, moo, &ret, NULL);
59+
printf("return2 (sceSblACMgrIsVideoplayerProcess): %i %"PRId64"\n", r, ret);
5860

5961
ps4KernelMemoryCopy(sceSblACMgrIsVideoplayerProcess, moo, 32);
6062
for(i = 0; i < 32; ++i)
6163
printf("%02X", ((unsigned char *)moo)[i]);
6264
printf("\n");
6365

64-
r = ps4KernelExecute((void *)kmain3, moo, NULL, NULL);
65-
printf("return3 (sceSblACMgrIsVideoplayerProcess): %i\n", r);
66+
r = ps4KernelExecute((void *)kmain3, moo, &ret, NULL);
67+
printf("return3 (sceSblACMgrIsVideoplayerProcess): %i %"PRId64"\n", r, ret);
6668

6769
ps4KernelMemoryCopy(sceSblACMgrIsVideoplayerProcess, moo, 32);
6870
for(i = 0; i < 32; ++i)

0 commit comments

Comments
 (0)