unicorn-engine / unicorn

Unicorn CPU emulator framework (ARM, AArch64, M68K, Mips, Sparc, PowerPC, RiscV, S390x, TriCore, X86)
http://www.unicorn-engine.org
GNU General Public License v2.0
7.33k stars 1.31k forks source link

Fix/from handle unsafe #1868

Closed mlgiraud closed 10 months ago

mlgiraud commented 10 months ago

Hi, another small api change. Currently the TryFrom trait is used to convert a uc_handle (a raw pointer) into a Unicorn struct. This is inherently unsafe and should be marked as such. Since the TryFrom trait cannot be unsafe, i introduced a new method from_handle that is marked as unsafe. This way the user is responsible for ensuring the safety of the program (we cannot guarantee this, since the uc_handle pointer is supplied by the user).

wtdcode commented 10 months ago

Thanks!