mirror of
https://github.com/wiidev/usbloadergx.git
synced 2024-11-15 16:05:10 +01:00
0e7d37b18b
*Fixed freeze in theme menu when its empty *Optimized the game list loading on fat/ntfs/ext. This should speed up the loading process. *Added cache of game titles. This will speed up the startup after the cache file is written (in other words on second start of this rev). A TitlesCache.bin will be created in the same path as the wiitdb.xml for this. This should especial speed up the startup of fat/ntfs/ext partitions by a lot if no sub folders with the game titles are used, like GAMEID.wbfs only. That must have been painfully slow before on a lot of games. Should be at about the same speed as with sub folders now. I would still recommend to use sub folders. *Removed wiilight (disc slot) blinking when switching USB port on Hermes cIOSes (thanks rodries) *Added the ehcmodule sources from rodries to the branches *Updated language files
79 lines
3.1 KiB
C
79 lines
3.1 KiB
C
// Copyright 2010 Joseph Jordan <joe.ftpii@psychlaw.com.au>
|
|
// This code is licensed to you under the terms of the GNU GPL, version 2;
|
|
// see file COPYING or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
|
|
|
|
// Some modifications taken from dop-mii. Credits to them
|
|
#include <gccore.h>
|
|
#include <ogc/machine/processor.h>
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include "runtime_ios_patch.h"
|
|
|
|
#define MEM_REG_BASE 0xd8b4000
|
|
#define MEM_PROT (MEM_REG_BASE + 0x20a)
|
|
|
|
static void disable_memory_protection() {
|
|
write32(MEM_PROT, read32(MEM_PROT) & 0x0000FFFF);
|
|
}
|
|
|
|
static u32 apply_patch(char *name, const u8 *old, u32 old_size, const u8 *patch, u32 patch_size, u32 patch_offset) {
|
|
u8 *ptr = (u8 *)0x93400000;
|
|
u32 found = 0;
|
|
u8 *location = NULL;
|
|
while ((u32)ptr < (0x94000000 - patch_size)) {
|
|
if (!memcmp(ptr, old, old_size)) {
|
|
found++;
|
|
location = ptr + patch_offset;
|
|
u8 *start = location;
|
|
u32 i;
|
|
for (i = 0; i < patch_size; i++) {
|
|
*location++ = patch[i];
|
|
}
|
|
DCFlushRange((u8 *)(((u32)start) >> 5 << 5), (patch_size >> 5 << 5) + 64);
|
|
ICInvalidateRange((u8 *)(((u32)start) >> 5 << 5), (patch_size >> 5 << 5) + 64);
|
|
}
|
|
ptr++;
|
|
}
|
|
if (found) {
|
|
printf("\b..");
|
|
} else {
|
|
printf("\b!.");
|
|
}
|
|
return found;
|
|
}
|
|
|
|
static const u8 di_readlimit_old[] = {
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x0A, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
|
|
0x7E, 0xD4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08
|
|
};
|
|
static const u8 di_readlimit_patch[] = { 0x7e, 0xd4 };
|
|
|
|
const u8 isfs_permissions_old[] = { 0x42, 0x8B, 0xD0, 0x01, 0x25, 0x66 };
|
|
const u8 isfs_permissions_patch[] = { 0x42, 0x8B, 0xE0, 0x01, 0x25, 0x66 };
|
|
static const u8 setuid_old[] = { 0xD1, 0x2A, 0x1C, 0x39 };
|
|
static const u8 setuid_patch[] = { 0x46, 0xC0 };
|
|
const u8 es_identify_old[] = { 0x28, 0x03, 0xD1, 0x23 };
|
|
const u8 es_identify_patch[] = { 0x00, 0x00 };
|
|
const u8 hash_old[] = { 0x20, 0x07, 0x23, 0xA2 };
|
|
const u8 hash_patch[] = { 0x00 };
|
|
const u8 new_hash_old[] = { 0x20, 0x07, 0x4B, 0x0B };
|
|
|
|
u32 IOSPATCH_Apply() {
|
|
printf("\n\n");
|
|
u32 count = 0;
|
|
if (HAVE_AHBPROT) {
|
|
disable_memory_protection();
|
|
count += apply_patch("di_readlimit", di_readlimit_old, sizeof(di_readlimit_old), di_readlimit_patch, sizeof(di_readlimit_patch), 12);
|
|
count += apply_patch("isfs_permissions", isfs_permissions_old, sizeof(isfs_permissions_old), isfs_permissions_patch, sizeof(isfs_permissions_patch), 0);
|
|
count += apply_patch("es_setuid", setuid_old, sizeof(setuid_old), setuid_patch, sizeof(setuid_patch), 0);
|
|
count += apply_patch("es_identify", es_identify_old, sizeof(es_identify_old), es_identify_patch, sizeof(es_identify_patch), 2);
|
|
count += apply_patch("hash_check", hash_old, sizeof(hash_old), hash_patch, sizeof(hash_patch), 1);
|
|
count += apply_patch("new_hash_check", new_hash_old, sizeof(new_hash_old), hash_patch, sizeof(hash_patch), 1);
|
|
}
|
|
return count;
|
|
}
|