Browse code

Sync with compiler.

Török Edvin authored on 2009/11/06 23:34:46
Showing 15 changed files
... ...
@@ -21,8 +21,9 @@
21 21
  */
22 22
 #ifndef BYTECODE_H
23 23
 #define BYTECODE_H
24
-#include <stdio.h>
24
+#include <stdint.h>
25 25
 #include "clambc.h"
26
+#include <stdio.h>
26 27
 
27 28
 struct cli_dbio;
28 29
 struct cli_bc_ctx;
... ...
@@ -90,3 +90,16 @@ uint32_t cli_bcapi_setvirusname(struct cli_bc_ctx* ctx, const uint8_t *name, uin
90 90
     ctx->virname = name;
91 91
     return 0;
92 92
 }
93
+
94
+uint32_t cli_bcapi_disasm_x86(struct cli_bc_ctx *ctx, struct DISASM_RESULT *res, uint32_t len)
95
+{
96
+    //TODO: call disasm_x86_wrap, which outputs a MARIO struct
97
+}
98
+
99
+int32_t cli_bcapi_write(struct cli_bc_ctx *ctx, uint8_t*data, int32_t len)
100
+{
101
+    //TODO: write to tempfile (checking maxsize), and later scan it via
102
+    //magicscandesc
103
+}
104
+
105
+
... ...
@@ -24,12 +24,13 @@
24 24
 
25 25
 #ifdef __CLAMBC__
26 26
 #include "bytecode_execs.h"
27
-//#include "bytecode_pe.h"
27
+#include "bytecode_pe.h"
28
+#include "bytecode_disasm.h"
28 29
 #endif
29 30
 
30 31
 #ifndef __CLAMBC__
31 32
 #include "execs.h"
32
-#include "pe.h"
33
+struct DISASM_RESULT;
33 34
 #endif
34 35
 
