For now, it just wrap udis86 public API (the functions in libudis86/udis86.c file) but I project to also add some operand stuff and input hook part.
The result is available in an example file here :
For the equivalent code in C (from the available udis86.pdf doc) which is :
import udis86
import sys
def main():
ud_obj = udis86.init()
ud_obj.set_input_file(sys.stdin)
ud_obj.set_mode(udis86.MOD_64)
ud_obj.set_pc(0)
ud_obj.set_syntax(udis86.UD_SYN_INTEL)
while True:
ud_obj.disassemble()
print "%016d %-16s %-24s" % (
ud_obj.insn_off(), ud_obj.insn_hex(), ud_obj.insn_asm()
)
if __name__ == '__main__':
try:
main()
except KeyboardInterrupt, e:
sys.exit(-1)
#includeThe trunk repository is on my github in project pyudis86, more to come :).
#include
int main(void) {
ud_t ud_obj;
ud_init(&ud_obj);
ud_set_input_file(&ud_obj, stdin);
ud_set_mode(&ud_obj, 64);
ud_set_syntax(&ud_obj, UD_SYN_INTEL);
while (ud_disassemble(&ud_obj)) {
printf("\t%s\n", ud_insn_asm(&ud_obj));
}
return 0;
}
0 comments:
Post a Comment