Skip to content

Commit

Permalink
Merge remote-tracking branch 'aquynh/master' into PowerShell-Binding
Browse files Browse the repository at this point in the history
  • Loading branch information
FuzzySecurity committed Nov 12, 2016
2 parents 2a66831 + d909de0 commit 4088ce5
Show file tree
Hide file tree
Showing 13 changed files with 49 additions and 25 deletions.
1 change: 1 addition & 0 deletions CREDITS.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 4 additions & 3 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
11 changes: 10 additions & 1 deletion arch/X86/X86ATTInstPrinter.c
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ static void printMemReference(MCInst *MI, unsigned Op, SStream *O)
}
}
} else {
SStream_concat0(O, "0");
//SStream_concat0(O, "0");
}
}

Expand Down Expand Up @@ -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) {
Expand Down
24 changes: 20 additions & 4 deletions arch/X86/X86GenAsmWriter.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion cstool/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ else
endif

clean:
${RM} -rf *.o cstool
${RM} -rf *.o $(TARGET)

%.o: %.c
ifeq ($(V),0)
Expand Down
15 changes: 13 additions & 2 deletions cstool/cstool.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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");

Expand Down Expand Up @@ -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);
Expand Down
2 changes: 0 additions & 2 deletions cstool/cstool_arm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
2 changes: 0 additions & 2 deletions cstool/cstool_arm64.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
2 changes: 0 additions & 2 deletions cstool/cstool_mips.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,4 @@ void print_insn_detail_mips(csh handle, cs_insn *ins)
}

}

printf("\n");
}
2 changes: 0 additions & 2 deletions cstool/cstool_ppc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
2 changes: 0 additions & 2 deletions cstool/cstool_sparc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
2 changes: 0 additions & 2 deletions cstool/cstool_systemz.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
2 changes: 0 additions & 2 deletions cstool/cstool_x86.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

0 comments on commit 4088ce5

Please sign in to comment.