Skip to content

Commit

Permalink
sdk cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
JoseAaronLopezGarcia committed Sep 17, 2024
1 parent befb5b2 commit 88bb10e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 224 deletions.
253 changes: 29 additions & 224 deletions common/include/systemctrl.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ extern "C"{

#define GAME_ID_MINIMUM_BUFFER_SIZE 10

enum BootLoadFlags
{
BOOTLOAD_VSH = 1,
BOOTLOAD_GAME = 2,
BOOTLOAD_UPDATER = 4,
BOOTLOAD_POPS = 8,
BOOTLOAD_UMDEMU = 64, /* for original NP9660 */
};

// Function Name Clones (of old but gold times)
//#define sctrlKernelQuerySystemCall sceKernelQuerySystemCall

Expand All @@ -43,6 +52,10 @@ typedef int (* STMOD_HANDLER)(SceModule2 *);
// Thread Context
typedef struct SceThreadContext SceThreadContext;

// Decrypt extension functions
typedef int (* KDEC_HANDLER)(u32 *buf, int size, int *retSize, int m);
typedef int (* MDEC_HANDLER)(u32 *tag, u8 *keys, u32 code, u32 *buf, int size, int *retSize, int m, void *unk0, int unk1, int unk2, int unk3, int unk4);

// Find Import Library Stub Table
SceLibraryStubTable * findImportLib(SceModule2 * pMod, char * library);

Expand All @@ -52,27 +65,6 @@ unsigned int findImportByNID(SceModule2 * pMod, char * library, unsigned int nid
// Replace Import Function Stub
int hookImportByNID(SceModule2 * pMod, char * library, unsigned int nid, void * func);

// Set User Level
int sctrlKernelSetUserLevel(int level);

// Set System Firmware Version
int sctrlKernelSetDevkitVersion(int version);

// Get HEN Version
int sctrlHENGetVersion();

// Get HEN Minor Version
int sctrlHENGetMinorVersion();

// Find Filesystem Driver
PspIoDrv * sctrlHENFindDriver(char * drvname);

// Replace Function in Syscall Table
void sctrlHENPatchSyscall(void * addr, void * newaddr);

// Load Execute Module via Kernel Internal Function
int sctrlKernelLoadExecVSHWithApitype(int apitype, const char * file, struct SceKernelLoadExecVSHParam * param);

/**
* Restart the vsh.
*
Expand All @@ -83,9 +75,6 @@ int sctrlKernelLoadExecVSHWithApitype(int apitype, const char * file, struct Sce
*/
int sctrlKernelExitVSH(struct SceKernelLoadExecVSHParam *param);

// Register Prologue Module Start Handler
STMOD_HANDLER sctrlHENSetStartModuleHandler(STMOD_HANDLER new_handler);

// Return Reboot Configuration UMD File
char * sctrlSEGetUmdFile(void);

Expand All @@ -95,12 +84,6 @@ void sctrlSESetUmdFile(char * file);
// Calculate Random Number via KIRK
unsigned int sctrlKernelRand(void);

// Set Init Apitype
int sctrlKernelSetInitApitype(int apitype);

// Set Init Filename
int sctrlKernelSetInitFileName(char * filename);

// Register Custom init.prx sceKernelStartModule Handler, returns previous handler (if any)
void sctrlSetCustomStartModule(int (* func)(int modid, SceSize argsize, void * argp, int * modstatus, SceKernelSMOption * opt));

Expand Down Expand Up @@ -164,6 +147,7 @@ int sctrlKernelExitVSH(struct SceKernelLoadExecVSHParam *param);
*
* @returns < 0 on some errors.
*/
int sctrlKernelLoadExecVSHDisc(const char *file, struct SceKernelLoadExecVSHParam *param);

/**
* Executes a new executable from a disc.
Expand Down Expand Up @@ -197,6 +181,16 @@ int sctrlKernelLoadExecVSHMs1(const char *file, struct SceKernelLoadExecVSHParam
* @returns < 0 on some errors.
*/
int sctrlKernelLoadExecVSHMs2(const char *file, struct SceKernelLoadExecVSHParam *param);

/**
* Executes a new executable from PSP Go's Internal Memory.
* It is the function used by the firmware to execute games (and homebrew :P) from internal memory.
*
* @param file - The file to execute.
* @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL.
*
* @returns < 0 on some errors.
*/
int sctrlKernelLoadExecVSHEf2(const char *file, struct SceKernelLoadExecVSHParam *param);

/**
Expand Down Expand Up @@ -242,13 +236,15 @@ int sctrlKernelLoadExecVSHWithApitype(int apitype, const char *file, struct SceK
* @Note - this will modify also the value of sceKernelBootFrom, since the value of
* bootfrom is calculated from the apitype
*/
int sctrlKernelSetInitApitype(int apitype);

/**
* Sets the filename of the launched executable.
*
* @param filename - The filename to set
* @returns 0 on success
*/
int sctrlKernelSetInitFileName(char * filename);

/**
* Sets the init key config
Expand Down Expand Up @@ -281,15 +277,15 @@ int sctrlKernelSetDevkitVersion(int version);
* @returns 1 if we are in SE-C or later, 0 if we are in HEN-D or later,
* and < 0 (a kernel error code) in any other case
*/
int sctrlHENIsSE();
int sctrlHENIsSE();

/**
* Checks if we are in Devhook.
*
* @returns 1 if we are in SE-C/HEN-D for devhook or later, 0 if we are in normal SE-C/HEN-D or later,
* and < 0 (a kernel error code) in any other case
*/
int sctrlHENIsDevhook();
int sctrlHENIsDevhook();

/**
* Gets the HEN version
Expand Down Expand Up @@ -369,9 +365,7 @@ unsigned int sctrlHENFindFunction(char *modname, char *libname, unsigned int nid
* in order to avoid problems with gp register that may lead to a crash.
*
*/

typedef int (* KDEC_HANDLER)(u32 *buf, int size, int *retSize, int m);
typedef int (* MDEC_HANDLER)(u32 *tag, u8 *keys, u32 code, u32 *buf, int size, int *retSize, int m, void *unk0, int unk1, int unk2, int unk3, int unk4);
STMOD_HANDLER sctrlHENSetStartModuleHandler(STMOD_HANDLER new_handler);

/**
* Sets the speed (only for kernel usage)
Expand All @@ -393,196 +387,10 @@ void sctrlHENSetSpeed(int cpu, int bus);
*/
int sctrlHENSetMemory(u32 p2, u32 p8);

void sctrlHENPatchSyscall(void *addr, void *newaddr);

int sctrlKernelQuerySystemCall(void *func_addr);

int sctrlKernelBootFrom(void);


// ################# SAVESTATE USER ##############

enum BootLoadFlags
{
BOOTLOAD_VSH = 1,
BOOTLOAD_GAME = 2,
BOOTLOAD_UPDATER = 4,
BOOTLOAD_POPS = 8,
BOOTLOAD_UMDEMU = 64, /* for original NP9660 */
};

/**
* Restart the vsh.
*
* @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL
*
* @returns < 0 on some errors.
*
*/
int sctrlKernelExitVSH(struct SceKernelLoadExecVSHParam *param);

/**
* Executes a new executable from a disc.
* It is the function used by the firmware to execute the EBOOT.BIN from a disc.
*
* @param file - The file to execute.
* @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL.
*
* @returns < 0 on some errors.
*/
int sctrlKernelLoadExecVSHDisc(const char *file, struct SceKernelLoadExecVSHParam *param);

/**
* Executes a new executable from a disc.
* It is the function used by the firmware to execute an updater from a disc.
*
* @param file - The file to execute.
* @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL.
*
* @returns < 0 on some errors.
*/

/**
* Executes a new executable from a memory stick.
* It is the function used by the firmware to execute an updater from a memory stick.
*
* @param file - The file to execute.
* @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL.
*
* @returns < 0 on some errors.
*/

/**
* Executes a new executable from a memory stick.
* It is the function used by the firmware to execute games (and homebrew :P) from a memory stick.
*
* @param file - The file to execute.
* @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL.
*
* @returns < 0 on some errors.
*/

/**
* Executes a new executable from a memory stick.
* It is the function used by the firmware to execute ... ?
*
* @param file - The file to execute.
* @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL.
*
* @returns < 0 on some errors.
*/

/**
* Executes a new executable from a memory stick.
* It is the function used by the firmware to execute psx games
*
* @param file - The file to execute.
* @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL.
*
* @returns < 0 on some errors.
*/


/**
* Executes a new executable with the specified apitype
*
* @param apitype - The apitype
* @param file - The file to execute.
* @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL.
*
* @returns < 0 on some errors.
*/

/**
* Sets the api type
*
* @param apitype - The apitype to set
* @returns the previous apitype
*
* @Note - this will modify also the value of sceKernelBootFrom, since the value of
* bootfrom is calculated from the apitype
*/
int sctrlKernelSetInitApitype(int apitype);

/**
* Sets the filename of the launched executable.
*
* @param filename - The filename to set
* @returns 0 on success
*/

/**
* Sets the init key config
*
* @param key - The key code
* @returns the previous key config
*/

/**
* Sets the user level of the current thread
*
* @param level - The user level
* @return the previous user level on success
*/
int sctrlKernelSetUserLevel(int level);

/**
* Sets the devkit version
*
* @param version - The devkit version to set
* @return the previous devkit version
*
*/
int sctrlKernelSetDevkitVersion(int version);

/**
* Sets a function to be called just before module_start of a module is gonna be called (useful for patching purposes)
*
* @param handler - The function, that will receive the module structure before the module is started.
*
* @returns - The previous set function (NULL if none);
* @Note: because only one handler function is handled by HEN, you should
* call the previous function in your code.
*
* @Example:
*
* STMOD_HANDLER previous = NULL;
*
* int OnModuleStart(SceModule2 *mod);
*
* void somepointofmycode()
* {
* previous = sctrlHENSetStartModuleHandler(OnModuleStart);
* }
*
* int OnModuleStart(SceModule2 *mod)
* {
* if (strcmp(mod->modname, "vsh_module") == 0)
* {
* // Do something with vsh module here
* }
*
* if (!previous)
* return 0;
*
* // Call previous handler
*
* return previous(mod);
* }
*
* @Note2: The above example should be compiled with the flag -fno-pic
* in order to avoid problems with gp register that may lead to a crash.
*
*/
STMOD_HANDLER sctrlHENSetStartModuleHandler(STMOD_HANDLER handler);

/**
* Sets the speed (only for kernel usage)
*
* @param cpu - The cpu speed
* @param bus - The bus speed
*/

/**
* Sets the partition 2 and 8 memory for next loadexec.
*
Expand All @@ -596,8 +404,6 @@ STMOD_HANDLER sctrlHENSetStartModuleHandler(STMOD_HANDLER handler);

void sctrlHENPatchSyscall(void *addr, void *newaddr);



/**
* Patch module by offset
*
Expand Down Expand Up @@ -656,7 +462,6 @@ void sctrlSetCustomStartModule(int (*func)(int modid, SceSize argsize, void *arg
* sctrlHENLoadModuleOnReboot on module_start, a prx can cause itself to be resident in the modes choosen by flags.
* If all flags are selected, the module will stay resident until a psp shutdown, or until sctrlHENLoadModuleOnReboot is not called.
*/

void sctrlHENLoadModuleOnReboot(char *module_after, void *buf, int size, int flags);

/**
Expand Down
Binary file modified contrib/PC/prxencrypter/prxencrypter
Binary file not shown.

0 comments on commit 88bb10e

Please sign in to comment.