forked from AmrThabet/x86Emulator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathx86emu.h
695 lines (640 loc) · 20.5 KB
/
x86emu.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
/*
*
* Copyright (C) 2010-2011 Amr Thabet <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to Amr Thabet
*
*/
// #ifndef __EMU__
//#define __EMU__
//typedef unsigned long DWORD;
#define EXP_IGNORE 0
#define EXP_ERROR -1
class Process;
class Log;
class Thread;
#ifndef DWORD
#define DWORD unsigned long
#endif
#if BUILDING_DLL
#include "hde28c/hde32.h"
#include "disasm/disassembler.h"
#include "apis/apis.h"
#include "emu/emu.h"
#include "seh.h"
#include "os/os.h"
#include "macros.h"
#endif
//------
#include "tib.h"
#include "pe.h"
#include <iostream>
#include <string.h>
//FLAGS
#define EFLG_OF (1<<11)
#define EFLG_SF (1<<7)
#define EFLG_ZF (1<<6)
#define EFLG_AF (1<<4)
#define EFLG_PF (1<<2)
#define EFLG_CF (1<<0)
#define EFLG_SYS (0x202)
//-------
//CUSTOM FLAGS SETTING
#define UPDATEFLAGS_CMP 1
#define UPDATEFLAGS_ADD 2
#define UPDATEFLAGS_SUB 4
//------
//MEMORY FLAGS
#define MEM_READWRITE 0
#define MEM_READONLY 1
#define MEM_IMAGEBASE 2 //mixing readonly & readwrite so it needs to be check
#define MEM_DLLBASE 3
#define MEM_VIRTUALPROTECT 4
//--------
//EXCEPTIONS
#define EXP_EXCEED_MAX_ITERATIONS 0
#define EXP_INVALIDPOINTER 1
#define EXP_WRITEACCESS_DENIED 2
#define EXP_INVALID_OPCODE 3
#define EXP_DIVID_BY_ZERO 4
#define EXP_INVALID_INSTRUCTION 5
#define EXP_DIV_OVERFLOW 6
#define EXP_BREAKPOINT 7
//--------
//PROCESS FLAGS
#define PROCESS_FILENAME 0
#define PROCESS_LOADEDIMAGE 1
#define PROCESS_UNLOADEDIMAGE 2
#define PROCESS_SHELLCODE 3
#define ERROR_FILENAME 8
using namespace std;
#ifndef DLLIMPORT
#ifdef WIN32
#if BUILDING_DLL
# define DLLIMPORT __declspec (dllexport)
#else /* Not BUILDING_DLL */
# define DLLIMPORT __declspec (dllimport)
#endif /* Not BUILDING_DLL */
#else
#define DLLIMPORT
#endif
#endif
struct DISASM_INSTRUCTION;
struct bytes;
struct FLAGTABLE;
struct hde32s;
struct DLL;
struct API;
//==================================
//APIs
struct DLL{
char* name;
DWORD imagebase;
DWORD size;
DWORD vAddr;
};
struct API{
char* name;
DLL* lib;
DWORD args;
DWORD addr;
int (*emu_func)(Thread*,DWORD*);
};
//===================================
//Debugger
#define NO_OF_BP_FUNCTIONS 100
#define BP_RUN 0
#define BP_PAUSE 1
#define BP_REMOVE 2
struct BPFunction{
int params;
DWORD dbg_func;
string name;
int flags;
};
//===================================
struct FLAGTABLE{
int opcode;
int reg;
int (*emu_func)(Thread&,DISASM_INSTRUCTION*);
string mnemonics;
int flags;
DWORD category;
DWORD opcode_name;
};
struct Exception{
int Type;
char* error;
DWORD ptr;
};
struct EnviromentVariables{
DWORD date;
DWORD time;
DWORD kernel32;
DWORD ntdll;
DWORD user32;
char* dllspath;
DWORD MaxIterations;
};
#define MAX_NUM_APIS_PER_DLL 200
struct Imports{
DWORD name;
DWORD addr;
bool defined;
DWORD napis;
DWORD apis[MAX_NUM_APIS_PER_DLL]; //Maximum Number of Apis is 300 per 1 DLL
};
//The Maximum Numbers (we could modify it to be dynamic arrays)
#define SYS_MAX_NO_INSTRUCTIONS 512*7
#define SYS_MAX_NO_APIS 1000
#define SYS_MAX_NO_DLLS 20
//The Start of every type of opcodes (for fast looping)
#define OPCODE_GROUP_START 100
#define OPCODE_FPU_0F 500
#define OPCODE_FPU_START 1000
class DLLIMPORT System
{
public:
int dis_entries;
FLAGTABLE FlagTable[SYS_MAX_NO_INSTRUCTIONS];
DLL DLLs[SYS_MAX_NO_DLLS];
API APITable[SYS_MAX_NO_APIS];
int dll_entries;
int api_entries;
EnviromentVariables enVars;
System(EnviromentVariables* v);
System(); //For Disassembling only
~System();
string getversion();
string getCopyrights();
// Assembler
bytes* assembl(string instruction);
DISASM_INSTRUCTION* disasm(DISASM_INSTRUCTION* bIns,char* ins_bytes);
DISASM_INSTRUCTION* disasm(DISASM_INSTRUCTION* bIns,char* ins_bytes,string& str);
int define_opcodes(unsigned int opcode,int reg,int (*emu_func)(Thread&,DISASM_INSTRUCTION*),string mnemonics,int flags,DWORD category);
int opcodes_init();
void init_vars(EnviromentVariables* v);
//APIs
int define_dll(char* name,char* path,DWORD vAddr);
int define_api(char* name,DLL* lib,DWORD args,int (*emu_func)(Thread*,DWORD*));
bool IsApiCall(Thread& thread, DISASM_INSTRUCTION * s);
int CallToAPI(Thread*,DISASM_INSTRUCTION*);
unsigned long GetAPI(char* func,unsigned long dll);
char* GetAPIbyAddress(unsigned long ptr,unsigned long dll);
unsigned long GetDllBase(char*);
unsigned long GetDllIndex(char* s);
char* GetTiggeredAPI(Thread& thread);
void init_apis(char* path);
bytes * System::assembl(DISASM_INSTRUCTION* instruction);
};
extern "C"
class DLLIMPORT Debugger{
protected:
struct {
DWORD ptr;
int state;
} bp[1000];
DWORD nbp;
Process* process;
BPFunction funcs[NO_OF_BP_FUNCTIONS];
int func_entries;
DWORD parser(string);
string lasterror;
public:
virtual bool TestBp(Thread& thread,DISASM_INSTRUCTION* ins);
virtual int AddBp(string s);
void RemoveBp(int index);
void PauseBp(int index);
void ActivateBp(int index);
int define_func(string name,int params,DWORD func,int flags);
int init_funcs();
Debugger(Process&);
Debugger();
string GetLastError();
private:
bool TestBp(int num,Thread& thread,DISASM_INSTRUCTION* ins);
};
class DLLIMPORT AsmDebugger : public Debugger{
DWORD parser(string);
public:
virtual bool TestBp(Thread& thread,DISASM_INSTRUCTION* ins);
virtual int AddBp(string s);
AsmDebugger(Process&);
private:
bool TestBp(int num,Thread& thread,DISASM_INSTRUCTION* ins);
//expressions solvers
DWORD boolexp(string&);
DWORD boolexp2(string&);
DWORD mathexp(string&);
DWORD mulexp(string&);
DWORD getnum(string&);
//math
DWORD domul(string&);
DWORD dodiv(string&);
DWORD doand(string&);
DWORD domod(string&);
DWORD doadd(string&);
DWORD dosub(string&);
DWORD door(string&);
DWORD doxor(string&);
DWORD donot(string&);
DWORD doneg(string&);
//boolean
DWORD dogreaterequal(string&);
DWORD dolowerequal(string&);
DWORD doequal(string&);
DWORD donotequal(string&);
DWORD dogreater(string&);
DWORD dolower(string&);
DWORD doandbool(string&);
DWORD doorbool(string&);
//Variables
DWORD doreg32(int);
//functions
DWORD callfunc(string&);
DWORD strfunc(string&);
//---
void add_to_buffer(bytes*);
};
#define VMEM_TYPE_STACK 0
#define VMEM_TYPE_DLL 1
#define VMEM_TYPE_ALLOC 2
class DLLIMPORT VirtualMemory
{
struct vMem{
DWORD vmem;
DWORD rmem;
DWORD size;
DWORD flags;
};
struct cMem{ //the changes in the memory during the emulation
DWORD ptr; //here the pointer to the virtual memory not the real pointer
DWORD size;
DWORD flags;
};
Log* last_accessed;
Log* last_modified;
public:
DWORD vAllocCommittedPages;
DWORD DLLCommittedPages;
DWORD StackCommittedPages;
int vmem_length;
int cmem_length;
vMem** vmem;
cMem** cmem;
VirtualMemory ();
~VirtualMemory();
DWORD get_virtual_pointer(DWORD ptr);
DWORD* read_virtual_mem(DWORD ptr);
DWORD write_virtual_mem(DWORD ptr,DWORD size,unsigned char* buff); //ptr , size, buff -return-> valid or not
bool get_memory_flags(DWORD ptr);
void set_memory_flags(DWORD ptr,int size);
DWORD get_last_accessed(int index);
DWORD get_last_modified(int index);
void _cdecl add_pointer(DWORD rptr,DWORD vptr,DWORD size,int=MEM_READWRITE);
DWORD delete_pointer(DWORD ptr);
bool check_writeaccess(DWORD ptr,DWORD imagebase);
DWORD create_memory_address(int Type);
};
class DLLIMPORT Stack{
Thread* thread;
public:
DWORD stackTop;
DWORD stackBottom;
Stack(Thread&);
void push(DWORD);
int pop();
};
class DLLIMPORT Thread{
TIB* tib;
TEB* teb;
DWORD fs;
bool seh_enable;
DWORD entry_point;
DWORD tls_callback_index;
public:
Process* process;
Log* log;
Stack* stack;
VirtualMemory* mem;
DWORD EFlags;
DWORD Eip;
bool still_tls;
DWORD Exx[8];
double ST[8];
//this structure need to be revised
struct{
DWORD FPUControlWord;
DWORD FPUStatusWord;
DWORD FPUTagWord;
DWORD LastInstructionPointer;
unsigned short LastOpcode;
unsigned short FPUDataPointer;
} FpuEnv;
DWORD GetFS();
Process* GetProcess();
void updateflags(DWORD,DWORD,DWORD,int,DWORD);
void generateException(DWORD code);
int doException(DWORD rec);
void sehReturn();
void TLSContinue();
void FpuUpdateFlags( DISASM_INSTRUCTION * s);
Thread(DWORD,Process&);
Thread();
void CreateTEB();
int SelectedReg; //the reg that will be the next to push in
//*/
friend class Process;
};
class DLLIMPORT Process {
private:
System* sys;
Thread* threads[100];
int nthreads;
int error;
int Imagebase;
int ImportTableFixup(DWORD);
int APIsFixup(DWORD,image_import_descriptor*,DWORD);
void CreatePEB();
DISASM_INSTRUCTION* ins;
bool TiggeredBreakpoint;
public:
bool IsDLL;
int AppType;
DWORD MaxIterations;
DWORD nimports;
Imports* imports[20];
PEB* peb;
Debugger* debugger;
VirtualMemory* SharedMem;
System* getsystem();
int emulate();
int emulate(string);
int emulatecommand(int);
int emulatecommand();
int CreateThread(DWORD);
Thread* GetThread(int);
int GetNumOfThreads(){return nthreads;};
DISASM_INSTRUCTION* GetLastIns();
DWORD GetImagebase();
void SkipIt();
Process (System* sys,string filename);
Process (System* sys,char* buff,int size,int Flags);
~Process();
};
class DLLIMPORT Log {
private:
DWORD log[10];
int cur;
public:
Log(DWORD);
void addlog(DWORD);
DWORD getlog(int);
};
//strings
int compare_array(string,string[],int);
int compare_array(string,string[],int,int);
string DLLIMPORT to_lower_case(string);
string DLLIMPORT trim(string);
int DLLIMPORT imm_to_dec(string);
//important functions
int call_to_func(DWORD,DWORD,DWORD);
DWORD DLLIMPORT PELoader(char* buff);
DWORD DLLIMPORT PELoader(string filename);
DWORD DLLIMPORT PEDump(DWORD Eip,Process* c,char* filename);
DWORD DLLIMPORT FindAPI(Process* c,DWORD ApiName,DWORD DllHandle,DWORD napi,DWORD ndll,bool defined);
DWORD DLLIMPORT ReconstructImportTable(Process* c);
DWORD DLLIMPORT UnloadImportTable(Process* c);
DWORD DLLIMPORT ZeroImportTable(Process * c);
DWORD DLLIMPORT modrm_calc(Thread&,DISASM_INSTRUCTION*);
//==========================================
// Hacker Disassmbler Engine
#ifndef _HDE32_H_
#define _HDE32_H_
//#include <stdint.h>
#define F_MODRM 0x00000001
#define F_SIB 0x00000002
#define F_IMM8 0x00000004
#define F_IMM16 0x00000008
#define F_IMM32 0x00000010
#define F_DISP8 0x00000020
#define F_DISP16 0x00000040
#define F_DISP32 0x00000080
#define F_RELATIVE 0x00000100
#define F_2IMM16 0x00000800
#define F_ERROR 0x00001000
#define F_ERROR_OPCODE 0x00002000
#define F_ERROR_LENGTH 0x00004000
#define F_ERROR_LOCK 0x00008000
#define F_ERROR_OPERAND 0x00010000
#define F_PREFIX_REPNZ 0x01000000
#define F_PREFIX_REPX 0x02000000
#define F_PREFIX_REP 0x03000000
#define F_PREFIX_66 0x04000000
#define F_PREFIX_67 0x08000000
#define F_PREFIX_LOCK 0x10000000
#define F_PREFIX_SEG 0x20000000
#define F_PREFIX_ANY 0x3f000000
#define PREFIX_SEGMENT_CS 0x2e
#define PREFIX_SEGMENT_SS 0x36
#define PREFIX_SEGMENT_DS 0x3e
#define PREFIX_SEGMENT_ES 0x26
#define PREFIX_SEGMENT_FS 0x64
#define PREFIX_SEGMENT_GS 0x65
#define PREFIX_LOCK 0xf0
#define PREFIX_REPNZ 0xf2
#define PREFIX_REPX 0xf3
#define PREFIX_OPERAND_SIZE 0x66
#define PREFIX_ADDRESS_SIZE 0x67
#endif
#pragma pack(push,1)
struct hde32sexport{
unsigned char len;
unsigned char p_rep;
unsigned char p_lock;
unsigned char p_seg;
unsigned char p_66;
unsigned char p_67;
unsigned char opcode;
unsigned char opcode2;
unsigned char modrm;
unsigned char modrm_mod;
unsigned char modrm_reg;
unsigned char modrm_rm;
unsigned char sib;
unsigned char sib_scale;
unsigned char sib_index;
unsigned char sib_base;
union {
unsigned char imm8;
unsigned short imm16;
unsigned int imm32;
} imm;
union {
unsigned char disp8;
unsigned short disp16;
unsigned int disp32;
} disp;
int flags;
};
#pragma pack(pop)
//==============================
//Disassembler
//the register flags
#define OP_REG_EAX 0x00000001
#define OP_REG_ECX 0x00000002
#define OP_REG_EDX 0x00000004
#define OP_REG_EBX 0x00000008
#define OP_REG_ESP 0x00000010
#define OP_REG_EBP 0x00000020
#define OP_REG_ESI 0x00000040
#define OP_REG_EDI 0x00000080
//FPU Registers
#define OP_REG_ST0 0x00000001
#define OP_REG_ST1 0x00000002
#define OP_REG_ST2 0x00000003
#define OP_REG_ST3 0x00000004
#define OP_REG_ST4 0x00000005
#define OP_REG_ST5 0x00000006
#define OP_REG_ST6 0x00000007
#define OP_REG_ST7 0x00000008
//for all registers
#define OP_REG_ALL 0x000000FF
#define OP_REG_ALL_EXP_EAX 0x000000FE
//Opcode States
#define OP_IMM8 0x00000100
#define OP_IMM32 0x00000200
#define OP_IMM 0x00000300 //IMM8 or IMM32
#define OP_BITS8 0x00000400
#define OP_BITS32 0x00000800
#define OP_RM_R 0x00001000 //Eb,Gb or Ev,Gv
#define OP_R_RM 0x00002000 //Gb,Eb or Gv,Ev
#define OP_RM_IMM 0x00004000 //Eb,Ib
#define OP_R_IMM 0x00008000 //Gb,Ib
#define OP_REG_EXT 0x00010000 //reg used as an opcode extention
#define OP_REG_ONLY 0x00020000 // like inc or dec
#define OP_RM_ONLY 0x00040000
#define OP_IMM_ONLY 0x00080000 // for push & pop
#define OP_RM_DISP 0x00100000 //disp only
#define OP_GROUP 0x00200000
#define OP_LOCK 0x00400000
#define OP_0F 0x00800000 //for 2 bytes opcode
#define OP_SRC8 0x01000000 //for movzx
#define OP_SRC16 0x02000000 //for movzx
#define OP_ANY 0x04000000 //no source and no destination
#define OP_FPU 0x08000000 //FPU Instructions
#define OP_MMX 0x10000000 //FPU Instructions
#define OP_UNUSED 0x20000000 //ignored entry in the FlagTables
//Assembler states
#define NO_SRCDEST 0x80000000 // no opcodes
#define DEST_REG 0x00000100
#define DEST_RM 0x00000200
#define DEST_IMM 0x00000400 //IMM8 or IMM32
#define DEST_BITS32 0x00000800
#define DEST_BITS16 0x00001000
#define DEST_BITS8 0x00002000
#define SRC_REG 0x00004000
#define SRC_NOSRC 0x00008000
#define SRC_RM 0x00010000
#define SRC_IMM 0x00020000 //IMM8 or IMM32
#define SRC_BITS32 0x00040000
#define SRC_BITS16 0x00001000 //the same as DEST_BITS16
#define SRC_BITS8 0x00080000
#define RM_SIB 0x00100000 // it will not differ dest or src because it should be one rm
#define INS_UNDEFINED 0x00200000 //for the disasembler only
#define INS_INVALID 0x00400000 //invalid instruction (returned by hde32)
#define MOVXZ_SRC16 0x00800000
#define MOVXZ_SRC8 0x01000000
#define EIP_UPDATED 0x02000000
#define API_CALL 0x04000000
//ModRM states
#define RM_REG 0x00000001
#define RM_DISP8 0x00000002
#define RM_DISP16 0x00000004
#define RM_DISP32 0x00000008
#define RM_DISP 0x00000010
#define RM_MUL2 0x00000020
#define RM_MUL4 0x00000040
#define RM_MUL8 0x00000080
#define RM_ADDR16 0x00000100
//FPU States
#define FPU_NULL 0x00000100 //no source or destinaion
#define FPU_DEST_ONLY 0x00000200 // Destination only
#define FPU_SRCDEST 0x00000400 // with source and destination
#define FPU_DEST_ST 0x00000800 // destination == ST0
#define FPU_SRC_STi 0x00000800 // source == STi (the same as before)
#define FPU_DEST_STi 0x00001000 // destination == STi
#define FPU_SRC_ST 0x00001000 // source == ST0 (the same as before)
#define FPU_DEST_RM 0x00002000 // destination is RM
#define FPU_MODRM 0x00002000 // destination is RM & there's a ModRM
#define FPU_BITS32 0x00004000
#define FPU_BITS16 0x00008000
#define FPU_BITS64 0x00010000
#define FPU_BITS80 0x00020000 //tbyte []
//MMX States
#define MMX_NULL 0x00000100 //no source or destinaion
//Opcode Categories
#define OP_TYPE_I386 0x00000001
#define OP_TYPE_FPU 0x00000002
#define OP_TYPE_MMX 0x00000004
#define OP_TYPE_SSE 0x00000008
#define OP_TYPE_ARTHIMETIC1 0x00000010 //add,sub,xor,or,shl,shr,and,ror,rol and the same for fpu,mmx
#define OP_TYPE_ARTHIMETIC2 0x00000020 //mul,div ...
#define OP_TYPE_ARTHIMETIC3 0x00000040 //all abnormal fpu mathimatics
#define OP_TYPE_FLOW_REDIRECTION 0x00000080 //like call,jmp,jcc, ...
#define OP_TYPE_FLAG_TEST 0x000000C0 //cmp,test, or ...
#define OP_TYPE_PRIVILEDGE 0x00000100 //like in,out ...
#define OP_TYPE_DATA_MANIPULATE 0x00000200 //movs, lods,stos,xchg, lea ... (not included xadd)
#define OP_TYPE_FLAG_MANIPULATE 0x00000400 //like cli,sti ...
#define OP_TYPE_NOP 0x00000800 //nop instructions
#define OP_TYPE_ARTIMITIC1_FLAGS 0x00000C10 //it's a part of Arthimitic 1 and it's like adc ...
#define OP_TYPE_UNKNOWN_BEHAVIOR 0x00001000 //like jp, aad,daa ...
#define OP_TYPE_STACK_MANIPULATE 0x00002000 //like push, pop ..
struct DISASM_INSTRUCTION
{
hde32sexport hde;
int entry; //the index of this opcode in the FlagTable
string* opcode;
int ndest;
int nsrc;
int other; //used for mul to save the imm and used for any call to api to save the index of the api(it's num in APITable)
struct {
int length;
int items[3];
int flags[3];
} modrm;
int (*emu_func)(Thread&,DISASM_INSTRUCTION*);
int flags;
DWORD category;
};
//assembler & disassembler
struct bytes {
int length;
unsigned char s[16];
};
/*
#ifdef WIN32
#ifdef EXPORT_CLASS_FOO
#define CLASS_FOO __declspec(dllexport) //while building the dll
#else
#define CLASS_FOO __declspec(dllimport) //while use the dll
#endif
#else
#define CLASS_FOO
#endif
class CLASS_Foo foo
{ ... };
//*/
//#endif