Loadexec: added headers

This commit is contained in:
Arthur Blot 2013-04-13 21:32:54 +02:00
parent a9258addf3
commit 03361356c7
4 changed files with 603 additions and 0 deletions

427
include/loadexec_kernel.h Normal file
View File

@ -0,0 +1,427 @@
/* Copyright (C) 2011, 2012, 2013 The uOFW team
See the file COPYING for copying permission.
*/
#include "common_header.h"
/** @defgroup LoadExecForKernel LoadExecForKernel Library
* Allows the kernel and VSH to run executables through reboot.bin.
* @{
*/
#ifndef LOADEXEC_KERNEL_H
#define LOADEXEC_KERNEL_H
/** Execution parameters for most kernel LoadExec functions. */
typedef struct
{
/** Size of the structure in bytes. */
SceSize size;
/** Size of the arguments string. */
SceSize args;
/** Pointer to the arguments strings. */
void *argp;
/** The key: "game", "updater", "vsh", "umdemu" or "mlnapp". */
const char *key;
/** The size of the vshmain arguments. */
u32 vshmainArgs;
/** Vshmain arguments that will be passed to vshmain after the program has exited. */
void *vshmainArgp;
/** "/kd/pspbtcnf_game.txt" or "/kd/pspbtcnf.txt" if not supplied (max. 256 chars). */
char *configFile;
/** An unknown string (max. 256 chars). */
char *string;
/** Unknown flag default value = 0x10000. */
u32 flags;
/** The size of the external arguments. */
u32 extArgs;
/** "External" arguments only used when calling a function accepting a SceKernelLoadExecVSHParam as an argument. */
void *extArgp;
/** Unused. */
u32 opt11;
} SceKernelLoadExecVSHParam;
/** Types of arguments passed to reboot.bin. */
typedef enum
{
/** No argument (just used as a default value). */
SCE_KERNEL_REBOOT_ARGTYPE_NONE = 0x0,
/** Used by arguments needed for some api types (USBWLAN, USBWLAN_DEBUG, 'UNK', 'UNK_DEBUG'). */
SCE_KERNEL_REBOOT_ARGTYPE_KERNEL = 0x1,
/** The file path (the one passed to the LoadExec() functions). */
SCE_KERNEL_REBOOT_ARGTYPE_FILENAME = 0x2,
/** Vshmain arguments, passed to vshmain after the program has exited. */
SCE_KERNEL_REBOOT_ARGTYPE_VSHMAIN = 0x4,
/** Unknown (not argument made in loadexec has this type). */
SCE_KERNEL_REBOOT_ARGTYPE_UNKNOWN8 = 0x8,
/** Game info (as returned by sceKernelGetGameInfo()). */
SCE_KERNEL_REBOOT_ARGTYPE_GAMEINFO = 0x20,
/** Used only by emulation api types. */
SCE_KERNEL_REBOOT_ARGTYPE_EMU = 0x40,
/** Used only by NpDrm api types. */
SCE_KERNEL_REBOOT_ARGTYPE_NPDRM = 0x80,
/** Same as SCE_KERNEL_REBOOT_ARGTYPE_KERNEL? */
SCE_KERNEL_REBOOT_ARGTYPE_DEFAULT = 0x100,
/** Used by arguments passed to LoadExec() functions through the extArgs/extArgp fields of the parameters. */
SCE_KERNEL_REBOOT_ARGTYPE_EXT = 0x400
} SceKernelRebootArgType;
/**
* Exit VSH from VSH.
*
* @param opt Execution parameters.
*
* @return 0 on success.
*/
s32 sceKernelExitVSHVSH(SceKernelLoadExecVSHParam *opt);
/**
* Invoke the exit callback.
*
* @return 0 on success.
*/
s32 sceKernelInvokeExitCallback(void);
/**
* Check an execution parameters key.
*
* @param opt The execution parameters.
* @param notUpdater If set to 1, will check if key is not "updater"; if set to 0, will check if key is "game", "vsh" or "updater"; otherwise, returns an error.
*
* @return 0 if key is inccorrect, 1 if key is correct, < 0 on error.
*/
s32 LoadExecForKernel_BC26BEEF(SceKernelLoadExecVSHParam *opt, s32 notUpdater);
/**
* Set an argument to send to reboot.bin next time it will be started.
*
* @param argp The argument pointer.
* @param args The argument size.
* @param argType The argument type.
*
* @return 0.
*/
s32 LoadExecForKernel_DBD0CF1B(void *argp, s32 args, SceKernelRebootArgType argType);
/**
* Load an executable from a disc by VSH.
*
* @param file The execution path.
* @param opt Execution parameters.
*
* @return 0 on success.
*/
s32 sceKernelLoadExecVSHDisc(char *file, SceKernelLoadExecVSHParam *opt);
/**
* Load an updater executable from a disc by VSH.
*
* @param file The execution path.
* @param opt Execution parameters.
*
* @return 0 on success.
*/
s32 sceKernelLoadExecVSHDiscUpdater(char *file, SceKernelLoadExecVSHParam *opt);
/**
* Load an executable from a disc in debugging mode by VSH.
*
* @param file The execution path.
* @param opt Execution parameters.
*
* @return 0 on success.
*/
s32 sceKernelLoadExecVSHDiscDebug(char *file, SceKernelLoadExecVSHParam *opt);
/**
* Load an executable from an emulated disc in MS 1 by VSH.
*
* @param file The execution path.
* @param opt Execution parameters.
*
* @return 0 on success.
*/
s32 LoadExecForKernel_F9CFCF2F(char *file, SceKernelLoadExecVSHParam *opt);
/**
* Load an executable from an emulated disc in MS 2 by VSH.
*
* @param file The execution path.
* @param opt Execution parameters.
*
* @return 0 on success.
*/
s32 LoadExecForKernel_077BA314(char *file, SceKernelLoadExecVSHParam *opt);
/**
* Load an executable from an emulated disc in EF 1 by VSH.
*
* @param file The execution path.
* @param opt Execution parameters.
*
* @return 0 on success.
*/
s32 LoadExecForKernel_E704ECC3(char *file, SceKernelLoadExecVSHParam *opt);
/**
* Load an executable from an emulated disc in EF 2 by VSH.
*
* @param file The execution path.
* @param opt Execution parameters.
*
* @return 0 on success.
*/
s32 LoadExecForKernel_47A5A49C(char *file, SceKernelLoadExecVSHParam *opt);
/**
* Load an executable from USB or Wlan by VSH.
*
* @param file The execution path.
* @param opt Execution parameters.
*
* @return 0 on success.
*/
s32 sceKernelLoadExecBufferVSHUsbWlan(s32 args, void *argp, SceKernelLoadExecVSHParam *opt);
/**
* Load an executable from USB or Wlan in debug mode by VSH.
*
* @param file The execution path.
* @param opt Execution parameters.
*
* @return 0 on success.
*/
s32 sceKernelLoadExecBufferVSHUsbWlanDebug(s32 args, void *argp, SceKernelLoadExecVSHParam *opt);
/**
* Load an executable from ??? by VSH.
*
* @param file The execution path.
* @param opt Execution parameters.
*
* @return 0 on success.
*/
s32 LoadExecForKernel_87C3589C(s32 args, void *argp, SceKernelLoadExecVSHParam *opt);
/**
* Load an executable from ??? (same as with LoadExecForKernel_87C3589C) in debug mode by VSH.
*
* @param file The execution path.
* @param opt Execution parameters.
*
* @return 0 on success.
*/
s32 LoadExecForKernel_7CAFE77F(s32 args, void *argp, SceKernelLoadExecVSHParam *opt);
/**
* Load an executable from MS 1 by VSH.
*
* @param file The execution path.
* @param opt Execution parameters.
*
* @return 0 on success.
*/
s32 sceKernelLoadExecVSHMs1(char *file, SceKernelLoadExecVSHParam *opt);
/**
* Load an executable from MS 2 by VSH.
*
* @param file The execution path.
* @param opt Execution parameters.
*
* @return 0 on success.
*/
s32 sceKernelLoadExecVSHMs2(char *file, SceKernelLoadExecVSHParam *opt);
/**
* Load an executable from MS 3 by VSH.
*
* @param file The execution path.
* @param opt Execution parameters.
*
* @return 0 on success.
*/
s32 sceKernelLoadExecVSHMs3(char *file, SceKernelLoadExecVSHParam *opt);
/**
* Load an executable from MS 4 by VSH.
*
* @param file The execution path.
* @param opt Execution parameters.
*
* @return 0 on success.
*/
s32 sceKernelLoadExecVSHMs4(char *file, SceKernelLoadExecVSHParam *opt);
/**
* Load an executable from MS 5 by VSH.
*
* @param file The execution path.
* @param opt Execution parameters.
*
* @return 0 on success.
*/
s32 sceKernelLoadExecVSHMs5(char *file, SceKernelLoadExecVSHParam *opt);
/**
* Load an executable from MS 6 by VSH.
*
* @param file The execution path.
* @param opt Execution parameters.
*
* @return 0 on success.
*/
s32 LoadExecForKernel_A6658F10(char *file, SceKernelLoadExecVSHParam *opt);
/**
* Load an executable from EF 1 by VSH.
*
* @param file The execution path.
* @param opt Execution parameters.
*
* @return 0 on success.
*/
s32 LoadExecForKernel_16A68007(char *file, SceKernelLoadExecVSHParam *opt);
/**
* Load an executable from EF 2 by VSH.
*
* @param file The execution path.
* @param opt Execution parameters.
*
* @return 0 on success.
*/
s32 LoadExecForKernel_032A7938(char *file, SceKernelLoadExecVSHParam *opt);
/**
* Load an executable from EF 3 by VSH.
*
* @param file The execution path.
* @param opt Execution parameters.
*
* @return 0 on success.
*/
s32 LoadExecForKernel_40564748(char *file, SceKernelLoadExecVSHParam *opt);
/**
* Load an executable from EF 4 by VSH.
*
* @param file The execution path.
* @param opt Execution parameters.
*
* @return 0 on success.
*/
s32 LoadExecForKernel_E1972A24(char *file, SceKernelLoadExecVSHParam *opt);
/**
* Load an executable from EF 5 by VSH.
*
* @param file The execution path.
* @param opt Execution parameters.
*
* @return 0 on success.
*/
s32 LoadExecForKernel_C7C83B1E(char *file, SceKernelLoadExecVSHParam *opt);
/**
* Load an executable from EF 6 by VSH.
*
* @param file The execution path.
* @param opt Execution parameters.
*
* @return 0 on success.
*/
s32 LoadExecForKernel_8C4679D3(char *file, SceKernelLoadExecVSHParam *opt);
/**
* Load an executable from ??? 1 (game mode) by VSH.
*
* @param file The execution path.
* @param opt Execution parameters.
*
* @return 0 on success.
*/
s32 LoadExecForKernel_B343FDAB(char *file, SceKernelLoadExecVSHParam *opt);
/**
* Load an executable from ??? 2 (game mode) by VSH.
*
* @param file The execution path.
* @param opt Execution parameters.
*
* @return 0 on success.
*/
s32 LoadExecForKernel_1B8AB02E(char *file, SceKernelLoadExecVSHParam *opt);
/**
* Load an executable of a MLN (PSN) application from MS by VSH.
*
* @param file The execution path.
* @param opt Execution parameters.
*
* @return 0 on success.
*/
s32 LoadExecForKernel_C11E6DF1(char *file, SceKernelLoadExecVSHParam *opt);
/**
* Load an executable of a MLN (PSN) application from EF by VSH.
*
* @param file The execution path.
* @param opt Execution parameters.
*
* @return 0 on success.
*/
s32 LoadExecForKernel_9BD32619(char *file, SceKernelLoadExecVSHParam *opt);
/**
* Exit the VSH from kernel.
*
* @param opt Execution parameters.
*
* @return 0 on success.
*/
s32 sceKernelExitVSHKernel(SceKernelLoadExecVSHParam *opt);
/**
* Returns 0. (Probably a disabled debugging function.)
*
* @return 0.
*/
s32 LoadExecForKernel_C540E3B3(void);
/**
* Register an exit callback, started upon game exit through the "Home" button.
*
* @param cbId The callback ID.
*
* @return 0 on success.
*/
s32 sceKernelRegisterExitCallback(SceUID cbId);
/**
* Unregister the exit callback.
*
* @return 0 on success.
*/
s32 sceKernelUnregisterExitCallback(void);
/**
* Get the current exit callback.
*
* @return The current exit callback ID.
*/
SceUID sceKernelCheckExitCallback(void);
/**
* Register a function which will be started upon exit callback registering.
*
* @param cb The function to register.
*
* @return 0.
*/
s32 LoadExecForKernel_A5ECA6E3(void (*cb)());
#endif /* LOADEXEC_KERNEL_H */
/** @} */

