Difference between revisions of "Scripts"

From UODemo Wiki
Jump to: navigation, search
Line 1: Line 1:
 
The '''scripts''' subdirectory contains many files with a .m extension.  The files contain binary data and cannot be read by hand.  There is also one text file named [[sdb.txt]].
 
The '''scripts''' subdirectory contains many files with a .m extension.  The files contain binary data and cannot be read by hand.  There is also one text file named [[sdb.txt]].
  
The .m files are not encrypted but they do contain a sort of obfusicated, intermediate binary language between the original script files and the runtime engine of [[uodemo.exe]].  How the original scripts looked like is unknown but similar output can be re-generated by walking through the tokens created by the parser inside [[uodemo.exe]].
+
The .m files are not encrypted but they do contain a sort of obfusicated, intermediate binary language between the original script files and the runtime engine of [[uodemo.exe]].
 +
 
 +
The .m files consist of obfusicated tokens, constants (byte, word, and double word values), string indexes into [[sdb.txt]] and quoted string indexes into [[sdb.txt]].  Constant, strings and quoted strings are preceded by a (obfusicated) token describing themQuoted strings can be concatenated on-the-fly by the parser.
 +
 
 +
The obfusication works as follows: each token is represented by 5 different words (2 bytes).
 +
 
 +
For example, the token "IF" is coded as byte 0x25, which is obfusicated to be 0x12C2, 0x1003, 0x0607, 0x0784 or 0x2B0F.  So to decompile the .m file you must look-up each obfuscated word and convert it to a byte, then convert that byte to a token which we humans can read.  This is a straight-forward process, therefor, (re-)compilation of .m files can be achieved with ease.
 +
 
 +
Decompilation : 0x12C2 or 0x1003 or 0x0607 or 0x0784 or 0x2B0F -> 0x25 -> IF
 +
Compilation : IF -> 0x25 -> 0x12C2 or 0x1003 or 0x0607 or 0x0784 or 0x2B0F

Revision as of 10:34, 8 June 2009

The scripts subdirectory contains many files with a .m extension. The files contain binary data and cannot be read by hand. There is also one text file named sdb.txt.

The .m files are not encrypted but they do contain a sort of obfusicated, intermediate binary language between the original script files and the runtime engine of uodemo.exe.

The .m files consist of obfusicated tokens, constants (byte, word, and double word values), string indexes into sdb.txt and quoted string indexes into sdb.txt. Constant, strings and quoted strings are preceded by a (obfusicated) token describing them. Quoted strings can be concatenated on-the-fly by the parser.

The obfusication works as follows: each token is represented by 5 different words (2 bytes).

For example, the token "IF" is coded as byte 0x25, which is obfusicated to be 0x12C2, 0x1003, 0x0607, 0x0784 or 0x2B0F. So to decompile the .m file you must look-up each obfuscated word and convert it to a byte, then convert that byte to a token which we humans can read. This is a straight-forward process, therefor, (re-)compilation of .m files can be achieved with ease.

Decompilation : 0x12C2 or 0x1003 or 0x0607 or 0x0784 or 0x2B0F -> 0x25 -> IF Compilation : IF -> 0x25 -> 0x12C2 or 0x1003 or 0x0607 or 0x0784 or 0x2B0F