WISESCRIPT.hexpat 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. #include <std/mem.pat>
  2. #include <std/io.pat>
  3. u8 langCount = 1; // default, will be overwritten
  4. u8 failed = 0;
  5. fn failUnknownOp(char op) {
  6. std::print("Failed! unknown op 0x{:02X} at 0x{:08X}", op, $);
  7. // stop processing
  8. failed = 1;
  9. };
  10. // \0 terminated string
  11. struct cstr {
  12. char string[];
  13. };
  14. struct Header {
  15. char unknown_5[5];
  16. u32 someOffset_1; // deflated file data size?
  17. u32 someOffset_2;
  18. char unknown_4[4];
  19. // Creation of this WiseScript.bin in seconds since UNIX epoch
  20. u32 datetime;
  21. char unknown_22[22];
  22. };
  23. struct InstStruct1 {
  24. cstr url;
  25. cstr log_path;
  26. cstr font;
  27. char unknown_6[6];
  28. u8 languageCount;
  29. // NOTE: NOT part of the struct just set global for later use
  30. langCount = languageCount;
  31. char unknown_7[7];
  32. // NOTE: langCount of 0 is invalid..
  33. if (langCount == 1) {
  34. cstr ui_strings_1[56];
  35. }
  36. else {
  37. cstr ui_strings_1[((55 * languageCount) + languageCount * 2) + 2];
  38. }
  39. };
  40. // 0x00 Wise deflated file header
  41. struct FileHeader {
  42. char unknown_2[2]; // 0x8000, 0x8100, 0x0000, 0x9800 0xA100
  43. u32 deflateStart;
  44. u32 deflateEnd;
  45. u16 date;
  46. u16 time;
  47. u32 inflatedSize;
  48. char unknown_20[20];
  49. u32 crc32;
  50. cstr filePath;
  51. cstr fileText[langCount];
  52. cstr unknownString;
  53. };
  54. struct Unknown_0x03 {
  55. char unknown_1;
  56. cstr lang_strings[(langCount * 2)];
  57. };
  58. struct FormItem_0x04 {
  59. u8 no;
  60. cstr command_strings[langCount];
  61. // read this struct again until 'no' == 0 ???
  62. };
  63. struct Unknown_0x05 {
  64. // write .ini file?
  65. cstr file;
  66. cstr heading;
  67. cstr values;
  68. };
  69. struct DeflateInfo {
  70. u32 deflateStart;
  71. u32 deflateEnd;
  72. u32 inflatedSize;
  73. };
  74. struct Unknown_0x06 {
  75. char unknown_2[2];
  76. u32 unknown;
  77. DeflateInfo deflateInfoPerLang[langCount];
  78. char terminator;
  79. };
  80. struct Unknown_0x07 {
  81. char unknown_1;
  82. cstr string_1;
  83. cstr string_2;
  84. cstr string_3;
  85. };
  86. struct Unknown_0x08 {
  87. char unknown_1;
  88. };
  89. struct Unknown_0x09 {
  90. char unknown_1;
  91. cstr string_1;
  92. cstr string_2;
  93. cstr string_3;
  94. cstr string_4;
  95. cstr lang_strs[langCount];
  96. };
  97. struct Unknown_0x0A {
  98. char unknown_2[2]; // 0x0200
  99. cstr string_1;
  100. cstr string_2;
  101. cstr string_3;
  102. };
  103. struct Unknown_0x0B {
  104. char unknown_1;
  105. cstr string_1;
  106. };
  107. struct Unknown_0x0C {
  108. char unknown_1;
  109. cstr string_1;
  110. cstr string_2;
  111. };
  112. struct Unknown_0x11 {
  113. cstr string_1;
  114. };
  115. // Existing file on install medium (CD/DVD)
  116. struct ExistingFile_0x12 {
  117. char unknown_1; // 0C
  118. char unknown_41[41];
  119. cstr from_path;
  120. cstr unknown_string_1;
  121. cstr lang_strings[langCount];
  122. cstr to_path;
  123. };
  124. struct Unknown_0x14 {
  125. DeflateInfo deflateInfo;
  126. cstr name;
  127. cstr message;
  128. };
  129. struct Unknown_0x15 {
  130. char unknown_1;
  131. cstr string_1;
  132. cstr string_2;
  133. };
  134. struct TempFile_0x16 {
  135. cstr name;
  136. };
  137. struct Unknown_0x17 {
  138. char unknown_1;
  139. char unknown_4[4];
  140. cstr string_1;
  141. };
  142. struct Unknown_0x18 {
  143. std::print("0x18 at 0x{:08X}", $);
  144. if (($ + 1) > std::mem::size()) {
  145. return 0;
  146. }
  147. char testChar;
  148. if (testChar == 0x00) {
  149. $ = $ + 5; // skip 6 bytes in total
  150. }
  151. else {
  152. $ = $ - 1; // skip none
  153. }
  154. };
  155. struct Unknown_0x19 {
  156. char unknown_1;
  157. cstr string_1;
  158. cstr string_2;
  159. cstr string_3;
  160. };
  161. struct Unknown_0x1A {
  162. char unknown_1;
  163. cstr string_1;
  164. cstr string_2;
  165. };
  166. struct Unknown_0x1C {
  167. cstr string_1;
  168. };
  169. struct Unknown_0x1D {
  170. cstr string_1;
  171. cstr string_2;
  172. };
  173. struct Unknown_0x1E {
  174. char unknown;
  175. cstr unknownString;
  176. };
  177. struct Unknown_0x20 {
  178. char unknown;
  179. };
  180. struct Unknown_0x23 { // else if
  181. char unknown_1;
  182. cstr string_1;
  183. cstr string_2;
  184. };
  185. struct Unknown_0x30 {
  186. char unknown;
  187. cstr string_1;
  188. cstr string_2;
  189. };
  190. struct Container {
  191. char op;
  192. match (op) {
  193. (0x00): FileHeader fileHeader;
  194. (0x03): Unknown_0x03 unknown_0x03;
  195. (0x04): FormItem_0x04 formItem;
  196. (0x05): Unknown_0x05 unknown_0x05;
  197. (0x06): Unknown_0x06 unknown_0x06;
  198. (0x07): Unknown_0x07 unknown_0x07;
  199. (0x08): Unknown_0x08 unknown_0x08; // end statements block
  200. (0x09): Unknown_0x09 unknown_0x09;
  201. (0x0F): continue; // start form data?
  202. (0x10): continue; // end form data?
  203. (0x11): Unknown_0x11 unknown_0x11;
  204. (0x12): ExistingFile_0x12 existingFile_0x12;
  205. (0x14): Unknown_0x14 unknown_0x14;
  206. (0x15): Unknown_0x15 unknown_0x15;
  207. (0x16): TempFile_0x16 tempFile_0x16;
  208. (0x17): Unknown_0x17 unknown_0x17;
  209. (0x18): Unknown_0x18 unknown_0x18;
  210. (0x19): Unknown_0x19 unknown_0x19;
  211. (0x1A): Unknown_0x1A unknown_0x1A;
  212. (0x23): Unknown_0x23 unknown_0x23; // else if
  213. (0x0A): Unknown_0x0A unknown_0x0A;
  214. (0x0B): Unknown_0x0B unknown_0x0B;
  215. (0x0C): Unknown_0x0C unknown_0x0C; // if
  216. (0x0D): continue; // else / default
  217. (0x1B): continue;
  218. (0x20): Unknown_0x20 unknown_0x20;
  219. (0x1C): Unknown_0x1C unknown_0x1C;
  220. (0x1D): Unknown_0x1D unknown_0x1D;
  221. (0x1E): Unknown_0x1E unknown_0x1E;
  222. (0x30): Unknown_0x30 unknown_0x30;
  223. (_): failUnknownOp(op);
  224. }
  225. };
  226. struct MainStruct {
  227. Header header;
  228. InstStruct1 install_struct_1;
  229. Container items[while($ < std::mem::size() && failed == 0)];
  230. };
  231. /* Example:
  232. // NOTE: Set absolute path to WISEINSTALL.hexpat
  233. #include </home/user/code/WISESCRIPT.hexpat>
  234. MainStruct mainStruct @0x0;
  235. */
  236. MainStruct mainStruct @0x0;