-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove cs_disasm_iter, cs_malloc and cs_free. API change unifies disassembly process. Before, there were two separate functions to disassemble one instruction at a time in a loop and many instructions into a dynamic buffer. Commit will introduce user allocatable buffer that can be used in both situations with one function. Updating the use of cs_disasm_iter() is a little more complicated than cs_disasm(): // old api cs_insn *insn = cs_malloc(handle); while (cs_disasm_iter(handle, &code, &code_size, &ip, insn)) { disassembled_instructions += 1; } cs_free(insn); Must be changed to: // new api cs_buffer *buffer = cs_buffer_new(1); // create buffer with 1 element while (cs_disasm(handle, code, code_size, ip, 1, buffer)) { cs_insn *insn = &buffer->insn[0]; // get first insn in a buffer disassembled_instructions += 1; // update code pointer, code size and instruction pointer code += insn->size; code_size += insn->size; ip += insn->size; } cs_buffer_free(buffer); // free buffer Updating the use of cs_disasm() is straightforward, just use cs_buffer_new(0) to create a buffer and pass it to cs_disasm().
- Loading branch information
Showing
34 changed files
with
403 additions
and
522 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.