-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathleohax.h
133 lines (103 loc) · 2.71 KB
/
leohax.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
//Access to libleo variables (2.0I)
#ifdef DEBUG
#error Compiling this in this state will break hard. Compile it with FINAL=YES instead.
#endif
#ifdef _LANGUAGE_C_PLUS_PLUS
extern "C" {
#endif
//Variables
extern u32 LEO_country_code; //Disk Country Code Lock
extern u8 LEOdisk_type; //Current Disk Type
extern u8 LEO_sys_data[0xE8]; //System Data
extern u8 LEOdrive_flag; //Is System Area Read (0xFF = Read, 0 = Not Read)
extern u32 __leoActive; //Is Leo Manager Active?
#define haxSystemAreaReadSet() (LEOdrive_flag = 0xff)
#define haxSystemAreaReadClr() (LEOdrive_flag = 0)
//Functions
extern void leoRead(); //Read LBAs
extern void leomain(); //Command Thread
extern void leointerrupt(); //Interrupt Thread
extern void leoRead_system_area(); //System Area Read
extern void leoClrUA_MEDIUM_CHANGED(); //Clear Medium Changed Flag
extern void leoSetUA_MEDIUM_CHANGED(); //Set Medium Changed Flag
extern u32 LeoDriveExist(); //Read Drive IPL
extern int leoWait_mecha_cmd_done(); //Wait until Command is processed
#ifdef _LANGUAGE_C_PLUS_PLUS
}
#endif
#define LEO_COUNTRY_JPN 0xE848D316
#define LEO_COUNTRY_USA 0x2263EE56
#define LEO_COUNTRY_NONE 0x00000000
//Hack libleo functions in real time (and avoid doing all the hax beforehand)
void haxSystemAreaAccess()
{
//Force System Area access
u32 *hax;
hax = &leoRead + 0x18;
*hax = 0x24040000; //Don't add +24 to LBAs, Nintendo, please.
}
void haxDriveDetection()
{
//Force Drive Detection for Dev Drives
u32 *hax;
hax = &LeoCJCreateLeoManager + 0x2C;
*hax = 0x00000000;
hax = &LeoCJCreateLeoManager + 0x34;
*hax = 0x10000003;
hax = &LeoCJCreateLeoManager + 0x1A0;
*hax = 0x14610000;
hax = &LeoCJCreateLeoManager + 0x1E0; //Ignore Region
*hax = 0x10000000;
hax = &LeoCJCreateLeoManager + 0x1F4;
*hax = 0x03240019;
}
void haxIDDrive()
{
//Ignore Drive ID
u32 *hax;
hax = &leomain + 0x330;
*hax = 0x10000000;
hax = &leomain + 0x398;
*hax = 0x00000000;
}
void haxDevDiskAccess()
{
u32 *hax;
hax = &leoRead_system_area + 0xFC;
*hax = 0x14400000;
hax = &leoRead_system_area + 0x118;
*hax = 0x10400000;
hax = &leoRead_system_area + 0x170;
*hax = 0x14430000;
}
void haxReadErrorRetry(u16 retries)
{
u32 *hax;
hax = &leointerrupt + 0x6A4;
*hax = 0x3A820000 | retries;
osWritebackDCacheAll();
}
void haxDriveExist()
{
u32 *hax;
hax = &LeoDriveExist + 0x0;
*hax = 0x24020001; //addiu v0,0,1
hax = &LeoDriveExist + 0x4;
*hax = 0x03E00008; //jr ra
hax = &LeoDriveExist + 0x8;
*hax = 0x00000000; //nop
}
void haxAll()
{
haxSystemAreaAccess();
haxDriveDetection();
haxIDDrive();
haxDevDiskAccess();
haxDriveExist();
osWritebackDCacheAll();
}
void haxMediumChangedClear()
{
LeoResetClear();
leoClrUA_MEDIUM_CHANGED();
}