Difference between revisions of "/dev/es"

From WiiBrew
Jump to: navigation, search
(/dev/es IOS_Ioctlv)
(Error codes)
 
(55 intermediate revisions by 16 users not shown)
Line 1: Line 1:
The ES (ETicket Services?) is responsible for the security of Wii, making it the enemy!  Along with the rest of IOS, this is generally considered a "private interface" -- game developers never call any of these functions directly. Most of these are now implemented in libogc -- see http://devkitpro.cvs.sourceforge.net/viewvc/devkitpro/libogc/libogc/es.c?view=markup. Please feel free to submit patches to implement the remaining functions.
+
__FORCETOC__
 +
 
 +
''ES'' (E-Ticket Services) is the IOS module that is notably responsible for title management, bootstrapping the PowerPC and giving it access to title contents.
 +
 
 +
This module is always part of the main, bootable binary, along with the IOS kernel, crypto code (IOSC) and the flash filesystem driver (FFS). It runs with more privileges than any other process and has access to most syscalls.
 +
 
 +
Along with the rest of IOS, this is generally considered a "private interface" -- game developers never call any of these functions directly.  
 +
 
 +
Most of these are now implemented in [http://devkitpro.svn.sourceforge.net/viewvc/devkitpro/trunk/libogc/libogc/es.c?view=log libogc]. Please feel free to submit patches to implement the remaining functions.
 
   
 
   
Here are the known ES functions:
+
== Commands ==
 +
{| class="wikitable"
 +
! Command !! Name !! Notes
 +
|-
 +
| 0x1 || Open || ES keeps track of three contexts, one per active handle, so only three handles can be opened at once. -1016 will be returned if the maximum amount of handles is exceeded.
 +
|-
 +
| 0x2 || Close || -
 +
|-
 +
| 0x3 || Read || Not supported; returns IPC_EINVAL (-4).
 +
|-
 +
| 0x4 || Write || Not supported; returns IPC_EINVAL (-4).
 +
|-
 +
| 0x5 || Seek || Not supported; returns IPC_EINVAL (-4).
 +
|-
 +
| 0x6 || Ioctl || Not supported; returns IPC_EINVAL (-4).
 +
|-
 +
| 0x7 || Ioctlv || Up to 0x45 ioctlvs available depending on the version.
 +
|-
 +
|}
  
  ios_ioctlv( fd, 0x01, 4, 0, vec); // ES_AddTicket(const signed_blob *stik, u32 stik_size, const signed_blob *certificates, u32 certificates_size, const signed_blob *crl, u32 crl_size)
+
== Known ES Functions ==
 +
 
 +
  ios_ioctlv( fd, 0x01, 3, 0, vec); // ES_AddTicket(const signed_blob *stik, u32 stik_size, const signed_blob *certificates, u32 certificates_size, const signed_blob *crl, u32 crl_size)
 
  ios_ioctlv( fd, 0x02, 4, 0, vec); // ES_AddTitleStart(const signed_blob *stmd, u32 tmd_size, const signed_blob *certificates, u32 certificates_size, const signed_blob *crl, u32 crl_size)
 
  ios_ioctlv( fd, 0x02, 4, 0, vec); // ES_AddTitleStart(const signed_blob *stmd, u32 tmd_size, const signed_blob *certificates, u32 certificates_size, const signed_blob *crl, u32 crl_size)
 
  ios_ioctlv( fd, 0x03, 2, 0, vec); // ES_AddContentStart(u64 titleID, u32 cid)
 
  ios_ioctlv( fd, 0x03, 2, 0, vec); // ES_AddContentStart(u64 titleID, u32 cid)
Line 10: Line 38:
 
  ios_ioctlv( fd, 0x06, 0, 0, vec); // ES_AddTitleFinish(void)
 
  ios_ioctlv( fd, 0x06, 0, 0, vec); // ES_AddTitleFinish(void)
 
  ios_ioctlv( fd, 0x07, 0, 1, vec); // ES_GetDeviceID
 
  ios_ioctlv( fd, 0x07, 0, 1, vec); // ES_GetDeviceID
  ios_ioctlvReboot(fd, 8, 2, 0, vec); // ES_LaunchTitle(u64 titleID, const tikview *view)
+
  ios_ioctlvReboot(fd, 0x08, 2, 0, vec); // ES_LaunchTitle(u64 titleID, const tikview *view)
 
  ios_ioctlv( fd, 0x09, 1, 0, vec);  // ES_OpenContent(u16 index)
 
  ios_ioctlv( fd, 0x09, 1, 0, vec);  // ES_OpenContent(u16 index)
 
  ios_ioctlv( fd, 0x0A, 1, 1, vec); // ES_ReadContent(s32 cfd, u8 *data, u32 data_size)
 
  ios_ioctlv( fd, 0x0A, 1, 1, vec); // ES_ReadContent(s32 cfd, u8 *data, u32 data_size)
Line 18: Line 46:
 
  ios_ioctlv( fd, 0x0E, 0, 1, vec); // ES_GetTitlesCount
 
  ios_ioctlv( fd, 0x0E, 0, 1, vec); // ES_GetTitlesCount
 
  ios_ioctlv( fd, 0x0F, 1, 1, vec); // ES_GetTitles
 
  ios_ioctlv( fd, 0x0F, 1, 1, vec); // ES_GetTitles
  ios_ioctlv( fd, 0x10, 0, 1, vec); // ES_GetTitleContentsCount
+
  ios_ioctlv( fd, 0x10, 1, 1, vec); // ES_GetTitleContentsCount
 
  ios_ioctlv( fd, 0x11, 2, 1, vec); // ES_GetTitleContent
 
  ios_ioctlv( fd, 0x11, 2, 1, vec); // ES_GetTitleContent
 
  ios_ioctlv( fd, 0x12, 1, 1, vec); // ES_GetNumTicketViews(u64 titleID, u32 *cnt)
 
  ios_ioctlv( fd, 0x12, 1, 1, vec); // ES_GetNumTicketViews(u64 titleID, u32 *cnt)
  ios_ioctlv( fd, 0x13, 1, 1, vec); // ES_GetTicketViews(u64 titleID, tikview *views, u32 cnt)
+
  ios_ioctlv( fd, 0x13, 2, 1, vec); // ES_GetTicketViews(u64 titleID, tikview *views, u32 cnt)
 
  ios_ioctlv( fd, 0x14, 1, 1, vec); // ES_GetTmdViewSize
 
  ios_ioctlv( fd, 0x14, 1, 1, vec); // ES_GetTmdViewSize
 
  ios_ioctlv( fd, 0x15, 2, 1, vec); // ES_GetTmdView
 
  ios_ioctlv( fd, 0x15, 2, 1, vec); // ES_GetTmdView
 
  ios_ioctlv( fd, 0x16, 1, 2, vec); // ES_GetConsumption
 
  ios_ioctlv( fd, 0x16, 1, 2, vec); // ES_GetConsumption
  ios_ioctlv( fd, 0x17, 1, 2, vec); // ES_DeleteTitle
+
  ios_ioctlv( fd, 0x17, 1, 0, vec); // ES_DeleteTitle
  ios_ioctlv( fd, 0x18, 1, 2, vec); // ES_DeleteTicket
+
  ios_ioctlv( fd, 0x18, 1, 0, vec); // ES_DeleteTicket
  ios_ioctlv( fd, 0x19, 1, 1, vec); // ES_DiGetTmdViewCount
+
  ios_ioctlv( fd, 0x19, 1, 1, vec); // ES_DIGetTmdViewSize( u8 *TMD, u32 *TMDViewSize )
 
  ios_ioctlv( fd, 0x1A, 2, 1, vec); // ES_DiGetTmdView
 
  ios_ioctlv( fd, 0x1A, 2, 1, vec); // ES_DiGetTmdView
 
  ios_ioctlv( fd, 0x1B, 1, 1, vec); // ES_DiGetTicketView
 
  ios_ioctlv( fd, 0x1B, 1, 1, vec); // ES_DiGetTicketView
  ios_ioctlv( fd, 0x1c, 1, 1, vec); // ES_DiVerify
+
  ios_ioctlv( fd, 0x1C, 4, 2, vec); // ES_DiVerify
  ios_ioctlv( fd, 0x1d, 1, 1, vec); // ES_GetDataDir
+
  ios_ioctlv( fd, 0x1D, 1, 1, vec); // ES_GetDataDir
  ios_ioctlv( fd, 0x1e, 0, 1, vec); // ES_GetDeviceCert(u8 *outbuf)
+
  ios_ioctlv( fd, 0x1E, 0, 1, vec); // ES_GetDeviceCert(u8 *outbuf)
  ios_ioctlv( fd, 0x1f, 6, 0, vec); // ES_ImportBoot( const signed_blob *tik, u32 tik_size, const signed_blob *tik_certs, u32 tik_certs_size, const signed_blob *tmd, u32 tmd_size, const signed_blob *tmd_certs, u32 tmd_certs_size, const u8 *content, u32 content_size )
+
  ios_ioctlv( fd, 0x1F, 6, 0, vec); // ES_ImportBoot( const signed_blob *tik, u32 tik_size, const signed_blob *tik_certs, u32 tik_certs_size, const signed_blob *tmd, u32 tmd_size, const signed_blob *tmd_certs, u32 tmd_certs_size, const u8 *content, u32 content_size )
 
  ios_ioctlv( fd, 0x20, 0, 1, vec); // ES_GetTitleId
 
  ios_ioctlv( fd, 0x20, 0, 1, vec); // ES_GetTitleId
 
  ios_ioctlv( fd, 0x21, 1, 0, vec); // ES_SetUid
 
  ios_ioctlv( fd, 0x21, 1, 0, vec); // ES_SetUid
 
  ios_ioctlv( fd, 0x22, 1, 0, vec); // ES_DeleteTitleContent(u64 titleID) - deletes all files containing 'app' in a /title/xxxxxxxx/yyyyyyyy/content
 
  ios_ioctlv( fd, 0x22, 1, 0, vec); // ES_DeleteTitleContent(u64 titleID) - deletes all files containing 'app' in a /title/xxxxxxxx/yyyyyyyy/content
 
  ios_ioctlv( fd, 0x23, 3, 0, vec); // ES_SeekContent
 
  ios_ioctlv( fd, 0x23, 3, 0, vec); // ES_SeekContent
  ios_ioctlv( fd, 0x24, 3, 0, vec); // ES_OpenTitleContent
+
  ios_ioctlv( fd, 0x24, 3, 0, vec); // ES_OpenTitleContent(u64 titleID, const tikview *view, u16 index)
 
  ios_ioctlv( fd, 0x25, 0, 0, vec); // ES_LaunchBC(void)
 
  ios_ioctlv( fd, 0x25, 0, 0, vec); // ES_LaunchBC(void)
  ios_ioctlv( fd, 0x26, 1, 0, vec); // ES_ExportTitleInit
+
  ios_ioctlv( fd, 0x26, 1, 1, vec); // ES_ExportTitleInit
 
  ios_ioctlv( fd, 0x27, 2, 0, vec); // ES_ExportContentBegin
 
  ios_ioctlv( fd, 0x27, 2, 0, vec); // ES_ExportContentBegin
 
  ios_ioctlv( fd, 0x28, 1, 1, vec); // ES_ExportContentData
 
  ios_ioctlv( fd, 0x28, 1, 1, vec); // ES_ExportContentData
Line 52: Line 80:
 
  ios_ioctlv( fd, 0x30, 1, 2, vec); // ES_Sign(u8 *source, u32 size, u8 *sig, u8 *certs)
 
  ios_ioctlv( fd, 0x30, 1, 2, vec); // ES_Sign(u8 *source, u32 size, u8 *sig, u8 *certs)
 
  ios_ioctlv( fd, 0x31, 3, 0, vec); // ES_VerifySign
 
  ios_ioctlv( fd, 0x31, 3, 0, vec); // ES_VerifySign
  ios_ioctlv( fd, 0x32, 0, 1, vec); // ES_GetStoredContentCount
+
// the following functions are only available in IOS28+
  ios_ioctlv( fd, 0x33, 0, 1, vec); // ES_GetStoredContent
+
  ios_ioctlv( fd, 0x32, 1, 1, vec); // ES_GetStoredContentCount
  ios_ioctlv( fd, 0x34, 0, 1, vec); // ES_GetStoredTmdSize
+
  ios_ioctlv( fd, 0x33, 2, 1, vec); // ES_GetStoredContent
  ios_ioctlv( fd, 0x35, 0, 1, vec); // ES_GetStoredTmd
+
  ios_ioctlv( fd, 0x34, 1, 1, vec); // ES_GetStoredTmdSize
 +
  ios_ioctlv( fd, 0x35, 2, 1, vec); // ES_GetStoredTmd
 
  ios_ioctlv( fd, 0x36, 0, 1, vec); // ES_GetSharedContentCount
 
  ios_ioctlv( fd, 0x36, 0, 1, vec); // ES_GetSharedContentCount
  ios_ioctlv( fd, 0x37, 0, 1, vec); // ES_GetSharedContents
+
  ios_ioctlv( fd, 0x37, 1, 1, vec); // ES_GetSharedContents
  ios_ioctlv( fd, 0x38, ?, ?, vec);  
+
  ios_ioctlv( fd, 0x38, 1, 0, vec); // ES_DeleteSharedContent
 
  ios_ioctlv( fd, 0x39, 0, 1, vec); // ES_GetDiTmdSize
 
  ios_ioctlv( fd, 0x39, 0, 1, vec); // ES_GetDiTmdSize
 
  ios_ioctlv( fd, 0x3A, 1, 1, vec); // ES_GetDiTmd
 
  ios_ioctlv( fd, 0x3A, 1, 1, vec); // ES_GetDiTmd
  ios_ioctlv( fd, 0x3B, 0, 1, vec); // Unknown ... calls ES_DiVerify
+
  ios_ioctlv( fd, 0x3B, 4, 2, vec); // ES_DiVerifyWithTicketView (DI only; takes a ticket view instead of a ticket and calls ES_DiVerify)
  ios_ioctlv( fd, 0x3C, 0, 1, vec); // Unknown ... calls ES_DiVerify
+
ios_ioctlv( fd, 0x3C, 2, 1, vec); // ES_SetupStreamKey(TicketView* ticket_view, TMD* tmd, u32 tmd_size, int* key_handle) (WFS only, only usable for some title types and UIDs)
  ios_ioctlv( fd, 0x3D, 0, 1, vec); // wrapper for syscall 5c
+
ios_ioctlv( fd, 0x3D, 0, 1, vec); // ES_DeleteStreamKey (calls IOSC_DeleteObject)
 +
// the following functions are only available in IOS37+ but not in IOS38
 +
ios_ioctlv( fd, 0x3E, 2, 0, vec); // Unknown ... Deletes a content from a title's private directory
 +
// the following functions are only available in IOS37v3609+ but not in IOS38
 +
  ios_ioctlv( fd, 0x3F, ?, ?, vec); // non-existant ioctl why? ... because.
 +
  ios_ioctlv( fd, 0x40, 1, 1, vec); // ES_GetV0TicketFromView(const u8* ticket_view, u8* ticket)
 +
// the following functions are only available in IOS56+
 +
ios_ioctlv( fd, 0x41, 1, 1, vec); // Unknown -- retrieves a key?
 +
ios_ioctlv( fd, 0x42, 2, 0, vec); // Unknown -- something with a key?
 +
// the following functions are only available in IOS56v5405+/IOS57v5661+/IOS61v5405+/IOS70+ Please check (I thought it was a rule never add new functions existing IOS)
 +
ios_ioctlv( fd, 0x43, 1, 1, vec); // ES_GetTicketFromView(const u8* ticket_view, u8* ticket, u32* ticket_size) -- used to get the ticket size from a view (internally called with ticket = nullptr)
 +
ios_ioctlv( fd, 0x44, 2, 1, vec); // ES_GetTicketFromView(const u8* ticket_view, u8* ticket, u32* ticket_size) -- used to get a ticket from a view
 +
ios_ioctlv( fd, 0x45, 0, 0, vec); // Unknown ... korean-common-key check
  
 
== /dev/es IOS_Ioctlv ==
 
== /dev/es IOS_Ioctlv ==
 +
{{stub}}
 
{| class="wikitable" style="margin: 1em auto 1em auto"
 
{| class="wikitable" style="margin: 1em auto 1em auto"
 
! style="vertical-align: top;" |number
 
! style="vertical-align: top;" |number
Line 72: Line 114:
 
! style="vertical-align: top;" |out count
 
! style="vertical-align: top;" |out count
 
! style="vertical-align: top;" |vec entry target
 
! style="vertical-align: top;" |vec entry target
! style="vertical-align: top;" |vec entry size
+
! style="vertical-align: top;" |vec entry size [bytes]
 
! style="vertical-align: top;" |libogc prototype
 
! style="vertical-align: top;" |libogc prototype
 
! style="vertical-align: top;" |Description
 
! style="vertical-align: top;" |Description
Line 78: Line 120:
 
| style="vertical-align: top;"|0x00
 
| style="vertical-align: top;"|0x00
 
| style="vertical-align: top;"|?
 
| style="vertical-align: top;"|?
| style="vertical-align: top;"|0
 
| style="vertical-align: top;"|0
 
| style="vertical-align: top;"|
 
| style="vertical-align: top;"|
 
 
| style="vertical-align: top;"|?
 
| style="vertical-align: top;"|?
| style="vertical-align: top;"|returns -1017
+
| style="vertical-align: top;"|?
 +
| style="vertical-align: top;"|?
 +
| style="vertical-align: top;"|?
 +
| style="vertical-align: top;"|?
 +
| style="vertical-align: top;"|returns -1017 non-existant ioctl
 
|-  style="background-color: #eee;"
 
|-  style="background-color: #eee;"
 
| style="vertical-align: top;" rowspan="3" |0x01
 
| style="vertical-align: top;" rowspan="3" |0x01
Line 106: Line 148:
 
| style="vertical-align: top;" |?  
 
| style="vertical-align: top;" |?  
 
| style="vertical-align: top;" |?
 
| style="vertical-align: top;" |?
| style="vertical-align: top;" rowspan="4" |?
+
| style="vertical-align: top;" rowspan="4" |ES_AddTitleStart(const signed_blob *stmd, u32 tmd_size, const signed_blob *certificates, u32 certificates_size, const signed_blob *crl, u32 crl_size)
 
| style="vertical-align: top;" rowspan="4" |?
 
| style="vertical-align: top;" rowspan="4" |?
 
|-
 
|-
Line 124: Line 166:
 
| style="vertical-align: top;" |?  
 
| style="vertical-align: top;" |?  
 
| style="vertical-align: top;" |0x8
 
| style="vertical-align: top;" |0x8
| style="vertical-align: top;" rowspan="2" |?
+
| style="vertical-align: top;" rowspan="2" |ES_AddContentStart(u64 titleID, u32 cid)
 
| style="vertical-align: top;" rowspan="2" |?
 
| style="vertical-align: top;" rowspan="2" |?
 
|- style="background-color: #eee;"
 
|- style="background-color: #eee;"
Line 136: Line 178:
 
| style="vertical-align: top;" |?  
 
| style="vertical-align: top;" |?  
 
| style="vertical-align: top;" |0x4
 
| style="vertical-align: top;" |0x4
| style="vertical-align: top;" rowspan="2" |?
+
| style="vertical-align: top;" rowspan="2" |ES_AddContentData(s32 cfd, u8 *data, u32 data_size)
 
| style="vertical-align: top;" rowspan="2" |?
 
| style="vertical-align: top;" rowspan="2" |?
 
|-
 
|-
Line 148: Line 190:
 
| style="vertical-align: top;" |?  
 
| style="vertical-align: top;" |?  
 
| style="vertical-align: top;" |0x4
 
| style="vertical-align: top;" |0x4
| style="vertical-align: top;" |?
+
| style="vertical-align: top;" |ES_AddContentFinish(u32 cid)
 
| style="vertical-align: top;" |?
 
| style="vertical-align: top;" |?
 
|-
 
|-
Line 157: Line 199:
 
| style="vertical-align: top;" |
 
| style="vertical-align: top;" |
 
| style="vertical-align: top;" |
 
| style="vertical-align: top;" |
| style="vertical-align: top;" rowspan="1" |?
+
| style="vertical-align: top;" rowspan="1" |ES_AddTitleFinish(void)
 
| style="vertical-align: top;" rowspan="1" |?
 
| style="vertical-align: top;" rowspan="1" |?
 
|- style="background-color: #eee;"
 
|- style="background-color: #eee;"
Line 166: Line 208:
 
| style="vertical-align: top;" |?  
 
| style="vertical-align: top;" |?  
 
| style="vertical-align: top;" |0x4
 
| style="vertical-align: top;" |0x4
| style="vertical-align: top;" |?
+
| style="vertical-align: top;" |ES_GetDeviceID(u32 *device_id)
 
| style="vertical-align: top;" |?
 
| style="vertical-align: top;" |?
 
|-
 
|-
Line 175: Line 217:
 
| style="vertical-align: top;" |?
 
| style="vertical-align: top;" |?
 
| style="vertical-align: top;" |0x8
 
| style="vertical-align: top;" |0x8
| style="vertical-align: top;" rowspan="2" |?
+
| style="vertical-align: top;" rowspan="2" |ES_LaunchTitleBackground(u64 titleID, const tikview *view); ES_LaunchTitle(u64 titleID, const tikview *view);
 
| style="vertical-align: top;" rowspan="2" |?
 
| style="vertical-align: top;" rowspan="2" |?
 
|-
 
|-
Line 187: Line 229:
 
| style="vertical-align: top;" |?  
 
| style="vertical-align: top;" |?  
 
| style="vertical-align: top;" |0x4
 
| style="vertical-align: top;" |0x4
| style="vertical-align: top;" |?
+
| style="vertical-align: top;" |ES_OpenContent(u16 index)
 
| style="vertical-align: top;" |?
 
| style="vertical-align: top;" |?
 
|-
 
|-
| style="vertical-align: top;" rowspan="2" |0x0a
+
| style="vertical-align: top;" rowspan="2" |0x0A
 
| style="vertical-align: top;" rowspan="2" |ES_ReadContent
 
| style="vertical-align: top;" rowspan="2" |ES_ReadContent
 
| style="vertical-align: top;" rowspan="2" |1
 
| style="vertical-align: top;" rowspan="2" |1
Line 196: Line 238:
 
| style="vertical-align: top;" |?
 
| style="vertical-align: top;" |?
 
| style="vertical-align: top;" |0x4
 
| style="vertical-align: top;" |0x4
| style="vertical-align: top;" rowspan="2" |?
+
| style="vertical-align: top;" rowspan="2" |ES_ReadContent(s32 cfd, u8 *data, u32 data_size)
 
| style="vertical-align: top;" rowspan="2" |?
 
| style="vertical-align: top;" rowspan="2" |?
 
|-
 
|-
Line 202: Line 244:
 
| style="vertical-align: top;" |?
 
| style="vertical-align: top;" |?
 
|- style="background-color: #eee;"
 
|- style="background-color: #eee;"
| style="vertical-align: top;" |0x0b
+
| style="vertical-align: top;" |0x0B
 
| style="vertical-align: top;" |ES_CloseContent
 
| style="vertical-align: top;" |ES_CloseContent
 
| style="vertical-align: top;" |1
 
| style="vertical-align: top;" |1
Line 208: Line 250:
 
| style="vertical-align: top;" |?  
 
| style="vertical-align: top;" |?  
 
| style="vertical-align: top;" |0x4
 
| style="vertical-align: top;" |0x4
| style="vertical-align: top;" |?
+
| style="vertical-align: top;" |ES_CloseContent(s32 cfd)
 
| style="vertical-align: top;" |?
 
| style="vertical-align: top;" |?
 
|-
 
|-
| style="vertical-align: top;" rowspan="1" |0x0c
+
| style="vertical-align: top;" rowspan="1" |0x0C
 
| style="vertical-align: top;" rowspan="1" |ES_GetOwnedTitlesCount
 
| style="vertical-align: top;" rowspan="1" |ES_GetOwnedTitlesCount
 
| style="vertical-align: top;" rowspan="1" |0
 
| style="vertical-align: top;" rowspan="1" |0
Line 217: Line 259:
 
| style="vertical-align: top;" |u32* count
 
| style="vertical-align: top;" |u32* count
 
| style="vertical-align: top;" |0x4
 
| style="vertical-align: top;" |0x4
| style="vertical-align: top;" rowspan="1" |?
+
| style="vertical-align: top;" rowspan="1" |ES_GetNumOwnedTitles(u32 *cnt)
 
| style="vertical-align: top;" rowspan="1" |?
 
| style="vertical-align: top;" rowspan="1" |?
 
|- style="background-color: #eee;"
 
|- style="background-color: #eee;"
| style="vertical-align: top;" rowspan="2" |0x0d
+
| style="vertical-align: top;" rowspan="2" |0x0D
 
| style="vertical-align: top;" rowspan="2" |ES_GetOwnedTitles
 
| style="vertical-align: top;" rowspan="2" |ES_GetOwnedTitles
 
| style="vertical-align: top;" rowspan="2" |1
 
| style="vertical-align: top;" rowspan="2" |1
Line 226: Line 268:
 
| style="vertical-align: top;" |u32* count  
 
| style="vertical-align: top;" |u32* count  
 
| style="vertical-align: top;" |0x4
 
| style="vertical-align: top;" |0x4
| style="vertical-align: top;" rowspan="2" |?
+
| style="vertical-align: top;" rowspan="2" |ES_GetOwnedTitles(u64 *titles, u32 cnt)
 
| style="vertical-align: top;" rowspan="2" |?
 
| style="vertical-align: top;" rowspan="2" |?
 
|- style="background-color: #eee;"
 
|- style="background-color: #eee;"
 
| style="vertical-align: top;" |u64 titles[]
 
| style="vertical-align: top;" |u64 titles[]
| style="vertical-align: top;" |count*0x8
+
| style="vertical-align: top;" |[count]*0x8
 
|-
 
|-
| style="vertical-align: top;" |0x0e
+
| style="vertical-align: top;" |0x0E
 
| style="vertical-align: top;" |ES_GetTitlesCount
 
| style="vertical-align: top;" |ES_GetTitlesCount
 
| style="vertical-align: top;" |0
 
| style="vertical-align: top;" |0
 
| style="vertical-align: top;" |1
 
| style="vertical-align: top;" |1
 
| style="vertical-align: top;" |u32* count  
 
| style="vertical-align: top;" |u32* count  
| style="vertical-align: top;" |0x8
+
| style="vertical-align: top;" |0x4
| style="vertical-align: top;" |?
+
| style="vertical-align: top;" |ES_GetNumTitles(u32 *cnt)
 
| style="vertical-align: top;" |Sets the u32 pointed to by ''count'' to the number of titles on the system under /title.
 
| style="vertical-align: top;" |Sets the u32 pointed to by ''count'' to the number of titles on the system under /title.
 
|- style="background-color: #eee;"
 
|- style="background-color: #eee;"
| style="vertical-align: top;" rowspan="2" |0x0f
+
| style="vertical-align: top;" rowspan="2" |0x0F
 
| style="vertical-align: top;" rowspan="2" |ES_GetTitles
 
| style="vertical-align: top;" rowspan="2" |ES_GetTitles
 
| style="vertical-align: top;" rowspan="2" |1
 
| style="vertical-align: top;" rowspan="2" |1
 
| style="vertical-align: top;" rowspan="2" |1
 
| style="vertical-align: top;" rowspan="2" |1
| style="vertical-align: top;" |u8 buffer[]
+
| style="vertical-align: top;" |u32* count
| style="vertical-align: top;" |count*0x8
+
| style="vertical-align: top;" |0x4
| style="vertical-align: top;" rowspan="2" |?
+
| style="vertical-align: top;" rowspan="2" |ES_GetTitles(u64 *titles, u32 cnt)
| style="vertical-align: top;" rowspan="2" |Fills out ''buffer'' with at most ''count'' 8 byte title ids of titles on the system under /title. It also update ''count'' for the number of title ids copied.
+
| style="vertical-align: top;" rowspan="2" |Fills out ''buffer'' with at most ''count'' 8 byte title ids of titles on the system under /title. It also update ''count'' for the number of title its copied.
 
|- style="background-color: #eee;"
 
|- style="background-color: #eee;"
|u32* count
+
|u64 buffer[]
|0x4
+
|[count]*0x8
 
|-  
 
|-  
 
| style="vertical-align: top;" rowspan="2" |0x10
 
| style="vertical-align: top;" rowspan="2" |0x10
Line 259: Line 301:
 
| style="vertical-align: top;" |u64 title_id  
 
| style="vertical-align: top;" |u64 title_id  
 
| style="vertical-align: top;" |0x8
 
| style="vertical-align: top;" |0x8
| style="vertical-align: top;" rowspan="2" |?
+
| style="vertical-align: top;" rowspan="2" |ES_GetTitleContentsCount(u64 titleID, u32 *num)
 
| style="vertical-align: top;" rowspan="2" |Gets the number of contents from the tmd. It checks that the contents are present in the title's private content directory or linked via /shared1/content.map
 
| style="vertical-align: top;" rowspan="2" |Gets the number of contents from the tmd. It checks that the contents are present in the title's private content directory or linked via /shared1/content.map
 
|-
 
|-
|u32* num_contents
+
|u32* count
 
|0x4  
 
|0x4  
 
|- style="background-color: #eee;"
 
|- style="background-color: #eee;"
Line 271: Line 313:
 
| style="vertical-align: top;" |u64 title_id
 
| style="vertical-align: top;" |u64 title_id
 
| style="vertical-align: top;" |0x8
 
| style="vertical-align: top;" |0x8
| style="vertical-align: top;" rowspan="3" |?
+
| style="vertical-align: top;" rowspan="3" |No
 
| style="vertical-align: top;" rowspan="3" |Fills out ''content_ids'' with the content ids from the title's tmd. It checks if the contents are present in the title's private content directory or linked via /shared1/content.map
 
| style="vertical-align: top;" rowspan="3" |Fills out ''content_ids'' with the content ids from the title's tmd. It checks if the contents are present in the title's private content directory or linked via /shared1/content.map
 
|- style="background-color: #eee;"
 
|- style="background-color: #eee;"
|u32* num_contents
+
|u32* count
 
|0x4
 
|0x4
 
|- style="background-color: #eee;"
 
|- style="background-color: #eee;"
 
|u32 content_ids[]
 
|u32 content_ids[]
|num_contents*0x4
+
|[count]*0x4
 
|-  
 
|-  
 
| style="vertical-align: top;" rowspan="2" |0x12
 
| style="vertical-align: top;" rowspan="2" |0x12
Line 286: Line 328:
 
| style="vertical-align: top;" |u64 title_id
 
| style="vertical-align: top;" |u64 title_id
 
| style="vertical-align: top;" |0x8
 
| style="vertical-align: top;" |0x8
| style="vertical-align: top;" rowspan="2" |?
+
| style="vertical-align: top;" rowspan="2" |ES_GetNumTicketViews(u64 titleID, u32 *cnt)
 
| style="vertical-align: top;" rowspan="2" |?
 
| style="vertical-align: top;" rowspan="2" |?
 
|-
 
|-
Line 298: Line 340:
 
| style="vertical-align: top;" |u64 title_id
 
| style="vertical-align: top;" |u64 title_id
 
| style="vertical-align: top;" |0x8
 
| style="vertical-align: top;" |0x8
 +
| style="vertical-align: top;" rowspan="3" |ES_GetTicketViews(u64 titleID, tikview *views, u32 cnt)
 
| style="vertical-align: top;" rowspan="3" |?
 
| style="vertical-align: top;" rowspan="3" |?
 +
|- style="background-color: #eee;"
 +
|u32* count
 +
|0x4
 +
|- style="background-color: #eee;"
 +
|tikview_t ticketviews[]
 +
|[count]*0xd8
 +
|-
 +
| style="vertical-align: top;" rowspan="2" |0x14
 +
| style="vertical-align: top;" rowspan="2" |ES_GetTmdViewSize
 +
| style="vertical-align: top;" rowspan="2" |1
 +
| style="vertical-align: top;" rowspan="2" |1
 +
| style="vertical-align: top;" |u64 title_id
 +
| style="vertical-align: top;" |0x8
 +
| style="vertical-align: top;" rowspan="2" |ES_GetTMDViewSize(u64 titleID, u32 *size)
 +
| style="vertical-align: top;" rowspan="2" |?
 +
|-
 +
|u32* count
 +
|0x4
 +
|- style="background-color: #eee;"
 +
| style="vertical-align: top;" rowspan="3" |0x15
 +
| style="vertical-align: top;" rowspan="3" |ES_GetTmdView
 +
| style="vertical-align: top;" rowspan="3" |2
 +
| style="vertical-align: top;" rowspan="3" |1
 +
| style="vertical-align: top;" |u64 title_id
 +
| style="vertical-align: top;" |0x8
 +
| style="vertical-align: top;" rowspan="3" |ES_GetTMDView(u64 titleID, u8 *data, u32 size)
 
| style="vertical-align: top;" rowspan="3" |?
 
| style="vertical-align: top;" rowspan="3" |?
 
|- style="background-color: #eee;"
 
|- style="background-color: #eee;"
Line 304: Line 373:
 
|0x4
 
|0x4
 
|- style="background-color: #eee;"
 
|- style="background-color: #eee;"
|ticketview_t ticketviews[]
+
|tmdiew_t tmdview
|count*0xd8
+
|[count]
 +
|-
 +
| style="vertical-align: top;"|0x16
 +
| style="vertical-align: top;"|ES_GetConsumption
 +
| style="vertical-align: top;"|1
 +
| style="vertical-align: top;"|2
 +
| style="vertical-align: top;"|?
 +
| style="vertical-align: top;"|?
 +
| style="vertical-align: top;"|No
 +
| style="vertical-align: top;"|?
 +
|-
 +
|-
 +
| style="vertical-align: top;"|0x17
 +
| style="vertical-align: top;"|ES_DELETETITLE
 +
| style="vertical-align: top;"|1
 +
| style="vertical-align: top;"|0
 +
| style="vertical-align: top;"|u64 titleID
 +
| style="vertical-align: top;"|0x8
 +
| style="vertical-align: top;"|ES_DeleteTitle(u64 titleID)
 +
| style="vertical-align: top;"|?
 +
|-
 +
 
 +
|-
 +
| style="vertical-align: top;"|0x18
 +
| style="vertical-align: top;"|ES_DeleteTicket
 +
| style="vertical-align: top;"|1
 +
| style="vertical-align: top;"|0
 +
| style="vertical-align: top;"|?
 +
| style="vertical-align: top;"|?
 +
| style="vertical-align: top;"|ES_DeleteTicket(const tikview *view)
 +
| style="vertical-align: top;"|?
 +
|-
 +
|-
 +
| style="vertical-align: top;"|0x19
 +
| style="vertical-align: top;"|ES_DIGetTmdViewSize
 +
| style="vertical-align: top;"|1
 +
| style="vertical-align: top;"|0
 +
| style="vertical-align: top;"|?
 +
| style="vertical-align: top;"|?
 +
| style="vertical-align: top;"|No
 +
| style="vertical-align: top;"|?
 +
|-
 +
|-
 +
| style="vertical-align: top;"|0x1A
 +
| style="vertical-align: top;"|ES_DIGetTmdViewSize
 +
| style="vertical-align: top;"|2
 +
| style="vertical-align: top;"|1
 +
| style="vertical-align: top;"|?
 +
| style="vertical-align: top;"|?
 +
| style="vertical-align: top;"|No
 +
| style="vertical-align: top;"|?
 +
|-
 +
|-
 +
| style="vertical-align: top;"|0x1B
 +
| style="vertical-align: top;"|ES_DiGetTicketView
 +
| style="vertical-align: top;"|1
 +
| style="vertical-align: top;"|1
 +
| style="vertical-align: top;"|?
 +
| style="vertical-align: top;"|?
 +
| style="vertical-align: top;"|No
 +
| style="vertical-align: top;"|?
 +
|-
 +
|-
 +
| style="vertical-align: top;"|0x1C
 +
| style="vertical-align: top;"|ES_DiVerify
 +
| style="vertical-align: top;"|4
 +
| style="vertical-align: top;"|2
 +
| style="vertical-align: top;"|?
 +
| style="vertical-align: top;"|?
 +
| style="vertical-align: top;"|ES_Identify(const signed_blob *certificates, u32 certificates_size, const signed_blob *stmd, u32 tmd_size, const signed_blob *sticket, u32 ticket_size, u32 *keyid)
 +
| style="vertical-align: top;"|?
 +
|-
 +
|-
 +
| style="vertical-align: top;"|0x1D
 +
| style="vertical-align: top;"|ES_GetTitleDir
 +
| style="vertical-align: top;"|1
 +
| style="vertical-align: top;"|1
 +
| style="vertical-align: top;"|?
 +
| style="vertical-align: top;"|?
 +
| style="vertical-align: top;"|ES_GetDataDir(u64 titleID,char *filepath)
 +
| style="vertical-align: top;"|?
 +
|-
 +
|-
 +
| style="vertical-align: top;"|0x1E
 +
| style="vertical-align: top;"|ES_GetDeviceCert
 +
| style="vertical-align: top;"|1
 +
| style="vertical-align: top;"|0
 +
| style="vertical-align: top;"|?
 +
| style="vertical-align: top;"|?
 +
| style="vertical-align: top;"|ES_GetDeviceCert(u8 *outbuf)
 +
| style="vertical-align: top;"|?
 +
|-
 +
 
 +
|-
 +
| style="vertical-align: top;"|0x1F
 +
| style="vertical-align: top;"|ES_GetDeviceCert
 +
| style="vertical-align: top;"|6
 +
| style="vertical-align: top;"|0
 +
| style="vertical-align: top;"|?
 +
| style="vertical-align: top;"|?
 +
| style="vertical-align: top;"|ES_ImportBoot(const signed_blob *tik, u32 tik_size,const signed_blob *tik_certs,u32 tik_certs_size,const signed_blob *tmd,u32 tmd_size,const signed_blob *tmd_certs,u32 tmd_certs_size,const u8 *content,u32 content_size)
 +
| style="vertical-align: top;"|?
 +
|-
 +
|-
 +
| style="vertical-align: top;"|0x20
 +
| style="vertical-align: top;"|ES_GetTitleId
 +
| style="vertical-align: top;"|0
 +
| style="vertical-align: top;"|1
 +
| style="vertical-align: top;"|?
 +
| style="vertical-align: top;"|?
 +
| style="vertical-align: top;"|ES_GetTitleID(u64 *titleID)
 +
| style="vertical-align: top;"|?
 +
|-
 +
|-
 +
| style="vertical-align: top;"|0x21
 +
| style="vertical-align: top;"|ES_SetUid
 +
| style="vertical-align: top;"|1
 +
| style="vertical-align: top;"|0
 +
| style="vertical-align: top;"|?
 +
| style="vertical-align: top;"|?
 +
| style="vertical-align: top;"|ES_SetUID(u64 uid)
 +
| style="vertical-align: top;"|?
 
|-
 
|-
 
| style="vertical-align: top;" |0x22
 
| style="vertical-align: top;" |0x22
Line 311: Line 501:
 
| style="vertical-align: top;" |1
 
| style="vertical-align: top;" |1
 
| style="vertical-align: top;" |0
 
| style="vertical-align: top;" |0
| style="vertical-align: top;" |u64 title_id
 
| style="vertical-align: top;" |0x8
 
 
| style="vertical-align: top;" |?
 
| style="vertical-align: top;" |?
 +
| style="vertical-align: top;" |?
 +
| style="vertical-align: top;" |ES_DeleteTitleContent(u64 titleID)
 
| style="vertical-align: top;" |Deletes all files containing the substring "app" in a title's content directory (/title/xxxxxxxx/yyyyyyyy/content).
 
| style="vertical-align: top;" |Deletes all files containing the substring "app" in a title's content directory (/title/xxxxxxxx/yyyyyyyy/content).
 +
|-
 +
| style="vertical-align: top;" |0x23
 +
| style="vertical-align: top;" |ES_SeekContent
 +
| style="vertical-align: top;" |3
 +
| style="vertical-align: top;" |0
 +
| style="vertical-align: top;" |?
 +
| style="vertical-align: top;" |?
 +
| style="vertical-align: top;" |s32 ES_SeekContent(s32 cfd, s32 where, s32 whence)
 +
| style="vertical-align: top;" |?
 +
|-
 +
| style="vertical-align: top;" |0x24
 +
| style="vertical-align: top;" |ES_OpenTitleContent
 +
| style="vertical-align: top;" |3
 +
| style="vertical-align: top;" |0
 +
| style="vertical-align: top;" |?
 +
| style="vertical-align: top;" |?
 +
| style="vertical-align: top;" |s32 ES_OpenTitleContent(u64 titleID, tikview *views, u16 index)
 +
| style="vertical-align: top;" |?
 +
|-
 +
| style="vertical-align: top;" |0x25
 +
| style="vertical-align: top;" |ES_LaunchBC
 +
| style="vertical-align: top;" |0
 +
| style="vertical-align: top;" |0
 +
| style="vertical-align: top;" |?
 +
| style="vertical-align: top;" |?
 +
| style="vertical-align: top;" |No
 +
| style="vertical-align: top;" |?
 
|-
 
|-
 
| style="vertical-align: top;" |0x38
 
| style="vertical-align: top;" |0x38
Line 355: Line 572:
 
| style="vertical-align: top;" rowspan="2" |Copies the ticket associated with ''ticketview'' into ''ticket_buffer'' based on some access checks [currently unknown ticket offsets +0x1e8 to +0x1ef, +0x1f0.]
 
| style="vertical-align: top;" rowspan="2" |Copies the ticket associated with ''ticketview'' into ''ticket_buffer'' based on some access checks [currently unknown ticket offsets +0x1e8 to +0x1ef, +0x1f0.]
 
|-
 
|-
|ticket_t ticket_buffer
+
|tik_t ticket_buffer
 
|0x2a4
 
|0x2a4
 +
|- style="background-color: #eee;"
 +
| style="vertical-align: top;"|0x45
 +
| style="vertical-align: top;"|?
 +
| style="vertical-align: top;"|0
 +
| style="vertical-align: top;"|0
 +
| style="vertical-align: top;"|
 +
| style="vertical-align: top;"|
 +
| style="vertical-align: top;"|?
 +
| style="vertical-align: top;"|Used by system menu 4.2 to check if the wii is a region changed Korean wii. returns -1017 if the keys are not found. see [[Error_003]]
 
|}
 
|}
  
== /dev/es error codes ==
+
== Error codes ==
 +
This list of ES error codes should be complete for IOS59. Other codes that can technically be returned, but only indirectly (since ES makes use of the FS module and IOSC) are not included in an exhaustive manner in this list.
  
{| style="border-collapse: collapse; padding: 0.2em 0.2em 0.2em 0.2em;"
+
{| class="wikitable"
|- style="background-color: #ddd;"
+
|-
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #cdc;" | '''Error code'''
+
! Error code
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ccd;" | '''POSIX equivalent'''
+
! Notes
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #dcc;" | '''notes'''
+
|-
|- style="background-color: #ddd;"
+
| -106 (FS)
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ded;" | -106
+
| No such file or directory (returned by the FS module indirectly)
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #dde;" | ?
+
|-
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #edd;" | invalid TMD when using ES_OpenContent or <marcan> HUGHLALUGH SOMETHING FUCKED UP AND I'M NOT TELLING, or access denied
+
| -1005 (ES)
|- style="background-color: #ddd;"
+
| Invalid public key type in certificate
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ded;" | -1009
+
|-
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #dde;" | ?
+
| -1009 (ES)
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #edd;" | ? read less data than expected
+
| Read failure (short read)
|- style="background-color: #ddd;"
+
|-
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ded;" | -1010
+
| -1010 (ES)
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #dde;" | ?
+
| Write failure (short write)
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #edd;" | ?
+
|-
|- style="background-color: #ddd;"
+
| -1012 (ES)
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ded;" | -1017
+
| Invalid signature type (for signed blobs)
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #dde;" | ?
+
|-
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #edd;" | Wrong IN or OUT size, wrong size for a part of the vector, vector alignment problems
+
| -1016 (ES)
|- style="background-color: #ddd;"
+
| Maximum amount of handles exceeded (3 handles, as there are only 3 contexts)
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ded;" | -1022
+
|-
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #dde;" | ?
+
| -1017 (ES)
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #edd;" | Content did not match hash in TMD
+
| Invalid arguments
|- style="background-color: #ddd;"
+
|-
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ded;" | -1024
+
| -1020 (ES)
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #dde;" | ?
+
| Device ID mismatch. Returned by ES_ImportTicket if the ticket is personalised and the device ID from the ticket mismatches with the actual ID.
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #edd;" | memory allocation failure
+
|-
|- style="background-color: #ddd;"
+
| -1022 (ES)
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ded;" | -1026
+
| Imported content hash does not match with the hash from the TMD. Returned by ES_ImportContentEnd and ES_ImportBoot.
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #dde;" | ?
+
|-
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #edd;" | Incorrect access rights
+
| -1024 (ES)
|- style="background-color: #ddd;"
+
| Memory allocation failure
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ded;" | -1028
+
|-
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #dde;" | ?
+
| -1026 (ES)
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #edd;" | No ticket installed
+
| Incorrect access rights (according to the TMD)
|- style="background-color: #ddd;"
+
|-
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ded;" | -1029
+
| -1027 (ES)
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #dde;" | ?
+
| Issuer not found in the certificate chain
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #edd;" | Installed ticket is invalid
+
|-
|- style="background-color: #ddd;"
+
| -1028 (ES)
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ded;" | -2008
+
| Ticket not found
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #dde;" | EINVAL
+
|-
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #edd;" | Invalid parameter(s)
+
| -1029 (ES)
|- style="background-color: #ddd;"
+
| Invalid ticket. This is returned if the common key field contains an invalid value (anything other than 0 or 1). This is also returned from ES_LaunchTitle if the title ID contained in the ticket does not match the TMD title ID.
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ded;" | -2011
+
|-
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #dde;" | ?
+
| -1031 (ES)
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #edd;" | Signature check failed
+
| During LaunchTitle/ImportTitle: installed boot2 version is too old.
|- style="background-color: #ddd;"
+
During ImportBoot: downgrades are not allowed.
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ded;" | -2014
+
|-
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #dde;" | ?
+
| -1032 (ES)
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #edd;" | Bad hash length (!= 20)
+
| Fatal error early in ES initialisation. Can also be returned in ES_CheckHasKoreanKey in some cases. {{check}}
 +
|-
 +
| -1033 (ES)
 +
| A ticket limit was exceeded (duration or launch count)
 +
|-
 +
| -1034 (ES)
 +
| Returned in ES_CheckHasKoreanKey in some cases. {{check}}
 +
|-
 +
| -1035 (ES)
 +
| A title with a higher version is already installed
 +
|-
 +
| -1036 (ES)
 +
| Required sysversion(IOS) is not installed (only for the system menu {{check}})
 +
|-
 +
| -1037 (ES)
 +
| Installed number of contents doesn't match TMD (only for the system menu {{check}})
 +
|-
 +
| -1039 (DI)
 +
| Returned by DI as an ES error code when "TMD not supplied for disc/nand game"
 +
|-
 +
| -2000 (IOSC)
 +
| Permission denied (returned when accessing an object for which the caller has no permission)
 +
|-
 +
| -2001 (IOSC)
 +
| IOSC_EEXIST
 +
|-
 +
| -2003 (IOSC)
 +
| IOSC_EMAX
 +
|-
 +
| -2004 (IOSC)
 +
| IOSC_ENOENT
 +
|-
 +
| -2005 (IOSC)
 +
| IOSC_INVALID_OBJTYPE
 +
|-
 +
| -2006 (IOSC)
 +
| IOSC_INVALID_RNG
 +
|-
 +
| -2007 (IOSC)
 +
| IOSC_INVALID_FLAG
 +
|-
 +
| -2008 (IOSC)
 +
| IOSC_INVALID_FORMAT
 +
|-
 +
| -2009 (IOSC)
 +
| IOSC_INVALID_VERSION
 +
|-
 +
| -2010 (IOSC)
 +
| IOSC_INVALID_SIGNER
 +
|-
 +
| -2011 (IOSC)
 +
| IOSC_FAIL_CHECKVALUE
 +
Known to be returned when a signature check failed.
 +
|-
 +
| -2012 (IOSC)
 +
| Internal failure
 +
|-
 +
| -2013 (IOSC)
 +
| Memory allocation failure. Known to be returned when the keyring is full (contains 0x20 keys)
 +
|-
 +
| -2014 (IOSC)
 +
| Invalid size
 +
|-
 +
| -2015 (IOSC)
 +
| Invalid address
 +
|-
 +
| -2016 (IOSC)
 +
| Unaligned data
 
|}
 
|}
 +
 
[[Category:IOS API documentation]]
 
[[Category:IOS API documentation]]

Latest revision as of 12:32, 25 February 2018


ES (E-Ticket Services) is the IOS module that is notably responsible for title management, bootstrapping the PowerPC and giving it access to title contents.

This module is always part of the main, bootable binary, along with the IOS kernel, crypto code (IOSC) and the flash filesystem driver (FFS). It runs with more privileges than any other process and has access to most syscalls.

Along with the rest of IOS, this is generally considered a "private interface" -- game developers never call any of these functions directly.

Most of these are now implemented in libogc. Please feel free to submit patches to implement the remaining functions.

Commands

Command Name Notes
0x1 Open ES keeps track of three contexts, one per active handle, so only three handles can be opened at once. -1016 will be returned if the maximum amount of handles is exceeded.
0x2 Close -
0x3 Read Not supported; returns IPC_EINVAL (-4).
0x4 Write Not supported; returns IPC_EINVAL (-4).
0x5 Seek Not supported; returns IPC_EINVAL (-4).
0x6 Ioctl Not supported; returns IPC_EINVAL (-4).
0x7 Ioctlv Up to 0x45 ioctlvs available depending on the version.

Known ES Functions

ios_ioctlv( fd, 0x01, 3, 0, vec); // ES_AddTicket(const signed_blob *stik, u32 stik_size, const signed_blob *certificates, u32 certificates_size, const signed_blob *crl, u32 crl_size)
ios_ioctlv( fd, 0x02, 4, 0, vec); // ES_AddTitleStart(const signed_blob *stmd, u32 tmd_size, const signed_blob *certificates, u32 certificates_size, const signed_blob *crl, u32 crl_size)
ios_ioctlv( fd, 0x03, 2, 0, vec); // ES_AddContentStart(u64 titleID, u32 cid)
ios_ioctlv( fd, 0x04, 2, 0, vec); // ES_AddContentData(s32 cfd, u8 *data, u32 data_size)
ios_ioctlv( fd, 0x05, 1, 0, vec); // ES_AddContentFinish(u32 cid)
ios_ioctlv( fd, 0x06, 0, 0, vec); // ES_AddTitleFinish(void)
ios_ioctlv( fd, 0x07, 0, 1, vec); // ES_GetDeviceID
ios_ioctlvReboot(fd, 0x08, 2, 0, vec); // ES_LaunchTitle(u64 titleID, const tikview *view)
ios_ioctlv( fd, 0x09, 1, 0, vec);  // ES_OpenContent(u16 index)
ios_ioctlv( fd, 0x0A, 1, 1, vec); // ES_ReadContent(s32 cfd, u8 *data, u32 data_size)
ios_ioctlv( fd, 0x0B, 1, 0, vec); // ES_CloseContent(s32 cfd)
ios_ioctlv( fd, 0x0C, 0, 1, vec); // ES_GetOwnedTitlesCount
ios_ioctlv( fd, 0x0D, 1, 1, vec); // ES_GetOwnedTitles
ios_ioctlv( fd, 0x0E, 0, 1, vec); // ES_GetTitlesCount
ios_ioctlv( fd, 0x0F, 1, 1, vec); // ES_GetTitles
ios_ioctlv( fd, 0x10, 1, 1, vec); // ES_GetTitleContentsCount
ios_ioctlv( fd, 0x11, 2, 1, vec); // ES_GetTitleContent
ios_ioctlv( fd, 0x12, 1, 1, vec); // ES_GetNumTicketViews(u64 titleID, u32 *cnt)
ios_ioctlv( fd, 0x13, 2, 1, vec); // ES_GetTicketViews(u64 titleID, tikview *views, u32 cnt)
ios_ioctlv( fd, 0x14, 1, 1, vec); // ES_GetTmdViewSize
ios_ioctlv( fd, 0x15, 2, 1, vec); // ES_GetTmdView
ios_ioctlv( fd, 0x16, 1, 2, vec); // ES_GetConsumption
ios_ioctlv( fd, 0x17, 1, 0, vec); // ES_DeleteTitle
ios_ioctlv( fd, 0x18, 1, 0, vec); // ES_DeleteTicket
ios_ioctlv( fd, 0x19, 1, 1, vec); // ES_DIGetTmdViewSize( u8 *TMD, u32 *TMDViewSize )
ios_ioctlv( fd, 0x1A, 2, 1, vec); // ES_DiGetTmdView
ios_ioctlv( fd, 0x1B, 1, 1, vec); // ES_DiGetTicketView
ios_ioctlv( fd, 0x1C, 4, 2, vec); // ES_DiVerify
ios_ioctlv( fd, 0x1D, 1, 1, vec); // ES_GetDataDir
ios_ioctlv( fd, 0x1E, 0, 1, vec); // ES_GetDeviceCert(u8 *outbuf)
ios_ioctlv( fd, 0x1F, 6, 0, vec); // ES_ImportBoot( const signed_blob *tik, u32 tik_size, const signed_blob *tik_certs, u32 tik_certs_size, const signed_blob *tmd, u32 tmd_size, const signed_blob *tmd_certs, u32 tmd_certs_size, const u8 *content, u32 content_size )
ios_ioctlv( fd, 0x20, 0, 1, vec); // ES_GetTitleId
ios_ioctlv( fd, 0x21, 1, 0, vec); // ES_SetUid
ios_ioctlv( fd, 0x22, 1, 0, vec); // ES_DeleteTitleContent(u64 titleID) - deletes all files containing 'app' in a /title/xxxxxxxx/yyyyyyyy/content
ios_ioctlv( fd, 0x23, 3, 0, vec); // ES_SeekContent
ios_ioctlv( fd, 0x24, 3, 0, vec); // ES_OpenTitleContent(u64 titleID, const tikview *view, u16 index)
ios_ioctlv( fd, 0x25, 0, 0, vec); // ES_LaunchBC(void)
ios_ioctlv( fd, 0x26, 1, 1, vec); // ES_ExportTitleInit
ios_ioctlv( fd, 0x27, 2, 0, vec); // ES_ExportContentBegin
ios_ioctlv( fd, 0x28, 1, 1, vec); // ES_ExportContentData
ios_ioctlv( fd, 0x29, 1, 0, vec); // ES_ExportContentEnd
ios_ioctlv( fd, 0x2A, 0, 0, vec); // ES_ExportTitleDone(void)
ios_ioctlv( fd, 0x2B, 1, 0, vec); // ES_AddTmd
ios_ioctlv( fd, 0x2C, 3, 2, vec); // ES_Encrypt(u32 keynum, u8 *iv, u8 *source, u32 size, u8 *dest)
ios_ioctlv( fd, 0x2D, 3, 2, vec); // ES_Decrypt(u32 keynum, u8 *iv, u8 *source, u32 size, u8 *dest)
ios_ioctlv( fd, 0x2E, 0, 1, vec); // ES_GetBoot2Version(u32 *version)
ios_ioctlv( fd, 0x2F, 0, 0, vec); // ES_AddTitleCancel(void)
ios_ioctlv( fd, 0x30, 1, 2, vec); // ES_Sign(u8 *source, u32 size, u8 *sig, u8 *certs)
ios_ioctlv( fd, 0x31, 3, 0, vec); // ES_VerifySign
// the following functions are only available in IOS28+
ios_ioctlv( fd, 0x32, 1, 1, vec); // ES_GetStoredContentCount
ios_ioctlv( fd, 0x33, 2, 1, vec); // ES_GetStoredContent
ios_ioctlv( fd, 0x34, 1, 1, vec); // ES_GetStoredTmdSize
ios_ioctlv( fd, 0x35, 2, 1, vec); // ES_GetStoredTmd
ios_ioctlv( fd, 0x36, 0, 1, vec); // ES_GetSharedContentCount
ios_ioctlv( fd, 0x37, 1, 1, vec); // ES_GetSharedContents
ios_ioctlv( fd, 0x38, 1, 0, vec); // ES_DeleteSharedContent
ios_ioctlv( fd, 0x39, 0, 1, vec); // ES_GetDiTmdSize
ios_ioctlv( fd, 0x3A, 1, 1, vec); // ES_GetDiTmd
ios_ioctlv( fd, 0x3B, 4, 2, vec); // ES_DiVerifyWithTicketView (DI only; takes a ticket view instead of a ticket and calls ES_DiVerify)
ios_ioctlv( fd, 0x3C, 2, 1, vec); // ES_SetupStreamKey(TicketView* ticket_view, TMD* tmd, u32 tmd_size, int* key_handle) (WFS only, only usable for some title types and UIDs)
ios_ioctlv( fd, 0x3D, 0, 1, vec); // ES_DeleteStreamKey (calls IOSC_DeleteObject)
// the following functions are only available in IOS37+ but not in IOS38
ios_ioctlv( fd, 0x3E, 2, 0, vec); // Unknown ... Deletes a content from a title's private directory
// the following functions are only available in IOS37v3609+ but not in IOS38
ios_ioctlv( fd, 0x3F, ?, ?, vec); // non-existant ioctl why? ... because.
ios_ioctlv( fd, 0x40, 1, 1, vec); // ES_GetV0TicketFromView(const u8* ticket_view, u8* ticket)
// the following functions are only available in IOS56+
ios_ioctlv( fd, 0x41, 1, 1, vec); // Unknown -- retrieves a key?
ios_ioctlv( fd, 0x42, 2, 0, vec); // Unknown -- something with a key?
// the following functions are only available in IOS56v5405+/IOS57v5661+/IOS61v5405+/IOS70+ Please check (I thought it was a rule never add new functions existing IOS)
ios_ioctlv( fd, 0x43, 1, 1, vec); // ES_GetTicketFromView(const u8* ticket_view, u8* ticket, u32* ticket_size) -- used to get the ticket size from a view (internally called with ticket = nullptr)
ios_ioctlv( fd, 0x44, 2, 1, vec); // ES_GetTicketFromView(const u8* ticket_view, u8* ticket, u32* ticket_size) -- used to get a ticket from a view
ios_ioctlv( fd, 0x45, 0, 0, vec); // Unknown ... korean-common-key check

/dev/es IOS_Ioctlv

number name in count out count vec entry target vec entry size [bytes] libogc prototype Description
0x00 ? ? ? ? ? ? returns -1017 non-existant ioctl
0x01 ES_AddTicket 3 0 ? 0x2A4 ES_AddTicket(const signed_blob *stik, u32 stik_size, const signed_blob *certificates, u32 certificates_size, const signed_blob *crl, u32 crl_size) ?
? ?
? ?
0x02 ES_AddTitleStart 4 0 ? ? ES_AddTitleStart(const signed_blob *stmd, u32 tmd_size, const signed_blob *certificates, u32 certificates_size, const signed_blob *crl, u32 crl_size) ?
? ?
? ?
? 0x1c
0x03 ES_AddContentStart 2 0 ? 0x8 ES_AddContentStart(u64 titleID, u32 cid) ?
? 0x4
0x04 ES_AddContentData 2 0 ? 0x4 ES_AddContentData(s32 cfd, u8 *data, u32 data_size) ?
? ?
0x05 ES_AddContentFinish 1 0 ? 0x4 ES_AddContentFinish(u32 cid) ?
0x06 ES_AddTitleFinish 0 0 ES_AddTitleFinish(void) ?
0x07 ES_GetDeviceID 0 1 ? 0x4 ES_GetDeviceID(u32 *device_id) ?
0x08 ES_LaunchTitle 2 0 ? 0x8 ES_LaunchTitleBackground(u64 titleID, const tikview *view); ES_LaunchTitle(u64 titleID, const tikview *view); ?
? 0xd8
0x09 ES_OpenContent 1 0 ? 0x4 ES_OpenContent(u16 index) ?
0x0A ES_ReadContent 1 1 ? 0x4 ES_ReadContent(s32 cfd, u8 *data, u32 data_size) ?
? ?
0x0B ES_CloseContent 1 0 ? 0x4 ES_CloseContent(s32 cfd) ?
0x0C ES_GetOwnedTitlesCount 0 1 u32* count 0x4 ES_GetNumOwnedTitles(u32 *cnt) ?
0x0D ES_GetOwnedTitles 1 1 u32* count 0x4 ES_GetOwnedTitles(u64 *titles, u32 cnt) ?
u64 titles[] [count]*0x8
0x0E ES_GetTitlesCount 0 1 u32* count 0x4 ES_GetNumTitles(u32 *cnt) Sets the u32 pointed to by count to the number of titles on the system under /title.
0x0F ES_GetTitles 1 1 u32* count 0x4 ES_GetTitles(u64 *titles, u32 cnt) Fills out buffer with at most count 8 byte title ids of titles on the system under /title. It also update count for the number of title its copied.
u64 buffer[] [count]*0x8
0x10 ES_GetTitleContentsCount 1 1 u64 title_id 0x8 ES_GetTitleContentsCount(u64 titleID, u32 *num) Gets the number of contents from the tmd. It checks that the contents are present in the title's private content directory or linked via /shared1/content.map
u32* count 0x4
0x11 ES_GetTitleContents 2 1 u64 title_id 0x8 No Fills out content_ids with the content ids from the title's tmd. It checks if the contents are present in the title's private content directory or linked via /shared1/content.map
u32* count 0x4
u32 content_ids[] [count]*0x4
0x12 ES_GetNumTicketViews 1 1 u64 title_id 0x8 ES_GetNumTicketViews(u64 titleID, u32 *cnt) ?
u32* count 0x4
0x13 ES_GetTicketViews 2 1 u64 title_id 0x8 ES_GetTicketViews(u64 titleID, tikview *views, u32 cnt) ?
u32* count 0x4
tikview_t ticketviews[] [count]*0xd8
0x14 ES_GetTmdViewSize 1 1 u64 title_id 0x8 ES_GetTMDViewSize(u64 titleID, u32 *size) ?
u32* count 0x4
0x15 ES_GetTmdView 2 1 u64 title_id 0x8 ES_GetTMDView(u64 titleID, u8 *data, u32 size) ?
u32* count 0x4
tmdiew_t tmdview [count]
0x16 ES_GetConsumption 1 2 ? ? No ?
0x17 ES_DELETETITLE 1 0 u64 titleID 0x8 ES_DeleteTitle(u64 titleID) ?
0x18 ES_DeleteTicket 1 0 ? ? ES_DeleteTicket(const tikview *view) ?
0x19 ES_DIGetTmdViewSize 1 0 ? ? No ?
0x1A ES_DIGetTmdViewSize 2 1 ? ? No ?
0x1B ES_DiGetTicketView 1 1 ? ? No ?
0x1C ES_DiVerify 4 2 ? ? ES_Identify(const signed_blob *certificates, u32 certificates_size, const signed_blob *stmd, u32 tmd_size, const signed_blob *sticket, u32 ticket_size, u32 *keyid) ?
0x1D ES_GetTitleDir 1 1 ? ? ES_GetDataDir(u64 titleID,char *filepath) ?
0x1E ES_GetDeviceCert 1 0 ? ? ES_GetDeviceCert(u8 *outbuf) ?
0x1F ES_GetDeviceCert 6 0 ? ? ES_ImportBoot(const signed_blob *tik, u32 tik_size,const signed_blob *tik_certs,u32 tik_certs_size,const signed_blob *tmd,u32 tmd_size,const signed_blob *tmd_certs,u32 tmd_certs_size,const u8 *content,u32 content_size) ?
0x20 ES_GetTitleId 0 1 ? ? ES_GetTitleID(u64 *titleID) ?
0x21 ES_SetUid 1 0 ? ? ES_SetUID(u64 uid) ?
0x22 ES_DeleteTitleContent 1 0 ? ? ES_DeleteTitleContent(u64 titleID) Deletes all files containing the substring "app" in a title's content directory (/title/xxxxxxxx/yyyyyyyy/content).
0x23 ES_SeekContent 3 0 ? ? s32 ES_SeekContent(s32 cfd, s32 where, s32 whence) ?
0x24 ES_OpenTitleContent 3 0 ? ? s32 ES_OpenTitleContent(u64 titleID, tikview *views, u16 index) ?
0x25 ES_LaunchBC 0 0 ? ? No ?
0x38 ? (ES_DeleteSharedContent) 1 0 u8 sha1[] 0x14 ? Deletes the content file from /shared1 with the given sha1 checksum. It aborts if the tmd of an essential system title references the content. It rebuilds content.map after, removing the entry for the deleted file.
0x3e ? 2 0 u64 title_id 0x8 ? Deletes a specific content from a title's private content directory.
u32 content_id 0x4
0x3f ? 0 0 ? returns -1017
0x40 ? 1 1 tikview_t ticketview 0xd8 ? Copies the ticket associated with ticketview into ticket_buffer based on some access checks [currently unknown ticket offsets +0x1e8 to +0x1ef, +0x1f0.]
tik_t ticket_buffer 0x2a4
0x45 ? 0 0 ? Used by system menu 4.2 to check if the wii is a region changed Korean wii. returns -1017 if the keys are not found. see Error_003

Error codes

This list of ES error codes should be complete for IOS59. Other codes that can technically be returned, but only indirectly (since ES makes use of the FS module and IOSC) are not included in an exhaustive manner in this list.

Error code Notes
-106 (FS) No such file or directory (returned by the FS module indirectly)
-1005 (ES) Invalid public key type in certificate
-1009 (ES) Read failure (short read)
-1010 (ES) Write failure (short write)
-1012 (ES) Invalid signature type (for signed blobs)
-1016 (ES) Maximum amount of handles exceeded (3 handles, as there are only 3 contexts)
-1017 (ES) Invalid arguments
-1020 (ES) Device ID mismatch. Returned by ES_ImportTicket if the ticket is personalised and the device ID from the ticket mismatches with the actual ID.
-1022 (ES) Imported content hash does not match with the hash from the TMD. Returned by ES_ImportContentEnd and ES_ImportBoot.
-1024 (ES) Memory allocation failure
-1026 (ES) Incorrect access rights (according to the TMD)
-1027 (ES) Issuer not found in the certificate chain
-1028 (ES) Ticket not found
-1029 (ES) Invalid ticket. This is returned if the common key field contains an invalid value (anything other than 0 or 1). This is also returned from ES_LaunchTitle if the title ID contained in the ticket does not match the TMD title ID.
-1031 (ES) During LaunchTitle/ImportTitle: installed boot2 version is too old.

During ImportBoot: downgrades are not allowed.

-1032 (ES) Fatal error early in ES initialisation. Can also be returned in ES_CheckHasKoreanKey in some cases. [check]
-1033 (ES) A ticket limit was exceeded (duration or launch count)
-1034 (ES) Returned in ES_CheckHasKoreanKey in some cases. [check]
-1035 (ES) A title with a higher version is already installed
-1036 (ES) Required sysversion(IOS) is not installed (only for the system menu [check])
-1037 (ES) Installed number of contents doesn't match TMD (only for the system menu [check])
-1039 (DI) Returned by DI as an ES error code when "TMD not supplied for disc/nand game"
-2000 (IOSC) Permission denied (returned when accessing an object for which the caller has no permission)
-2001 (IOSC) IOSC_EEXIST
-2003 (IOSC) IOSC_EMAX
-2004 (IOSC) IOSC_ENOENT
-2005 (IOSC) IOSC_INVALID_OBJTYPE
-2006 (IOSC) IOSC_INVALID_RNG
-2007 (IOSC) IOSC_INVALID_FLAG
-2008 (IOSC) IOSC_INVALID_FORMAT
-2009 (IOSC) IOSC_INVALID_VERSION
-2010 (IOSC) IOSC_INVALID_SIGNER
-2011 (IOSC) IOSC_FAIL_CHECKVALUE

Known to be returned when a signature check failed.

-2012 (IOSC) Internal failure
-2013 (IOSC) Memory allocation failure. Known to be returned when the keyring is full (contains 0x20 keys)
-2014 (IOSC) Invalid size
-2015 (IOSC) Invalid address
-2016 (IOSC) Unaligned data