sq3: show SQLite error messages on stderr by default
[iv.d.git] / capstone / test00.d
blobf21450cc834758a4da103e4c77cc7a4d83863dbd
1 import iv.capstone;
3 immutable(ubyte)[] CODE = cast(immutable(ubyte)[])"\x55\x48\x8b\x05\xb8\x13\x00\x00";
5 void main () {
6 csh handle;
7 cs_insn* insn;
8 usize count;
10 if (cs_open(CS_ARCH_X86, CS_MODE_32, &handle) != CS_ERR_OK) assert(0, "can't initialize capstone");
11 scope(exit) cs_close(&handle);
13 count = cs_disasm(handle, CODE.ptr, CODE.length-1, 0x1000, 0, &insn);
14 if (count > 0) {
15 foreach (immutable j; 0..count) {
16 import core.stdc.stdio : printf;
17 printf("0x%08x: %-8s %s\n", cast(uint)insn[j].address, insn[j].mnemonic.ptr, insn[j].op_str.ptr);
19 cs_free(insn, count);
20 } else {
21 import core.stdc.stdio : printf;
22 printf("ERROR: Failed to disassemble given code!\n");