Browse code

change bytecode format to allow structs with more than 16 fields.

Török Edvin authored on 2009/12/04 23:45:48
Showing 4 changed files
... ...
@@ -497,7 +497,7 @@ static void parseType(struct cli_bc *bc, struct cli_bc_type *ty,
497 497
 {
498 498
     unsigned j;
499 499
 
500
-    ty->numElements = readFixedNumber(buffer, off, len, ok, 1);
500
+    ty->numElements = readNumber(buffer, off, len, ok);
501 501
     if (!ok) {
502 502
 	cli_errmsg("Error parsing type\n");
503 503
 	*ok = 0;
... ...
@@ -56,7 +56,7 @@ const struct cli_apiglobal cli_globals[] = {
56 56
 /* Bytecode globals END */
57 57
 };
58 58
 const unsigned cli_apicall_maxglobal = _LAST_GLOBAL-1;
59
-static uint16_t cli_tmp0[]={79, 77, 75, 72, 70, 32, 32};
59
+static uint16_t cli_tmp0[]={79, 77, 75, 72, 70, 32, 32, 32, 8, 65};
60 60
 static uint16_t cli_tmp1[]={71};
61 61
 static uint16_t cli_tmp2[]={32, 32};
62 62
 static uint16_t cli_tmp3[]={73};
... ...
@@ -83,7 +83,7 @@ static uint16_t cli_tmp23[]={93};
83 83
 static uint16_t cli_tmp24[]={92};
84 84
 
85 85
 const struct cli_bc_type cli_apicall_types[]={
86
-	{DStructType, cli_tmp0, 7, 0, 0},
86
+	{DStructType, cli_tmp0, 10, 0, 0},
87 87
 	{DPointerType, cli_tmp1, 1, 0, 0},
88 88
 	{DStructType, cli_tmp2, 2, 0, 0},
89 89
 	{DPointerType, cli_tmp3, 1, 0, 0},
... ...
@@ -2125,6 +2125,7 @@ int cli_scanpe(cli_ctx *ctx)
2125 2125
     pedata.opt32 = &pe_opt.opt32;
2126 2126
     pedata.opt64 = &pe_opt.opt64;
2127 2127
     pedata.dirs = dirs;
2128
+    pedata.e_lfanew = e_lfanew;
2128 2129
     pedata.overlays = overlays;
2129 2130
     pedata.overlays_sz = fsize - overlays;
2130 2131
     cli_bytecode_context_setpe(bc_ctx, &pedata);
... ...
@@ -26,6 +26,7 @@
26 26
 #include "others.h"
27 27
 #include "cltypes.h"
28 28
 #include "fmap.h"
29
+#include "bcfeatures.h"
29 30
 /** @file */
30 31
 /** Header for this PE file */
31 32
 struct pe_image_file_hdr {
... ...
@@ -141,8 +142,12 @@ struct cli_pe_hook_data {
141 141
     struct pe_image_optional_hdr32 *opt32;
142 142
     struct pe_image_optional_hdr64 *opt64;
143 143
     struct pe_image_data_dir *dirs;
144
+    uint32_t e_lfanew;/**< address of new exe header */
144 145
     uint32_t overlays;/**< number of overlays */
145 146
     int32_t overlays_sz;/**< size of overlays */
147
+    /* FIXME: these should not be necessary (they are for now) */
148
+    uint8_t dummyn;
149
+    uint8_t *dummy EBOUNDS(dummyn);
146 150
 };
147 151
 
148 152
 int cli_scanpe(cli_ctx *ctx);