Commit Graph

161 Commits

Author SHA1 Message Date
Nguyen Anh Quynh 0b690387b3 x86: update core with upstream. this added bunch of new instructions & groups. also updated Python & Java bindings after the core change 2014-08-13 13:01:50 +08:00
Nguyen Anh Quynh 5d8067822b Merge branch 'next' of https://github.com/flyingsymbols/capstone into arm 2014-07-31 15:36:13 +08:00
flyingsymbols 298d413bbc * added a test file to suite for testing invalid and valid instruction sequences
* fixed and added a test for a thumb-2 invalid sequence that was incorrectly allowed before these changes (pop.w with sp argument included)
* fixed and added a test for a blx from thumb to ARM that had its immediate argument incorrect (misaligned)

* eliminated some warnings by explicitly casting so I could turn on
  treat warnings as errors locally

General notes:
*  probably worth turning on treat all warnings as errors in the msvc project files, had a subtle bug that resulted from a missing declaration causing differences in dll and static compilation modes

( code was working incorrectly in dll form because of missing declaration in arch/ARM/ARMMapping.h for new function ARM_blx_to_arm_mode. Something about the linking was confusing ld when making the dll, and the resulting offsets were wonky (e.g. the added ble test would show up as #0x1fc instead of #0x1fe like it should have )

* the invalid pop was being treated as a soft fail which then gets coerced
  to a success because it is != MCDisassembler_Fail in Thumb_getInstruction
  what are the semantics of a soft fail? Maybe we should be able to set up
  whether or not we want a soft fail to be a real fail in the csh struct?
2014-07-15 04:33:40 -04:00
Nguyen Anh Quynh 027afdc179 Change the prototype of the callback in SKIPDATA option. Suggested by Ben Nagy.
Original prototype:
  typedef size_t (*cs_skipdata_cb_t)(const uint8_t *code, uint64_t offset, void* user_data);

Now we add @code_size argument to reflect the size of the input buffer @code.
Also, we change the data type of @offset to size_t because this argument indicates the
distance from currently examining bytes to @code, but not the address of the byte.

  typedef size_t (*cs_skipdata_cb_t)(const uint8_t *code, size_t code_size, size_t offset, void* user_data);
2014-07-10 15:46:10 +08:00
Nguyen Anh Quynh 0df7e93a3c Change the prototype of the callback in SKIPDATA option. Suggested by Ben Nagy.
Original prototype:
  typedef size_t (*cs_skipdata_cb_t)(const uint8_t *code, uint64_t offset, void* user_data);

Now we add @code_size argument to reflect the size of the input buffer @code.
Also, we change the data type of @offset to size_t because this argument indicates the
distance from currently examining bytes to @code, but not the address of the byte.

  typedef size_t (*cs_skipdata_cb_t)(const uint8_t *code, size_t code_size, size_t offset, void* user_data);
2014-07-10 15:42:16 +08:00
Nguyen Anh Quynh 650f96ce43 add new API cs_group_name() to return group name in string, given the group id 2014-07-08 08:59:27 +08:00
Nguyen Anh Quynh 25b7f760ce simplify code copying @mnemonic in fill_insn() 2014-07-02 12:24:15 +08:00
Nguyen Anh Quynh d392f6ef89 simplify code copying @mnemonic in fill_insn() 2014-07-02 12:22:39 +08:00
Nguyen Anh Quynh 22ea683583 only verify x86_prefix[0] for x86 arch. bug reported by @pancake 2014-07-02 09:09:08 +08:00
Nguyen Anh Quynh 1d3100ad5b only verify x86_prefix[0] for x86 arch. bug reported by @pancake 2014-07-02 09:08:10 +08:00
Nguyen Anh Quynh 5a7f409dec set @insn to NULL on error in cs_disasm_ex() 2014-06-19 11:15:54 +08:00
Nguyen Anh Quynh dab17fd0b1 set @insn to NULL on error in cs_disasm_ex() 2014-06-19 11:15:18 +08:00
Nguyen Anh Quynh 6c182aedcf fix a memleaking issue in cs_disasm_ex() where memory was not freed when input code is illegit 2014-06-18 21:50:25 +08:00
Nguyen Anh Quynh cae09bf543 replace offset_of with offsetof from stddef.h 2014-06-17 14:58:39 +08:00
Nguyen Anh Quynh 64091f77e0 resize total memory allocated for @insns to just the right size for cs_disasm_ex() 2014-06-16 18:37:11 +08:00
Nguyen Anh Quynh 495295ecd4 MCInst_Init() is arch-independent 2014-06-16 15:54:32 +08:00
Nguyen Anh Quynh db3c00c0ff consider tab as delimiter char in asm bufffer in fill_insn() 2014-06-13 11:16:53 +07:00
Nguyen Anh Quynh 69582d71ae initialize cs_insn.detail by properly zero-out right members for each arch 2014-06-09 17:50:01 +07:00
Nguyen Anh Quynh c88d9929ae cs_disasm_ex(): properly calculate insn_cache when reallocating total variable 2014-06-09 01:59:00 +08:00
Nguyen Anh Quynh ee5839420d cs_disasm_ex(): avoid multiple memcpy() by allocating memory for total, then directly work on that instead of using static array insn_cache[] 2014-06-09 00:13:31 +07:00
Nguyen Anh Quynh 5329a6ffd4 directly update cs_insn from MCInst interface to avoid multiple memcpy() 2014-06-08 23:35:52 +07:00
Nguyen Anh Quynh 7566a2d9dd copy mnemonic in the same loop of searching for mnemonic/opstring delimiter 2014-06-08 22:09:31 +08:00
Nguyen Anh Quynh 07e84a2094 do not need to verify handle->insn_id in fill_insn() 2014-06-08 19:27:22 +08:00
Nguyen Anh Quynh 6ddd715fac we have to consider \t in input buffer of fill_insn() 2014-06-08 19:11:38 +08:00
Nguyen Anh Quynh f8ea346310 properly copy buffer to op_str 2014-06-08 18:57:52 +08:00
Nguyen Anh Quynh 177dd9b223 simplify fill_insn(): do not check for \t in asm buffer 2014-06-08 00:17:10 +08:00
Nguyen Anh Quynh 22a5a761d8 x86: simplify byteReader_t 2014-06-07 23:41:20 +08:00
Nguyen Anh Quynh df1acfd106 nullify cs_insn.detail when detail is OFF 2014-06-07 15:39:32 +07:00
Nguyen Anh Quynh 30c065998b optimize memset() of MCInst_Init() 2014-06-07 13:30:59 +08:00
Nguyen Anh Quynh 99e69e1868 remove a redundant call to memset() in cs_disasm_ex() 2014-06-06 16:49:23 +08:00
Nguyen Anh Quynh 07c3693cf2 cmake: properly export public APIs in capstone.DLL. thanks to Daniel Pistelli for helping to fix this issue 2014-06-03 18:33:15 +08:00
Nguyen Anh Quynh 9786566aaa msvc: fix some Nmake warnings 2014-05-28 14:33:32 +08:00
Nguyen Anh Quynh c80d840ffc add XCore architecture 2014-05-26 23:02:48 +08:00
Nguyen Anh Quynh 6456481508 x86: add immediate operand (1) for SHL/SHR/ROR/ROL/SAR/SAL in detail mode & Intel syntax 2014-05-19 16:46:31 +08:00
Nguyen Anh Quynh 8c2e2db84e fix an warning on unused local variable in fill-insn() when CAPSTONE_DIET is defined 2014-05-14 07:32:56 +08:00
Nguyen Anh Quynh bb0744df5d do not initialize some local vars unnecessarily. this problem was introduced when we fixed C89 issues for MSVC 2014-05-12 13:41:49 +08:00
Axel 0vercl0k Souchet 84fecf2f99 added the debug configuration + correct the macro name for consistency 2014-05-10 09:49:29 +01:00
Axel 0vercl0k Souchet 605faf1db9 moved the hardcoded macros in the vcproj & just disable the warning for the crt 2014-05-09 20:40:00 +01:00
Nguyen Anh Quynh 42706a39e2 indentation with tab 2014-05-09 07:33:35 +08:00
Axel 0vercl0k Souchet 779d4c75d9 first changes to get a successfully compiled version of capstone on VS2012 2014-05-08 23:44:49 +01:00
Giovanni Condello 95657e0ca9 cs.c : Conform to original indentation rules 2014-05-07 17:31:27 +02:00
Giovanni Condello a715df17a9 Do not access instructions details if the instruction is marked as SKIPDATA or if the details are NULL
Fixes issues #105
2014-05-07 17:25:38 +02:00
Nguyen Anh Quynh 1dbc9593aa x86: use strncpy() to update instruction mnemonic 2014-05-07 14:14:07 +08:00
Nguyen Anh Quynh a5ffdc3a80 x86: properly handle LOCK/REP in the core, so remove buch of hacks 2014-05-07 08:25:24 +08:00
Nguyen Anh Quynh 6023ef7843 Disassembler -> Disassembly 2014-04-29 11:21:04 +08:00
Nguyen Anh Quynh 2cff6f61fc x86: handle instructions with LOCK/REP/REPNE prefix after other prefixes. bear with this until we have a better approach 2014-04-28 11:19:44 +08:00
Nguyen Anh Quynh a88c1164bf move the macro MIN to utils.h 2014-04-27 13:38:04 +08:00
Nguyen Anh Quynh 42288ac4e3 SKIPDATA: add 1 more argument to callback function pointing to the input buffer of cs_disasm_ex() 2014-04-14 14:53:13 +08:00
Nguyen Anh Quynh 11ec8817dc core: add CS_ERR_SKIPDATA error code to report when code access irrelevant info in SKIPDATA mode 2014-04-10 17:20:01 +08:00
Nguyen Anh Quynh 07ffd64c38 SKIPDATA: @offset of callback function should indicate the position of examining byte in input buffer 2014-04-10 14:36:08 +08:00