Skip to content

Commit f99ae34

Browse files
Merge pull request #22 from SKGleba/topr
Added support for 3.71 - 3.73
2 parents 4ef918d + 2159be4 commit f99ae34

File tree

4 files changed

+78
-7
lines changed

4 files changed

+78
-7
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44

55
## Requirements
66

7-
- Your device must already run **HENkaku/h-encore** on firmwares 3.60-3.70 in order to use this software. **ATTENTION: You should NOT attempt downgrading using modoru on FW 3.71-3.73**
7+
- Your device must already run **HENkaku/h-encore** on firmwares 3.60-3.73 in order to use this software.
88
- Your device's battery has be at least at 50%.
99
- All your plugins must be disabled, therefore you will not be able to launch the downgrader from a SD2VITA and hence, you must have a Memory Card (or Internal Storage).
10-
- If you have installed IMCUnlock by SKGleba, it is recommended to uninstall it first before attempting to downgrade.
10+
- If you have installed IMCUnlock by SKGleba, it is recommended to uninstall it first before attempting to downgrade to a firmware lower than 2.10.
1111

1212
## Installation
1313

14-
1. Download and install [modoru.vpk](https://github.com/TheOfficialFloW/modoru/releases/download/v1.0/modoru.vpk) using *VitaShell*.
14+
1. Download and install [modoru.vpk](https://github.com/TheOfficialFloW/modoru/releases/download/v2.1/modoru.vpk) using *VitaShell*.
1515
2. Obtain the `PSP2UPDAT.PUP` file of your desired firmware (make sure that this firmware is officially hackable) and place it at `ux0:app/MODORU000/PSP2UPDAT.PUP` (don't install `modoru.vpk` afterwards, otherwise the update file will be removed).
1616
3. Disable all your plugins. Easiest way is renaming `ux0:tai` and `ur0:tai` to some other name.
1717
4. Reboot your device and relaunch *HENkaku/h-encore*.
@@ -52,6 +52,6 @@ Thank you!
5252
- Thanks to Freakler for the LiveArea design.
5353
- Thanks to liblor for the name suggestion.
5454
- Thanks to yifanlu for prior research on downgrading.
55-
- Thanks to molecule for SCE decryption utilities.
55+
- Thanks to molecule for SCE decryption utilities and secure coprocessor write primitive.
5656
- Thanks to SKGleba for betatesting.
5757

kernel.c

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,46 @@
2323

2424
#define MOD_LIST_SIZE 128
2525

26+
#define NZERO_RANGE(off, end, ctx) \
27+
do { \
28+
int curr = 0; \
29+
while (off + curr < end + 4) { \
30+
nzero32((off + curr), ctx); \
31+
curr = curr + 4; \
32+
} \
33+
} while (0)
34+
35+
typedef struct {
36+
void *addr;
37+
uint32_t length;
38+
} __attribute__((packed)) region_t;
39+
40+
typedef struct {
41+
uint32_t unused_0[2];
42+
uint32_t use_lv2_mode_0; // if 1, use lv2 list
43+
uint32_t use_lv2_mode_1; // if 1, use lv2 list
44+
uint32_t unused_10[3];
45+
uint32_t list_count; // must be < 0x1F1
46+
uint32_t unused_20[4];
47+
uint32_t total_count; // only used in LV1 mode
48+
uint32_t unused_34[1];
49+
union {
50+
region_t lv1[0x1F1];
51+
region_t lv2[0x1F1];
52+
} list;
53+
} __attribute__((packed)) cmd_0x50002_t;
54+
55+
typedef struct heap_hdr {
56+
void *data;
57+
uint32_t size;
58+
uint32_t size_aligned;
59+
uint32_t padding;
60+
struct heap_hdr *prev;
61+
struct heap_hdr *next;
62+
} __attribute__((packed)) heap_hdr_t;
63+
64+
cmd_0x50002_t cargs;
65+
2666
int module_get_export_func(SceUID pid, const char *modname, uint32_t libnid, uint32_t funcnid, uintptr_t *func);
2767

2868
int ksceAppMgrLaunchAppByPath(const char *name, const char *cmd, int cmdlen, int dynamic, void *opt, void *id);
@@ -38,6 +78,8 @@ static tai_hook_ref_t ksceSblSmCommCallFuncRef;
3878

3979
static SceUID hooks[8];
4080

81+
static int doInject = 0;
82+
4183
static int ksceKernelStartPreloadedModulesPatched(SceUID pid) {
4284
int res = TAI_CONTINUE(int, ksceKernelStartPreloadedModulesRef, pid);
4385

@@ -97,7 +139,28 @@ static int ksceSblSsInfraAllocatePARangeVectorPatched(void *buf, int size, SceUI
97139
return TAI_CONTINUE(int, ksceSblSsInfraAllocatePARangeVectorRef, buf, size, blockid, list);
98140
}
99141

142+
static int nzero32(uint32_t addr, int ctx) {
143+
int ret = 0, sm_ret = 0;
144+
memset(&cargs, 0, sizeof(cargs));
145+
cargs.use_lv2_mode_0 = cargs.use_lv2_mode_1 = 0;
146+
cargs.list_count = 3;
147+
cargs.total_count = 1;
148+
cargs.list.lv1[0].addr = cargs.list.lv1[1].addr = 0x50000000;
149+
cargs.list.lv1[0].length = cargs.list.lv1[1].length = 0x10;
150+
cargs.list.lv1[2].addr = 0;
151+
cargs.list.lv1[2].length = addr - offsetof(heap_hdr_t, next);
152+
ret = TAI_CONTINUE(int, ksceSblSmCommCallFuncRef, ctx, 0x50002, &sm_ret, &cargs, sizeof(cargs));
153+
if (sm_ret < 0) {
154+
return sm_ret;
155+
}
156+
return ret;
157+
}
158+
100159
static int ksceSblSmCommCallFuncPatched(int id, int service_id, int *f00d_resp, void *data, int size) {
160+
161+
if (doInject == 1 && service_id == 0xb0002)
162+
NZERO_RANGE(0x0080bb44, 0x0080bb98, id);
163+
101164
int res = TAI_CONTINUE(int, ksceSblSmCommCallFuncRef, id, service_id, f00d_resp, data, size);
102165

103166
if (f00d_resp && service_id == SCE_SBL_SM_COMM_FID_SM_AUTH_SPKG) {
@@ -310,8 +373,11 @@ int k_modoru_get_factory_firmware(void) {
310373
unsigned int factory_fw = -1;
311374

312375
void *sysroot = ksceKernelGetSysrootBuffer();
313-
if (sysroot)
376+
if (sysroot) {
314377
factory_fw = *(unsigned int *)(sysroot + 8);
378+
if (*(unsigned int *)(sysroot + 4) > 0x03700011)
379+
doInject = 1;
380+
}
315381

316382
EXIT_SYSCALL(state);
317383
return factory_fw;

main.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ int main(int argc, char *argv[]) {
264264
psvDebugScreenInit();
265265
sceKernelPowerLock(0);
266266

267-
printf("-- modoru v1.0\n");
267+
printf("-- modoru v2.1\n");
268268
printf(" by TheFloW\n\n");
269269

270270
if (sceIoDevctl("ux0:", 0x3001, NULL, 0, NULL, 0) == 0x80010030)
@@ -344,6 +344,11 @@ int main(int argc, char *argv[]) {
344344
if (target_version < factory_version)
345345
ErrorExit(10000, "Error you cannot go lower than your factory firmware.");
346346

347+
if (!bypass) {
348+
if (current_version > 0x03730011)
349+
ErrorExit(10000, "Error your current system software version is not supported.");
350+
}
351+
347352
if (target_version == current_version) {
348353
printf("Do you want to reinstall firmware ");
349354
psvDebugScreenSetTextColor(YELLOW);

pkg/template.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<frame id="frame4">
2121
<liveitem>
2222
<text align="left" text-align="left" word-wrap="off" ellipsis="on">
23-
<str size="18" color="#000000" shadow="off">v1.0</str>
23+
<str size="18" color="#000000" shadow="off">v2.1</str>
2424
</text>
2525
</liveitem>
2626
</frame>

0 commit comments

Comments
 (0)