Skip to content

Commit 663a25a

Browse files
committed
altered API from ps4KernelRun to ps4KernelRunMain as part of further cleanup (and reuse of ps4KernelRun), minor cleanup
1 parent ba27961 commit 663a25a

File tree

5 files changed

+26
-74
lines changed

5 files changed

+26
-74
lines changed

kernel/kernel-run/source/kmain.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,20 @@ int kmain(int argc, char **argv)
4141

4242
return sceSblACMgrIsVideoplayerProcess(); //see kmain2's content & return
4343
}
44+
45+
int kmain2(int argc, char **argv)
46+
{
47+
RunnableInt sceSblACMgrIsVideoplayerProcess = (RunnableInt)ps4KernelDlSym("sceSblACMgrIsVideoplayerProcess");
48+
ps4KernelPatchToTruthFunction((void *)sceSblACMgrIsVideoplayerProcess);
49+
50+
return sceSblACMgrIsVideoplayerProcess(); // important notice from kernel!
51+
}
52+
53+
int kmain3(int argc, char **argv)
54+
{
55+
RunnableInt sceSblACMgrIsVideoplayerProcess = (RunnableInt)ps4KernelDlSym("sceSblACMgrIsVideoplayerProcess");
56+
void *sceSblACMgrIsShellcoreProcess = ps4KernelDlSym("sceSblACMgrIsShellcoreProcess");
57+
ps4KernelHookFunction((void *)sceSblACMgrIsVideoplayerProcess, sceSblACMgrIsShellcoreProcess);
58+
59+
return sceSblACMgrIsVideoplayerProcess();
60+
}

kernel/kernel-run/source/kmain2.c

Lines changed: 0 additions & 31 deletions
This file was deleted.

kernel/kernel-run/source/kmain3.c

Lines changed: 0 additions & 32 deletions
This file was deleted.

kernel/kernel-run/source/main.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,14 @@ int main(int argc, char **argv)
2424
kargv[1] = NULL;
2525

2626
printf("uid: %zu\n", getuid());
27-
// this syscall returns 0 after the first ps4KernelRun (see in a rerun process)
27+
// this syscall returns 0 after the first ps4KernelRunMain (see in a rerun process)
2828
// do not use this directly (just for show and tell here)
29-
// use the self-patching ps4KernelRun wrapper instead
29+
// use the self-patching ps4KernelRunMain wrapper instead
3030
printf("sys: %i\n", syscall(SYS_ps4_kernel_run, NULL));
3131

3232
strcpy(moo, "Hmm ... ? *yum, grass*");
33-
int r = ps4KernelRun(kmain, kargc, kargv);
33+
// I will also add a ps4KernelRun(Syscall?) that uses the syscall interface instead
34+
int r = ps4KernelRunMain(kmain, kargc, kargv);
3435
printf("return (sceSblACMgrIsVideoplayerProcess): %i\n", r);
3536
printf("moo: %s\n", moo);
3637

@@ -54,15 +55,15 @@ int main(int argc, char **argv)
5455
printf("%02X", ((unsigned char *)moo)[i]);
5556
printf("\n");
5657

57-
r = ps4KernelRun(kmain2, kargc, kargv);
58+
r = ps4KernelRunMain(kmain2, kargc, kargv);
5859
printf("return2 (sceSblACMgrIsVideoplayerProcess): %i\n", r);
5960

6061
ps4KernelMemcpy(moo, sceSblACMgrIsVideoplayerProcess, 32);
6162
for(i = 0; i < 32; ++i)
6263
printf("%02X", ((unsigned char *)moo)[i]);
6364
printf("\n");
6465

65-
r = ps4KernelRun(kmain3, kargc, kargv);
66+
r = ps4KernelRunMain(kmain3, kargc, kargv);
6667
printf("return3 (sceSblACMgrIsVideoplayerProcess): %i\n", r);
6768

6869
ps4KernelMemcpy(moo, sceSblACMgrIsVideoplayerProcess, 32);
@@ -72,5 +73,8 @@ int main(int argc, char **argv)
7273

7374
free(moo); //Bye moo, you did real good :(~
7475

76+
// kernel function called from userland without run
77+
//printf("getnanouptime: %i\n", getnanouptime(0));
78+
7579
return EXIT_SUCCESS;
7680
}

libps4/resolve-intercept/source/main.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#include <math.h>
99

1010
#include <kernel.h>
11-
#include <ps4/internal/resolve.h> // used for fail demonstation
1211
#include <ps4/resolve.h>
1312

1413
typedef unsigned int (*SceKernelSleep)(unsigned int seconds);
@@ -59,8 +58,6 @@ int main(int argc, char **argv)
5958
uint64_t r = 0;
6059
PS4ResolveStatus stat;
6160

62-
//int module = 0; void *symbol = NULL;
63-
6461
// either ps4Resolve or a call before using them in a handler or
6562
// we run into an infinite loop on a resolve interception
6663
//ps4Resolve((void *)strcmp);
@@ -85,9 +82,6 @@ int main(int argc, char **argv)
8582
printf("%i // should be 0 - re-resolve of sceKernelSleep succeeds - also hooked\n", stat);
8683
printf("%i // result of call to hooked sleep\n", sceKernelSleep(2));
8784

88-
// failing symbol lookup
89-
//printf("%i // return of failed foo lookup \n", ps4ResolveModuleAndSymbol("libkernel.sprx", "foo", &module, &symbol));
90-
9185
div_t d = div(128, (int)pow(3.1415, 3));
9286
r = abs(d.quot + d.rem);
9387
sleep(1);

0 commit comments

Comments
 (0)