Merge branch 'next' of https://github.com/aquynh/capstone into module
This commit is contained in:
commit
31baeb570f
13
Makefile
13
Makefile
|
@ -104,11 +104,14 @@ $(ARCHIVE): $(LIBOBJ)
|
|||
$(RANLIB) $(ARCHIVE)
|
||||
|
||||
$(PKGCFGF):
|
||||
echo Name: capstone > $(PKGCFGF)
|
||||
echo Description: Capstone disassembler engine >> $(PKGCFGF)
|
||||
echo Version: $(VERSION) >> $(PKGCFGF)
|
||||
echo Libs: -L$(LIBDIR) -lcapstone >> $(PKGCFGF)
|
||||
echo Cflags: -I$(PREFIX)/include/capstone >> $(PKGCFGF)
|
||||
echo 'Name: capstone' > $(PKGCFGF)
|
||||
echo 'Description: Capstone disassembler engine' >> $(PKGCFGF)
|
||||
echo 'Version: $(VERSION)' >> $(PKGCFGF)
|
||||
echo 'libdir=$(LIBDIR)' >> $(PKGCFGF)
|
||||
echo 'includedir=$(PREFIX)/include/capstone' >> $(PKGCFGF)
|
||||
echo 'archive=$${libdir}/libcapstone.a' >> $(PKGCFGF)
|
||||
echo 'Libs: -L$${libdir} -lcapstone' >> $(PKGCFGF)
|
||||
echo 'Cflags: -I$${includedir}' >> $(PKGCFGF)
|
||||
|
||||
install: $(PKGCFGF) $(ARCHIVE) $(LIBRARY)
|
||||
mkdir -p $(LIBDIR)
|
||||
|
|
|
@ -42,20 +42,20 @@ public class Capstone {
|
|||
public byte[] bytes;
|
||||
public byte[] mnemonic;
|
||||
public byte[] operands;
|
||||
public int[] regs_read;
|
||||
public int regs_read_count;
|
||||
public int[] regs_write;
|
||||
public int regs_write_count;
|
||||
public int[] groups;
|
||||
public int groups_count;
|
||||
public byte[] regs_read;
|
||||
public byte regs_read_count;
|
||||
public byte[] regs_write;
|
||||
public byte regs_write_count;
|
||||
public byte[] groups;
|
||||
public byte groups_count;
|
||||
|
||||
public _cs_insn(Pointer p) {
|
||||
bytes = new byte[16];
|
||||
mnemonic = new byte[32];
|
||||
operands = new byte[96];
|
||||
regs_read = new int[32];
|
||||
regs_write = new int[32];
|
||||
groups = new int[8];
|
||||
regs_read = new byte[12];
|
||||
regs_write = new byte[20];
|
||||
groups = new byte[8];
|
||||
useMemory(p);
|
||||
read();
|
||||
}
|
||||
|
@ -81,9 +81,9 @@ public class Capstone {
|
|||
public short size;
|
||||
public String mnemonic;
|
||||
public String opStr;
|
||||
public int[] regsRead;
|
||||
public int[] regsWrite;
|
||||
public int[] groups;
|
||||
public byte[] regsRead;
|
||||
public byte[] regsWrite;
|
||||
public byte[] groups;
|
||||
|
||||
public CsInsn (_cs_insn struct, Pointer _ptr_origin, NativeLong _csh, CS _cs, OpInfo _op_info) {
|
||||
id = struct.id;
|
||||
|
@ -92,13 +92,13 @@ public class Capstone {
|
|||
mnemonic = new String(struct.mnemonic).replace("\u0000","");
|
||||
opStr = new String(struct.operands).replace("\u0000","");
|
||||
|
||||
regsRead = new int[struct.regs_read_count];
|
||||
regsRead = new byte[struct.regs_read_count];
|
||||
for (int i=0; i<regsRead.length; i++)
|
||||
regsRead[i] = struct.regs_read[i];
|
||||
regsWrite = new int[struct.regs_write_count];
|
||||
regsWrite = new byte[struct.regs_write_count];
|
||||
for (int i=0; i<regsWrite.length; i++)
|
||||
regsWrite[i] = struct.regs_write[i];
|
||||
groups = new int[struct.groups_count];
|
||||
groups = new byte[struct.groups_count];
|
||||
for (int i=0; i<groups.length; i++)
|
||||
groups[i] = struct.groups[i];
|
||||
operands = _op_info;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
To install Python binding, simply run below command:
|
||||
1. To install Python binding on *nix, simply run below command:
|
||||
|
||||
$ sudo python setup.py install
|
||||
|
||||
|
@ -21,3 +21,26 @@ This directory contains some test code to show how to use Capstone API.
|
|||
- test_<arch>.py
|
||||
These code show how to access architecture-specific information for each
|
||||
architecture.
|
||||
|
||||
|
||||
2. To install Python binding on Windows:
|
||||
|
||||
Recommended method:
|
||||
|
||||
Use the Python module installer for 32/64 bit Windows from:
|
||||
|
||||
http://www.capstone-engine.org/download.html
|
||||
|
||||
|
||||
Manual method:
|
||||
|
||||
If the module installer fails to locate your Python install, or if you have
|
||||
additional Python installs (e.g. Anaconda / virtualenv), run the following
|
||||
command in command prompt:
|
||||
|
||||
C:\> C:\location_to_python\python.exe setup.py install
|
||||
|
||||
Next, copy libcapstone.dll from the 'Core engine for Windows' package available
|
||||
on the same Capstone download page and paste it in the path:
|
||||
|
||||
C:\location_to_python\Lib\site-packages\capstone\
|
||||
|
|
|
@ -151,12 +151,12 @@ class _cs_insn(ctypes.Structure):
|
|||
('bytes', ctypes.c_ubyte * 16),
|
||||
('mnemonic', ctypes.c_char * 32),
|
||||
('op_str', ctypes.c_char * 96),
|
||||
('regs_read', ctypes.c_uint * 32),
|
||||
('regs_read_count', ctypes.c_uint),
|
||||
('regs_write', ctypes.c_uint * 32),
|
||||
('regs_write_count', ctypes.c_uint),
|
||||
('groups', ctypes.c_uint * 8),
|
||||
('groups_count', ctypes.c_uint),
|
||||
('regs_read', ctypes.c_ubyte * 12),
|
||||
('regs_read_count', ctypes.c_ubyte),
|
||||
('regs_write', ctypes.c_ubyte * 20),
|
||||
('regs_write_count', ctypes.c_ubyte),
|
||||
('groups', ctypes.c_ubyte * 8),
|
||||
('groups_count', ctypes.c_ubyte),
|
||||
('arch', _cs_arch),
|
||||
)
|
||||
|
||||
|
|
2
cs.c
2
cs.c
|
@ -327,7 +327,7 @@ const char *cs_insn_name(csh ud, unsigned int insn)
|
|||
return handle->insn_name(ud, insn);
|
||||
}
|
||||
|
||||
static bool arr_exist(unsigned int *arr, int max, unsigned int id)
|
||||
static bool arr_exist(unsigned char *arr, unsigned char max, unsigned int id)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
|
|
@ -91,14 +91,14 @@ typedef struct cs_insn {
|
|||
|
||||
// NOTE: All information below is not available when CS_OPT_DETAIL = CS_OPT_OFF
|
||||
|
||||
unsigned int regs_read[32]; // list of implicit registers read by this insn
|
||||
unsigned int regs_read_count; // number of implicit registers read by this insn
|
||||
uint8_t regs_read[12]; // list of implicit registers read by this insn
|
||||
uint8_t regs_read_count; // number of implicit registers read by this insn
|
||||
|
||||
unsigned int regs_write[32]; // list of implicit registers modified by this insn
|
||||
unsigned int regs_write_count; // number of implicit registers modified by this insn
|
||||
uint8_t regs_write[20]; // list of implicit registers modified by this insn
|
||||
uint8_t regs_write_count; // number of implicit registers modified by this insn
|
||||
|
||||
unsigned int groups[8]; // list of group this instruction belong to
|
||||
unsigned int groups_count; // number of groups this insn belongs to
|
||||
uint8_t groups[8]; // list of group this instruction belong to
|
||||
uint8_t groups_count; // number of groups this insn belongs to
|
||||
|
||||
// Architecture-specific instruction info
|
||||
union {
|
||||
|
|
2
utils.c
2
utils.c
|
@ -71,7 +71,7 @@ unsigned int insn_reverse_id(insn_map *insns, unsigned int max, unsigned int id)
|
|||
|
||||
// count number of positive members in a list.
|
||||
// NOTE: list must be guaranteed to end in 0
|
||||
unsigned int count_positive(unsigned int *list)
|
||||
unsigned int count_positive(unsigned char *list)
|
||||
{
|
||||
unsigned int c;
|
||||
|
||||
|
|
8
utils.h
8
utils.h
|
@ -18,9 +18,9 @@ typedef struct Pair {
|
|||
typedef struct insn_map {
|
||||
unsigned int id;
|
||||
unsigned int mapid;
|
||||
unsigned int regs_use[32]; // list of implicit registers used by this instruction
|
||||
unsigned int regs_mod[32]; // list of implicit registers modified by this instruction
|
||||
unsigned int groups[8]; // list of group this instruction belong to
|
||||
unsigned char regs_use[12]; // list of implicit registers used by this instruction
|
||||
unsigned char regs_mod[20]; // list of implicit registers modified by this instruction
|
||||
unsigned char groups[8]; // list of group this instruction belong to
|
||||
bool branch; // branch instruction?
|
||||
bool indirect_branch; // indirect branch instruction?
|
||||
} insn_map;
|
||||
|
@ -48,7 +48,7 @@ unsigned int insn_reverse_id(insn_map *insns, unsigned int max, unsigned int id)
|
|||
|
||||
// count number of positive members in a list.
|
||||
// NOTE: list must be guaranteed to end in 0
|
||||
unsigned int count_positive(unsigned int *list);
|
||||
unsigned int count_positive(unsigned char *list);
|
||||
|
||||
#define ARR_SIZE(a) (sizeof(a)/sizeof(a[0]))
|
||||
|
||||
|
|
Loading…
Reference in New Issue