CHANS: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
bytecode |
||
| Line 55: | Line 55: | ||
} chans_header; | } chans_header; | ||
typedef struct { | |||
u32 offset; | |||
u16 table4_method; // Points to an id in table 4, index is 0 based | |||
u8 paramcount; //maybe | |||
u8 unk1; | |||
} table1_chunk; | |||
typedef struct { | typedef struct { | ||
| Line 101: | Line 108: | ||
</pre> | </pre> | ||
Bytecode: | |||
<pre> | |||
40 XX - (XX is index from table 4) Grab anything from table 4 (could be variables or methods, etc) | |||
31 XX - follows after a 40 YY bytecode, defines amount of arguments to use off the stack, and invokes the method defined by 40 YY | |||
01 - return last item | |||
2C 00 XX - grab string literal from table 3 | |||
30 00 XX YY - invoke method off table 2, XX = index of table2, YY == argument count (this is basically a 40 XX 31 YY, all in one) | |||
</pre> | |||
'''TODO: A lot! Keep adding data, people!''' | '''TODO: A lot! Keep adding data, people!''' | ||
Revision as of 01:02, 28 May 2009
| This article is a stub. You can help WiiBrew by expanding it. |
ChannelScript (abbreviated as CHANS) is the system used by the Wii's system menu to display "dynamic" banners. It seems to be some form of interpreted bytecode, which resembles JavaScript in many ways. The same bytecode can also apparently be interpreted on the Starlet while the Wii is off; this is performed by the /dev/kd module and forms the basis of WiiConnect24.
This page shall describe said bytecode and the header for CHANS files. You may find a CHANS file in the News Channel as content index 5.
Here is what is known of the structure for the header:
This data is in no way 100% complete, or even 100% proven.
typedef struct {
//START: Main Header
u32 head; // 0x00000000
u32 version; // 0x00000004
u32 file_size; // 0x00000008
u8 unk[0x14]; // 0x0000000C
//END: Main Header
// All offsets are from 0x20
u32 unk10; // 0x00000020
u32 unk20; // 0x00000024
u32 unk30; // 0x00000028
// First data section (this is the bytecode)
u32 fds_size; // 0x0000002C
u32 fds_offset; // 0x00000030
u32 table4_count; // 0x00000034
u32 unk5; // 0x00000038
u32 unk6; // 0x0000003C
// Table 1 is made up of 8 byte chunks
u32 table1_count; // 0x00000040
u32 table1_offset; // 0x00000044
// Table 2 is the method name list
u32 table2_count; // 0x00000048
u32 table2_offset; // 0x0000004C
// Table 3 is a string literal table.
// Each string is in utf-16, preceded by a u16 which specifies BYTE length of utf-18 string
u32 table3_count; // 0x00000050
u32 table3_offset; // 0x00000054
// Possibly unused table
u32 unk7; // 0x00000058
u32 unk8; // 0x0000005C
u32 table4_offset; // 0x00000060
u32 unk9_offset; // 0x00000064
u32 unk11; // 0x00000068
u32 unk12; // 0x0000006C
u8 unk13[0x10]; // 0x00000070
} chans_header;
typedef struct {
u32 offset;
u16 table4_method; // Points to an id in table 4, index is 0 based
u8 paramcount; //maybe
u8 unk1;
} table1_chunk;
typedef struct {
u8 length;
u8 padding;
u16 offset;
} table2_entry;
Here's a list of method names extracted from the IOS "KD" module:
length, join, new2d, pop, push, shift, slice, unshift getDate, getDay, getFullYear, getHours, getMilliseconds, getMinutes, getMonth, getSeconds, getTime, getRTC charAt, *fromCharCode, indexOf, lastIndexOf, replace, search, slice, split, toLowerCase, toUpperCase *create, seek, skip, isEqual, getLength, setLength, fill, getU8, getU16, getU32, getS8, getS16, getS32, getS64, setU8, setU16, setU32, setS8, setS16, setS32, setS64, getString, getWString, setString, setWString, getBlob, setBlob, getHexString, copyRangeFrom, calcSHA1Digest, calcMD5Digest, calcCRC16, calcCRC32, calcHMAC, calcRangeSHA1Digest, calcRangeMD5Digest, calcRangeCRC16, calcRangeCRC32, calcRangeHMAC, pack, unpack verbose, logLevel, stat_result, stat_permission, stat_lastCriticalError, stat_newMsgFlag, stat_taskStage, stat_numErrors, stat_numMsgSent, stat_numMsgReceived, stat_numMsgSaved, stat_numMsgRejected, stat_numMsgFiltered, stat_countMailChk, stat_countMailRcv, stat_countMailSav, stat_countMailSnd, stat_countDL, stat_countEstablished, stat_mailTaskTrace, stat_dlTaskTrace, stat_countMailPrc, stat_countForceRecv, stat_countMailIdle, stat_countScriptExec, stat_errorLog getMyUserId, getReceivedMsg, getReplyMsg, getStorage, getRandom, isStandbyMode, launchApplication, getHomeDir, isSucceed, isFailed getId getType getAppId readToId readToAddr readFromAddr getFromId readFromId readSubject readAltName readText getCommand getScriptParameter getScriptTtl getTag getSequenceNumber getDate hasMii readField readAttached getNumAttached getAttachedSize getAttachedType setToId setToAddr setSubject setAltName setMBNoReply setMBRegDate setMBDelay setText setLedPattern setIconNewSign setIconNewSignEx setDesignatedTime setExecScript setTag setSequenceNumber copyMiiFrom copyFromFrom setAttached commit _commitNow status name fdId wiiId mailAddr check isEstablished isWiiFriend read _write _update _delete isExist searchBy Id searchByAddr getNum getNumReg getNumRegisterd getNumEst getNumEstablished
Bytecode:
40 XX - (XX is index from table 4) Grab anything from table 4 (could be variables or methods, etc) 31 XX - follows after a 40 YY bytecode, defines amount of arguments to use off the stack, and invokes the method defined by 40 YY 01 - return last item 2C 00 XX - grab string literal from table 3 30 00 XX YY - invoke method off table 2, XX = index of table2, YY == argument count (this is basically a 40 XX 31 YY, all in one)
TODO: A lot! Keep adding data, people!