89
include/loadexec_user.h Normal file
View File

@ -0,0 +1,89 @@
/* Copyright (C) 2011, 2012, 2013 The uOFW team
See the file COPYING for copying permission.
*/
#include "common_header.h"
/** @defgroup LoadExecForUser LoadExecForUser Library
* Allows the user to run executables through reboot.bin.
* @{
*/
#ifndef LOADEXEC_USER_H
#define LOADEXEC_USER_H
/** Execution parameters for user LoadExec functions */
typedef struct {
/** Size of the structure */
SceSize size;
/** Size of the arg string */
SceSize args;
/** Pointer to the arg string */
void *argp;
/** Encryption key ? */
const char *key;
} SceKernelLoadExecParam;
/**
* Update the exit callback status (exported as a variable in the kernel module)
*
* @return 0 on success.
*/
s32 LoadExecForUser_362A956B(void);
/**
* Load an executable.
*
* @param file The executable path.
* @param opt Execution parameters.
*
* @return 0 on success.
*/
s32 sceKernelLoadExec(char *file, SceKernelLoadExecParam *opt);
/**
* Load an executable using npdrm.
*
* @param file The executable path.
* @param opt Execution parameters.
*
* @return 0 on success.
*/
s32 LoadExecForUser_8ADA38D3(char *file, SceKernelLoadExecParam *opt);
/**
* Exit a game with an argument.
*
* @param arg An unknown argument.
*
* @return 0 on success.
*/
s32 LoadExecForUser_D1FB50DC(void *arg);
/**
* Register an exit callback, started upon game exit through the "Home" button.
*
* @param cbId The callback ID.
*
* @return 0 on success.
*/
s32 sceKernelRegisterExitCallback(SceUID cbId);
/**
* Exit a game (with no status, as opposed to the function's name)
*
* @return 0 on success.
*/
s32 sceKernelExitGameWithStatus(void);
/**
* Exit a game.
*
* @return 0 on success.
*/
s32 sceKernelExitGame(void);
#endif /* LOADEXEC_USER_H */
/** @} */

