2 次代碼提交 499ad06fef ... 26752a6525

作者 SHA1 備註 提交日期
  CYBERDEV 26752a6525 Update OP 0x1E 1 月之前
  CYBERDEV 0e50dff050 Found new unknown OP 0x30 in cuteftp.exe 1 月之前
共有 2 個文件被更改,包括 96 次插入7 次删除
  1. 85 4
      src/wisescript.c
  2. 11 3
      src/wisescript.h

+ 85 - 4
src/wisescript.c

@@ -819,10 +819,20 @@ REWError readWiseScriptUnknown0x1D(FILE *fp, WiseScriptUnknown0x1D *data) {
 
 REWError readWiseScriptUnknown0x1E(FILE * fp, WiseScriptUnknown0x1E * data) {
   REWError status;
-  status = readBytesInto(fp, data->unknown_2, 2);
+  data->unknownString = NULL;
+
+  status = readBytesInto(fp, &data->unknown, 1);
   if (status != REWERR_OK) {
     return status;
   }
+
+  status = readCString(fp, &data->unknownString);
+  if (status != REWERR_OK) {
+    printError("readWiseScriptUnknown0x1E failed to read unknownString: "
+               "%d\n", status);
+    return status;
+  }
+
   return REWERR_OK;
 }
 
@@ -858,6 +868,37 @@ REWError readWiseScriptUnknown0x23(FILE * fp, WiseScriptUnknown0x23 * data) {
 }
 
 
+REWError readWiseScriptUnknown0x30(FILE *fp, WiseScriptUnknown0x30 *data)
+{
+  REWError status;
+
+  // init struct
+  data->unknownString_1 = NULL;
+  data->unknownString_2 = NULL;
+
+  status = readBytesInto(fp, &data->unknown_1, 1);
+  if (status != REWERR_OK) {
+    return status;
+  }
+
+  status = readCString(fp, &data->unknownString_1);
+  if (status != REWERR_OK) {
+    printError("readWiseScriptUnknown0x30 failed to read unknownString_1: "
+               "%d\n", status);
+    return status;
+  }
+
+  status = readCString(fp, &data->unknownString_2);
+  if (status != REWERR_OK) {
+    printError("readWiseScriptUnknown0x30 failed to read unknownString_2: "
+               "%d\n", status);
+    freeWiseScriptUnknown0x30(data);
+    return status;
+  }
+
+  return REWERR_OK;
+}
+
 
 
 void freeWiseScriptHeader(WiseScriptHeader * header) {
@@ -1117,6 +1158,14 @@ void freeWiseScriptUnknown0x1D(WiseScriptUnknown0x1D *data) {
 }
 
 
+void freeWiseScriptUnknown0x1E(WiseScriptUnknown0x1E *data) {
+  if (data->unknownString != NULL) {
+    free(data->unknownString);
+    data->unknownString = NULL;
+  }
+}
+
+
 void freeWiseScriptUnknown0x23(WiseScriptUnknown0x23 *data) {
   if (data->varName != NULL) {
     free(data->varName);
@@ -1129,6 +1178,18 @@ void freeWiseScriptUnknown0x23(WiseScriptUnknown0x23 *data) {
 }
 
 
+void freeWiseScriptUnknown0x30(WiseScriptUnknown0x30 *data) {
+  if (data->unknownString_1 != NULL) {
+    free(data->unknownString_1);
+    data->unknownString_1 = NULL;
+  }
+  if (data->unknownString_2 != NULL) {
+    free(data->unknownString_2);
+    data->unknownString_2 = NULL;
+  }
+}
+
+
 // https://www.doubleblak.com/m/blogPosts.php?id=7
 // MS-Dos FileTime
 // DATE
@@ -1352,9 +1413,7 @@ void printWiseScriptUnknown0x1D(WiseScriptUnknown0x1D *data) {
 }
 
 void printWiseScriptUnknown0x1E(WiseScriptUnknown0x1E * data) {
-  printf("0x1E 0x");
-  printHex(data->unknown_2, 2);
-  printf("\n");
+  printf("0x1E 0x%02X '%s'\n", data->unknown, data->unknownString);
 }
 
 void printWiseScriptUnknown0x23(WiseScriptUnknown0x23 * data) {
@@ -1369,6 +1428,13 @@ void printWiseScriptUnknown0x24(void) {
 void printWiseScriptUnknown0x25(void) {
   printf("0x25 \n");
 }
+
+void printWiseScriptUnknown0x30(WiseScriptUnknown0x30 *data)
+{
+  printf("0x30 %02X '%s' '%s'\n", data->unknown_1,
+         data->unknownString_1,
+         data->unknownString_2);
+}
 #endif // REWISE_DEBUG
 
 
@@ -1407,6 +1473,7 @@ void initWiseScriptCallbacks(WiseScriptCallbacks * callbacks) {
   callbacks->cb_0x23 = NULL;
   callbacks->cb_0x24 = NULL;
   callbacks->cb_0x25 = NULL;
+  callbacks->cb_0x30 = NULL;
 }
 
 
@@ -2003,6 +2070,7 @@ bool parseWiseScript(FILE *fp, WiseScriptParsedInfo *parsedInfo,
         if (status == REWERR_OK && callbacks->cb_0x1E != NULL) {
           (*callbacks->cb_0x1E)(&data);
         }
+        freeWiseScriptUnknown0x1E(&data);
       }
         break;
 
@@ -2090,6 +2158,18 @@ bool parseWiseScript(FILE *fp, WiseScriptParsedInfo *parsedInfo,
       }
         break;
 
+      case 0x30:
+      {
+        WiseScriptUnknown0x30 data;
+        status = readWiseScriptUnknown0x30(fp, &data);
+        // TODO need to stop wise parse on error??????
+        if (status == REWERR_OK && callbacks->cb_0x30 != NULL) {
+          (*callbacks->cb_0x30)(&data);
+        }
+        freeWiseScriptUnknown0x30(&data);
+      }
+        break;
+
       default:
         printError("parseWiseScript unknown OP: %02X at 0x%08X\n", ch,
                    ftell(fp));
@@ -2174,6 +2254,7 @@ bool wiseScriptDebugPrint(FILE *fp, WiseScriptParsedInfo *parsedInfo) {
   callbacks.cb_0x23 = printWiseScriptUnknown0x23;
   callbacks.cb_0x24 = printWiseScriptUnknown0x24;
   callbacks.cb_0x25 = printWiseScriptUnknown0x25;
+  callbacks.cb_0x30 = printWiseScriptUnknown0x30;
 
   return parseWiseScript(fp, parsedInfo, &callbacks);
 }

+ 11 - 3
src/wisescript.h

@@ -58,7 +58,7 @@ Operation codes:
   0x06  // Deflated file just used by the installer? (No filename)
   0x07
   0x08  // end branch
-  0x09
+  0x09  // function call ?
   0x0A
   0x0B
   0x0C  // if statement (new branch)
@@ -79,6 +79,8 @@ Operation codes:
   0x1C
   0x1D
   0x1E
+  0x30  // read 1 byte and 2 strings, only seen in cuteftp.exe, same
+        // as 0x15? or maybe even 0x23?
 */
 
 #ifndef H_WISESCRIPT
@@ -387,7 +389,8 @@ typedef struct {
 
 /* WiseScriptUnknown0x1E */
 typedef struct {
-  unsigned char unknown_2[2];
+  unsigned char unknown;
+  char *unknownString;
 } WiseScriptUnknown0x1E;
 
 /* WiseScriptUnknown0x23 aka the 'else if' struct, same as the
@@ -419,8 +422,9 @@ REWError readWiseScriptUnknown0x16(FILE * fp, WiseScriptUnknown0x16 * data);
 REWError readWiseScriptUnknown0x17(FILE * fp, WiseScriptUnknown0x17 * data);
 REWError readWiseScriptUnknown0x1C(FILE * fp, WiseScriptUnknown0x1C * data);
 REWError readWiseScriptUnknown0x1D(FILE * fp, WiseScriptUnknown0x1D * data);
-REWError readWiseScriptUnknown0x1E(FILE * fp, WiseScriptUnknown0x1E * data); // no-free (no strings)
+REWError readWiseScriptUnknown0x1E(FILE * fp, WiseScriptUnknown0x1E * data);
 REWError readWiseScriptUnknown0x23(FILE * fp, WiseScriptUnknown0x23 * data);
+REWError readWiseScriptUnknown0x30(FILE * fp, WiseScriptUnknown0x30 * data);
 
 
 void freeWiseScriptHeader(WiseScriptHeader * header);
@@ -443,7 +447,9 @@ void freeWiseScriptUnknown0x16(WiseScriptUnknown0x16 * data);
 void freeWiseScriptUnknown0x17(WiseScriptUnknown0x17 * data);
 void freeWiseScriptUnknown0x1C(WiseScriptUnknown0x1C * data);
 void freeWiseScriptUnknown0x1D(WiseScriptUnknown0x1D * data);
+void freeWiseScriptUnknown0x1E(WiseScriptUnknown0x1E * data);
 void freeWiseScriptUnknown0x23(WiseScriptUnknown0x23 * data);
+void freeWiseScriptUnknown0x30(WiseScriptUnknown0x30 * data);
 
 
 // For debugging
@@ -476,6 +482,7 @@ void printWiseScriptUnknown0x1E(WiseScriptUnknown0x1E * data);
 void printWiseScriptUnknown0x23(WiseScriptUnknown0x23 * data);
 void printWiseScriptUnknown0x24(void);
 void printWiseScriptUnknown0x25(void);
+void printWiseScriptUnknown0x30(WiseScriptUnknown0x30 * data);
 #endif
 
 
@@ -512,6 +519,7 @@ typedef struct {
   void (*cb_0x23)(WiseScriptUnknown0x23*);
   void (*cb_0x24)(void);
   void (*cb_0x25)(void);
+  void (*cb_0x30)(WiseScriptUnknown0x30*);
 } WiseScriptCallbacks;