DBG: completely removed BeaEngine
This commit is contained in:
parent
a89e0eb1c0
commit
2e0e9d55c7
|
@ -58,7 +58,6 @@ copy help\x64dbg.chm %RELEASEDIR%\help
|
|||
echo pluginsdk
|
||||
|
||||
mkdir %RELEASEDIR%\pluginsdk
|
||||
mkdir %RELEASEDIR%\pluginsdk\BeaEngine
|
||||
mkdir %RELEASEDIR%\pluginsdk\capstone
|
||||
mkdir %RELEASEDIR%\pluginsdk\dbghelp
|
||||
mkdir %RELEASEDIR%\pluginsdk\DeviceNameResolver
|
||||
|
@ -69,7 +68,6 @@ mkdir %RELEASEDIR%\pluginsdk\XEDParse
|
|||
mkdir %RELEASEDIR%\pluginsdk\yara
|
||||
mkdir %RELEASEDIR%\pluginsdk\yara\yara
|
||||
|
||||
xcopy x64_dbg_dbg\BeaEngine %RELEASEDIR%\pluginsdk\BeaEngine /S /Y
|
||||
xcopy x64_dbg_dbg\capstone %RELEASEDIR%\pluginsdk\capstone /S /Y
|
||||
xcopy x64_dbg_dbg\dbghelp %RELEASEDIR%\pluginsdk\dbghelp /S /Y
|
||||
xcopy x64_dbg_dbg\DeviceNameResolver %RELEASEDIR%\pluginsdk\DeviceNameResolver /S /Y
|
||||
|
|
|
@ -1,392 +0,0 @@
|
|||
#ifndef _BEA_ENGINE_
|
||||
#define _BEA_ENGINE_
|
||||
#if defined(__cplusplus) && defined(__BORLANDC__)
|
||||
namespace BeaEngine
|
||||
{
|
||||
#endif
|
||||
|
||||
#include "macros.h"
|
||||
#include "export.h"
|
||||
#include "basic_types.h"
|
||||
|
||||
#if !defined(BEA_ENGINE_STATIC)
|
||||
#if defined(BUILD_BEA_ENGINE_DLL)
|
||||
#define BEA_API bea__api_export__
|
||||
#else
|
||||
#define BEA_API bea__api_import__
|
||||
#endif
|
||||
#else
|
||||
#define BEA_API
|
||||
#endif
|
||||
|
||||
|
||||
#define INSTRUCT_LENGTH 64
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct
|
||||
{
|
||||
UInt8 W_;
|
||||
UInt8 R_;
|
||||
UInt8 X_;
|
||||
UInt8 B_;
|
||||
UInt8 state;
|
||||
} REX_Struct ;
|
||||
#pragma pack()
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct
|
||||
{
|
||||
int Number;
|
||||
int NbUndefined;
|
||||
UInt8 LockPrefix;
|
||||
UInt8 OperandSize;
|
||||
UInt8 AddressSize;
|
||||
UInt8 RepnePrefix;
|
||||
UInt8 RepPrefix;
|
||||
UInt8 FSPrefix;
|
||||
UInt8 SSPrefix;
|
||||
UInt8 GSPrefix;
|
||||
UInt8 ESPrefix;
|
||||
UInt8 CSPrefix;
|
||||
UInt8 DSPrefix;
|
||||
UInt8 BranchTaken;
|
||||
UInt8 BranchNotTaken;
|
||||
REX_Struct REX;
|
||||
char alignment[2];
|
||||
} PREFIXINFO ;
|
||||
#pragma pack()
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct
|
||||
{
|
||||
UInt8 OF_;
|
||||
UInt8 SF_;
|
||||
UInt8 ZF_;
|
||||
UInt8 AF_;
|
||||
UInt8 PF_;
|
||||
UInt8 CF_;
|
||||
UInt8 TF_;
|
||||
UInt8 IF_;
|
||||
UInt8 DF_;
|
||||
UInt8 NT_;
|
||||
UInt8 RF_;
|
||||
UInt8 alignment;
|
||||
} EFLStruct ;
|
||||
#pragma pack()
|
||||
|
||||
#pragma pack(4)
|
||||
typedef struct
|
||||
{
|
||||
Int32 BaseRegister;
|
||||
Int32 IndexRegister;
|
||||
Int32 Scale;
|
||||
Int64 Displacement;
|
||||
} MEMORYTYPE ;
|
||||
#pragma pack()
|
||||
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct
|
||||
{
|
||||
Int32 Category; //INSTRUCTION_TYPE
|
||||
Int32 Opcode;
|
||||
char Mnemonic[16];
|
||||
Int32 BranchType; //BRANCH_TYPE
|
||||
EFLStruct Flags;
|
||||
UInt64 AddrValue;
|
||||
Int64 Immediat;
|
||||
UInt32 ImplicitModifiedRegs;
|
||||
} INSTRTYPE;
|
||||
#pragma pack()
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct
|
||||
{
|
||||
char ArgMnemonic[64];
|
||||
Int32 ArgType; //ARGUMENTS_TYPE
|
||||
Int32 ArgSize;
|
||||
Int32 ArgPosition;
|
||||
UInt32 AccessMode;
|
||||
MEMORYTYPE Memory;
|
||||
UInt32 SegmentReg;
|
||||
} ARGTYPE;
|
||||
#pragma pack()
|
||||
|
||||
/* reserved structure used for thread-safety */
|
||||
/* unusable by customer */
|
||||
#pragma pack(1)
|
||||
typedef struct
|
||||
{
|
||||
UIntPtr EIP_;
|
||||
UInt64 EIP_VA;
|
||||
UIntPtr EIP_REAL;
|
||||
Int32 OriginalOperandSize;
|
||||
Int32 OperandSize;
|
||||
Int32 MemDecoration;
|
||||
Int32 AddressSize;
|
||||
Int32 MOD_;
|
||||
Int32 RM_;
|
||||
Int32 INDEX_;
|
||||
Int32 SCALE_;
|
||||
Int32 BASE_;
|
||||
Int32 MMX_;
|
||||
Int32 SSE_;
|
||||
Int32 CR_;
|
||||
Int32 DR_;
|
||||
Int32 SEG_;
|
||||
Int32 REGOPCODE;
|
||||
UInt32 DECALAGE_EIP;
|
||||
Int32 FORMATNUMBER;
|
||||
Int32 SYNTAX_;
|
||||
UInt64 EndOfBlock;
|
||||
Int32 RelativeAddress;
|
||||
UInt32 Architecture;
|
||||
Int32 ImmediatSize;
|
||||
Int32 NB_PREFIX;
|
||||
Int32 PrefRepe;
|
||||
Int32 PrefRepne;
|
||||
UInt32 SEGMENTREGS;
|
||||
UInt32 SEGMENTFS;
|
||||
Int32 third_arg;
|
||||
Int32 TAB_;
|
||||
Int32 ERROR_OPCODE;
|
||||
REX_Struct REX;
|
||||
Int32 OutOfBlock;
|
||||
} InternalDatas;
|
||||
#pragma pack()
|
||||
|
||||
/* ************** main structure ************ */
|
||||
#pragma pack(1)
|
||||
typedef struct _Disasm
|
||||
{
|
||||
UIntPtr EIP;
|
||||
UInt64 VirtualAddr;
|
||||
UInt32 SecurityBlock;
|
||||
char CompleteInstr[INSTRUCT_LENGTH];
|
||||
UInt32 Archi;
|
||||
UInt64 Options;
|
||||
INSTRTYPE Instruction;
|
||||
ARGTYPE Argument1;
|
||||
ARGTYPE Argument2;
|
||||
ARGTYPE Argument3;
|
||||
PREFIXINFO Prefix;
|
||||
InternalDatas Reserved_;
|
||||
} DISASM, *PDISASM, *LPDISASM;
|
||||
#pragma pack()
|
||||
|
||||
#define ESReg 1
|
||||
#define DSReg 2
|
||||
#define FSReg 3
|
||||
#define GSReg 4
|
||||
#define CSReg 5
|
||||
#define SSReg 6
|
||||
|
||||
#define InvalidPrefix 4
|
||||
#define SuperfluousPrefix 2
|
||||
#define NotUsedPrefix 0
|
||||
#define MandatoryPrefix 8
|
||||
#define InUsePrefix 1
|
||||
|
||||
#define LowPosition 0
|
||||
#define HighPosition 1
|
||||
|
||||
enum INSTRUCTION_TYPE
|
||||
{
|
||||
GENERAL_PURPOSE_INSTRUCTION = 0x10000,
|
||||
FPU_INSTRUCTION = 0x20000,
|
||||
MMX_INSTRUCTION = 0x40000,
|
||||
SSE_INSTRUCTION = 0x80000,
|
||||
SSE2_INSTRUCTION = 0x100000,
|
||||
SSE3_INSTRUCTION = 0x200000,
|
||||
SSSE3_INSTRUCTION = 0x400000,
|
||||
SSE41_INSTRUCTION = 0x800000,
|
||||
SSE42_INSTRUCTION = 0x1000000,
|
||||
SYSTEM_INSTRUCTION = 0x2000000,
|
||||
VM_INSTRUCTION = 0x4000000,
|
||||
UNDOCUMENTED_INSTRUCTION = 0x8000000,
|
||||
AMD_INSTRUCTION = 0x10000000,
|
||||
ILLEGAL_INSTRUCTION = 0x20000000,
|
||||
AES_INSTRUCTION = 0x40000000,
|
||||
CLMUL_INSTRUCTION = (int)0x80000000,
|
||||
|
||||
|
||||
DATA_TRANSFER = 0x1,
|
||||
ARITHMETIC_INSTRUCTION,
|
||||
LOGICAL_INSTRUCTION,
|
||||
SHIFT_ROTATE,
|
||||
BIT_UInt8,
|
||||
CONTROL_TRANSFER,
|
||||
STRING_INSTRUCTION,
|
||||
InOutINSTRUCTION,
|
||||
ENTER_LEAVE_INSTRUCTION,
|
||||
FLAG_CONTROL_INSTRUCTION,
|
||||
SEGMENT_REGISTER,
|
||||
MISCELLANEOUS_INSTRUCTION,
|
||||
COMPARISON_INSTRUCTION,
|
||||
LOGARITHMIC_INSTRUCTION,
|
||||
TRIGONOMETRIC_INSTRUCTION,
|
||||
UNSUPPORTED_INSTRUCTION,
|
||||
LOAD_CONSTANTS,
|
||||
FPUCONTROL,
|
||||
STATE_MANAGEMENT,
|
||||
CONVERSION_INSTRUCTION,
|
||||
SHUFFLE_UNPACK,
|
||||
PACKED_SINGLE_PRECISION,
|
||||
SIMD128bits,
|
||||
SIMD64bits,
|
||||
CACHEABILITY_CONTROL,
|
||||
FP_INTEGER_CONVERSION,
|
||||
SPECIALIZED_128bits,
|
||||
SIMD_FP_PACKED,
|
||||
SIMD_FP_HORIZONTAL ,
|
||||
AGENT_SYNCHRONISATION,
|
||||
PACKED_ALIGN_RIGHT ,
|
||||
PACKED_SIGN,
|
||||
PACKED_BLENDING_INSTRUCTION,
|
||||
PACKED_TEST,
|
||||
PACKED_MINMAX,
|
||||
HORIZONTAL_SEARCH,
|
||||
PACKED_EQUALITY,
|
||||
STREAMING_LOAD,
|
||||
INSERTION_EXTRACTION,
|
||||
DOT_PRODUCT,
|
||||
SAD_INSTRUCTION,
|
||||
ACCELERATOR_INSTRUCTION, /* crc32, popcnt (sse4.2) */
|
||||
ROUND_INSTRUCTION
|
||||
};
|
||||
|
||||
enum EFLAGS_STATES
|
||||
{
|
||||
TE_ = 1,
|
||||
MO_ = 2,
|
||||
RE_ = 4,
|
||||
SE_ = 8,
|
||||
UN_ = 0x10,
|
||||
PR_ = 0x20
|
||||
};
|
||||
|
||||
enum BRANCH_TYPE
|
||||
{
|
||||
//JO vs JNO
|
||||
JO = 1,
|
||||
JNO = -1,
|
||||
//JC=JB=JNAE vs JNC=JNB=JAE
|
||||
JC = 2,
|
||||
JB = 2,
|
||||
JNAE = 2,
|
||||
JNC = -2,
|
||||
JNB = -2,
|
||||
JAE = -2,
|
||||
//JE=JZ vs JNE=JNZ
|
||||
JE = 3,
|
||||
JZ = 3,
|
||||
JNE = -3,
|
||||
JNZ = -3,
|
||||
//JA=JNBE vs JNA=JBE
|
||||
JA = 4,
|
||||
JNBE = 4,
|
||||
JNA = -4,
|
||||
JBE = -4,
|
||||
//JS vs JNS
|
||||
JS = 5,
|
||||
JNS = -5,
|
||||
//JP=JPE vs JNP=JPO
|
||||
JP = 6,
|
||||
JPE = 6,
|
||||
JNP = -6,
|
||||
JPO = -6,
|
||||
//JL=JNGE vs JNL=JGE
|
||||
JL = 7,
|
||||
JNGE = 7,
|
||||
JNL = -7,
|
||||
JGE = -7,
|
||||
//JG=JNLE vs JNG=JLE
|
||||
JG = 8,
|
||||
JNLE = 8,
|
||||
JNG = -8,
|
||||
JLE = -8,
|
||||
//others
|
||||
JECXZ = 9,
|
||||
JmpType = 10,
|
||||
CallType = 11,
|
||||
RetType = 12,
|
||||
};
|
||||
|
||||
enum ARGUMENTS_TYPE
|
||||
{
|
||||
NO_ARGUMENT = 0x10000000,
|
||||
REGISTER_TYPE = 0x20000000,
|
||||
MEMORY_TYPE = 0x40000000,
|
||||
CONSTANT_TYPE = (int)0x80000000,
|
||||
|
||||
MMX_REG = 0x10000,
|
||||
GENERAL_REG = 0x20000,
|
||||
FPU_REG = 0x40000,
|
||||
SSE_REG = 0x80000,
|
||||
CR_REG = 0x100000,
|
||||
DR_REG = 0x200000,
|
||||
SPECIAL_REG = 0x400000,
|
||||
MEMORY_MANAGEMENT_REG = 0x800000,
|
||||
SEGMENT_REG = 0x1000000,
|
||||
|
||||
RELATIVE_ = 0x4000000,
|
||||
ABSOLUTE_ = 0x8000000,
|
||||
|
||||
READ = 0x1,
|
||||
WRITE = 0x2,
|
||||
|
||||
REG0 = 0x1,
|
||||
REG1 = 0x2,
|
||||
REG2 = 0x4,
|
||||
REG3 = 0x8,
|
||||
REG4 = 0x10,
|
||||
REG5 = 0x20,
|
||||
REG6 = 0x40,
|
||||
REG7 = 0x80,
|
||||
REG8 = 0x100,
|
||||
REG9 = 0x200,
|
||||
REG10 = 0x400,
|
||||
REG11 = 0x800,
|
||||
REG12 = 0x1000,
|
||||
REG13 = 0x2000,
|
||||
REG14 = 0x4000,
|
||||
REG15 = 0x8000
|
||||
};
|
||||
|
||||
enum SPECIAL_INFO
|
||||
{
|
||||
UNKNOWN_OPCODE = -1,
|
||||
OUT_OF_BLOCK = 0,
|
||||
|
||||
/* === mask = 0xff */
|
||||
NoTabulation = 0x00000000,
|
||||
Tabulation = 0x00000001,
|
||||
|
||||
/* === mask = 0xff00 */
|
||||
MasmSyntax = 0x00000000,
|
||||
GoAsmSyntax = 0x00000100,
|
||||
NasmSyntax = 0x00000200,
|
||||
ATSyntax = 0x00000400,
|
||||
|
||||
/* === mask = 0xff0000 */
|
||||
PrefixedNumeral = 0x00010000,
|
||||
SuffixedNumeral = 0x00020000,
|
||||
NoformatNumeral = 0x00030000,
|
||||
CleanNumeral = 0x00000000,
|
||||
|
||||
/* === mask = 0xff000000 */
|
||||
ShowSegmentRegs = 0x01000000
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
|
||||
BEA_API int __bea_callspec__ Disasm(LPDISASM pDisAsm);
|
||||
BEA_API const__ char* __bea_callspec__ BeaEngineVersion(void);
|
||||
BEA_API const__ char* __bea_callspec__ BeaEngineRevision(void);
|
||||
#if defined(__cplusplus) && defined(__BORLANDC__)
|
||||
};
|
||||
using namespace BeaEngine;
|
||||
#endif
|
||||
#endif
|
Binary file not shown.
Binary file not shown.
|
@ -1,272 +0,0 @@
|
|||
/**
|
||||
* @file basic_types.h
|
||||
* @author <igor.gutnik@gmail.com>
|
||||
* @date Thu Dec 24 19:31:22 2009
|
||||
*
|
||||
* @brief Definitions of fixed-size integer types for various platforms
|
||||
*
|
||||
* This file is part of BeaEngine.
|
||||
*
|
||||
* BeaEngine is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* BeaEngine 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with BeaEngine. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifndef __BEA_BASIC_TYPES_HPP__
|
||||
#define __BEA_BASIC_TYPES_HPP__
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#if defined(__GNUC__) || defined (__INTEL_COMPILER) || defined(__LCC__) || defined(__POCC__)
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && !defined(__BORLANDC__)
|
||||
/*
|
||||
* Windows/Visual C++
|
||||
*/
|
||||
typedef signed char Int8;
|
||||
typedef unsigned char UInt8;
|
||||
typedef signed short Int16;
|
||||
typedef unsigned short UInt16;
|
||||
typedef signed int Int32;
|
||||
typedef unsigned int UInt32;
|
||||
typedef signed __int64 Int64;
|
||||
typedef unsigned __int64 UInt64;
|
||||
#if defined(_WIN64)
|
||||
#define BEA_PTR_IS_64_BIT 1
|
||||
typedef signed __int64 IntPtr;
|
||||
typedef unsigned __int64 UIntPtr;
|
||||
#else
|
||||
typedef signed long IntPtr;
|
||||
typedef size_t UIntPtr;
|
||||
#endif
|
||||
#define BEA_HAVE_INT64 1
|
||||
#elif defined(__POCC__)
|
||||
/*
|
||||
* PellesC
|
||||
*/
|
||||
typedef signed char Int8;
|
||||
typedef unsigned char UInt8;
|
||||
typedef signed short Int16;
|
||||
typedef unsigned short UInt16;
|
||||
typedef signed int Int32;
|
||||
typedef unsigned int UInt32;
|
||||
typedef signed long long Int64;
|
||||
typedef unsigned long long UInt64;
|
||||
#if defined(_WIN64)
|
||||
#define BEA_PTR_IS_64_BIT 1
|
||||
typedef signed long long IntPtr;
|
||||
typedef unsigned long long UIntPtr;
|
||||
#else
|
||||
typedef signed long IntPtr;
|
||||
typedef size_t UIntPtr;
|
||||
#endif
|
||||
#define BEA_HAVE_INT64 1
|
||||
#elif defined(__GNUC__) || defined(__LCC__)
|
||||
/*
|
||||
* Unix/GCC
|
||||
*/
|
||||
typedef signed char Int8;
|
||||
typedef unsigned char UInt8;
|
||||
typedef signed short Int16;
|
||||
typedef unsigned short UInt16;
|
||||
typedef signed int Int32;
|
||||
typedef unsigned int UInt32;
|
||||
typedef intptr_t IntPtr;
|
||||
typedef uintptr_t UIntPtr;
|
||||
#if defined(__LP64__)
|
||||
#define BEA_PTR_IS_64_BIT 1
|
||||
#define BEA_LONG_IS_64_BIT 1
|
||||
typedef signed long Int64;
|
||||
typedef unsigned long UInt64;
|
||||
#else
|
||||
#if defined (__INTEL_COMPILER) || defined (__ICC) || defined (_ICC)
|
||||
typedef __int64 Int64;
|
||||
typedef unsigned __int64 UInt64;
|
||||
#else
|
||||
typedef signed long long Int64;
|
||||
typedef unsigned long long UInt64;
|
||||
#endif
|
||||
#endif
|
||||
#define BEA_HAVE_INT64 1
|
||||
#elif defined(__DECCXX)
|
||||
/*
|
||||
* Compaq C++
|
||||
*/
|
||||
typedef signed char Int8;
|
||||
typedef unsigned char UInt8;
|
||||
typedef signed short Int16;
|
||||
typedef unsigned short UInt16;
|
||||
typedef signed int Int32;
|
||||
typedef unsigned int UInt32;
|
||||
typedef signed __int64 Int64;
|
||||
typedef unsigned __int64 UInt64;
|
||||
#if defined(__VMS)
|
||||
#if defined(__32BITS)
|
||||
typedef signed long IntPtr;
|
||||
typedef unsigned long UIntPtr;
|
||||
#else
|
||||
typedef Int64 IntPtr;
|
||||
typedef UInt64 UIntPtr;
|
||||
#define BEA_PTR_IS_64_BIT 1
|
||||
#endif
|
||||
#else
|
||||
typedef signed long IntPtr;
|
||||
typedef unsigned long UIntPtr;
|
||||
#define BEA_PTR_IS_64_BIT 1
|
||||
#define BEA_LONG_IS_64_BIT 1
|
||||
#endif
|
||||
#define BEA_HAVE_INT64 1
|
||||
#elif defined(__HP_aCC)
|
||||
/*
|
||||
* HP Ansi C++
|
||||
*/
|
||||
typedef signed char Int8;
|
||||
typedef unsigned char UInt8;
|
||||
typedef signed short Int16;
|
||||
typedef unsigned short UInt16;
|
||||
typedef signed int Int32;
|
||||
typedef unsigned int UInt32;
|
||||
typedef signed long IntPtr;
|
||||
typedef unsigned long UIntPtr;
|
||||
#if defined(__LP64__)
|
||||
#define BEA_PTR_IS_64_BIT 1
|
||||
#define BEA_LONG_IS_64_BIT 1
|
||||
typedef signed long Int64;
|
||||
typedef unsigned long UInt64;
|
||||
#else
|
||||
typedef signed long long Int64;
|
||||
typedef unsigned long long UInt64;
|
||||
#endif
|
||||
#define BEA_HAVE_INT64 1
|
||||
#elif defined(__SUNPRO_CC) || defined(__SUNPRO_C)
|
||||
/*
|
||||
* SUN Forte C++
|
||||
*/
|
||||
typedef signed char Int8;
|
||||
typedef unsigned char UInt8;
|
||||
typedef signed short Int16;
|
||||
typedef unsigned short UInt16;
|
||||
typedef signed int Int32;
|
||||
typedef unsigned int UInt32;
|
||||
typedef signed long IntPtr;
|
||||
typedef unsigned long UIntPtr;
|
||||
#if defined(__sparcv9)
|
||||
#define BEA_PTR_IS_64_BIT 1
|
||||
#define BEA_LONG_IS_64_BIT 1
|
||||
typedef signed long Int64;
|
||||
typedef unsigned long UInt64;
|
||||
#else
|
||||
typedef signed long long Int64;
|
||||
typedef unsigned long long UInt64;
|
||||
#endif
|
||||
#define BEA_HAVE_INT64 1
|
||||
#elif defined(__IBMCPP__)
|
||||
/*
|
||||
* IBM XL C++
|
||||
*/
|
||||
typedef signed char Int8;
|
||||
typedef unsigned char UInt8;
|
||||
typedef signed short Int16;
|
||||
typedef unsigned short UInt16;
|
||||
typedef signed int Int32;
|
||||
typedef unsigned int UInt32;
|
||||
typedef signed long IntPtr;
|
||||
typedef unsigned long UIntPtr;
|
||||
#if defined(__64BIT__)
|
||||
#define BEA_PTR_IS_64_BIT 1
|
||||
#define BEA_LONG_IS_64_BIT 1
|
||||
typedef signed long Int64;
|
||||
typedef unsigned long UInt64;
|
||||
#else
|
||||
typedef signed long long Int64;
|
||||
typedef unsigned long long UInt64;
|
||||
#endif
|
||||
#define BEA_HAVE_INT64 1
|
||||
#elif defined(__BORLANDC__)
|
||||
/*
|
||||
* Borland C/C++
|
||||
*/
|
||||
typedef signed char Int8;
|
||||
typedef unsigned char UInt8;
|
||||
typedef signed short Int16;
|
||||
typedef unsigned short UInt16;
|
||||
typedef signed int Int32;
|
||||
typedef unsigned int UInt32;
|
||||
typedef unsigned __int64 Int64;
|
||||
typedef signed __int64 UInt64;
|
||||
typedef signed long IntPtr;
|
||||
typedef unsigned long UIntPtr;
|
||||
#define BEA_HAVE_INT64 1
|
||||
#elif defined(__WATCOMC__)
|
||||
/*
|
||||
* Watcom C/C++
|
||||
*/
|
||||
typedef signed char Int8;
|
||||
typedef unsigned char UInt8;
|
||||
typedef signed short Int16;
|
||||
typedef unsigned short UInt16;
|
||||
typedef signed int Int32;
|
||||
typedef unsigned int UInt32;
|
||||
typedef unsigned __int64 Int64;
|
||||
typedef signed __int64 UInt64;
|
||||
#define BEA_HAVE_INT64 1
|
||||
typedef size_t UIntPtr;
|
||||
#elif defined(__sgi)
|
||||
/*
|
||||
* MIPSpro C++
|
||||
*/
|
||||
typedef signed char Int8;
|
||||
typedef unsigned char UInt8;
|
||||
typedef signed short Int16;
|
||||
typedef unsigned short UInt16;
|
||||
typedef signed int Int32;
|
||||
typedef unsigned int UInt32;
|
||||
typedef signed long IntPtr;
|
||||
typedef unsigned long UIntPtr;
|
||||
#if _MIPS_SZLONG == 64
|
||||
#define BEA_PTR_IS_64_BIT 1
|
||||
#define BEA_LONG_IS_64_BIT 1
|
||||
typedef signed long Int64;
|
||||
typedef unsigned long UInt64;
|
||||
#else
|
||||
typedef signed long long Int64;
|
||||
typedef unsigned long long UInt64;
|
||||
#endif
|
||||
#define BEA_HAVE_INT64 1
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) || defined(__BORLANDC__)
|
||||
#define W64LIT(x) x##ui64
|
||||
#else
|
||||
#define W64LIT(x) x##ULL
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef C_STATIC_ASSERT
|
||||
#define C_STATIC_ASSERT(tag_name, x) \
|
||||
typedef int cache_static_assert_ ## tag_name[(x) * 2-1]
|
||||
#endif
|
||||
|
||||
C_STATIC_ASSERT(sizeof_Int8 , (sizeof(Int8) == 1));
|
||||
C_STATIC_ASSERT(sizeof_UInt8, (sizeof(UInt8) == 1));
|
||||
|
||||
C_STATIC_ASSERT(sizeof_Int16 , (sizeof(Int16) == 2));
|
||||
C_STATIC_ASSERT(sizeof_UInt16, (sizeof(UInt16) == 2));
|
||||
|
||||
C_STATIC_ASSERT(sizeof_Int32 , (sizeof(Int32) == 4));
|
||||
C_STATIC_ASSERT(sizeof_UInt32, (sizeof(UInt32) == 4));
|
||||
|
||||
C_STATIC_ASSERT(sizeof_Int64 , (sizeof(Int64) == 8));
|
||||
C_STATIC_ASSERT(sizeof_UInt64, (sizeof(UInt64) == 8));
|
||||
|
||||
#endif
|
|
@ -1,173 +0,0 @@
|
|||
/**
|
||||
* @file export.h
|
||||
* @author igor.gutnik@gmail.com
|
||||
* @date Mon Sep 22 09:28:54 2008
|
||||
*
|
||||
* @brief This file sets things up for C dynamic library function definitions and
|
||||
* static inlined functions
|
||||
*
|
||||
* This file is part of BeaEngine.
|
||||
*
|
||||
* BeaEngine is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* BeaEngine 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with BeaEngine. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifndef __BEA_EXPORT_H__
|
||||
#define __BEA_EXPORT_H__
|
||||
|
||||
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define CPP_VISIBLE_BEGIN extern "C" {
|
||||
#define CPP_VISIBLE_END }
|
||||
#else
|
||||
#define CPP_VISIBLE_BEGIN
|
||||
#define CPP_VISIBLE_END
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning( disable: 4251 )
|
||||
#endif
|
||||
|
||||
/* Some compilers use a special export keyword */
|
||||
#ifndef bea__api_export__
|
||||
# if defined(__BEOS__)
|
||||
# if defined(__GNUC__)
|
||||
# define bea__api_export__ __declspec(dllexport)
|
||||
# else
|
||||
# define bea__api_export__ __declspec(export)
|
||||
# endif
|
||||
# elif defined(_WIN32) || defined(_WIN64)
|
||||
# ifdef __BORLANDC__
|
||||
# define bea__api_export__ __declspec(dllexport)
|
||||
# define bea__api_import__ __declspec(dllimport)
|
||||
# elif defined(__WATCOMC__)
|
||||
# define bea__api_export__ __declspec(dllexport)
|
||||
# define bea__api_import__
|
||||
# else
|
||||
# define bea__api_export__ __declspec(dllexport)
|
||||
# define bea__api_import__ __declspec(dllimport)
|
||||
# endif
|
||||
# elif defined(__OS2__)
|
||||
# ifdef __WATCOMC__
|
||||
# define bea__api_export__ __declspec(dllexport)
|
||||
# define bea__api_import__
|
||||
# else
|
||||
# define bea__api_export__
|
||||
# define bea__api_import__
|
||||
# endif
|
||||
# else
|
||||
# if defined(_WIN32) && defined(__GNUC__) && __GNUC__ >= 4
|
||||
# define bea__api_export__ __attribubea__ ((visibility("default")))
|
||||
# define bea__api_import__ __attribubea__ ((visibility("default")))
|
||||
# else
|
||||
# define bea__api_export__
|
||||
# define bea__api_import__
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Use C calling convention by default*/
|
||||
|
||||
#ifndef __bea_callspec__
|
||||
#if defined(BEA_USE_STDCALL)
|
||||
#if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) || defined(_WIN64)
|
||||
#if defined(__BORLANDC__) || defined(__WATCOMC__) || defined(_MSC_VER) || defined(__MINGW32__) || defined(__POCC__)
|
||||
#define __bea_callspec__ __stdcall
|
||||
#else
|
||||
#define __bea_callspec__
|
||||
#endif
|
||||
#else
|
||||
#ifdef __OS2__
|
||||
#define __bea_callspec__ _System
|
||||
#else
|
||||
#define __bea_callspec__
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
#define __bea_callspec__
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __SYMBIAN32__
|
||||
# ifndef EKA2
|
||||
# undef bea__api_export__
|
||||
# undef bea__api_import__
|
||||
# define bea__api_export__
|
||||
# define bea__api_import__
|
||||
# elif !defined(__WINS__)
|
||||
# undef bea__api_export__
|
||||
# undef bea__api_import__
|
||||
# define bea__api_export__ __declspec(dllexport)
|
||||
# define bea__api_import__ __declspec(dllexport)
|
||||
# endif /* !EKA2 */
|
||||
#endif /* __SYMBIAN32__ */
|
||||
|
||||
|
||||
#if defined(__GNUC__) && (__GNUC__ > 2)
|
||||
#define BEA_EXPECT_CONDITIONAL(c) (__builtin_expect((c), 1))
|
||||
#define BEA_UNEXPECT_CONDITIONAL(c) (__builtin_expect((c), 0))
|
||||
#else
|
||||
#define BEA_EXPECT_CONDITIONAL(c) (c)
|
||||
#define BEA_UNEXPECT_CONDITIONAL(c) (c)
|
||||
#endif
|
||||
|
||||
|
||||
/* Set up compiler-specific options for inlining functions */
|
||||
#ifndef BEA_HAS_INLINE
|
||||
#if defined(__GNUC__) || defined(__POCC__) || defined(__WATCOMC__) || defined(__SUNPRO_C)
|
||||
#define BEA_HAS_INLINE
|
||||
#else
|
||||
/* Add any special compiler-specific cases here */
|
||||
#if defined(_MSC_VER) || defined(__BORLANDC__) || \
|
||||
defined(__DMC__) || defined(__SC__) || \
|
||||
defined(__WATCOMC__) || defined(__LCC__) || \
|
||||
defined(__DECC) || defined(__EABI__)
|
||||
#ifndef __inline__
|
||||
#define __inline__ __inline
|
||||
#endif
|
||||
#define BEA_HAS_INLINE
|
||||
#else
|
||||
#if !defined(__MRC__) && !defined(_SGI_SOURCE)
|
||||
#ifndef __inline__
|
||||
#define __inline__ inline
|
||||
#endif
|
||||
#define BEA_HAS_INLINE
|
||||
#endif /* Not a funky compiler */
|
||||
#endif /* Visual C++ */
|
||||
#endif /* GNU C */
|
||||
#endif /* CACHE_HAS_INLINE */
|
||||
|
||||
/* If inlining isn't supported, remove "__inline__", turning static
|
||||
inlined functions into static functions (resulting in code bloat
|
||||
in all files which include the offending header files)
|
||||
*/
|
||||
#ifndef BEA_HAS_INLINE
|
||||
#define __inline__
|
||||
#endif
|
||||
|
||||
/* fix a bug with gcc under windows */
|
||||
|
||||
#if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) || defined(_WIN64)
|
||||
#if defined(__MINGW32__)
|
||||
#define const__
|
||||
#else
|
||||
#define const__ const
|
||||
#endif
|
||||
#else
|
||||
#define const__ const
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif
|
Binary file not shown.
Binary file not shown.
|
@ -1,41 +0,0 @@
|
|||
#ifndef __BEAENGINE_MACROS_H__
|
||||
#define __BEAENGINE_MACROS_H__
|
||||
/*
|
||||
============================================================================
|
||||
Compiler Silencing macros
|
||||
|
||||
Some compilers complain about parameters that are not used. This macro
|
||||
should keep them quiet.
|
||||
============================================================================
|
||||
*/
|
||||
|
||||
# if defined (__GNUC__) && ((__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)))
|
||||
# define BEA_UNUSED_ARG(a) (void) (a)
|
||||
#elif defined (ghs) || defined (__GNUC__) || defined (__hpux) || defined (__sgi) || defined (__DECCXX) || defined (__rational__) || defined (__USLC__) || defined (BEA__RM544) || defined (__DCC__) || defined (__PGI) || defined (__TANDEM) || defined(__BORLANDC__)
|
||||
/*
|
||||
Some compilers complain about "statement with no effect" with (a).
|
||||
This eliminates the warnings, and no code is generated for the null
|
||||
conditional statement. Note, that may only be true if -O is enabled,
|
||||
such as with GreenHills (ghs) 1.8.8.
|
||||
*/
|
||||
|
||||
# define BEA_UNUSED_ARG(a) do {/* null */} while (&a == 0)
|
||||
#elif defined (__DMC__)
|
||||
#if defined(__cplusplus)
|
||||
#define BEA_UNUSED_ID(identifier)
|
||||
template <class T>
|
||||
inline void BEA_UNUSED_ARG(const T & BEA_UNUSED_ID(t)) { }
|
||||
#else
|
||||
#define BEA_UNUSED_ARG(a)
|
||||
#endif
|
||||
#else /* ghs || __GNUC__ || ..... */
|
||||
# define BEA_UNUSED_ARG(a) (a)
|
||||
#endif /* ghs || __GNUC__ || ..... */
|
||||
|
||||
#if defined (_MSC_VER) || defined(__sgi) || defined (ghs) || defined (__DECCXX) || defined(__BORLANDC__) || defined (BEA_RM544) || defined (__USLC__) || defined (__DCC__) || defined (__PGI) || defined (__TANDEM) || (defined (__HP_aCC) && (__HP_aCC >= 60500))
|
||||
# define BEA_NOTREACHED(a)
|
||||
#else /* __sgi || ghs || ..... */
|
||||
# define BEA_NOTREACHED(a) a
|
||||
#endif /* __sgi || ghs || ..... */
|
||||
|
||||
#endif /* __BEAENGINE_MACROS_H__ */
|
|
@ -794,23 +794,10 @@ extern "C" DLL_EXPORT uint _dbg_sendmessage(DBGMSG type, void* param1, void* par
|
|||
{
|
||||
if(!param1 or !param2)
|
||||
return 0;
|
||||
unsigned char data[16];
|
||||
if(!MemRead(param1, data, sizeof(data), 0))
|
||||
return 0;
|
||||
DISASM disasm;
|
||||
memset(&disasm, 0, sizeof(disasm));
|
||||
#ifdef _WIN64
|
||||
disasm.Archi = 64;
|
||||
#endif // _WIN64
|
||||
disasm.EIP = (UIntPtr)data;
|
||||
disasm.VirtualAddr = (UInt64)param1;
|
||||
int len = Disasm(&disasm);
|
||||
if(len == UNKNOWN_OPCODE)
|
||||
len = 1;
|
||||
uint i = 0;
|
||||
BASIC_INSTRUCTION_INFO* basicinfo = (BASIC_INSTRUCTION_INFO*)param2;
|
||||
fillbasicinfo(&disasm, basicinfo);
|
||||
basicinfo->size = len;
|
||||
if(!disasmfast((uint)param1, basicinfo))
|
||||
basicinfo->size = 1;
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -79,7 +79,10 @@ String Capstone::OperandText(int opindex)
|
|||
|
||||
case X86_OP_IMM:
|
||||
{
|
||||
sprintf_s(temp, "%"fext"X", op.imm);
|
||||
if(InGroup(CS_GRP_JUMP) || InGroup(CS_GRP_CALL))
|
||||
sprintf_s(temp, "%"fext"X", op.imm + mInstr->size);
|
||||
else
|
||||
sprintf_s(temp, "%"fext"X", op.imm);
|
||||
result = temp;
|
||||
}
|
||||
break;
|
||||
|
@ -160,4 +163,12 @@ bool Capstone::IsFilling()
|
|||
x86_insn Capstone::GetId()
|
||||
{
|
||||
return (x86_insn)mInstr->id;
|
||||
}
|
||||
|
||||
String Capstone::InstructionText()
|
||||
{
|
||||
String result = mInstr->mnemonic;
|
||||
result += " ";
|
||||
result += mInstr->op_str;
|
||||
return result;
|
||||
}
|
|
@ -23,6 +23,7 @@ public:
|
|||
const cs_x86 & x86();
|
||||
bool IsFilling();
|
||||
x86_insn GetId();
|
||||
String InstructionText();
|
||||
|
||||
private:
|
||||
csh mHandle;
|
||||
|
|
|
@ -24,79 +24,64 @@ static MEMORY_SIZE argsize2memsize(int argsize)
|
|||
return size_byte;
|
||||
}
|
||||
|
||||
void fillbasicinfo(DISASM* disasm, BASIC_INSTRUCTION_INFO* basicinfo)
|
||||
void fillbasicinfo(Capstone* cp, BASIC_INSTRUCTION_INFO* basicinfo)
|
||||
{
|
||||
//zero basicinfo
|
||||
memset(basicinfo, 0, sizeof(BASIC_INSTRUCTION_INFO));
|
||||
//copy instruction text
|
||||
strcpy_s(basicinfo->instruction, disasm->CompleteInstr);
|
||||
//find immidiat
|
||||
if(disasm->Instruction.BranchType == 0) //no branch
|
||||
{
|
||||
if((disasm->Argument1.ArgType & CONSTANT_TYPE) == CONSTANT_TYPE)
|
||||
{
|
||||
basicinfo->type |= TYPE_VALUE;
|
||||
basicinfo->value.value = (ULONG_PTR)disasm->Instruction.Immediat;
|
||||
basicinfo->value.size = argsize2memsize(disasm->Argument1.ArgSize);
|
||||
}
|
||||
else if((disasm->Argument2.ArgType & CONSTANT_TYPE) == CONSTANT_TYPE)
|
||||
{
|
||||
basicinfo->type |= TYPE_VALUE;
|
||||
basicinfo->value.value = (ULONG_PTR)disasm->Instruction.Immediat;
|
||||
basicinfo->value.size = argsize2memsize(disasm->Argument2.ArgSize);
|
||||
}
|
||||
}
|
||||
else //branch
|
||||
strcpy_s(basicinfo->instruction, cp->InstructionText().c_str());
|
||||
//instruction size
|
||||
basicinfo->size = cp->Size();
|
||||
//branch/call info
|
||||
if(cp->InGroup(CS_GRP_CALL))
|
||||
{
|
||||
basicinfo->branch = true;
|
||||
if(disasm->Instruction.BranchType == CallType)
|
||||
basicinfo->call = true;
|
||||
if(disasm->Instruction.BranchType == RetType)
|
||||
basicinfo->branch = false;
|
||||
basicinfo->call = true;
|
||||
}
|
||||
//find memory displacement
|
||||
if((disasm->Argument1.ArgType & MEMORY_TYPE) == MEMORY_TYPE)
|
||||
else if(cp->InGroup(CS_GRP_JUMP))
|
||||
{
|
||||
if(disasm->Argument1.Memory.Displacement)
|
||||
basicinfo->branch = true;
|
||||
}
|
||||
//handle operands
|
||||
for(int i = 0; i < cp->x86().op_count; i++)
|
||||
{
|
||||
const cs_x86_op & op = cp->x86().operands[i];
|
||||
switch(op.type)
|
||||
{
|
||||
basicinfo->type |= TYPE_MEMORY;
|
||||
basicinfo->memory.value = (ULONG_PTR)disasm->Argument1.Memory.Displacement;
|
||||
strcpy_s(basicinfo->memory.mnemonic, disasm->Argument1.ArgMnemonic);
|
||||
case CS_OP_IMM:
|
||||
{
|
||||
if(basicinfo->branch)
|
||||
{
|
||||
basicinfo->type |= TYPE_ADDR;
|
||||
basicinfo->addr = (duint)op.imm;
|
||||
basicinfo->value.value = (duint)op.imm + basicinfo->size;
|
||||
}
|
||||
else
|
||||
{
|
||||
basicinfo->type |= TYPE_VALUE;
|
||||
basicinfo->value.size = (VALUE_SIZE)op.size;
|
||||
basicinfo->value.value = (duint)op.imm;
|
||||
}
|
||||
}
|
||||
basicinfo->memory.size = argsize2memsize(disasm->Argument1.ArgSize);
|
||||
}
|
||||
if((disasm->Argument2.ArgType & MEMORY_TYPE) == MEMORY_TYPE)
|
||||
{
|
||||
if(disasm->Argument2.Memory.Displacement)
|
||||
break;
|
||||
|
||||
case CS_OP_MEM:
|
||||
{
|
||||
basicinfo->type |= TYPE_MEMORY;
|
||||
basicinfo->memory.value = (ULONG_PTR)disasm->Argument2.Memory.Displacement;
|
||||
strcpy_s(basicinfo->memory.mnemonic, disasm->Argument2.ArgMnemonic);
|
||||
const x86_op_mem & mem = op.mem;
|
||||
strcpy_s(basicinfo->memory.mnemonic, cp->InstructionText().c_str());
|
||||
basicinfo->memory.size = (MEMORY_SIZE)op.size;
|
||||
if(op.mem.base == X86_REG_RIP) //rip-relative
|
||||
{
|
||||
basicinfo->memory.value = (ULONG_PTR)(cp->GetInstr()->address + op.mem.disp + basicinfo->size);
|
||||
basicinfo->type |= TYPE_MEMORY;
|
||||
}
|
||||
else if(mem.disp)
|
||||
{
|
||||
basicinfo->type |= TYPE_MEMORY;
|
||||
basicinfo->memory.value = (ULONG_PTR)mem.disp;
|
||||
}
|
||||
}
|
||||
basicinfo->memory.size = argsize2memsize(disasm->Argument2.ArgSize);
|
||||
}
|
||||
//find address value
|
||||
if(disasm->Instruction.BranchType && disasm->Instruction.AddrValue)
|
||||
{
|
||||
basicinfo->type |= TYPE_ADDR;
|
||||
basicinfo->addr = (ULONG_PTR)disasm->Instruction.AddrValue;
|
||||
}
|
||||
//rip-relative (non-branch)
|
||||
if(disasm->Instruction.BranchType == 0)
|
||||
{
|
||||
if((disasm->Argument1.ArgType & RELATIVE_) == RELATIVE_)
|
||||
{
|
||||
basicinfo->type |= TYPE_MEMORY;
|
||||
basicinfo->memory.value = (ULONG_PTR)disasm->Instruction.AddrValue;
|
||||
strcpy_s(basicinfo->memory.mnemonic, disasm->Argument1.ArgMnemonic);
|
||||
basicinfo->memory.size = argsize2memsize(disasm->Argument1.ArgSize);
|
||||
}
|
||||
else if((disasm->Argument2.ArgType & RELATIVE_) == RELATIVE_)
|
||||
{
|
||||
basicinfo->type |= TYPE_MEMORY;
|
||||
basicinfo->memory.value = (ULONG_PTR)disasm->Instruction.AddrValue;
|
||||
strcpy_s(basicinfo->memory.mnemonic, disasm->Argument2.ArgMnemonic);
|
||||
basicinfo->memory.size = argsize2memsize(disasm->Argument2.ArgSize);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -105,18 +90,14 @@ bool disasmfast(unsigned char* data, uint addr, BASIC_INSTRUCTION_INFO* basicinf
|
|||
{
|
||||
if(!data or !basicinfo)
|
||||
return false;
|
||||
DISASM disasm;
|
||||
memset(&disasm, 0, sizeof(disasm));
|
||||
#ifdef _WIN64
|
||||
disasm.Archi = 64;
|
||||
#endif // _WIN64
|
||||
disasm.EIP = (UIntPtr)data;
|
||||
disasm.VirtualAddr = (UInt64)addr;
|
||||
int len = Disasm(&disasm);
|
||||
if(len == UNKNOWN_OPCODE)
|
||||
Capstone cp;
|
||||
if(!cp.Disassemble(addr, data, MAX_DISASM_BUFFER))
|
||||
{
|
||||
strcpy_s(basicinfo->instruction, "???");
|
||||
basicinfo->size = 1;
|
||||
return false;
|
||||
fillbasicinfo(&disasm, basicinfo);
|
||||
basicinfo->size = len;
|
||||
}
|
||||
fillbasicinfo(&cp, basicinfo);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
#define _DISASM_FAST_H
|
||||
|
||||
#include "_global.h"
|
||||
#include "BeaEngine\BeaEngine.h"
|
||||
#include "capstone_wrapper.h"
|
||||
|
||||
void fillbasicinfo(DISASM* disasm, BASIC_INSTRUCTION_INFO* basicinfo);
|
||||
void fillbasicinfo(Capstone* disasm, BASIC_INSTRUCTION_INFO* basicinfo);
|
||||
bool disasmfast(uint addr, BASIC_INSTRUCTION_INFO* basicinfo);
|
||||
bool disasmfast(unsigned char* data, uint addr, BASIC_INSTRUCTION_INFO* basicinfo);
|
||||
|
||||
|
|
|
@ -812,7 +812,7 @@ struct VALUERANGE
|
|||
uint end;
|
||||
};
|
||||
|
||||
static bool cbRefFind(DISASM* disasm, BASIC_INSTRUCTION_INFO* basicinfo, REFINFO* refinfo)
|
||||
static bool cbRefFind(Capstone* disasm, BASIC_INSTRUCTION_INFO* basicinfo, REFINFO* refinfo)
|
||||
{
|
||||
if(!disasm || !basicinfo) //initialize
|
||||
{
|
||||
|
@ -847,14 +847,14 @@ static bool cbRefFind(DISASM* disasm, BASIC_INSTRUCTION_INFO* basicinfo, REFINFO
|
|||
if(found)
|
||||
{
|
||||
char addrText[20] = "";
|
||||
sprintf(addrText, "%p", disasm->VirtualAddr);
|
||||
sprintf(addrText, "%p", disasm->Address());
|
||||
GuiReferenceSetRowCount(refinfo->refcount + 1);
|
||||
GuiReferenceSetCellContent(refinfo->refcount, 0, addrText);
|
||||
char disassembly[GUI_MAX_DISASSEMBLY_SIZE] = "";
|
||||
if(GuiGetDisassembly((duint)disasm->VirtualAddr, disassembly))
|
||||
if(GuiGetDisassembly((duint)disasm->Address(), disassembly))
|
||||
GuiReferenceSetCellContent(refinfo->refcount, 1, disassembly);
|
||||
else
|
||||
GuiReferenceSetCellContent(refinfo->refcount, 1, disasm->CompleteInstr);
|
||||
GuiReferenceSetCellContent(refinfo->refcount, 1, disasm->InstructionText().c_str());
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
@ -905,7 +905,7 @@ CMDRESULT cbInstrRefFindRange(int argc, char* argv[])
|
|||
return STATUS_CONTINUE;
|
||||
}
|
||||
|
||||
bool cbRefStr(DISASM* disasm, BASIC_INSTRUCTION_INFO* basicinfo, REFINFO* refinfo)
|
||||
bool cbRefStr(Capstone* disasm, BASIC_INSTRUCTION_INFO* basicinfo, REFINFO* refinfo)
|
||||
{
|
||||
if(!disasm || !basicinfo) //initialize
|
||||
{
|
||||
|
@ -935,14 +935,14 @@ bool cbRefStr(DISASM* disasm, BASIC_INSTRUCTION_INFO* basicinfo, REFINFO* refinf
|
|||
if(found)
|
||||
{
|
||||
char addrText[20] = "";
|
||||
sprintf(addrText, "%p", disasm->VirtualAddr);
|
||||
sprintf(addrText, "%p", disasm->Address());
|
||||
GuiReferenceSetRowCount(refinfo->refcount + 1);
|
||||
GuiReferenceSetCellContent(refinfo->refcount, 0, addrText);
|
||||
char disassembly[4096] = "";
|
||||
if(GuiGetDisassembly((duint)disasm->VirtualAddr, disassembly))
|
||||
if(GuiGetDisassembly((duint)disasm->Address(), disassembly))
|
||||
GuiReferenceSetCellContent(refinfo->refcount, 1, disassembly);
|
||||
else
|
||||
GuiReferenceSetCellContent(refinfo->refcount, 1, disasm->CompleteInstr);
|
||||
GuiReferenceSetCellContent(refinfo->refcount, 1, disasm->InstructionText().c_str());
|
||||
char dispString[1024] = "";
|
||||
if(strtype == str_ascii)
|
||||
sprintf(dispString, "\"%s\"", string);
|
||||
|
@ -1233,7 +1233,7 @@ CMDRESULT cbInstrFindAll(int argc, char* argv[])
|
|||
return STATUS_CONTINUE;
|
||||
}
|
||||
|
||||
static bool cbModCallFind(DISASM* disasm, BASIC_INSTRUCTION_INFO* basicinfo, REFINFO* refinfo)
|
||||
static bool cbModCallFind(Capstone* disasm, BASIC_INSTRUCTION_INFO* basicinfo, REFINFO* refinfo)
|
||||
{
|
||||
if(!disasm || !basicinfo) //initialize
|
||||
{
|
||||
|
@ -1253,14 +1253,14 @@ static bool cbModCallFind(DISASM* disasm, BASIC_INSTRUCTION_INFO* basicinfo, REF
|
|||
if(found)
|
||||
{
|
||||
char addrText[20] = "";
|
||||
sprintf(addrText, "%p", disasm->VirtualAddr);
|
||||
sprintf(addrText, "%p", disasm->Address());
|
||||
GuiReferenceSetRowCount(refinfo->refcount + 1);
|
||||
GuiReferenceSetCellContent(refinfo->refcount, 0, addrText);
|
||||
char disassembly[GUI_MAX_DISASSEMBLY_SIZE] = "";
|
||||
if(GuiGetDisassembly((duint)disasm->VirtualAddr, disassembly))
|
||||
if(GuiGetDisassembly((duint)disasm->Address(), disassembly))
|
||||
GuiReferenceSetCellContent(refinfo->refcount, 1, disassembly);
|
||||
else
|
||||
GuiReferenceSetCellContent(refinfo->refcount, 1, disasm->CompleteInstr);
|
||||
GuiReferenceSetCellContent(refinfo->refcount, 1, disasm->InstructionText().c_str());
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
@ -1488,7 +1488,7 @@ CMDRESULT cbInstrSleep(int argc, char* argv[])
|
|||
return STATUS_CONTINUE;
|
||||
}
|
||||
|
||||
static bool cbFindAsm(DISASM* disasm, BASIC_INSTRUCTION_INFO* basicinfo, REFINFO* refinfo)
|
||||
static bool cbFindAsm(Capstone* disasm, BASIC_INSTRUCTION_INFO* basicinfo, REFINFO* refinfo)
|
||||
{
|
||||
if(!disasm || !basicinfo) //initialize
|
||||
{
|
||||
|
@ -1503,14 +1503,14 @@ static bool cbFindAsm(DISASM* disasm, BASIC_INSTRUCTION_INFO* basicinfo, REFINFO
|
|||
if(found)
|
||||
{
|
||||
char addrText[20] = "";
|
||||
sprintf(addrText, "%p", disasm->VirtualAddr);
|
||||
sprintf(addrText, "%p", disasm->Address());
|
||||
GuiReferenceSetRowCount(refinfo->refcount + 1);
|
||||
GuiReferenceSetCellContent(refinfo->refcount, 0, addrText);
|
||||
char disassembly[GUI_MAX_DISASSEMBLY_SIZE] = "";
|
||||
if(GuiGetDisassembly((duint)disasm->VirtualAddr, disassembly))
|
||||
if(GuiGetDisassembly((duint)disasm->Address(), disassembly))
|
||||
GuiReferenceSetCellContent(refinfo->refcount, 1, disassembly);
|
||||
else
|
||||
GuiReferenceSetCellContent(refinfo->refcount, 1, disasm->CompleteInstr);
|
||||
GuiReferenceSetCellContent(refinfo->refcount, 1, disasm->InstructionText().c_str());
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
|
|
@ -59,14 +59,8 @@ int RefFind(uint Address, uint Size, CBREF Callback, void* UserData, bool Silent
|
|||
sprintf_s(fullName, "%s (%p)", Name, scanStart);
|
||||
|
||||
// Initialize the disassembler
|
||||
DISASM disasm;
|
||||
memset(&disasm, 0, sizeof(disasm));
|
||||
|
||||
#ifdef _WIN64
|
||||
disasm.Archi = 64;
|
||||
#endif // _WIN64
|
||||
disasm.EIP = (UIntPtr)data;
|
||||
disasm.VirtualAddr = (UInt64)scanStart;
|
||||
Capstone cp;
|
||||
unsigned char* dataptr = data();
|
||||
|
||||
// Allow an "initialization" notice
|
||||
REFINFO refInfo;
|
||||
|
@ -90,16 +84,15 @@ int RefFind(uint Address, uint Size, CBREF Callback, void* UserData, bool Silent
|
|||
}
|
||||
|
||||
// Disassemble the instruction
|
||||
int len = Disasm(&disasm);
|
||||
|
||||
if(len != UNKNOWN_OPCODE)
|
||||
int len;
|
||||
if(cp.Disassemble(scanStart, dataptr, MAX_DISASM_BUFFER))
|
||||
{
|
||||
BASIC_INSTRUCTION_INFO basicinfo;
|
||||
fillbasicinfo(&disasm, &basicinfo);
|
||||
basicinfo.size = len;
|
||||
fillbasicinfo(&cp, &basicinfo);
|
||||
|
||||
if(Callback(&disasm, &basicinfo, &refInfo))
|
||||
if(Callback(&cp, &basicinfo, &refInfo))
|
||||
refInfo.refcount++;
|
||||
len = cp.Size();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -107,8 +100,8 @@ int RefFind(uint Address, uint Size, CBREF Callback, void* UserData, bool Silent
|
|||
len = 1;
|
||||
}
|
||||
|
||||
disasm.EIP += len;
|
||||
disasm.VirtualAddr += len;
|
||||
dataptr += len;
|
||||
scanStart += len;
|
||||
i += len;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,6 @@ struct REFINFO
|
|||
};
|
||||
|
||||
// Reference callback typedef
|
||||
typedef bool (*CBREF)(DISASM* disasm, BASIC_INSTRUCTION_INFO* basicinfo, REFINFO* refinfo);
|
||||
typedef bool (*CBREF)(Capstone* disasm, BASIC_INSTRUCTION_INFO* basicinfo, REFINFO* refinfo);
|
||||
|
||||
int RefFind(uint Address, uint Size, CBREF Callback, void* UserData, bool Silent, const char* Name);
|
|
@ -31,14 +31,6 @@ bool stackcommentget(uint addr, STACK_COMMENT* comment)
|
|||
uint prev = disasmback(disasmData, 0, sizeof(disasmData), data - readStart, 1);
|
||||
uint previousInstr = readStart + prev;
|
||||
|
||||
DISASM disasm;
|
||||
disasm.Options = NoformatNumeral | ShowSegmentRegs;
|
||||
#ifdef _WIN64
|
||||
disasm.Archi = 64;
|
||||
#endif // _WIN64
|
||||
disasm.VirtualAddr = previousInstr;
|
||||
disasm.EIP = (UIntPtr)(disasmData + prev);
|
||||
int len = Disasm(&disasm);
|
||||
BASIC_INSTRUCTION_INFO basicinfo;
|
||||
bool valid = disasmfast(disasmData + prev, previousInstr, &basicinfo);
|
||||
if(valid && basicinfo.call) //call
|
||||
|
|
|
@ -68,10 +68,6 @@
|
|||
<ItemGroup>
|
||||
<ClInclude Include="addrinfo.h" />
|
||||
<ClInclude Include="assemble.h" />
|
||||
<ClInclude Include="BeaEngine\basic_types.h" />
|
||||
<ClInclude Include="BeaEngine\BeaEngine.h" />
|
||||
<ClInclude Include="BeaEngine\export.h" />
|
||||
<ClInclude Include="BeaEngine\macros.h" />
|
||||
<ClInclude Include="bookmark.h" />
|
||||
<ClInclude Include="breakpoint.h" />
|
||||
<ClInclude Include="capstone\arm.h" />
|
||||
|
@ -254,7 +250,7 @@
|
|||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>capstone\capstone_x86.lib;yara\yara_x86.lib;lz4\lz4_x86.lib;jansson\jansson_x86.lib;DeviceNameResolver\DeviceNameResolver_x86.lib;XEDParse\XEDParse_x86.lib;$(SolutionDir)bin\x32\x32bridge.lib;dbghelp\dbghelp_x86.lib;TitanEngine\TitanEngine_x86.lib;BeaEngine\BeaEngine.lib;psapi.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>capstone\capstone_x86.lib;yara\yara_x86.lib;lz4\lz4_x86.lib;jansson\jansson_x86.lib;DeviceNameResolver\DeviceNameResolver_x86.lib;XEDParse\XEDParse_x86.lib;$(SolutionDir)bin\x32\x32bridge.lib;dbghelp\dbghelp_x86.lib;TitanEngine\TitanEngine_x86.lib;psapi.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
|
@ -275,7 +271,7 @@
|
|||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>false</EnableCOMDATFolding>
|
||||
<OptimizeReferences>false</OptimizeReferences>
|
||||
<AdditionalDependencies>capstone\capstone_x86.lib;yara\yara_x86.lib;lz4\lz4_x86.lib;jansson\jansson_x86.lib;DeviceNameResolver\DeviceNameResolver_x86.lib;XEDParse\XEDParse_x86.lib;$(SolutionDir)bin\x32\x32bridge.lib;dbghelp\dbghelp_x86.lib;TitanEngine\TitanEngine_x86.lib;BeaEngine\BeaEngine.lib;psapi.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>capstone\capstone_x86.lib;yara\yara_x86.lib;lz4\lz4_x86.lib;jansson\jansson_x86.lib;DeviceNameResolver\DeviceNameResolver_x86.lib;XEDParse\XEDParse_x86.lib;$(SolutionDir)bin\x32\x32bridge.lib;dbghelp\dbghelp_x86.lib;TitanEngine\TitanEngine_x86.lib;psapi.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
|
@ -302,7 +298,7 @@
|
|||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>capstone\capstone_x64.lib;yara\yara_x64.lib;lz4\lz4_x64.lib;jansson\jansson_x64.lib;DeviceNameResolver\DeviceNameResolver_x64.lib;XEDParse\XEDParse_x64.lib;$(SolutionDir)bin\x64\x64bridge.lib;dbghelp\dbghelp_x64.lib;TitanEngine\TitanEngine_x64.lib;BeaEngine\BeaEngine_64.lib;psapi.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>capstone\capstone_x64.lib;yara\yara_x64.lib;lz4\lz4_x64.lib;jansson\jansson_x64.lib;DeviceNameResolver\DeviceNameResolver_x64.lib;XEDParse\XEDParse_x64.lib;$(SolutionDir)bin\x64\x64bridge.lib;dbghelp\dbghelp_x64.lib;TitanEngine\TitanEngine_x64.lib;psapi.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
|
@ -326,7 +322,7 @@
|
|||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>false</EnableCOMDATFolding>
|
||||
<OptimizeReferences>false</OptimizeReferences>
|
||||
<AdditionalDependencies>capstone\capstone_x64.lib;yara\yara_x64.lib;lz4\lz4_x64.lib;jansson\jansson_x64.lib;DeviceNameResolver\DeviceNameResolver_x64.lib;XEDParse\XEDParse_x64.lib;$(SolutionDir)bin\x64\x64bridge.lib;dbghelp\dbghelp_x64.lib;TitanEngine\TitanEngine_x64.lib;BeaEngine\BeaEngine_64.lib;psapi.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>capstone\capstone_x64.lib;yara\yara_x64.lib;lz4\lz4_x64.lib;jansson\jansson_x64.lib;DeviceNameResolver\DeviceNameResolver_x64.lib;XEDParse\XEDParse_x64.lib;$(SolutionDir)bin\x64\x64bridge.lib;dbghelp\dbghelp_x64.lib;TitanEngine\TitanEngine_x64.lib;psapi.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
|
|
|
@ -40,9 +40,6 @@
|
|||
<Filter Include="Header Files\Third Party\XEDParse">
|
||||
<UniqueIdentifier>{6b85ff77-8866-4618-9d46-006d8c349f8f}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\Third Party\BeaEngine">
|
||||
<UniqueIdentifier>{6028af23-e8de-4db7-b1c7-bee2b5a4402b}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\Third Party\dbghelp">
|
||||
<UniqueIdentifier>{5623fb24-3b6d-49a6-a0d3-1cfcc46f87bd}</UniqueIdentifier>
|
||||
</Filter>
|
||||
|
@ -224,18 +221,6 @@
|
|||
<ClInclude Include="x64_dbg.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="BeaEngine\basic_types.h">
|
||||
<Filter>Header Files\Third Party\BeaEngine</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="BeaEngine\BeaEngine.h">
|
||||
<Filter>Header Files\Third Party\BeaEngine</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="BeaEngine\export.h">
|
||||
<Filter>Header Files\Third Party\BeaEngine</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="BeaEngine\macros.h">
|
||||
<Filter>Header Files\Third Party\BeaEngine</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="dbghelp\dbghelp.h">
|
||||
<Filter>Header Files\Third Party\dbghelp</Filter>
|
||||
</ClInclude>
|
||||
|
|
Loading…
Reference in New Issue