View File

@ -17,6 +17,7 @@
#include <threadman_kernel.h>
#include <loadexec_kernel.h>
#include <loadexec_user.h>
#include "loadexec_int.h"
#include "reboot.h"

View File

@ -0,0 +1,86 @@
/* Copyright (C) 2011, 2012, 2013 The uOFW team
See the file COPYING for copying permission.
*/
#ifndef LOADEXEC_H
#define LOADEXEC_H
typedef struct
{
s32 size; // 0
s32 unk4;
s32 npDrm2_1; // 8
s32 npDrm2_2; // 12
char npDrm1[16]; // 16
SceKernelLoadExecVSHParam vshParam; // 32
} NpDrmArg;
typedef struct
{
s32 apiType;
s32 args;
// Sometimes contains filename (args is then set to 0)
void *argp;
SceKernelLoadExecVSHParam *vshParam;
void *opt4;
char *npDrm1;
s32 npDrm2_1;
s32 npDrm2_2;
NpDrmArg *npDrmArg;
} RunExecParams;
typedef struct
{
void *argp; // 0
s32 args; // 4
SceKernelRebootArgType type; // 8
s32 unk12;
s32 unk16;
s32 unk20;
s32 unk24;
} SceKernelArgsStor;
typedef struct
{
void *addr; // 0
s32 memorySize; // 4
s32 unk8;
s32 unk12;
void *startAddr; // 16
void *endAddr; // 20
s32 unk24;
s32 curArgs; // 28
SceKernelArgsStor *args; // 32
s32 unk36;
s32 unk40;
s32 model; // 44
s32 unk48;
s32 unk52;
s32 unk56;
s32 unk60;
s32 dipswLo; // 64
s32 dipswHi; // 68
void *unk72; // 72
void *unk76; // 76
s32 cpTime; // 80
// ... ? size is max 0x1000
} SceKernelRebootParam;
s32 decodeKL4E(void *inPtr, s32 inSize, void *outPtr, s32 outSize);
void copyArgsToRebootParam(SceKernelRebootParam *hwOpt, SceKernelLoadExecVSHParam *opt);
void fixupArgsAddr(SceKernelRebootParam *hwOpt, SceKernelLoadExecVSHParam *opt __attribute__((unused)));
s32 runExec(RunExecParams *args);
s32 ioctlAndDevctl(char *name, s32 devcmd, s32 iocmd);
s32 checkVSHParam(SceKernelLoadExecVSHParam *opt);
s32 loadExecVSH(s32 apiType, char *file, SceKernelLoadExecVSHParam *opt, u32 flags);
s32 loadExecVSHWithArgs(s32 apiType, s32 args, void *argp, SceKernelLoadExecVSHParam *opt, u32 flags);
s32 loadExecKernel(s32 apiType, SceKernelLoadExecVSHParam *opt);
s32 rebootKernel(SceKernelLoadExecVSHParam *arg);
s32 runExecFromThread(u32 args, RunExecParams *opt);
void copyVSHParam(SceKernelLoadExecVSHParam *dstOpt, u32 flags, SceKernelLoadExecVSHParam *srcOpt);
s32 runReboot(RunExecParams *opt);
SceKernelRebootParam *makeRebootParam();
#endif /* LOADEXEC_H */