Merge remote-tracking branch 'aquynh/master' into PowerShell-Binding

This commit is contained in:
FuzzySecurity 2016-11-12 15:57:40 +01:00
commit 8e773ffbc1
13 changed files with 49 additions and 25 deletions

View File

@ -61,3 +61,4 @@ Xipiter LLC: Capstone logo redesigned.
Satoshi Tanda: Support Windows kernel driver.
Tang Yuhang: cstool.
Andrew Dutcher: better Python setup.
Ruben Boonen: PowerShell binding.

7
README
View File

@ -14,9 +14,10 @@ Capstone offers some unparalleled features:
- Provide semantics of the disassembled instruction, such as list of implicit
registers read & written.
- Implemented in pure C language, with lightweight bindings for Emacs, Haskell, Perl, Python,
Ruby, C#, NodeJS, Java, GO, C++, OCaml, Lua, Rust, Delphi, Free Pascal & Vala
ready either in main code, or provided externally by the community).
- Implemented in pure C language, with lightweight bindings for PowerShell,
Emacs, Haskell, Perl, Python, Ruby, C#, NodeJS, Java, GO, C++, OCaml, Lua,
Rust, Delphi, Free Pascal & Vala ready either in main code, or provided
externally by the community).
- Native support for all popular platforms: Windows, Mac OSX, iOS, Android,
Linux, *BSD, Solaris, etc.

View File

@ -728,7 +728,7 @@ static void printMemReference(MCInst *MI, unsigned Op, SStream *O)
}
}
} else {
SStream_concat0(O, "0");
//SStream_concat0(O, "0");
}
}
@ -799,6 +799,15 @@ void X86_ATT_printInst(MCInst *MI, SStream *OS, void *info)
else
printInstruction(MI, OS, info);
// HACK TODO: fix this in machine description
switch(MI->flat_insn->id) {
default: break;
case X86_INS_SYSEXIT:
SStream_Init(OS);
SStream_concat0(OS, "sysexit");
break;
}
if (MI->has_imm) {
// if op_count > 1, then this operand's size is taken from the destination op
if (MI->flat_insn->detail->x86.op_count > 1) {

View File

@ -14168,12 +14168,28 @@ static void printInstruction(MCInst *MI, SStream *O, MCRegisterInfo *MRI)
uint64_t Bits2 = OpInfo2[opcode];
uint64_t Bits = (Bits2 << 32) | Bits1;
// assert(Bits != 0 && "Cannot print this instruction.");
if (!X86_lockrep(MI, O))
if (!X86_lockrep(MI, O)) {
#ifndef CAPSTONE_DIET
SStream_concat0(O, AsmStrs+(Bits & 16383)-1);
#else
;
// HACK TODO
switch(opcode) {
default:
SStream_concat0(O, AsmStrs+(Bits & 16383)-1);
break;
case X86_MOV32sm:
SStream_concat0(O, "movw\t");
break;
case X86_ROL32r1:
SStream_concat0(O, "rol\t$1, ");
break;
case X86_LGS64rm:
SStream_concat0(O, "lgs\t");
break;
case X86_SLDT64m:
SStream_concat0(O, "sldt\t");
break;
}
#endif
}
// Fragment 0 encoded into 7 bits for 79 unique commands.

View File

@ -24,7 +24,7 @@ else
endif
clean:
${RM} -rf *.o cstool
${RM} -rf *.o $(TARGET)
%.o: %.c
ifeq ($(V),0)

View File

@ -7,7 +7,6 @@
#include <capstone.h>
#define VERSION "2.0"
void print_insn_detail_x86(csh ud, cs_mode mode, cs_insn *ins);
void print_insn_detail_arm(csh handle, cs_insn *ins);
@ -73,7 +72,7 @@ static uint8_t *preprocess(char *code, size_t *size)
static void usage(char *prog)
{
printf("Cstool v%s for Capstone Disassembler Engine (core v%u.%u.%u)\n\n", VERSION, CS_VERSION_MAJOR, CS_VERSION_MINOR, CS_VERSION_EXTRA);
printf("Cstool for Capstone Disassembler Engine v%u.%u.%u\n\n", CS_VERSION_MAJOR, CS_VERSION_MINOR, CS_VERSION_EXTRA);
printf("Syntax: %s [-d] <arch+mode> <assembly-hexstring> [start-address-in-hex-format]\n", prog);
printf("\nThe following <arch+mode> options are supported:\n");
@ -372,6 +371,18 @@ int main(int argc, char **argv)
if (arch == CS_ARCH_XCORE) {
print_insn_detail_xcore(handle, &insn[i]);
}
if (insn[i].detail->groups_count) {
int j;
printf("\tGroups: ");
for(j = 0; j < insn[i].detail->groups_count; j++) {
printf("%s ", cs_group_name(handle, insn[i].detail->groups[j]));
}
printf("\n");
}
printf("\n");
}
}
cs_free(insn, count);

View File

@ -110,6 +110,4 @@ void print_insn_detail_arm(csh handle, cs_insn *ins)
if (arm->mem_barrier)
printf("\tMemory-barrier: %u\n", arm->mem_barrier);
printf("\n");
}

View File

@ -99,6 +99,4 @@ void print_insn_detail_arm64(csh handle, cs_insn *ins)
if (arm64->cc)
printf("\tCode-condition: %u\n", arm64->cc);
printf("\n");
}

View File

@ -44,6 +44,4 @@ void print_insn_detail_mips(csh handle, cs_insn *ins)
}
}
printf("\n");
}

View File

@ -86,6 +86,4 @@ void print_insn_detail_ppc(csh handle, cs_insn *ins)
if (ppc->update_cr0)
printf("\tUpdate-CR0: True\n");
printf("\n");
}

View File

@ -51,6 +51,4 @@ void print_insn_detail_sparc(csh handle, cs_insn *ins)
if (sparc->hint != 0)
printf("\tHint code: %u\n", sparc->hint);
printf("\n");
}

View File

@ -53,6 +53,4 @@ void print_insn_detail_sysz(csh handle, cs_insn *ins)
if (sysz->cc != 0)
printf("\tCode condition: %u\n", sysz->cc);
printf("\n");
}

View File

@ -108,6 +108,4 @@ void print_insn_detail_x86(csh ud, cs_mode mode, cs_insn *ins)
printf("\t\toperands[%u].size: %u\n", i, op->size);
}
printf("\n");
}