unicorn icon indicating copy to clipboard operation
unicorn copied to clipboard

New and improved Python bindings

Open elicn opened this issue 2 years ago • 5 comments

Re-implemented Unicorn Python bindings while remaining compatible with the original bindings API.

Highlights:

  • OOP design for improved efficiency and extensibility
  • Pythonic code featuring type annotations to facilitate its usage
  • Cleaner code and documented methods
  • Lower memory footprint
  • Improved Uc resources deallocation

Changes:

  • UcError now provides additional information, when applicable, to provide the users with better error context (e.g. the target address and access size for invalid memory accesses)
  • Intel arch now supports reading and writing ZMM registers
  • ARM arch now supports reading and writing Q registers

elicn avatar Jun 08 '22 14:06 elicn

See my PoC in #1633

wtdcode avatar Jun 26 '22 07:06 wtdcode

@wtdcode, any thoughts or comments, considering this comment and this commit?

elicn avatar Oct 09 '22 09:10 elicn

we have been thinking about merging this after 2.0.1 release.

can you add some sample code under bindings/python/ to demonstrate the new API?

aquynh avatar Oct 17 '22 09:10 aquynh

can you add some sample code under bindings/python/ to demonstrate the new API?

The external facing API was not modified, it is only the internal implementation that was changed. Except minor additions (e.g. some archs now support more regs) nothing really changed in terms of functionality. UcError now provides more info, so that could be one possible feature to show. Do you have anything specific on your mind..?

elicn avatar Oct 19 '22 14:10 elicn

oh i thought you added some more Pythonic API

aquynh avatar Oct 19 '22 15:10 aquynh

merged and thanks for your patient.

I'm doing a careful comparison to ensure nothing breaks.

wtdcode avatar Mar 08 '24 08:03 wtdcode

It passes all local tests, if that counts.

elicn avatar Mar 08 '24 08:03 elicn

Our tests for Python bindings are not complete and thus I'm looking into the history to manually port missing features.

wtdcode avatar Mar 08 '24 08:03 wtdcode

Well, every time there was an update to the Python binding I changed my code to accommodate. Anyway, if something is missing or incompatible, let me know and I'll fix it.

elicn avatar Mar 08 '24 08:03 elicn