PS2SDK
PS2 Homebrew Libraries
patch_user_mem_clear.c
Go to the documentation of this file.
1 
6 #include <tamtypes.h>
7 #include <kernel.h>
8 
9 int sbv_patch_user_mem_clear(void *start)
10 {
11  int ret = -1;
12  u32 *p;
13 
14  DI();
15  ee_kmode_enter();
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 }
kernel.h
tamtypes.h
sbv_patch_user_mem_clear
int sbv_patch_user_mem_clear(void *start)
Definition: patch_user_mem_clear.c:9