ps2sdk  1.1
A collection of Open Source libraries used for developing applications on Sony's PlayStation 2® (PS2).
patch_user_mem_clear.c File Reference
#include <tamtypes.h>
#include <kernel.h>
+ Include dependency graph for patch_user_mem_clear.c:

Go to the source code of this file.

Functions

int sbv_patch_user_mem_clear (void *start)
 

Detailed Description

Patch user memory clear on EE restart.

Definition in file patch_user_mem_clear.c.

Function Documentation

◆ sbv_patch_user_mem_clear()

int sbv_patch_user_mem_clear ( void *  start)

@start address above which all user memory is cleared

Returns
0: success, -1: error

LoadExecPS2() wipes all user-space memory above 0x82000. With this patch, you can define a different start address to prevent your data from being overwritten. In order to completely disable the memory clear, simply pass 0x02000000 to it.

Definition at line 9 of file patch_user_mem_clear.c.

10 {
11  int ret = -1;
12  u32 *p;
13 
14  DI();
16 
17  for (p = (unsigned int*)0x80001000; p < (unsigned int*)0x80080000; p++) {
18  /*
19  * Search for function call and patch $a0
20  * lui $a0, 0x0008
21  * jal InitializeUserMemory
22  * ori $a0, $a0, 0x2000
23  */
24  if (p[0] == 0x3c040008 && (p[1] & 0xfc000000) == 0x0c000000 && p[2] == 0x34842000) {
25  p[0] = 0x3c040000 | ((unsigned int)start >> 16);
26  p[2] = 0x34840000 | ((unsigned int)start & 0xffff);
27  ret = 0;
28  break;
29  }
30  }
31 
32  ee_kmode_exit();
33  EI();
34 
35  return ret;
36 }
static int ee_kmode_exit()
Definition: kernel.h:198
static int ee_kmode_enter()
Definition: kernel.h:181
#define DI
Definition: kernel.h:24
#define EI
Definition: kernel.h:25
unsigned int u32
Definition: tamtypes.h:30

References DI, ee_kmode_enter(), ee_kmode_exit(), and EI.