mirror of
https://github.com/joel16/leda.git
synced 2024-11-23 03:29:46 +00:00
leda: Initial commit
This commit is contained in:
commit
389c578006
52
.gitignore
vendored
Normal file
52
.gitignore
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
# Prerequisites
|
||||
*.d
|
||||
|
||||
# Object files
|
||||
*.o
|
||||
*.ko
|
||||
*.obj
|
||||
*.elf
|
||||
|
||||
# Linker output
|
||||
*.ilk
|
||||
*.map
|
||||
|
||||
# Precompiled Headers
|
||||
*.gch
|
||||
*.pch
|
||||
|
||||
# Libraries
|
||||
*.lib
|
||||
*.la
|
||||
*.lo
|
||||
libs/lib/libpspsystemctrl_kernel.a
|
||||
|
||||
# Shared objects (inc. Windows DLLs)
|
||||
*.dll
|
||||
*.so
|
||||
*.so.*
|
||||
*.dylib
|
||||
|
||||
# Executables
|
||||
*.exe
|
||||
*.out
|
||||
*.app
|
||||
*.i*86
|
||||
*.x86_64
|
||||
*.hex
|
||||
*.prx
|
||||
|
||||
# Debug files
|
||||
*.dSYM/
|
||||
*.su
|
||||
*.idb
|
||||
*.pdb
|
||||
|
||||
# Kernel Module Compile Results
|
||||
*.mod*
|
||||
*.cmd
|
||||
.tmp_versions/
|
||||
modules.order
|
||||
Module.symvers
|
||||
Mkfile.old
|
||||
dkms.conf
|
7
Makefile
Normal file
7
Makefile
Normal file
@ -0,0 +1,7 @@
|
||||
SUBDIRS = libpspsystemctrl_kernel plugin
|
||||
|
||||
all:
|
||||
@for dir in $(SUBDIRS); do $(MAKE) -C $$dir; done
|
||||
|
||||
clean:
|
||||
@for dir in $(SUBDIRS); do $(MAKE) clean -C $$dir; done
|
15
README.md
Normal file
15
README.md
Normal file
@ -0,0 +1,15 @@
|
||||
# LEDA Reverse Engineering Project
|
||||
|
||||
This is a reverse engineered version of LEDA - Legacy Software Loader, version 0.1, by Dark_AleX.
|
||||
|
||||
|
||||
# How you can help:
|
||||
1. Get a copy of leda.prx from the [latest ME version 2.3](http://www.mediafire.com/download/6cz8ofj44a42wme/release_661me2.3+%28OFW+Version%29.zip)
|
||||
2. Extract leda.prx and load it into your favourite hex editor.
|
||||
3. Find the gzip magic (0x1F 0x8B 08 00 ...) and copy everything from the magic to the end of the file and save it as a new PRX file (leda_dec.prx).
|
||||
4. Disassemble the new prx with prxtool ``prxtool -w leda_dec.prx -o leda_dec.txt``
|
||||
5. Start Reversing :P
|
||||
|
||||
|
||||
# Credits:
|
||||
- Valantin/leda: https://github.com/Valantin/leda/blob/master/leda.c
|
14
libpspsystemctrl_kernel/Makefile
Normal file
14
libpspsystemctrl_kernel/Makefile
Normal file
@ -0,0 +1,14 @@
|
||||
PSPSDK=$(shell psp-config --pspsdk-path)
|
||||
OBJS = SystemCtrlForKernel_0000.o SystemCtrlForKernel_0001.o SystemCtrlForKernel_0002.o SystemCtrlForKernel_0003.o SystemCtrlForKernel_0004.o SystemCtrlForKernel_0005.o SystemCtrlForKernel_0006.o SystemCtrlForKernel_0007.o SystemCtrlForKernel_0008.o SystemCtrlForKernel_0009.o SystemCtrlForKernel_0010.o SystemCtrlForKernel_0011.o SystemCtrlForKernel_0012.o SystemCtrlForKernel_0013.o SystemCtrlForKernel_0014.o SystemCtrlForKernel_0015.o SystemCtrlForKernel_0016.o SystemCtrlForKernel_0017.o SystemCtrlForKernel_0018.o SystemCtrlForKernel_0019.o SystemCtrlForKernel_0020.o SystemCtrlForKernel_0021.o SystemCtrlForKernel_0022.o SystemCtrlForKernel_0023.o SystemCtrlForKernel_0024.o SystemCtrlForKernel_0025.o SystemCtrlForKernel_0026.o SystemCtrlForKernel_0027.o SystemCtrlForKernel_0028.o SystemCtrlForKernel_0029.o SystemCtrlForKernel_0030.o SystemCtrlForKernel_0031.o SystemCtrlForKernel_0032.o SystemCtrlForKernel_0033.o SystemCtrlForKernel_0034.o SystemCtrlForKernel_0035.o SystemCtrlForKernel_0036.o SystemCtrlForKernel_0037.o SystemCtrlForKernel_0038.o SystemCtrlForKernel_0039.o SystemCtrlForKernel_0040.o SystemCtrlForKernel_0041.o
|
||||
|
||||
%.o: SystemCtrlForKernel.S
|
||||
psp-gcc -g -O2 -G0 -Wall -I${PSPSDK}/include -DF_$* $< -c -o $@
|
||||
|
||||
all: $(OBJS)
|
||||
psp-ar cru libpspsystemctrl_kernel.a $(OBJS)
|
||||
psp-ranlib libpspsystemctrl_kernel.a
|
||||
mv libpspsystemctrl_kernel.a "../libs/lib/"
|
||||
|
||||
clean:
|
||||
rm -f *.o
|
||||
rm -f *.a
|
133
libpspsystemctrl_kernel/SystemCtrlForKernel.S
Normal file
133
libpspsystemctrl_kernel/SystemCtrlForKernel.S
Normal file
@ -0,0 +1,133 @@
|
||||
.set noreorder
|
||||
|
||||
#include "pspimport.s"
|
||||
|
||||
// Build files
|
||||
// SystemCtrlForKernel_0000.o SystemCtrlForKernel_0001.o SystemCtrlForKernel_0002.o SystemCtrlForKernel_0003.o SystemCtrlForKernel_0004.o SystemCtrlForKernel_0005.o SystemCtrlForKernel_0006.o SystemCtrlForKernel_0007.o SystemCtrlForKernel_0008.o SystemCtrlForKernel_0009.o SystemCtrlForKernel_0010.o SystemCtrlForKernel_0011.o SystemCtrlForKernel_0012.o SystemCtrlForKernel_0013.o SystemCtrlForKernel_0014.o SystemCtrlForKernel_0015.o SystemCtrlForKernel_0016.o SystemCtrlForKernel_0017.o SystemCtrlForKernel_0018.o SystemCtrlForKernel_0019.o SystemCtrlForKernel_0020.o SystemCtrlForKernel_0021.o SystemCtrlForKernel_0022.o SystemCtrlForKernel_0023.o SystemCtrlForKernel_0024.o SystemCtrlForKernel_0025.o SystemCtrlForKernel_0026.o SystemCtrlForKernel_0027.o SystemCtrlForKernel_0028.o SystemCtrlForKernel_0029.o SystemCtrlForKernel_0030.o SystemCtrlForKernel_0031.o SystemCtrlForKernel_0032.o SystemCtrlForKernel_0033.o SystemCtrlForKernel_0034.o SystemCtrlForKernel_0035.o SystemCtrlForKernel_0036.o SystemCtrlForKernel_0037.o SystemCtrlForKernel_0038.o SystemCtrlForKernel_0039.o SystemCtrlForKernel_0040.o SystemCtrlForKernel_0041.o
|
||||
|
||||
#ifdef F_SystemCtrlForKernel_0000
|
||||
IMPORT_START "SystemCtrlForKernel",0x00090000
|
||||
#endif
|
||||
#ifdef F_SystemCtrlForKernel_0001
|
||||
IMPORT_FUNC "SystemCtrlForKernel",0xEB74FE45,sctrlKernelSetUserLevel
|
||||
#endif
|
||||
#ifdef F_SystemCtrlForKernel_0002
|
||||
IMPORT_FUNC "SystemCtrlForKernel",0xD339E2E9,sctrlHENIsSE
|
||||
#endif
|
||||
#ifdef F_SystemCtrlForKernel_0003
|
||||
IMPORT_FUNC "SystemCtrlForKernel",0x2E2935EF,sctrlHENIsDevhook
|
||||
#endif
|
||||
#ifdef F_SystemCtrlForKernel_0004
|
||||
IMPORT_FUNC "SystemCtrlForKernel",0x1090A2E1,sctrlHENGetVersion
|
||||
#endif
|
||||
#ifdef F_SystemCtrlForKernel_0005
|
||||
IMPORT_FUNC "SystemCtrlForKernel",0x78E46415,sctrlHENFindDriver
|
||||
#endif
|
||||
#ifdef F_SystemCtrlForKernel_0006
|
||||
IMPORT_FUNC "SystemCtrlForKernel",0x159AF5CC,sctrlHENFindFunction
|
||||
#endif
|
||||
#ifdef F_SystemCtrlForKernel_0007
|
||||
IMPORT_FUNC "SystemCtrlForKernel",0xB47C9D77,sctrlSEGetVersion
|
||||
#endif
|
||||
#ifdef F_SystemCtrlForKernel_0008
|
||||
IMPORT_FUNC "SystemCtrlForKernel",0x2794CCF4,sctrlKernelExitVSH
|
||||
#endif
|
||||
#ifdef F_SystemCtrlForKernel_0009
|
||||
IMPORT_FUNC "SystemCtrlForKernel",0x577AF198,sctrlKernelLoadExecVSHDisc
|
||||
#endif
|
||||
#ifdef F_SystemCtrlForKernel_0010
|
||||
IMPORT_FUNC "SystemCtrlForKernel",0x94FE5E4B,sctrlKernelLoadExecVSHDiscUpdater
|
||||
#endif
|
||||
#ifdef F_SystemCtrlForKernel_0011
|
||||
IMPORT_FUNC "SystemCtrlForKernel",0x75643FCA,sctrlKernelLoadExecVSHMs1
|
||||
#endif
|
||||
#ifdef F_SystemCtrlForKernel_0012
|
||||
IMPORT_FUNC "SystemCtrlForKernel",0xABA7F1B0,sctrlKernelLoadExecVSHMs2
|
||||
#endif
|
||||
#ifdef F_SystemCtrlForKernel_0013
|
||||
IMPORT_FUNC "SystemCtrlForKernel",0x7B369596,sctrlKernelLoadExecVSHMs3
|
||||
#endif
|
||||
#ifdef F_SystemCtrlForKernel_0014
|
||||
IMPORT_FUNC "SystemCtrlForKernel",0xD690750F,sctrlKernelLoadExecVSHMs4
|
||||
#endif
|
||||
#ifdef F_SystemCtrlForKernel_0015
|
||||
IMPORT_FUNC "SystemCtrlForKernel",0x2D10FB28,sctrlKernelLoadExecVSHWithApitype
|
||||
#endif
|
||||
#ifdef F_SystemCtrlForKernel_0016
|
||||
IMPORT_FUNC "SystemCtrlForKernel",0x1DDDAD0C,sctrlSESetConfig
|
||||
#endif
|
||||
#ifdef F_SystemCtrlForKernel_0017
|
||||
IMPORT_FUNC "SystemCtrlForKernel",0x16C3B7EE,sctrlSEGetConfig
|
||||
#endif
|
||||
#ifdef F_SystemCtrlForKernel_0018
|
||||
IMPORT_FUNC "SystemCtrlForKernel",0xAD4D5EA5,sctrlSESetConfigEx
|
||||
#endif
|
||||
#ifdef F_SystemCtrlForKernel_0019
|
||||
IMPORT_FUNC "SystemCtrlForKernel",0x8E426F09,sctrlSEGetConfigEx
|
||||
#endif
|
||||
#ifdef F_SystemCtrlForKernel_0020
|
||||
IMPORT_FUNC "SystemCtrlForKernel",0x85B520C6,sctrlSEMountUmdFromFile
|
||||
#endif
|
||||
#ifdef F_SystemCtrlForKernel_0021
|
||||
IMPORT_FUNC "SystemCtrlForKernel",0x1C90BECB,sctrlHENSetStartModuleHandler
|
||||
#endif
|
||||
#ifdef F_SystemCtrlForKernel_0022
|
||||
IMPORT_FUNC "SystemCtrlForKernel",0x745286D1,sctrlHENSetMemory
|
||||
#endif
|
||||
#ifdef F_SystemCtrlForKernel_0023
|
||||
IMPORT_FUNC "SystemCtrlForKernel",0xAC56B90B,GetUmdFile
|
||||
#endif
|
||||
#ifdef F_SystemCtrlForKernel_0024
|
||||
IMPORT_FUNC "SystemCtrlForKernel",0xB64186D0,SetUmdFile
|
||||
#endif
|
||||
#ifdef F_SystemCtrlForKernel_0025
|
||||
IMPORT_FUNC "SystemCtrlForKernel",0x5CB025F0,sctrlSESetBootConfFileIndex
|
||||
#endif
|
||||
#ifdef F_SystemCtrlForKernel_0026
|
||||
IMPORT_FUNC "SystemCtrlForKernel",0xCE0A654E,sctrlHENLoadModuleOnReboot
|
||||
#endif
|
||||
#ifdef F_SystemCtrlForKernel_0027
|
||||
IMPORT_FUNC "SystemCtrlForKernel",0xF9584CAD,oe_malloc
|
||||
#endif
|
||||
#ifdef F_SystemCtrlForKernel_0028
|
||||
IMPORT_FUNC "SystemCtrlForKernel",0xA65E8BC4,oe_free
|
||||
#endif
|
||||
#ifdef F_SystemCtrlForKernel_0029
|
||||
IMPORT_FUNC "SystemCtrlForKernel",0xF988C1DC,sctrlHENPatchSyscall
|
||||
#endif
|
||||
#ifdef F_SystemCtrlForKernel_0030
|
||||
IMPORT_FUNC "SystemCtrlForKernel",0x826668E9,sctrlHENPatchSyscall
|
||||
#endif
|
||||
#ifdef F_SystemCtrlForKernel_0031
|
||||
IMPORT_FUNC "SystemCtrlForKernel",0x02BFCB5F,sctrlHENPatchSyscall
|
||||
#endif
|
||||
#ifdef F_SystemCtrlForKernel_0032
|
||||
IMPORT_FUNC "SystemCtrlForKernel",0x98012538,SetSpeed
|
||||
#endif
|
||||
#ifdef F_SystemCtrlForKernel_0033
|
||||
IMPORT_FUNC "SystemCtrlForKernel",0x2F157BAF,SetConfig
|
||||
#endif
|
||||
#ifdef F_SystemCtrlForKernel_0034
|
||||
IMPORT_FUNC "SystemCtrlForKernel",0x56CEAF00,sctrlKernelQuerySystemCall
|
||||
#endif
|
||||
#ifdef F_SystemCtrlForKernel_0035
|
||||
IMPORT_FUNC "SystemCtrlForKernel",0x07232EA5,sctrlHENRegisterHomebrewLoader
|
||||
#endif
|
||||
#ifdef F_SystemCtrlForKernel_0036
|
||||
IMPORT_FUNC "SystemCtrlForKernel",0xB86E36D1,ApplyMemory
|
||||
#endif
|
||||
#ifdef F_SystemCtrlForKernel_0037
|
||||
IMPORT_FUNC "SystemCtrlForKernel",0x05D8E209,sctrlGetUsbState
|
||||
#endif
|
||||
#ifdef F_SystemCtrlForKernel_0038
|
||||
IMPORT_FUNC "SystemCtrlForKernel",0x80C0ED7B,sctrlStartUsb
|
||||
#endif
|
||||
#ifdef F_SystemCtrlForKernel_0039
|
||||
IMPORT_FUNC "SystemCtrlForKernel",0x5FC12767,sctrlStopUsb
|
||||
#endif
|
||||
#ifdef F_SystemCtrlForKernel_0040
|
||||
IMPORT_FUNC "SystemCtrlForKernel",0x053172F8,sctrlRebootDevice
|
||||
#endif
|
||||
#ifdef F_SystemCtrlForKernel_0041
|
||||
IMPORT_FUNC "SystemCtrlForKernel",0x7021205F,sctrlGetTitleid
|
||||
#endif
|
182
libs/include/kubridge.h
Normal file
182
libs/include/kubridge.h
Normal file
@ -0,0 +1,182 @@
|
||||
#ifndef __KULIBRARY__
|
||||
#define __KULIBRARY__
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <pspsdk.h>
|
||||
#include <pspkernel.h>
|
||||
#include <pspsysmem_kernel.h>
|
||||
#include <pspctrl.h>
|
||||
|
||||
/**
|
||||
* Functions to let user mode access certain functions only available in
|
||||
* kernel mode
|
||||
*/
|
||||
|
||||
/**
|
||||
* Load a module using ModuleMgrForKernel.
|
||||
*
|
||||
* @param path - The path to the module to load.
|
||||
* @param flags - Unused, always 0 .
|
||||
* @param option - Pointer to a mod_param_t structure. Can be NULL.
|
||||
*
|
||||
* @returns The UID of the loaded module on success, otherwise one of ::PspKernelErrorCodes.
|
||||
*/
|
||||
SceUID kuKernelLoadModule(const char *path, int flags, SceKernelLMOption *option);
|
||||
|
||||
|
||||
/**
|
||||
* Load a module with a specific apitype
|
||||
*
|
||||
* @param ap<EFBFBD>type - The apitype
|
||||
* @param path - The path to the module to load.
|
||||
* @param flags - Unused, always 0 .
|
||||
* @param option - Pointer to a mod_param_t structure. Can be NULL.
|
||||
*
|
||||
* @returns The UID of the loaded module on success, otherwise one of ::PspKernelErrorCodes.
|
||||
*/
|
||||
SceUID kuKernelLoadModuleWithApitype2(int apitype, const char *path, int flags, SceKernelLMOption *option);
|
||||
|
||||
/**
|
||||
* Gets the api type
|
||||
*
|
||||
* @returns the api type in which the system has booted
|
||||
*/
|
||||
int kuKernelInitApitype();
|
||||
|
||||
/**
|
||||
* Gets the filename of the executable to be launched after all modules of the api.
|
||||
*
|
||||
* @param initfilename - String where copy the initfilename
|
||||
* @returns 0 on success
|
||||
*/
|
||||
int kuKernelInitFileName(char *initfilename);
|
||||
|
||||
/**
|
||||
*
|
||||
* Gets the device in which the application was launched.
|
||||
*
|
||||
* @returns the device code, one of PSPBootFrom values.
|
||||
*/
|
||||
int kuKernelBootFrom();
|
||||
|
||||
/**
|
||||
* Get the key configuration in which the system has booted.
|
||||
*
|
||||
* @returns the key configuration code, one of PSPKeyConfig values
|
||||
*/
|
||||
int kuKernelInitKeyConfig();
|
||||
|
||||
/**
|
||||
* Get the user level of the current thread
|
||||
*
|
||||
* @return The user level, < 0 on error
|
||||
*/
|
||||
int kuKernelGetUserLevel(void);
|
||||
|
||||
/**
|
||||
* Set the protection of a block of ddr memory
|
||||
*
|
||||
* @param addr - Address to set protection on
|
||||
* @param size - Size of block
|
||||
* @param prot - Protection bitmask
|
||||
*
|
||||
* @return < 0 on error
|
||||
*/
|
||||
int kuKernelSetDdrMemoryProtection(void *addr, int size, int prot);
|
||||
|
||||
/**
|
||||
* Gets the model of the PSP from user mode.
|
||||
* This function is available since 3.60 M33.
|
||||
* In previous version, use the kernel function sceKernelGetModel
|
||||
*
|
||||
* @return one of PspModel values
|
||||
*/
|
||||
int kuKernelGetModel(void);
|
||||
|
||||
/**
|
||||
* Find module by name
|
||||
*
|
||||
* @param modname - Name of Module
|
||||
* @param mod - module structure for output (actually treated as SceModule2)
|
||||
*
|
||||
* @return < 0 on error
|
||||
*/
|
||||
int kuKernelFindModuleByName(char *modname, SceModule *mod);
|
||||
|
||||
/**
|
||||
* Invalidate the entire instruction cache
|
||||
*/
|
||||
void kuKernelIcacheInvalidateAll(void);
|
||||
|
||||
/**
|
||||
* Read 4 bytes from memory (with kernel memory access)
|
||||
*
|
||||
* @param addr - Address to read, must have 4 bytes alignment
|
||||
*/
|
||||
u32 kuKernelPeekw(void *addr);
|
||||
|
||||
/**
|
||||
* Write 4 bytes to memory (with kernel memory access)
|
||||
*
|
||||
* @param addr - Address to write, must have 4 bytes alignment
|
||||
*/
|
||||
void kuKernelPokew(void *addr, u32 value);
|
||||
|
||||
/**
|
||||
* memcpy (with kernel memory access)
|
||||
*
|
||||
* @param dest - Destination address
|
||||
* @param src - Source address
|
||||
* @param num - copy bytes count
|
||||
*
|
||||
* @return Destination address
|
||||
*/
|
||||
void *kuKernelMemcpy(void *dest, const void *src, size_t num);
|
||||
|
||||
struct KernelCallArg {
|
||||
u32 arg1;
|
||||
u32 arg2;
|
||||
u32 arg3;
|
||||
u32 arg4;
|
||||
u32 arg5;
|
||||
u32 arg6;
|
||||
u32 arg7;
|
||||
u32 arg8;
|
||||
u32 arg9;
|
||||
u32 arg10;
|
||||
u32 arg11;
|
||||
u32 arg12;
|
||||
u32 ret1;
|
||||
u32 ret2;
|
||||
};
|
||||
|
||||
/**
|
||||
* Call a kernel function with kernel privilege
|
||||
*
|
||||
* @param func_addr - kernel function address
|
||||
* @param args - kernel arguments and return values
|
||||
*
|
||||
* return < 0 on error
|
||||
*/
|
||||
int kuKernelCall(void *func_addr, struct KernelCallArg *args);
|
||||
|
||||
/**
|
||||
* Call a kernel function with kernel privilege and extended stack
|
||||
*
|
||||
* @param func_addr - kernel function address
|
||||
* @param args - kernel arguments and return values
|
||||
*
|
||||
* return < 0 on error
|
||||
*/
|
||||
int kuKernelCallExtendStack(void *func_addr, struct KernelCallArg *args, int stack_size);
|
||||
|
||||
void kuKernelGetUmdFile(char *umdfile, int size);
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
BIN
libs/lib/libpspkubridge.a
Normal file
BIN
libs/lib/libpspkubridge.a
Normal file
Binary file not shown.
24
plugin/Makefile
Normal file
24
plugin/Makefile
Normal file
@ -0,0 +1,24 @@
|
||||
TARGET = leda
|
||||
OBJS = leda.o exports.o stubs/InterruptManagerForKernel.o stubs/ModuleMgrForUser.o stubs/sceLoaderCore.o
|
||||
|
||||
PRX_EXPORTS = exports.exp
|
||||
|
||||
PSP_FW_VERSION = 660
|
||||
|
||||
# Use the kernel's small inbuilt libc
|
||||
USE_KERNEL_LIBC = 1
|
||||
# Use only kernel libraries
|
||||
USE_KERNEL_LIBS = 1
|
||||
|
||||
INCDIR = ../libs/include
|
||||
CFLAGS = -Os -G0 -Wall -fno-builtin-printf
|
||||
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
|
||||
ASFLAGS = $(CFLAGS)
|
||||
|
||||
LIBDIR = ../libs/lib
|
||||
|
||||
LDFLAGS = -nostartfiles
|
||||
LIBS = -lpspkubridge -lpspsystemctrl_kernel
|
||||
|
||||
PSPSDK=$(shell psp-config --pspsdk-path)
|
||||
include $(PSPSDK)/lib/build_prx.mak
|
12
plugin/exports.exp
Normal file
12
plugin/exports.exp
Normal file
@ -0,0 +1,12 @@
|
||||
# Define the exports for the prx
|
||||
PSP_BEGIN_EXPORTS
|
||||
|
||||
# These four lines are mandatory (although you can add other functions like module_stop)
|
||||
# syslib is a psynonym for the single mandatory export.
|
||||
PSP_EXPORT_START(syslib, 0, 0x8000)
|
||||
PSP_EXPORT_FUNC(module_start)
|
||||
PSP_EXPORT_FUNC(module_stop)
|
||||
PSP_EXPORT_VAR(module_info)
|
||||
PSP_EXPORT_END
|
||||
|
||||
PSP_END_EXPORTS
|
234
plugin/leda.c
Normal file
234
plugin/leda.c
Normal file
@ -0,0 +1,234 @@
|
||||
#include <pspdisplay_kernel.h>
|
||||
#include <pspinit.h>
|
||||
#include <pspkdebug.h>
|
||||
#include <pspkernel.h>
|
||||
#include <psploadexec_kernel.h>
|
||||
#include <pspmodulemgr.h>
|
||||
#include <pspsyscon.h>
|
||||
|
||||
#include "kubridge.h"
|
||||
|
||||
PSP_MODULE_INFO("Legacy_Software_Loader", 0x1006, 1, 0);
|
||||
|
||||
// Structs and Macros (Mostly from uOFW)
|
||||
|
||||
/** Current number category size for libraries. */
|
||||
#define LIBRARY_VERSION_NUMBER_CATEGORY_SIZE (2)
|
||||
|
||||
/**
|
||||
* This structure represents a function stub belonging to same privilege-level linked libraries,
|
||||
* i.e. a kernel resident library linked with a kernel stub library.
|
||||
*/
|
||||
typedef struct {
|
||||
/** The call to the imported function via a MIPS ASM Jump instruction. */
|
||||
u32 call;
|
||||
/** The delay slot belonging to the call, typically a NOP instruction. */
|
||||
u32 delaySlot;
|
||||
} DirectCall;
|
||||
|
||||
/**
|
||||
* This structure represents a function stub belonging to different privilege-level linked libraries,
|
||||
* i.e. a kernel resident library linked with a user stub library.
|
||||
*/
|
||||
typedef struct {
|
||||
/** The return instruction from the stub. Typically a JR $ra command. */
|
||||
u32 returnAddr;
|
||||
/** The system call exception used to call the imported function. */
|
||||
u32 syscall;
|
||||
} Syscall;
|
||||
|
||||
/**
|
||||
* This structure represents an imported function stub.
|
||||
*/
|
||||
typedef union {
|
||||
/** User/User or Kernel/Kernel function stub. */
|
||||
DirectCall dc;
|
||||
/** Kernel/User function stub. */
|
||||
Syscall sc;
|
||||
} SceStub;
|
||||
|
||||
/**
|
||||
* This structure represents an imported variable stub.
|
||||
*/
|
||||
typedef struct {
|
||||
u32 *addr;
|
||||
/** The NID identifying the imported variable. */
|
||||
u32 nid;
|
||||
} SceVariableStub;
|
||||
|
||||
/**
|
||||
* This structure represents the imports, provided by a resident library, that a given module is using.
|
||||
* A module can have multiple stub libraries.
|
||||
*/
|
||||
typedef struct {
|
||||
/** The name of the library. */
|
||||
const char *libName; //0
|
||||
/**
|
||||
* The version of the library. It consists of a 'major' and 'minor' field. The version of a stub
|
||||
* library shouldn't be higher than the version(s) of the corresponding resident library/libraries.
|
||||
* Linking won't be performed in such a case.
|
||||
*/
|
||||
u8 version[LIBRARY_VERSION_NUMBER_CATEGORY_SIZE]; //4
|
||||
/** The library's attributes. Can be set to either SCE_LIB_NO_SPECIAL_ATTR or SCE_LIB_WEAK_IMPORT. */
|
||||
u16 attribute; //6
|
||||
/**
|
||||
* The length of this entry table in 32-Bit words. Set this to either "STUB_LIBRARY_ENTRY_TABLE_OLD_LEN"
|
||||
* or "STUB_LIBRARY_ENTRY_TABLE_NEW_LEN". Use this member when you want to iterate through a
|
||||
* list of entry tables (size = len * 4).
|
||||
*/
|
||||
u8 len; //8
|
||||
/** The number of imported variables by the stub library. */
|
||||
u8 vStubCount; //9
|
||||
/** The number of imported functions by the stub library. */
|
||||
u16 stubCount; //10
|
||||
/** Pointer to an array of NIDs containing the NIDs of the imported functions and variables. */
|
||||
u32 *nidTable; //12
|
||||
/** Pointer to an array of imported function stubs. */
|
||||
SceStub *stubTable; //16
|
||||
/** Pointer to an array of imported variable stubs. */
|
||||
SceVariableStub *vStubTable; // 20
|
||||
/** Unknown. */
|
||||
u16 unk24; //24
|
||||
} SceStubLibraryEntryTable;
|
||||
|
||||
// Globals
|
||||
SceOff g_pos = 0; // 0x00003DD0
|
||||
SceOff g_pos2 = 0; // 0x00003DCC
|
||||
s32 g_module_id = 0; // 0x00003DE4
|
||||
void *g_address = NULL; // 0x00003E10
|
||||
u32 g_address_size = 0; // 0x00003DE8
|
||||
|
||||
// Function prototypes
|
||||
s32 sctrlHENRegisterHomebrewLoader(s32 (* handler)(const char *path, s32 flags, SceKernelLMOption *option));
|
||||
s32 sceKernelLinkLibraryEntriesWithModule(SceModule *mod, SceStubLibraryEntryTable *libStubTable, u32 size);
|
||||
u32 sctrlHENFindFunction(char *modname, char *libname, u32 nid);
|
||||
extern u32 sceKernelQuerySystemCall(void *func);
|
||||
|
||||
s32 sub_000000F0(s32 *arg) {
|
||||
s32 ret = 1;
|
||||
|
||||
if (*arg == 0x3E00008) {
|
||||
ret = 0;
|
||||
|
||||
if (arg[1] != 0) {
|
||||
return arg[1] != 0x3CC;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void loc_00000164(void) {
|
||||
kuKernelLoadModule(NULL, 0, NULL);
|
||||
kuKernelLoadModuleWithApitype2(0, NULL, 0, NULL);
|
||||
kuKernelInitApitype();
|
||||
kuKernelInitFileName(NULL);
|
||||
kuKernelBootFrom();
|
||||
kuKernelInitKeyConfig();
|
||||
kuKernelGetUserLevel();
|
||||
kuKernelSetDdrMemoryProtection(NULL, 0, 0);
|
||||
kuKernelGetModel();
|
||||
return;
|
||||
}
|
||||
|
||||
SceOff sub_000001FC(SceUID fd, SceOff offset, s32 whence) {
|
||||
g_pos = sceIoLseek(fd, offset, whence);
|
||||
|
||||
if (g_pos2 != 0) {
|
||||
if (offset != 0 && whence == PSP_SEEK_END) {
|
||||
return g_pos2;
|
||||
}
|
||||
}
|
||||
|
||||
return g_pos;
|
||||
}
|
||||
|
||||
s32 sub_00000968(SceCtrlData *pad_data, s32 count) {
|
||||
s32 k1 = pspSdkSetK1(0);
|
||||
s32 ret = sceCtrlPeekBufferPositive(pad_data, count);
|
||||
pspSdkSetK1(k1);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void sub_000009C4(void) {
|
||||
s32 k1 = pspSdkSetK1(0);
|
||||
sceKernelIcacheInvalidateAll();
|
||||
pspSdkSetK1(k1);
|
||||
}
|
||||
|
||||
void sub_000009FC(s32 level, s32 unk) {
|
||||
s32 k1 = pspSdkSetK1(0);
|
||||
sceDisplaySetBrightness(level, unk);
|
||||
pspSdkSetK1(k1);
|
||||
}
|
||||
|
||||
s32 sub_00000A54(s32 SceLED, s32 state) {
|
||||
s32 k1 = pspSdkSetK1 (0);
|
||||
s32 ret = sceSysconCtrlLED(SceLED, state);
|
||||
pspSdkSetK1(k1);
|
||||
return ret;
|
||||
}
|
||||
|
||||
s32 sub_00000AB8(char *modname, char *libname, u32 nid) {
|
||||
s32 ret = 0;
|
||||
|
||||
u32 *func = (void *)sctrlHENFindFunction(modname, libname, nid);
|
||||
|
||||
if (func != 0) {
|
||||
ret = sceKernelQuerySystemCall(func);
|
||||
|
||||
if (ret < 0) {
|
||||
ret = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Subroutine at address 0x00000CCC
|
||||
*/
|
||||
void sub_00000CCC(void) {
|
||||
sceKernelDcacheWritebackAll();
|
||||
sceKernelIcacheClearAll();
|
||||
}
|
||||
|
||||
s32 sub_00002ACC(s32 arg, void *address, u32 size) {
|
||||
// LoadCoreForKernel_C0913394 was used without any args in the original leda plugin
|
||||
s32 ret = sceKernelLinkLibraryEntriesWithModule(NULL, NULL, 0);
|
||||
|
||||
if (g_address == NULL && ret < 0) {
|
||||
g_module_id = sceKernelGetModuleIdByAddress(address);
|
||||
g_address = address;
|
||||
g_address_size = size;
|
||||
}
|
||||
|
||||
// sub_000022D4();
|
||||
return ret;
|
||||
}
|
||||
|
||||
// TODO
|
||||
s32 sub_00003304(const char *path, s32 flags, SceKernelLMOption *option) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 loc_00000AB0(struct SceKernelLoadExecVSHParam *param) {
|
||||
return sceKernelExitVSHKernel(NULL);
|
||||
}
|
||||
|
||||
|
||||
s32 module_start(SceSize args, void *argp) {
|
||||
s32 api_type = sceKernelInitApitype();
|
||||
|
||||
if (api_type != PSP_INIT_APITYPE_MS2) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
Kprintf("LEDA - Legacy Software Loader, version 0.1, by Dark_AleX\n");
|
||||
sctrlHENRegisterHomebrewLoader(sub_00003304);
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 module_stop(void) {
|
||||
return 0;
|
||||
}
|
5
plugin/stubs/InterruptManagerForKernel.S
Normal file
5
plugin/stubs/InterruptManagerForKernel.S
Normal file
@ -0,0 +1,5 @@
|
||||
.set noreorder
|
||||
|
||||
#include "pspimport.s"
|
||||
IMPORT_START "InterruptManagerForKernel",0x00010000
|
||||
IMPORT_FUNC "InterruptManagerForKernel",0xF153B371,sceKernelQuerySystemCall
|
6
plugin/stubs/ModuleMgrForUser.S
Normal file
6
plugin/stubs/ModuleMgrForUser.S
Normal file
@ -0,0 +1,6 @@
|
||||
.set noreorder
|
||||
|
||||
#include "pspimport.s"
|
||||
|
||||
IMPORT_START "ModuleMgrForUser",0x40010011
|
||||
IMPORT_FUNC "ModuleMgrForUser",0xD8B73127, sceKernelGetModuleIdByAddress
|
7
plugin/stubs/sceLoaderCore.S
Normal file
7
plugin/stubs/sceLoaderCore.S
Normal file
@ -0,0 +1,7 @@
|
||||
.set noreorder
|
||||
|
||||
#include "pspimport.s"
|
||||
|
||||
IMPORT_START "LoadCoreForKernel",0x00010011
|
||||
IMPORT_FUNC "LoadCoreForKernel",0xA481E30E,sceKernelLinkLibraryEntriesWithModule
|
||||
IMPORT_FUNC "LoadCoreForKernel",0xD8779AC6,sceKernelIcacheClearAll
|
Loading…
Reference in New Issue
Block a user