35 36
 struct foo {
... ...
@@ -64,6 +65,7 @@ enum {
64 64
     SEEK_END
65 65
 };
66 66
 
67
+int32_t write(uint8_t *data, int32_t size);
67 68
 /* seeks current position to @pos, from @whence, returns current position from
68 69
  * start of file */
69 70
 int32_t seek(int32_t pos, uint32_t whence);
... ...
@@ -73,7 +75,8 @@ uint32_t setvirusname(const uint8_t *name, uint32_t len);
73 73
 
74 74
 uint32_t debug_print_str(const uint8_t *str, uint32_t len);
75 75
 uint32_t debug_print_uint(uint32_t a, uint32_t b);
76
-//const char *LogicalSignature;
77 76
 
77
+// disassembles at current file position, use lseek to disasm someplace else
78
+uint32_t disasm_x86(struct DISASM_RESULT*, uint32_t len);
78 79
 #endif
79 80
 #endif
... ...
@@ -29,16 +29,18 @@
29 29
 uint32_t cli_bcapi_test0(struct cli_bc_ctx *ctx, struct foo*, uint32_t);
30 30
 uint32_t cli_bcapi_test1(struct cli_bc_ctx *ctx, uint32_t, uint32_t);
31 31
 int32_t cli_bcapi_read(struct cli_bc_ctx *ctx, uint8_t*, int32_t);
32
+int32_t cli_bcapi_write(struct cli_bc_ctx *ctx, uint8_t*, int32_t);
32 33
 int32_t cli_bcapi_seek(struct cli_bc_ctx *ctx, int32_t, uint32_t);
33 34
 uint32_t cli_bcapi_setvirusname(struct cli_bc_ctx *ctx, const const uint8_t*, uint32_t);
34 35
 uint32_t cli_bcapi_debug_print_str(struct cli_bc_ctx *ctx, const const uint8_t*, uint32_t);
35 36
 uint32_t cli_bcapi_debug_print_uint(struct cli_bc_ctx *ctx, uint32_t, uint32_t);
37
+uint32_t cli_bcapi_disasm_x86(struct cli_bc_ctx *ctx, struct DISASM_RESULT*, uint32_t);
36 38
 
37 39
 const struct cli_apiglobal cli_globals[] = {
38 40
 /* Bytecode globals BEGIN */
39
-	{"__clambc_match_counts", GLOBAL_MATCH_COUNTS, 73,
41
+	{"__clambc_match_counts", GLOBAL_MATCH_COUNTS, 82,
40 42
 	 ((char*)&((struct cli_bc_ctx*)0)->hooks.match_counts - (char*)NULL)},
41
-	{"__clambc_exeinfo", GLOBAL_EXEINFO, 70,
43
+	{"__clambc_exeinfo", GLOBAL_EXEINFO, 79,
42 44
 	 ((char*)&((struct cli_bc_ctx*)0)->hooks.exeinfo - (char*)NULL)},
43 45
 	{"__clambc_kind", GLOBAL_KIND, 16,
44 46
 	 ((char*)&((struct cli_bc_ctx*)0)->hooks.kind - (char*)NULL)},
... ...
@@ -47,40 +49,72 @@ const struct cli_apiglobal cli_globals[] = {
47 47
 /* Bytecode globals END */
48 48
 };
49 49
 const unsigned cli_apicall_maxglobal = _LAST_GLOBAL-1;
50
-static uint16_t cli_tmp0[]={};
51
-static uint16_t cli_tmp1[]={71, 32, 32, 16};
52
-static uint16_t cli_tmp2[]={72};
53
-static uint16_t cli_tmp3[]={32, 32, 32, 32, 32, 32, 32, 32, 32};
54
-static uint16_t cli_tmp4[]={32};
55
-static uint16_t cli_tmp5[]={32, 32, 32};
56
-static uint16_t cli_tmp6[]={32, 65, 32};
57
-static uint16_t cli_tmp7[]={32, 77, 32};
50
+static uint16_t cli_tmp0[]={79, 77, 75, 72, 70, 32, 32};
51
+static uint16_t cli_tmp1[]={71};
52
+static uint16_t cli_tmp2[]={32, 32};
53
+static uint16_t cli_tmp3[]={73};
54
+static uint16_t cli_tmp4[]={16, 8, 8, 32, 32, 32, 32, 32, 64, 32, 32, 16, 16, 16, 16, 16, 16, 32, 32, 32, 32, 16, 16, 64, 64, 64, 64, 32, 32, 74};
55
+static uint16_t cli_tmp5[]={71};
56
+static uint16_t cli_tmp6[]={76};
57
+static uint16_t cli_tmp7[]={16, 8, 8, 32, 32, 32, 32, 32, 32, 32, 32, 32, 16, 16, 16, 16, 16, 16, 32, 32, 32, 32, 16, 16, 32, 32, 32, 32, 32, 32, 74};
58 58
 static uint16_t cli_tmp8[]={78};
59
-static uint16_t cli_tmp9[]={77};
59
+static uint16_t cli_tmp9[]={32, 16, 16, 32, 32, 32, 16, 16};
60
+static uint16_t cli_tmp10[]={80, 32, 32, 16};
61
+static uint16_t cli_tmp11[]={81};
62
+static uint16_t cli_tmp12[]={32, 32, 32, 32, 32, 32, 32, 32, 32};
63
+static uint16_t cli_tmp13[]={32};
64
+static uint16_t cli_tmp14[]={32, 84, 32};
65
+static uint16_t cli_tmp15[]={85};
66
+static uint16_t cli_tmp16[]={16, 8, 8, 8, 87, 86};
67
+static uint16_t cli_tmp17[]={8};
68
+static uint16_t cli_tmp18[]={88};
69
+static uint16_t cli_tmp19[]={8};
70
+static uint16_t cli_tmp20[]={32, 32, 32};
71
+static uint16_t cli_tmp21[]={32, 65, 32};
72
+static uint16_t cli_tmp22[]={32, 92, 32};
73
+static uint16_t cli_tmp23[]={93};
74
+static uint16_t cli_tmp24[]={92};
60 75
 
61 76
 const struct cli_bc_type cli_apicall_types[]={
62
-	{, cli_tmp0, , 0, 0},
63
-	{DStructType, cli_tmp1, 4, 0, 0},
64
-	{DPointerType, cli_tmp2, 1, 0, 0},
65
-	{DStructType, cli_tmp3, 9, 0, 0},
66
-	{DArrayType, cli_tmp4, 64, 0, 0},
67
-	{DFunctionType, cli_tmp5, 3, 0, 0},
68
-	{DFunctionType, cli_tmp6, 3, 0, 0},
69
-	{DFunctionType, cli_tmp7, 3, 0, 0},
77
+	{DStructType, cli_tmp0, 7, 0, 0},
78
+	{DPointerType, cli_tmp1, 1, 0, 0},
79
+	{DStructType, cli_tmp2, 2, 0, 0},
80
+	{DPointerType, cli_tmp3, 1, 0, 0},
81
+	{DStructType, cli_tmp4, 30, 0, 0},
82
+	{DArrayType, cli_tmp5, 16, 0, 0},
83
+	{DPointerType, cli_tmp6, 1, 0, 0},
84
+	{DStructType, cli_tmp7, 31, 0, 0},
70 85
 	{DPointerType, cli_tmp8, 1, 0, 0},
71
-	{DStructType, cli_tmp9, 1, 0, 0}
86
+	{DStructType, cli_tmp9, 8, 0, 0},
87
+	{DStructType, cli_tmp10, 4, 0, 0},
88
+	{DPointerType, cli_tmp11, 1, 0, 0},
89
+	{DStructType, cli_tmp12, 9, 0, 0},
90
+	{DArrayType, cli_tmp13, 64, 0, 0},
91
+	{DFunctionType, cli_tmp14, 3, 0, 0},
92
+	{DPointerType, cli_tmp15, 1, 0, 0},
93
+	{DStructType, cli_tmp16, 6, 0, 0},
94
+	{DArrayType, cli_tmp17, 29, 0, 0},
95
+	{DArrayType, cli_tmp18, 10, 0, 0},
96
+	{DArrayType, cli_tmp19, 3, 0, 0},
97
+	{DFunctionType, cli_tmp20, 3, 0, 0},
98
+	{DFunctionType, cli_tmp21, 3, 0, 0},
99
+	{DFunctionType, cli_tmp22, 3, 0, 0},
100
+	{DPointerType, cli_tmp23, 1, 0, 0},
101
+	{DStructType, cli_tmp24, 1, 0, 0}
72 102
 };
73 103
 
74 104
 const unsigned cli_apicall_maxtypes=sizeof(cli_apicall_types)/sizeof(cli_apicall_types[0]);
75 105
 const struct cli_apicall cli_apicalls[]={
76 106
 /* Bytecode APIcalls BEGIN */
77
-	{"test0", 7, 0, 1},
78
-	{"test1", 5, 0, 0},
79
-	{"read", 6, 1, 1},
80
-	{"seek", 5, 1, 0},
81
-	{"setvirusname", 6, 2, 1},
82
-	{"debug_print_str", 6, 3, 1},
83
-	{"debug_print_uint", 5, 2, 0}
107
+	{"test0", 22, 0, 1},
108
+	{"test1", 20, 0, 0},
109
+	{"read", 21, 1, 1},
110
+	{"write", 21, 2, 1},
111
+	{"seek", 20, 1, 0},
112
+	{"setvirusname", 21, 3, 1},
113
+	{"debug_print_str", 21, 4, 1},
114
+	{"debug_print_uint", 20, 2, 0},
115
+	{"disasm_x86", 14, 5, 1}
84 116
 /* Bytecode APIcalls END */
85 117
 };
86 118
 const cli_apicall_int2 cli_apicalls0[] = {
... ...
@@ -91,7 +125,9 @@ const cli_apicall_int2 cli_apicalls0[] = {
91 91
 const cli_apicall_pointer cli_apicalls1[] = {
92 92
 	(cli_apicall_pointer)cli_bcapi_test0,
93 93
 	(cli_apicall_pointer)cli_bcapi_read,
94
+	(cli_apicall_pointer)cli_bcapi_write,
94 95
 	(cli_apicall_pointer)cli_bcapi_setvirusname,
95
-	(cli_apicall_pointer)cli_bcapi_debug_print_str
96
+	(cli_apicall_pointer)cli_bcapi_debug_print_str,
97
+	(cli_apicall_pointer)cli_bcapi_disasm_x86
96 98
 };
97 99
 const unsigned cli_apicall_maxapi = sizeof(cli_apicalls)/sizeof(cli_apicalls[0]);
... ...
@@ -26,9 +26,11 @@ struct cli_bc_bctx;
26 26
 uint32_t cli_bcapi_test0(struct cli_bc_ctx *ctx, struct foo*, uint32_t);
27 27
 uint32_t cli_bcapi_test1(struct cli_bc_ctx *ctx, uint32_t, uint32_t);
28 28
 int32_t cli_bcapi_read(struct cli_bc_ctx *ctx, uint8_t*, int32_t);
29
+int32_t cli_bcapi_write(struct cli_bc_ctx *ctx, uint8_t*, int32_t);
29 30
 int32_t cli_bcapi_seek(struct cli_bc_ctx *ctx, int32_t, uint32_t);
30 31
 uint32_t cli_bcapi_setvirusname(struct cli_bc_ctx *ctx, const const uint8_t*, uint32_t);
31 32
 uint32_t cli_bcapi_debug_print_str(struct cli_bc_ctx *ctx, const const uint8_t*, uint32_t);
32 33
 uint32_t cli_bcapi_debug_print_uint(struct cli_bc_ctx *ctx, uint32_t, uint32_t);
34
+uint32_t cli_bcapi_disasm_x86(struct cli_bc_ctx *ctx, struct DISASM_RESULT*, uint32_t);
33 35
 
34 36
 #endif
... ...
@@ -24,8 +24,8 @@
24 24
 
25 25
 struct cli_bc_hooks {
26 26
 	 const uint32_t* match_counts;
27
-	 const struct cli_exe_info exeinfo;
28
-	 const uint16_t kind;
29
-	 const cli_pe_hook_data pedata;
27
+	 const struct cli_exe_info* exeinfo;
28
+	 const uint16_t* kind;
29
+	 const struct cli_pe_hook_data* pedata;
30 30
 };
31 31
 #endif
... ...
@@ -22,7 +22,6 @@
22 22
 #ifndef CLAMBC_H
23 23
 #define CLAMBC_H
24 24
 
25
-
26 25
 struct bytecode_metadata {
27 26
   unsigned long maxStack, maxMem;
28 27
   unsigned long maxTime;
... ...
@@ -75,6 +74,12 @@ enum bc_opcode {
75 75
   OP_BC_GEPN,
76 76
   OP_BC_STORE,
77 77
   OP_BC_LOAD,
78
+  OP_BC_MEMSET,
79
+  OP_BC_MEMCPY,
80
+  OP_BC_MEMMOVE,
81
+  OP_BC_MEMCMP,
82
+  OP_BC_ISBIGENDIAN,
83
+  OP_BC_ABORT,
78 84
   OP_BC_INVALID /* last */
79 85
 };
80 86
 
... ...
@@ -95,7 +100,13 @@ static const unsigned char operand_counts[] = {
95 95
   /* OP_BC_COPY */
96 96
   2,
97 97
   /* OP_BC_GEP1, OP_BC_GEP2, OP_BC_GEPN, OP_BC_STORE, OP_BC_LOAD*/
98
-  2, 3, 0, 2, 1
98
+  2, 3, 0, 2, 1,
99
+  /* OP_MEM* */
100
+  3, 3, 3, 3,
101
+  /* OP_BC_ISBIGENDIAN */
102
+  0,
103
+  /* OP_BC_ABORT */
104
+  0
99 105
 };
100 106
 
101 107
 enum bc_global {
... ...
@@ -104,6 +115,7 @@ enum bc_global {
104 104
   GLOBAL_KIND,
105 105
   GLOBAL_VIRUSNAMES,
106 106
   GLOBAL_EXEINFO,
107
+  GLOBAL_PEDATA,
107 108
   _LAST_GLOBAL
108 109
 };
109 110
 
... ...
@@ -18,6 +18,16 @@
18 18
  *  MA 02110-1301, USA.
19 19
  */
20 20
 
21
+#if HAVE_CONFIG_H
22
+#include "clamav-config.h"
23
+#endif
24
+
25
+#include <stdio.h>
26
+#include <string.h>
27
+#include <assert.h>
28
+
29
+#include "others.h"
30
+
21 31
 #include "disasmpriv.h"
22 32
 #include "disasm.h"
23 33
 
... ...
@@ -1669,22 +1679,11 @@ static uint8_t *disasm_x86(uint8_t *command, unsigned int len, struct DISASMED *
1669 1669
   }
1670 1670
 }
1671 1671
 
1672
-
1673 1672
 void disasmbuf(uint8_t *buff, unsigned int len, int fd) {
1674 1673
   uint8_t *next = buff;
1675 1674
   unsigned int counter=0;
1676 1675
   struct DISASMED s;
1677
-  struct MARIO {
1678
-    uint16_t real_op;
1679
-    uint8_t opsize;
1680
-    uint8_t adsize;
1681
-    uint8_t segment;
1682
-
1683
-    uint8_t arg[3][10];
1684
-
1685
-    uint8_t extra[29];
1686
-  } w;
1687
-
1676
+  struct DISASM_RESULT w;
1688 1677
   memset(&w.extra[0], 0, sizeof(w.extra));
1689 1678
 
1690 1679
   while(len && counter++<200) {
... ...
@@ -21,308 +21,7 @@
21 21
 #ifndef __DISASMPRIV_H
22 22
 #define __DISASMPRIV_H
23 23
 
24
-#if HAVE_CONFIG_H
25
-#include "clamav-config.h"
26
-#endif
27
-
28
-#include <stdio.h>
29
-#include <string.h>
30
-#include <assert.h>
31
-
32
-#include "others.h"
33
-
34
-enum X86OPS {
35
-  OP_INVALID,
36
-  OP_AAA,
37
-  OP_AAD,
38
-  OP_AAM,
39
-  OP_AAS,
40
-  OP_ADD,
41
-  OP_ADC,
42
-  OP_AND,
43
-  OP_ARPL,
44
-  OP_BOUND,
45
-  OP_BSF,
46
-  OP_BSR,
47
-  OP_BSWAP,
48
-  OP_BT,
49
-  OP_BTC,
50
-  OP_BTR,
51
-  OP_BTS,
52
-  OP_CALL,
53
-  OP_CDQ,
54
-  OP_CWD,
55
-  OP_CWDE,
56
-  OP_CBW,
57
-  OP_CLC,
58
-  OP_CLD,
59
-  OP_CLI,
60
-  OP_CLTS,
61
-  OP_CMC,
62
-  OP_CMOVO,
63
-  OP_CMOVNO,
64
-  OP_CMOVC,
65
-  OP_CMOVNC,
66
-  OP_CMOVZ,
67
-  OP_CMOVNZ,
68
-  OP_CMOVBE,
69
-  OP_CMOVA,
70
-  OP_CMOVS,
71
-  OP_CMOVNS,
72
-  OP_CMOVP,
73
-  OP_CMOVNP,
74
-  OP_CMOVL,
75
-  OP_CMOVGE,
76
-  OP_CMOVLE,
77
-  OP_CMOVG,
78
-  OP_CMP,
79
-  OP_CMPSD,
80
-  OP_CMPSW,
81
-  OP_CMPSB,
82
-  OP_CMPXCHG,
83
-  OP_CMPXCHG8B,
84
-  OP_CPUID,
85
-  OP_DAA,
86
-  OP_DAS,
87
-  OP_DEC,
88
-  OP_DIV,
89
-  OP_ENTER,
90
-  OP_FWAIT,
91
-  OP_HLT,
92
-  OP_IDIV,
93
-  OP_IMUL,
94
-  OP_INC,
95
-  OP_IN,
96
-  OP_INSD,
97
-  OP_INSW,
98
-  OP_INSB,
99
-  OP_INT,
100
-  OP_INT3,
101
-  OP_INTO,
102
-  OP_INVD,
103
-  OP_INVLPG,
104
-  OP_IRET,
105
-  OP_JO,
106
-  OP_JNO,
107
-  OP_JC,
108
-  OP_JNC,
109
-  OP_JZ,
110
-  OP_JNZ,
111
-  OP_JBE,
112
-  OP_JA,
113
-  OP_JS,
114
-  OP_JNS,
115
-  OP_JP,
116
-  OP_JNP,
117
-  OP_JL,
118
-  OP_JGE,
119
-  OP_JLE,
120
-  OP_JG,
121
-  OP_JMP,
122
-  OP_LAHF,
123
-  OP_LAR,
124
-  OP_LDS,
125
-  OP_LES,
126
-  OP_LFS,
127
-  OP_LGS,
128
-  OP_LEA,
129
-  OP_LEAVE,
130
-  OP_LGDT,
131
-  OP_LIDT,
132
-  OP_LLDT,
133
-  OP_PREFIX_LOCK,
134
-  OP_LODSD,
135
-  OP_LODSW,
136
-  OP_LODSB,
137
-  OP_LOOP,
138
-  OP_LOOPE,
139
-  OP_LOOPNE,
140
-  OP_JECXZ,
141
-  OP_LSL,
142
-  OP_LSS,
143
-  OP_LTR,
144
-  OP_MOV,
145
-  OP_MOVSD,
146
-  OP_MOVSW,
147
-  OP_MOVSB,
148
-  OP_MOVSX,
149
-  OP_MOVZX,
150
-  OP_MUL,
151
-  OP_NEG,
152
-  OP_NOP,
153
-  OP_NOT,
154
-  OP_OR,
155
-  OP_OUT,
156
-  OP_OUTSD,
157
-  OP_OUTSW,
158
-  OP_OUTSB,
159
-  OP_PUSH,
160
-  OP_PUSHAD,
161
-  OP_PUSHA,
162
-  OP_PUSHFD,
163
-  OP_PUSHF,
164
-  OP_POP,
165
-  OP_POPAD,
166
-  OP_POPFD,
167
-  OP_POPF,
168
-  OP_RCL,
169
-  OP_RCR,
170
-  OP_RDMSR,
171
-  OP_RDPMC,
172
-  OP_RDTSC,
173
-  OP_PREFIX_REPE,
174
-  OP_PREFIX_REPNE,
175
-  OP_RETF,
176
-  OP_RETN,
177
-  OP_ROL,
178
-  OP_ROR,
179
-  OP_RSM,
180
-  OP_SAHF,
181
-  OP_SAR,
182
-  OP_SBB,
183
-  OP_SCASD,
184
-  OP_SCASW,
185
-  OP_SCASB,
186
-  OP_SETO,
187
-  OP_SETNO,
188
-  OP_SETC,
189
-  OP_SETNC,
190
-  OP_SETZ,
191
-  OP_SETNZ,
192
-  OP_SETBE,
193
-  OP_SETA,
194
-  OP_SETS,
195
-  OP_SETNS,
196
-  OP_SETP,
197
-  OP_SETNP,
198
-  OP_SETL,
199
-  OP_SETGE,
200
-  OP_SETLE,
201
-  OP_SETG,
202
-  OP_SGDT,
203
-  OP_SIDT,
204
-  OP_SHL,
205
-  OP_SHLD,
206
-  OP_SHR,
207
-  OP_SHRD,
208
-  OP_SLDT,
209
-  OP_STOSD,
210
-  OP_STOSW,
211
-  OP_STOSB,
212
-  OP_STR,
213
-  OP_STC,
214
-  OP_STD,
215
-  OP_STI,
216
-  OP_SUB,
217
-  OP_SYSCALL,
218
-  OP_SYSENTER,
219
-  OP_SYSEXIT,
220
-  OP_SYSRET,
221
-  OP_TEST,
222
-  OP_UD2,
223
-  OP_VERR,
224
-  OP_VERRW,
225
-  OP_WBINVD,
226
-  OP_WRMSR,
227
-  OP_XADD,
228
-  OP_XCHG,
229
-  OP_XLAT,
230
-  OP_XOR,
231
-  OP_PREFIX_OPSIZE,
232
-  OP_PREFIX_ADDRSIZE,
233
-  OP_PREFIX_SEGMENT,
234
-  OP_2BYTE,
235
-
236
-  OP_FPU,
237
-
238
-  OP_F2XM1,
239
-  OP_FABS,
240
-  OP_FADD,
241
-  OP_FADDP,
242
-  OP_FBLD,
243
-  OP_FBSTP,
244
-  OP_FCHS,
245
-  OP_FCLEX,
246
-  OP_FCMOVB,
247
-  OP_FCMOVBE,
248
-  OP_FCMOVE,
249
-  OP_FCMOVNB,
250
-  OP_FCMOVNBE,
251
-  OP_FCMOVNE,
252
-  OP_FCMOVNU,
253
-  OP_FCMOVU,
254
-  OP_FCOM,
255
-  OP_FCOMI,
256
-  OP_FCOMIP,
257
-  OP_FCOMP,
258
-  OP_FCOMPP,
259
-  OP_FCOS,
260
-  OP_FDECSTP,
261
-  OP_FDIV,
262
-  OP_FDIVP,
263
-  OP_FDIVR,
264
-  OP_FDIVRP,
265
-  OP_FFREE,
266
-  OP_FIADD,
267
-  OP_FICOM,
268
-  OP_FICOMP,
269
-  OP_FIDIV,
270
-  OP_FIDIVR,
271
-  OP_FILD,
272
-  OP_FIMUL,
273
-  OP_FINCSTP,
274
-  OP_FINIT,
275
-  OP_FIST,
276
-  OP_FISTP,
277
-  OP_FISTTP,
278
-  OP_FISUB,
279
-  OP_FISUBR,
280
-  OP_FLD,
281
-  OP_FLD1,
282
-  OP_FLDCW,
283
-  OP_FLDENV,
284
-  OP_FLDL2E,
285
-  OP_FLDL2T,
286
-  OP_FLDLG2,
287
-  OP_FLDLN2,
288
-  OP_FLDPI,
289
-  OP_FLDZ,
290
-  OP_FMUL,
291
-  OP_FMULP,
292
-  OP_FNOP,
293
-  OP_FPATAN,
294
-  OP_FPREM,
295
-  OP_FPREM1,
296
-  OP_FPTAN,
297
-  OP_FRNDINT,
298
-  OP_FRSTOR,
299
-  OP_FSCALE,
300
-  OP_FSIN,
301
-  OP_FSINCOS,
302
-  OP_FSQRT,
303
-  OP_FSAVE,
304
-  OP_FST,
305
-  OP_FSTCW,
306
-  OP_FSTENV,
307
-  OP_FSTP,
308
-  OP_FSTSW,
309
-  OP_FSUB,
310
-  OP_FSUBP,
311
-  OP_FSUBR,
312
-  OP_FSUBRP,
313
-  OP_FTST,
314
-  OP_FUCOM,
315
-  OP_FUCOMI,
316
-  OP_FUCOMIP,
317
-  OP_FUCOMP,
318
-  OP_FUCOMPP,
319
-  OP_FXAM,
320
-  OP_FXCH,
321
-  OP_FXTRACT,
322
-  OP_FYL2X,
323
-  OP_FYL2XP1
324
-};
325
-
24
+#include "disasm-common.h"
326 25
 
327 26
 enum DIS_STATE {
328 27
   STATE_GETOP,
... ...
@@ -334,37 +33,6 @@ enum DIS_STATE {
334 334
   STATE_ERROR
335 335
 };
336 336
 
337
-enum DIS_ACCESS {
338
-  ACCESS_NOARG, /* arg not present */
339
-  ACCESS_IMM,   /* immediate */
340
-  ACCESS_REL,   /* +/- immediate */
341
-  ACCESS_REG,   /* register */
342
-  ACCESS_MEM    /* [something] */
343
-};
344
-
345
-enum DIS_SIZE { /* for mem access, immediate and relative */
346
-  SIZEB,
347
-  SIZEW,
348
-  SIZED,
349
-  SIZEF,
350
-  SIZEQ,
351
-  SIZET,
352
-  SIZEPTR
353
-};
354
-
355
-
356
-enum X86REGS {
357
-  REG_EAX, REG_ECX, REG_EDX, REG_EBX, REG_ESP, REG_EBP, REG_ESI, REG_EDI,
358
-  REG_AX, REG_CX, REG_DX, REG_BX, REG_SP, REG_BP, REG_SI, REG_DI,
359
-  REG_AH, REG_CH, REG_DH, REG_BH, REG_AL, REG_CL, REG_DL, REG_BL,
360
-  REG_ES, REG_CS, REG_SS, REG_DS, REG_FS, REG_GS,
361
-  REG_CR0, REG_CR1, REG_CR2, REG_CR3, REG_CR4, REG_CR5, REG_CR6, REG_CR7,
362
-  REG_DR0, REG_DR1, REG_DR2, REG_DR3, REG_DR4, REG_DR5, REG_DR6, REG_DR7,
363
-  REG_ST0, REG_ST1, REG_ST2, REG_ST3, REG_ST4, REG_ST5, REG_ST6, REG_ST7,
364
-  REG_INVALID
365
-};
366
-
367
-
368 337
 struct DIS_ARGS {
369 338
   enum DIS_ACCESS access;
370 339
   enum DIS_SIZE size;
... ...
@@ -388,7 +56,6 @@ struct DIS_ARGS {
388 388
   } arg;
389 389
 };
390 390
 
391
-
392 391
 /* FIXME: pack this thing and make macroes to access it in different compilers */
393 392
 struct DISASMED {
394 393
   uint16_t table_op;
... ...
@@ -1,7 +1,7 @@
1
-ClamBCaa`|``````|`afafp`clamcoincidencejb
1
+ClamBCaa`|``````|`ahafp`clamcoincidencejb
2 2
 
3
-Tedacb`bb`bb`b
4
-Eabaaabbed|afdgefcgdgac``
3
+Tedaa`ab`badacb`bb`bb`b
4
+Eabaaabbgd|afdgefcgdgac``
5 5
 G``
6 6
 A`b`bLacb`baab`bFadaa
7 7
 Bb`b`abbabHonnkm``odHm``oonnkdaaaaeab`b`Hhgfedcbadb`baboaaaDm``odDmjnmdTcab`babE
... ...
@@ -1,10 +1,10 @@
1
-ClamBCaa`|``````|`ajafp`clamcoincidencejb
1
+ClamBCaa`|``````|`alafp`clamcoincidencejb
2 2
 
3
-Tedcabidebidacb`bbidb`bacb`bb`bb`bebed
4
-Eababaabgd|afdgefcgdg`c``abbhd|afdgefcgdgac``
3
+Tedaa`cabkdebkdab`badacb`bbkdb`bacb`bb`bb`bebfd
4
+Eababaabid|afdgefcgdg`c``abbjd|afdgefcgdgac``
5 5
 G``
6
-A`b`bLahbedbfd`b`baab`baab`bFajac
7
-Bbfdaadb`@d@d``fb`aab`bacabbabHonnkm``odHm``oonnkdaaadeab`bacHhgfedcbadTaaadaaab
6
+A`b`bLahbfdbgd`b`baab`baab`bFajac
7
+Bbgdaadb`@d@d``bb``b`bacabbabHonnkm``odHm``oonnkdaaadeab`bacHhgfedcbadTaaadaaab
8 8
 Bb`baeabbaa`Honnkmjnmdaaafeab`baeHhgfedcbadb`bagoaafDm``odDmjnmdTcab`bag
9 9
 BTcab`bDmjnmdE
10 10
 Aab`bLabahaab`bFacaa
... ...
@@ -1,6 +1,6 @@
1
-ClamBCaa`|``````|`aebbep`clamcoincidencejb
1
+ClamBCaa`|``````|`agbbep`clamcoincidencejb
2 2
 
3
-Ted
3
+Tedaa`ab`bad
4 4
 E``
5 5
 G``
6 6
 A`b`bLbabb`bb`bb`bb`bb`bb`bb`bb`bb`bb`bb`bb`bb`bb`bb`bb`bb`bb`bb`bb`bb`bb`bb`bb`bb`bb`bb`bb`bb`bb`bb`bb`bb`bFbbbaa
... ...
@@ -1,6 +1,6 @@
1
-ClamBCaa`|``````|`aeabp`clamcoincidencejb
1
+ClamBCaa`|``````|`agabp`clamcoincidencejb
2 2
 
3
-Ted
3
+Tedaa`ab`bad
4 4
 E``
5 5
 G``
6 6
 A`b`bLaab`bFabaa
... ...
@@ -1,9 +1,11 @@
1
-ClamBCaa`|``c``a```|`alaap`clamcoincidencejb
1
+ClamBCaa`|``````|`bkaabp`clamcoincidencejb
2 2
 Trojan.Foo.{A,B};Target:0;((0|1|2)=42,2);aabb;ffffffff;aaccee;f00d
3
-Tedebkdebjdebadebcdacb`bbadb`bdb`db`bdabah
4
-Eaeaaaebid|amcgefdgfgifbgegcgnfafmfef``
5
-Gd```hahbkdBad@`bkdBbd@`bad@@`bad@Aa`bcdAcD```h`bcdAbD```h`bcd@D```h`bcdAaD```h`
3
+Tedebjeebieebheebgeebfeebeeebceebbeebadebcdaa`ab`badacb`bbadb`bdb`db`bchbadbdebadbdebadbdebadbdecab`bdagahdaiahdaeahdabbaddabahdakah
4
+Eafaaafbae|amcgefdgfgifbgegcgnfafmfef``
5
+Gd```hbeabjeBdeBbgBofBjfBafBnfBnbBfdBofBof@`bieBad@`bieBbd@`bhe@Aa@Ab`b`a@`b`aC``a`bgeBafBafBbfBbf@`bfeBffBffBffBffBffBffBffBff@`bgeBffB`cB`cBdf@`beeBafBafBcfBcfBefBef@`bce@Af@@AgAa@AhAc@AiAb`bad@Aa`bad@Ab`bad@Af`bad@Ag`bad@Ah`bad@Ai`bcdAcD```h`bcdAbD```h`bcd@D```h`bcdAaD```h`
6 6
 A`b`bLaeb`baaaabadb`bFahac
7
-Bb`b`gbAd`aaaaiab`b`AbdTaaaaabaa
8
-Baaabeab`b`AbdbadacoaabAb`Ac`b`badabbaeac@dTcab`b@d
7
+Bb`b`gbBaa`aaaaiab`b`AbdTaaaaabaa
8
+Baaabeab`b`AbdbadacoaabAk`Al`b`badabbafac@dTcab`b@d
9 9
 BTcab`b@dE
10
+A`aaLb`ab`bb`bb`bb`bb`baaaaaaaab`bb`bb`bb`bb`baaaaFbaaaa
11
+Bb`b`gbBca`b`baagbBda`b`babgbBba`b`baca`aa`b`bada`acabaaaeeab`badBjbdaaaffab`b`@daaagfab`baa@daaahfab`bab@db`bai`aafb`baj`aagb`bak`aahb`bala`ajaib`bama`alakaaaneab`bamAbdaaaok`anaeTcaaaaoE
... ...
@@ -1,6 +1,6 @@
1
-ClamBCaa`|``````|`aeaap`clamcoincidencejb
1
+ClamBCaa`|``````|`agaap`clamcoincidencejb
2 2
 
3
-Ted
3
+Tedaa`ab`bad
4 4
 E``
5 5
 G``
6 6
 A`b`bL`Faaaa