-
-
Notifications
You must be signed in to change notification settings - Fork 51
/
mcp.h
387 lines (337 loc) · 11.6 KB
/
mcp.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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
#pragma once
#include <wut.h>
/**
* \defgroup coreinit_mcp MCP
* \ingroup coreinit
* @{
*/
#ifdef __cplusplus
extern "C" {
#endif
typedef int32_t MCPError;
typedef struct MCPDevice MCPDevice;
typedef struct MCPDeviceList MCPDeviceList;
typedef struct MCPInstallInfo MCPInstallInfo;
typedef struct MCPInstallProgress MCPInstallProgress;
typedef struct MCPInstallTitleInfo MCPInstallTitleInfo;
typedef struct MCPSysProdSettings MCPSysProdSettings;
typedef struct MCPSystemVersion MCPSystemVersion;
typedef struct MCPTitleListType MCPTitleListType;
typedef enum MCPAppType
{
MCP_APP_TYPE_GAME_UPDATE = 0x0800001B,
MCP_APP_TYPE_GAME_DLC = 0x0800000E,
MCP_APP_TYPE_BOOT1 = 0x10000009,
MCP_APP_TYPE_SYSTEM_LIBRARIES = 0x1000000A,
MCP_APP_TYPE_BLUETOOTH_FIRMWARE = 0x10000012,
MCP_APP_TYPE_DRC_FIRMWARE = 0x10000013,
MCP_APP_TYPE_DRH_FIRMWARE = 0x10000014,
MCP_APP_TYPE_SYSTEM_VERSION = 0x10000015,
MCP_APP_TYPE_DRC_LANGUAGE = 0x1000001A,
MCP_APP_TYPE_EXCEPTIONS_DATA = 0x18000010,
MCP_APP_TYPE_SHARED_DATA = 0x1800001C,
MCP_APP_TYPE_CERT_STORE = 0x1800001E,
MCP_APP_TYPE_PATCH_MAP_DATA = 0x18000023,
MCP_APP_TYPE_WAGONU_MIGRATION_LIST = 0x18000029,
MCP_APP_TYPE_CAFFEINE_TITLE_LIST = 0x18000030,
MCP_APP_TYPE_MCP_TITLE_LIST = 0x18000031,
MCP_APP_TYPE_GAME = 0x80000000,
MCP_APP_TYPE_GAME_WII = 0x8000002E,
MCP_APP_TYPE_SYSTEM_MENU = 0x90000001,
MCP_APP_TYPE_SYSTEM_UPDATER = 0x9000000B,
MCP_APP_TYPE_SYSTEM_APPS = 0x90000020,
MCP_APP_TYPE_ACCOUNT_APPS = 0x90000021,
MCP_APP_TYPE_SYSTEM_SETTINGS = 0x90000022,
MCP_APP_TYPE_ECO_PROCESS = 0x9000002F,
MCP_APP_TYPE_EMANUAL = 0xD0000003,
MCP_APP_TYPE_HOME_MENU = 0xD0000004,
MCP_APP_TYPE_ERROR_DISPLAY = 0xD0000005,
MCP_APP_TYPE_BROWSER = 0xD0000006,
MCP_APP_TYPE_MIIVERSE_POST = 0xD000000D,
MCP_APP_TYPE_MIIVERSE = 0xD0000016,
MCP_APP_TYPE_ESHOP = 0xD0000017,
MCP_APP_TYPE_FRIEND_LIST = 0xD0000018,
MCP_APP_TYPE_DOWNLOAD_MANAGEMENT = 0xD0000019,
MCP_APP_TYPE_AOC_OVERLAY = 0xD000002C,
MCP_APP_TYPE_AMIIBO_SETTINGS = 0xD0000033,
} MCPAppType;
typedef enum MCPDeviceType
{
MCP_DEVICE_TYPE_ODD = 2,
MCP_DEVICE_TYPE_MLC = 3,
MCP_DEVICE_TYPE_USB = 4,
} MCPDeviceType;
typedef enum MCPDeviceFlags
{
MCP_DEVICE_FLAG_UNK_1 = 0x1,
MCP_DEVICE_FLAG_UNK_2 = 0x2,
MCP_DEVICE_FLAG_UNK_4 = 0x4,
MCP_DEVICE_FLAG_UNK_8 = 0x8,
} MCPDeviceFlags;
typedef enum MCPInstallTarget
{
MCP_INSTALL_TARGET_MLC = 0,
MCP_INSTALL_TARGET_USB = 1,
} MCPInstallTarget;
typedef enum MCPRegion
{
MCP_REGION_JAPAN = 0x01,
MCP_REGION_USA = 0x02,
MCP_REGION_EUROPE = 0x04,
MCP_REGION_CHINA = 0x10,
MCP_REGION_KOREA = 0x20,
MCP_REGION_TAIWAN = 0x40,
} MCPRegion;
typedef enum MCPCompatAVFile
{
//! DMCU firmware
MCP_COMPAT_AV_FILE_DMCU = 0x00,
//! Deinterlacer parameters
MCP_COMPAT_AV_FILE_DEINT = 0x01,
} MCPCompatAVFile;
struct WUT_PACKED MCPDevice
{
char type[8];
char unk0x08[128];
char filesystem[8];
char path[0x27F];
MCPDeviceFlags flags;
uint32_t uid;
uint32_t index;
};
WUT_CHECK_OFFSET(MCPDevice, 0x00, type);
WUT_CHECK_OFFSET(MCPDevice, 0x08, unk0x08);
WUT_CHECK_OFFSET(MCPDevice, 0x88, filesystem);
WUT_CHECK_OFFSET(MCPDevice, 0x90, path);
WUT_CHECK_OFFSET(MCPDevice, 0x30F, flags);
WUT_CHECK_OFFSET(MCPDevice, 0x313, uid);
WUT_CHECK_OFFSET(MCPDevice, 0x317, index);
WUT_CHECK_SIZE(MCPDevice, 0x31B);
struct MCPInstallInfo
{
WUT_UNKNOWN_BYTES(0x27F);
};
WUT_CHECK_SIZE(MCPInstallInfo, 0x27F);
struct WUT_PACKED MCPInstallProgress
{
uint32_t inProgress;
uint64_t tid;
uint64_t sizeTotal;
uint64_t sizeProgress;
uint32_t contentsTotal;
uint32_t contentsProgress;
};
WUT_CHECK_OFFSET(MCPInstallProgress, 0x00, inProgress);
WUT_CHECK_OFFSET(MCPInstallProgress, 0x04, tid);
WUT_CHECK_OFFSET(MCPInstallProgress, 0x0C, sizeTotal);
WUT_CHECK_OFFSET(MCPInstallProgress, 0x14, sizeProgress);
WUT_CHECK_OFFSET(MCPInstallProgress, 0x1C, contentsTotal);
WUT_CHECK_OFFSET(MCPInstallProgress, 0x20, contentsProgress);
WUT_CHECK_SIZE(MCPInstallProgress, 0x24);
struct MCPInstallTitleInfo
{
WUT_UNKNOWN_BYTES(0x27F);
};
WUT_CHECK_SIZE(MCPInstallTitleInfo, 0x27F);
struct WUT_PACKED MCPSysProdSettings
{
MCPRegion product_area;
uint16_t eeprom_version;
WUT_PADDING_BYTES(2);
MCPRegion game_region;
WUT_UNKNOWN_BYTES(4);
char ntsc_pal[5];
//! 5ghz_country_code in xml
char wifi_5ghz_country_code[4];
//! 5ghz_country_code_revision in xml
uint8_t wifi_5ghz_country_code_revision;
char code_id[8];
char serial_id[12];
WUT_UNKNOWN_BYTES(4);
char model_number[16];
uint32_t version;
};
WUT_CHECK_OFFSET(MCPSysProdSettings, 0x00, product_area);
WUT_CHECK_OFFSET(MCPSysProdSettings, 0x04, eeprom_version);
WUT_CHECK_OFFSET(MCPSysProdSettings, 0x08, game_region);
WUT_CHECK_OFFSET(MCPSysProdSettings, 0x10, ntsc_pal);
WUT_CHECK_OFFSET(MCPSysProdSettings, 0x15, wifi_5ghz_country_code);
WUT_CHECK_OFFSET(MCPSysProdSettings, 0x19, wifi_5ghz_country_code_revision);
WUT_CHECK_OFFSET(MCPSysProdSettings, 0x1A, code_id);
WUT_CHECK_OFFSET(MCPSysProdSettings, 0x22, serial_id);
WUT_CHECK_OFFSET(MCPSysProdSettings, 0x32, model_number);
WUT_CHECK_OFFSET(MCPSysProdSettings, 0x42, version);
WUT_CHECK_SIZE(MCPSysProdSettings, 0x46);
struct MCPSystemVersion
{
uint32_t major;
uint32_t minor;
uint32_t patch;
char region;
};
WUT_CHECK_OFFSET(MCPSystemVersion, 0x00, major);
WUT_CHECK_OFFSET(MCPSystemVersion, 0x04, minor);
WUT_CHECK_OFFSET(MCPSystemVersion, 0x08, patch);
WUT_CHECK_OFFSET(MCPSystemVersion, 0x0C, region);
WUT_CHECK_SIZE(MCPSystemVersion, 0x10);
struct WUT_PACKED MCPTitleListType
{
uint64_t titleId;
uint32_t groupId;
char path[56];
MCPAppType appType;
uint16_t titleVersion;
uint64_t osVersion;
uint32_t sdkVersion;
char indexedDevice[10];
uint8_t unk0x60;
};
WUT_CHECK_OFFSET(MCPTitleListType, 0x00, titleId);
WUT_CHECK_OFFSET(MCPTitleListType, 0x08, groupId);
WUT_CHECK_OFFSET(MCPTitleListType, 0x0C, path);
WUT_CHECK_OFFSET(MCPTitleListType, 0x44, appType);
WUT_CHECK_OFFSET(MCPTitleListType, 0x48, titleVersion);
WUT_CHECK_OFFSET(MCPTitleListType, 0x4A, osVersion);
WUT_CHECK_OFFSET(MCPTitleListType, 0x52, sdkVersion);
WUT_CHECK_OFFSET(MCPTitleListType, 0x56, indexedDevice);
WUT_CHECK_OFFSET(MCPTitleListType, 0x60, unk0x60);
WUT_CHECK_SIZE(MCPTitleListType, 0x61);
MCPError
MCP_Open();
MCPError
MCP_Close(int handle);
MCPError
MCP_DeviceList(int handle,
int *numDevices,
MCPDevice *outDeviceList,
uint32_t deviceListSizeInBytes);
MCPError
MCP_FullDeviceList(int handle,
int *numDevices,
MCPDevice *outDeviceList,
uint32_t deviceListSizeInBytes);
MCPError
MCP_GetOwnTitleInfo(int32_t handle,
MCPTitleListType *titleInfo);
MCPError
MCP_GetSysProdSettings(int32_t handle,
MCPSysProdSettings *settings);
MCPError
MCP_GetSystemVersion(int32_t handle,
MCPSystemVersion *systemVersion);
MCPError
MCP_GetTitleId(int32_t handle,
uint64_t *outTitleId);
MCPError
MCP_GetTitleInfo(int32_t handle,
uint64_t titleId,
MCPTitleListType *titleInfo);
MCPError
MCP_InstallSetTargetDevice(int handle,
MCPInstallTarget device);
MCPError
MCP_InstallGetTargetDevice(int handle,
MCPInstallTarget *deviceOut);
MCPError
MCP_InstallSetTargetUsb(int handle,
int usb);
MCPError
MCP_InstallGetInfo(int handle,
const char *path,
MCPInstallInfo *out);
MCPError
MCP_InstallTitleAsync(int handle,
const char *path,
MCPInstallTitleInfo *out);
MCPError
MCP_InstallGetProgress(int handle,
MCPInstallProgress *installProgressOut);
MCPError
MCP_InstallTitleAbort(int handle);
MCPError
MCP_TitleCount(int32_t handle);
MCPError
MCP_TitleList(int32_t handle,
uint32_t *outTitleCount,
MCPTitleListType *titleList,
uint32_t titleListSizeBytes);
MCPError
MCP_TitleListByAppType(int32_t handle,
MCPAppType appType,
uint32_t *outTitleCount,
MCPTitleListType *titleList,
uint32_t titleListSizeBytes);
MCPError
MCP_TitleListByUniqueId(int32_t handle,
uint32_t uniqueId,
uint32_t *outTitleCount,
MCPTitleListType *titleList,
uint32_t titleListSizeBytes);
MCPError
MCP_TitleListByDevice(int32_t handle,
const char *device,
uint32_t *outTitleCount,
MCPTitleListType *titleList,
uint32_t titleListSizeBytes);
MCPError
MCP_TitleListByDeviceType(int32_t handle,
MCPDeviceType deviceType,
uint32_t *outTitleCount,
MCPTitleListType *titleList,
uint32_t titleListSizeBytes);
MCPError
MCP_TitleListByAppAndDevice(int32_t handle,
MCPAppType appType,
const char *device,
uint32_t *outTitleCount,
MCPTitleListType *titleList,
uint32_t titleListSizeBytes);
MCPError
MCP_TitleListByAppAndDeviceType(int32_t handle,
MCPAppType appType,
MCPDeviceType deviceType,
uint32_t *outTitleCount,
MCPTitleListType *titleList,
uint32_t titleListSizeBytes);
MCPError
MCP_TitleListByUniqueIdAndIndexedDeviceAndAppType(int32_t handle,
uint32_t uniqueId,
const char *indexedDevice,
uint8_t unk0x60,
MCPAppType appType,
uint32_t *outTitleCount,
MCPTitleListType *titleList,
uint32_t titleListSizeBytes);
MCPError
MCP_UninstallTitleAsync(int32_t handle,
const char *path,
MCPInstallTitleInfo *out);
MCPError
MCP_CompatLoadAVFile(int32_t handle,
void *ptr,
uint32_t *size,
MCPCompatAVFile file);
/**
* Saves the current Cafe log to the SLC logs directory.
* Internally calls IOS_Ioctl() with request \c 0xCD .
*
* \return
* \c 0 on success.
*/
MCPError
MCP_TriggerCrashLogCollection(int32_t handle);
/**
* Sets values to /storage_slc/sys/config/eco.xml
*
* \return
* \c 0 on success.
*/
MCPError
MCP_ChangeEcoSettings(int32_t handle,
uint32_t enable,
uint32_t maxOnTime,
uint16_t defaultOffTime);
#ifdef __cplusplus
}
#endif
/** @} */