+capstone

This commit is contained in:
ABevier 2023-03-08 12:22:09 -05:00 committed by Jacob Heider
parent 1ea7ecba04
commit 295674a7b4

View file

@ -0,0 +1,50 @@
distributable:
url: https://github.com/capstone-engine/capstone/archive/{{ version }}.tar.gz
strip-components: 1
versions:
github: capstone-engine/capstone/releases/tags
strip: /^v/
provides:
- bin/cstool
build:
dependencies:
tea.xyz/gx/cc: c99
tea.xyz/gx/make: '*'
script: |
./make.sh
make install PREFIX={{ prefix }}
test:
dependencies:
tea.xyz/gx/cc: c99
script: |
mv $FIXTURE test.c
gcc test.c -lcapstone -o test
test "$(./test)" = "0x1000:\tpop\t\trsp\n0x1001:\tjs\t\t0x1038\n0x1003:\txor\t\teax, 0x3834785c\n0x1008:\tpop\t\trsp\n0x1009:\tjs\t\t0x1043\n"
fixture: |
#include <stdio.h>
#include <inttypes.h>
#include <capstone/capstone.h>
#define CODE "\\x55\\x48\\x8b\\x05\\xb8\\x13\\x00\\x00"
int main()
{
csh handle;
cs_insn *insn;
size_t count;
if (cs_open(CS_ARCH_X86, CS_MODE_64, &handle) != CS_ERR_OK)
return -1;
count = cs_disasm(handle, CODE, sizeof(CODE)-1, 0x1000, 0, &insn);
if (count > 0) {
size_t j;
for (j = 0; j < count; j++) {
printf("0x%"PRIx64":\\t%s\\t\\t%s\\n", insn[j].address, insn[j].mnemonic,insn[j].op_str);
}
cs_free(insn, count);
} else
printf("ERROR: Failed to disassemble given code!\\n");
cs_close(&handle);
return 0;
}