Commit Graph

209 Commits

Author SHA1 Message Date
lazymio 4441394258
Fix context saving (#1335)
* Fix context size

* Make UcContext convertible to bytes and picklable

Fix when updaing context

* Test context pickling

* Fix double free when the context is pickled from bytes
2020-09-24 00:53:23 +08:00
Nguyen Anh Quynh 2e0f753e6f save cpu->jmp_env in saving context, so uc_emu_start() can be reentrant. also improved Python binding on handling context 2020-06-05 20:12:44 +08:00
BrunoPujos 6cad700b69
fix recursive UC_HOOK_MEM callbacks for cross pages access (#1113)
Co-authored-by: bruno <bruno>
Co-authored-by: Nguyen Anh Quynh <aquynh@gmail.com>
2020-05-25 16:22:28 +08:00
Nguyen Anh Quynh fbef45b18f remove UC_ERR_TIMEOUT, so timeout on uc_emu_start() is not considered error. added UC_QUERY_TIMEOUT to query exit reason 2020-05-24 23:54:45 +08:00
Nguyen Anh Quynh ef92e5ed71 coding style cleanup 2020-05-07 14:30:22 +08:00
BAYET 881e08da01
Fix UAF when deleting hook while in hook callback #1127 (#1130)
* Handle the cpu context save in a more pythonic way, so the context can be serialized and reuse in an other process using the same emulator architecture and modes

* Fix type error ; mistakes a size_t uint64_t ; breaks in 32bit...

* Fix the UAF situation when deleting a hook while being in a hook callback. Added an attribute 'to_delete' to hooks, and a list hooks_to_del to delay the free of the hooks

* Minor fixes ; forgot return type of clear_deleted_hooks ; do not declare variable in for predicate
2020-05-07 14:24:48 +08:00
ζeh Matt 3a3bc0c22d Timeout error (#1173)
* Implement timeout state and new error for such case

* Adjust test_i386_loop sample

* Adjust test_i386_loop test
2019-12-29 00:16:54 +08:00
BAYET 8987ad0fff Handle serialization of cpu context save (#1129)
* Handle the cpu context save in a more pythonic way, so the context can be serialized and reuse in an other process using the same emulator architecture and modes

* Fix type error ; mistakes a size_t uint64_t ; breaks in 32bit...
2019-09-07 19:09:17 +08:00
Fish 626d72d6df Two fixes to get unicorn build better with MSVC. (#1136)
* Change MSVC keywords.

typename, class, and class are all keywords for MSVC. Adding a suffix for
all of them allows a successful compilation under VC 2017 (15.9).

* Switch from /ZI to /Zi to avoid crashes at longjmp in debug builds.
2019-09-05 00:53:37 +08:00
Chen Huitao 23a426625f check arguments, return error instead of raising exceptions. (#1125)
* check arguments, return error instaed of raising exceptions. close #1117.

* remove empty lines. remove thr underscore prefix in function name.
2019-08-23 17:05:13 +08:00
Aldo Mazzeo d38c8fb27f Don't duplicate a uc_mem_map_ptr'd memory region when splitting it (#1028) (#1030) 2019-03-07 09:05:26 +08:00
Nguyen Anh Quynh 4d0157eb4a x86: fix #968. also fix potential bug of not clearing high bytes when updateing EIP 2018-07-26 15:19:23 +08:00
Nguyen Anh Quynh 58e1f03f12 Revert "x86: fix #968"
This reverts commit 91033dd0f0.
2018-07-25 17:04:35 +08:00
Nguyen Anh Quynh 91033dd0f0 x86: fix #968 2018-07-25 13:34:15 +08:00
Ficture Seven ac9da14b3f uc_mem_unmap returns proper error code & fixes #863 (#864) 2017-08-01 18:59:55 +08:00
Nguyen Anh Quynh 821245e766 fix MSVC warning 2017-06-16 16:37:33 +07:00
Nguyen Anh Quynh fe466d003a callback to count number of instructions in uc_emu_start() should be executed first. fix #727 2017-06-16 13:22:38 +08:00
misson20000 3fdb2d2442 add architecture query (#842) 2017-05-21 09:47:02 +08:00
bulaza 4b9efdc986 Adding INSN hook checks for x86 (#833)
* adding INSN hook checking for x86

* tabs to spaces

* need to return bool not uc_err

* fixed conditional after switching to bool
2017-05-14 00:16:17 +07:00
Ryan Hileman b93ca7f565 fix unreachable UAF (fix #758) (#824) 2017-05-08 10:40:34 +08:00
zhangwm 2e973a13f0 arm64eb: add support for ARM64 big endian. 2017-04-24 23:30:01 +08:00
Nguyen Anh Quynh 094ca80092 fix conflicts 2017-03-30 12:23:24 +08:00
fG! 1bef32fff6 Fix huge memory leak on uc_mem_protect() (#787)
A memory region is allocated inside split_region() that was only freed in error case but not on success case, leading to huge memory leak if the region size was significant.
2017-03-18 09:17:23 +08:00
zhangwm ccdb0ff523 armeb: rename arm's and mips's *REGS_STORAGE_SIZE to avoid big-endian and little-endian's duplicated definition. 2017-03-15 22:25:35 +08:00
zhangwm d8fe34a2e8 armeb: Add support for ARM big endian. 2017-03-13 22:32:44 +08:00
Nguyen Anh Quynh c01dcf0a14 fix merge conflicts 2017-03-10 21:04:33 +08:00
Ahmed Samy 02e6c14e12 x86: add MSR API via reg API (#755)
Writing / reading to model specific registers should be as easy as
calling a function, it's a bit stupid to write shell code and run them
just to write/read to a MSR, and even worse, you need more than just a
shellcode to read...

So, add a special register ID called UC_X86_REG_MSR, which should be
passed to uc_reg_write()/uc_reg_read() as the register ID, and then a
data structure which is uc_x86_msr (12 bytes), as the value (always), where:
	Byte	Value		Size
	0	MSR ID		4
	4       MSR val		8
2017-02-24 21:37:19 +08:00
Nguyen Anh Quynh 6ea39f7d5a merge msvc with master 2017-02-24 10:39:36 +08:00
radare 8acd6d47c9 Properly honor UNICORN_HAS_ (#757)
* Properly honor UNICORN_HAS_

* Oops missed that
2017-02-24 10:00:36 +08:00
vardyh 7f9251511e MSVC port (vardyh) (#746)
* unicorn: use waitable timer to implement usleep() on Windows

Signed-off-by: vardyh <vardyh.dev@gmail.com>

* atomic: implement barrier() for msvc

Signed-off-by: vardyh <vardyh.dev@gmail.com>
2017-02-07 21:31:35 +08:00
xorstream 770c5616e2 Automated leading tab to spaces conversion. 2017-01-21 12:28:22 +11:00
xorstream b0ae2138fb Merge remote-tracking branch 'unicorn-engine/master' into msvc_native 2017-01-20 22:37:51 +11:00
xorstream ee294eebb0 Fixed double free in win32 threads and changed free() to g_free(). (#722) 2017-01-20 16:03:35 +08:00
Nguyen Anh Quynh 42771848d6 no more spinlock 2017-01-20 14:57:33 +08:00
xorstream 002151874a Unicorn interface working with test app in 32bit and 64bit builds. 2017-01-20 17:27:22 +11:00
xorstream 1aeaf5c40d This code should now build the x86_x64-softmmu part 2. 2017-01-19 22:50:28 +11:00
Nguyen Anh Quynh bc569f5a54 rename API uc_mem_free() to uc_free(). see #662 2017-01-10 20:59:14 +08:00
Nguyen Anh Quynh fdbbdc6216 rename uc_context_free() to uc_mem_free(). see #373 2017-01-09 20:52:14 +08:00
Nguyen Anh Quynh 52cb0ba78e cleanup more synchronization code 2017-01-09 14:05:39 +08:00
Nguyen Anh Quynh 5777c4f3fd Merge branch 'noglib' of https://github.com/unicorn-engine/unicorn into noglib 2016-12-22 12:13:53 +08:00
Nguyen Anh Quynh 93044e39f1 Merge branch 'master' into noglib 2016-12-22 12:13:34 +08:00
Ryan Hileman 19b92a4a7e fix possible segfault in hook del (#691) (#697) 2016-12-22 00:50:40 +08:00
Chris Eagle fccbcfd4c2 revert to use of g_free to make future qemu integrations easier (#695)
* revert to use of g_free to make future qemu integrations easier

* bracing
2016-12-21 22:28:36 +08:00
Chris Eagle e46545f722 remove glib dependency by provide compatible replacements 2016-12-18 14:56:58 -08:00
Nguyen Anh Quynh 200f0d195e fix some Msys complains 2016-11-04 21:40:35 +08:00
Nguyen Anh Quynh 04b103164d fix Brew installation in issue #663 2016-11-01 20:30:55 +08:00
Nguyen Anh Quynh 8f99d20695 turn cpu_context_size() into static function 2016-10-12 11:05:32 +08:00
Andrew Dutcher 80f35d3b2b remove safety checks, for some reason 2016-10-11 13:07:14 -07:00
Andrew Dutcher ea54204952 Tweak some names in a few places, encapsulate the uc_context struct to hide it from users for some reason 2016-10-10 14:04:51 -07:00
Andrew Dutcher 1ab2154fe5 Change save/restore API to have explicit alloc/free functions. Python has explicit save/update functions. 2016-10-07 11:39:42 -07:00