mirror of
https://github.com/wiiu-env/homebrew_launcher.git
synced 2024-11-16 17:59:18 +01:00
adaption to keep the sd_loader equal for RPX and ELF HBL versions
This commit is contained in:
parent
1a99264ab5
commit
ca7ece167f
@ -1,8 +1,8 @@
|
||||
#include <gctypes.h>
|
||||
#include "elf_abi.h"
|
||||
#include "../../src/common/common.h"
|
||||
#include "../../src/common/fs_defs.h"
|
||||
#include "../../src/common/os_defs.h"
|
||||
#include "fs_defs.h"
|
||||
#include "kernel_defs.h"
|
||||
#include "loader_defs.h"
|
||||
|
||||
@ -447,6 +447,26 @@ static int LoadFileToMem(private_data_t *private_data, const char *filepath, uns
|
||||
return success;
|
||||
}
|
||||
|
||||
static void setup_patches(private_data_t *private_data)
|
||||
{
|
||||
//! setup necessary syscalls and hooks for HBL
|
||||
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl1 + (0x25 * 4)), (unsigned int)KernelCopyData);
|
||||
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl2 + (0x25 * 4)), (unsigned int)KernelCopyData);
|
||||
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl3 + (0x25 * 4)), (unsigned int)KernelCopyData);
|
||||
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl4 + (0x25 * 4)), (unsigned int)KernelCopyData);
|
||||
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl5 + (0x25 * 4)), (unsigned int)KernelCopyData);
|
||||
|
||||
//! store physical address for later use
|
||||
addrphys_LiWaitOneChunk = private_data->OSEffectiveToPhysical((void*)OS_SPECIFICS->addr_LiWaitOneChunk);
|
||||
|
||||
u32 addr_my_PrepareTitle_hook = ((u32)my_PrepareTitle_hook) | 0x48000003;
|
||||
DCFlushRange(&addr_my_PrepareTitle_hook, 4);
|
||||
|
||||
//! create our copy syscall
|
||||
SC0x25_KernelCopyData(OS_SPECIFICS->addr_PrepareTitle_hook, private_data->OSEffectiveToPhysical(&addr_my_PrepareTitle_hook), 4);
|
||||
|
||||
}
|
||||
|
||||
static unsigned int load_elf_image (private_data_t *private_data, unsigned char *elfstart)
|
||||
{
|
||||
Elf32_Ehdr *ehdr;
|
||||
@ -502,22 +522,6 @@ static unsigned int load_elf_image (private_data_t *private_data, unsigned char
|
||||
}
|
||||
}
|
||||
|
||||
//! setup hooks
|
||||
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl1 + (0x25 * 4)), (unsigned int)KernelCopyData);
|
||||
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl2 + (0x25 * 4)), (unsigned int)KernelCopyData);
|
||||
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl3 + (0x25 * 4)), (unsigned int)KernelCopyData);
|
||||
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl4 + (0x25 * 4)), (unsigned int)KernelCopyData);
|
||||
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl5 + (0x25 * 4)), (unsigned int)KernelCopyData);
|
||||
|
||||
//! store physical address for later use
|
||||
addrphys_LiWaitOneChunk = private_data->OSEffectiveToPhysical((void*)OS_SPECIFICS->addr_LiWaitOneChunk);
|
||||
|
||||
u32 addr_my_PrepareTitle_hook = ((u32)my_PrepareTitle_hook) | 0x48000003;
|
||||
DCFlushRange(&addr_my_PrepareTitle_hook, 4);
|
||||
|
||||
//! create our copy syscall
|
||||
SC0x25_KernelCopyData(OS_SPECIFICS->addr_PrepareTitle_hook, private_data->OSEffectiveToPhysical(&addr_my_PrepareTitle_hook), 4);
|
||||
|
||||
return ehdr->e_entry;
|
||||
}
|
||||
|
||||
@ -593,6 +597,9 @@ int _start(int argc, char **argv)
|
||||
|
||||
if(MAIN_ENTRY_ADDR == 0xDEADC0DE || MAIN_ENTRY_ADDR == 0)
|
||||
{
|
||||
//! setup necessary syscalls and hooks for HBL before launching it
|
||||
setup_patches(&private_data);
|
||||
|
||||
if(HBL_CHANNEL)
|
||||
{
|
||||
break;
|
||||
|
62
sd_loader/src/fs_defs.h
Normal file
62
sd_loader/src/fs_defs.h
Normal file
@ -0,0 +1,62 @@
|
||||
#ifndef FS_DEFS_H
|
||||
#define FS_DEFS_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* FS defines and types */
|
||||
#define FS_MAX_LOCALPATH_SIZE 511
|
||||
#define FS_MAX_MOUNTPATH_SIZE 128
|
||||
#define FS_MAX_FULLPATH_SIZE (FS_MAX_LOCALPATH_SIZE + FS_MAX_MOUNTPATH_SIZE)
|
||||
#define FS_MAX_ARGPATH_SIZE FS_MAX_FULLPATH_SIZE
|
||||
|
||||
#define FS_STATUS_OK 0
|
||||
#define FS_RET_UNSUPPORTED_CMD 0x0400
|
||||
#define FS_RET_NO_ERROR 0x0000
|
||||
#define FS_RET_ALL_ERROR (unsigned int)(-1)
|
||||
|
||||
#define FS_STAT_FLAG_IS_DIRECTORY 0x80000000
|
||||
|
||||
/* max length of file/dir name */
|
||||
#define FS_MAX_ENTNAME_SIZE 256
|
||||
|
||||
#define FS_SOURCETYPE_EXTERNAL 0
|
||||
#define FS_SOURCETYPE_HFIO 1
|
||||
#define FS_SOURCETYPE_HFIO 1
|
||||
|
||||
#define FS_MOUNT_SOURCE_SIZE 0x300
|
||||
#define FS_CLIENT_SIZE 0x1700
|
||||
#define FS_CMD_BLOCK_SIZE 0xA80
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t flag;
|
||||
uint32_t permission;
|
||||
uint32_t owner_id;
|
||||
uint32_t group_id;
|
||||
uint32_t size;
|
||||
uint32_t alloc_size;
|
||||
uint64_t quota_size;
|
||||
uint32_t ent_id;
|
||||
uint64_t ctime;
|
||||
uint64_t mtime;
|
||||
uint8_t attributes[48];
|
||||
} __attribute__((packed)) FSStat;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
FSStat stat;
|
||||
char name[FS_MAX_ENTNAME_SIZE];
|
||||
} FSDirEntry;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* FS_DEFS_H */
|
||||
|
Loading…
Reference in New Issue
Block a user