Commit Graph

319 Commits

Author SHA1 Message Date
lazymio 247ffbe0e8
Support nested uc_emu_start calls 2021-11-16 21:07:03 +01:00
lazymio 640251e1aa
Leave out size parameter in callback 2021-11-09 00:21:34 +01:00
lazymio 56fcc07a7c
Add EXTRA field to uc_version 2021-11-08 22:51:49 +01:00
lazymio 35017a614f
Slightly change UC_CTL_TB_REMOVE_CACHE 2021-11-08 22:09:33 +01:00
lazymio 6ec016327d
Rename uc_hook_tcg_sub_t 2021-11-08 21:01:47 +01:00
lazymio 4df0ad5e83
Update docs for exits mechanism 2021-11-08 20:54:07 +01:00
lazymio e836b62e01
Minor fix for uc_ctl 2021-11-08 20:40:02 +01:00
lazymio c6fdbb3735
Add RISCV CSR registers 2021-11-07 20:36:04 +01:00
lazymio cd02c25802
Fix bug in remove cache and update comments 2021-11-04 21:29:55 +01:00
lazymio a9bfa0afb0
Update comments 2021-11-04 21:22:49 +01:00
lazymio 01d7e454b7
Fix typo 2021-11-04 20:59:07 +01:00
lazymio 1507f90059
Fix name typo 2021-11-04 20:07:01 +01:00
lazymio b9c0066a47
Format and naming 2021-11-04 20:04:57 +01:00
lazymio 871de4ad65
Split mips cpu to 32 and 64 2021-11-04 19:58:32 +01:00
lazymio 0555095388
Support changing cpu model for ppc 2021-11-04 19:53:02 +01:00
lazymio 94d952b410
Add depreciated in unicorn.h 2021-11-04 18:44:56 +01:00
lazymio dfbffa44ec
Support changing cpu model for ARM 2021-11-04 18:37:10 +01:00
lazymio 3e4b4af7d3
Support change page size 2021-11-04 17:03:30 +01:00
lazymio 6b5529fcb7
Merge pull request #1458 from bet4it/patch
Port some patches from Unicorn1 to Unicorn2
2021-11-03 20:59:42 +01:00
lazymio 9818840f4e
Add tests for UC_HOOK_TCG_OPCODE 2021-11-03 20:56:45 +01:00
lazymio bcf85be86d
Add a new hook type UC_HOOK_TCG_OPCODE 2021-11-03 01:46:24 +01:00
Bet4 aaf340d9e4 Merge branch 'dev' into patch 2021-11-02 18:36:22 +08:00
lazymio c11b9aa5c3
Add a new hook type UC_HOOK_EDGE_GENERATED and corresponding sample 2021-11-01 23:27:35 +01:00
lazymio b7e82d460c
Expose more TB related stuff 2021-11-01 22:11:43 +01:00
lazymio fb45b287ba
Add multiple exits mechanism and tests&samples 2021-11-01 14:00:43 +01:00
lazymio 3dd2e0f95d
Basic implementation of uc_ctl 2021-11-01 00:39:36 +01:00
lazymio 090686f8ed
uc_ctl proposal (#1473)
* Add uc_ctl

* Add comments

* Slightly changed for bindings generation

* Generate bindings
2021-10-30 10:45:32 +08:00
lazymio e62b0ef255
Add clang-format and format code to qemu code style 2021-10-29 12:44:49 +02:00
lazymio e695686c15
Remove AFL Integration by reverting 2021-10-26 11:22:21 +02:00
lazymio 1fa2eb688b
Fix UC_MODE_AFL and update config 2021-10-25 14:39:40 +02:00
lazymio d965c0f159
Use UCLOG and fix uc_afl_fuzz 2021-10-25 10:46:52 +02:00
lazymio dd7476a9bd
Initial import unicornafl 2021-10-25 00:51:16 +02:00
Sun Daowen 5eab884244 compile on VS2008/VS2010 (#1397)
Compiling with Win32 Release/MinSizeRel/RelWithDebInfo in VS2008 will cause "fatal error C1063: compiler limit: compiler stack overflow" problem.
Compiling with Win32 Debug or x64 does not have this problem.
You can easily bypass this problem by changing the optimization options /O1 and /O2 to /Od.
In VS2010, when _INTPTR is 0 or 1, UINTPTR_MAX is 0xFFFFFFFF.
2021-10-12 08:50:22 +08:00
Peter Meerwald-Stadler 00b4a17c1b Fix some typos in include files (#1350) 2021-10-11 11:18:27 +08:00
mio 4c438e7774
Update comments for UC_HOOK_INSN 2021-10-05 18:15:31 +02:00
mio 46e8ac03ad
Remove useless x86 registers according to #1440 2021-10-04 11:03:56 +02:00
mio 65e1a17386
Remove winsocks 2021-10-03 23:25:26 +02:00
mio 2d043d387d
Change mips model to add DSP 2021-10-03 23:10:39 +02:00
Nguyen Anh Quynh aaaea14214 import Unicorn2 2021-10-03 22:14:44 +08:00
Nguyen Anh Quynh 51665db668 Merge branch 'master' of github.com:unicorn-engine/unicorn 2021-05-16 21:38:17 +08:00
Nguyen Anh Quynh 2874435d2f bump version to 1.0.3 2021-05-16 21:38:08 +08:00
Sun Daowen 5790938452
compile on VS2008/VS2010 (#1397)
Compiling with Win32 Release/MinSizeRel/RelWithDebInfo in VS2008 will cause "fatal error C1063: compiler limit: compiler stack overflow" problem.
Compiling with Win32 Debug or x64 does not have this problem.
You can easily bypass this problem by changing the optimization options /O1 and /O2 to /Od.
In VS2010, when _INTPTR is 0 or 1, UINTPTR_MAX is 0xFFFFFFFF.
2021-05-16 21:36:33 +08:00
lazymio 225d387325
Fix wrong sync after UC_ERR_[READ, WRITE, FETCH]_[UNMAPPED, PROT] (#1368)
* Fix wrong sync after UC_ERR_[READ, WRITE, FETCH]_[UNMAPPED, PROT]

Note that:
1. We only guarantee the pc (and other internal states) is correct
if and only of `uc_emu_start` returns without any error (or errors
have been handled in callbacks.).
2. If memory read/write error isn't handled by hooks, the state is
undefined and the pc is probably wrong if no hook is installed.

This fixes #1323.

* Rename variables

* Add note in unicorn.h

* Refine test_i386_invalid_mem_read_in_tb
2021-05-12 00:10:45 +08:00
w4kfu-synacktiv 21ec6e8f83
Add ARM BE8 support (#1369)
Co-authored-by: w4kfu <gw4kfu@gmail.com>
2021-03-31 21:22:35 +08:00
Peter Meerwald-Stadler 770d5679c3
Fix some typos in include files (#1350) 2020-10-29 11:16:45 +08:00
lazymio 1044403d38
Implement uc_context_free (#1336)
* Implement uc_context_free

* Use uc_context_free for python bindings

* Format code

* Simplify code

* Move next,context inside while loop

* Add my name to CREDITS.TXT
2020-09-24 22:28:55 +08:00
Sunho Kim abe452babc
Fix enabled hooks even after deleting them (#1315) 2020-09-10 10:03:36 +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 3a2ad04f2b refine comments on UC_QUERY_TIMEOUT 2020-05-24 23:56:35 +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
el poto rico 149121539b
[arm64] Add some cool registers (#1253)
I've added the following registers to the API:

 * PSTATE
 * Exception link registers (ELR_ELx)
 * Stack pointers registers (SP_ELx)
 * MMU (TTBRn_EL1)
 * Exception syndrom registers (ESR_ELx)
 * Faulting virtual address registers (FAR_ELx)
 * PAR (PAR_EL1)
 * MAIR (MAIR_EL1)
 * Vector base address registers (VBAR_ELx)
2020-05-10 21:50:00 +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
Charles Ferguson f0b509c176
Ensure that hooks are unaffected by a request to stop emulation. (#1154)
This change removes the check for stop requests from the hook loop
macro.

Requests to stop emulation (uc_emu_stop) should only affect whether
the emulation stops. This isn't the case at present for the invocation
of hooks. If emulation is requested to be stopped (which is indicated
by `uc->stop_request`), the hooks will skip all execution. This means
that when the emulation stop is requested, some expected operations
may not occur before the emulation exits - leaving the system in an
inconsistent or broken state.

This is particularly obvious in the case where a CPU interrupt is
required, and a hook has been registered for such cases. The expected
operation is that the hook be called, and no CPU exception be raised
(because the hook has handled it). However, because of the short-cut
in the case where the `uc_emu_stop` function has been called out of
band (eg on another thread), this hook would not be called. In such
cases the execution would terminate with an error that an 'unhandled
CPU exception' occurred, and the hook would never have been called.

This probably affects other parts of the system, such as hooks which
handle remapping of memory on demand (UC_HOOK_MEM_READ_UNMAPPED and
friends) where the remap would not happen and instead an error about
the unmapped memory would be raised.

In all cases, it makes sense that execution continue normally until
the outer loop which controls the execution determines that the
emulation should stop. This will mean that for any given sequence of
events all the emulation operations are completed deterministically
regardless of when the stop request was received.
2020-05-05 08:36:50 +08:00
Dominik Maier 625399774c
X64 base regs (#1166)
* x86: setup FS & GS base

* Fixed base register writes for x64, removed then for x16/x32 (the don't exist there?)

* FS reg comes before GS so the base regs do so, too

* added shebang to const_generator.py

* Added base regs to and added 'all' support to const_generator

Co-authored-by: naq <aquynh@gmail.com>
2020-05-05 08:34:51 +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
meta ba74552199 Expose different 32-bit ARM CPU models to users via UC_MODE flags (#1165) 2019-10-26 05:01:00 +08:00
Azertinv 07f94ad1fc Added an invalid instruction hook (#1132)
* first draft for an invalid instruction hook

* Fixed documentation on return value of invalid insn hook
2019-09-23 01:53:06 +08:00
Chen Huitao 60896de9f4 add CMakeList.txt. build windows binary by using vs2019. (#1134)
* add CMakeList.txt. build windows binary by using vs2019.

* remove macro redefinition warning.

* add nmake.bat.

* update CMakeLists.txt. build successfully on Ubuntu-1804-amd64.

* add CMakeList.txt. build windows binary by using vs2019.

* remove macro redefinition warning.

* add nmake.bat.

* update CMakeLists.txt. build successfully on Ubuntu-1804-amd64.

* Add build specific arch option.

* fix old MSVC inline and mipsel macro.

* add install target and option of embeded MSVCRT lib.

* add cmake.sh and document.

* add xwings and chenhuitao as programmer.

* fix COMPILE-CMAKE. rename txt to md.
2019-09-08 16:42:43 +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
kj.xwings.l 24f55a7973 Removed hardcoded CP0C3_ULRI (#1098)
* activate CP0C3_ULRI for CONFIG3, mips

* updated with mips patches

* updated with mips patches

* remove hardcoded config3

* git ignore vscode

* fix spacing issue and turn on floating point
2019-07-06 17:53:02 +08:00
yhql 3185128031 Add ARM MSP, PSP and CONTROL register access (#1071)
Necessary for NVIC exception emulation from user.
2019-03-07 08:37:27 +08:00
cfrantz 6c319941a5 Add support for the ARM IPSR register. (#1067)
1. Create an enum name for the IPSR register.
2. Implement read and write of the IPSR via the xpsr helper functions.

Fixes #1065
2019-02-28 09:55:27 +08:00
dmarxn 256e7782ce Added MXCSR register, fixed writing to FPUCW. (#1059)
* Added MXCSR register for reading and writing

* Changed writing for fpucw register, now the qemu rounding status is updated as well
2019-02-15 12:59:49 +08:00
Tasuku SUENAGA a.k.a. gunyarakun da5f2fc883 Fix wrong register aliases on arm64 (#922) 2017-12-20 22:09:38 +08:00
Nguyen Anh Quynh e6c27cfbd5 LGPL2 for all header files under include/unicorn/ 2017-12-16 10:08:42 +08: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 14222bd5f0 Update UC_HOOK_MEM_VALID (#837)
* Update UC_HOOK_MEM_VALID

UC_HOOK_MEM_READ fires before handlers for invalid memory reads, so UC_HOOK_MEM_VALID would technically also be receiving invalid memory reads. Switching to UC_HOOK_MEM_READ_AFTER ensures that only actually valid reads are hooked

* Removed macro change, added comment

Removed the macro change, but added a clarifying comment. May submit a future PR with a new macro added

* Update unicorn.h

will -> may

* Update unicorn.h
2017-05-18 08:12:46 +07:00
misson20000 014ccfb94a Aarch64 add thread registers (#834)
* add thread registers to AArch64

* update bindings to add AArch64 thread registers

* fix indentation for register read/write switch-case in unicorn_aarch64.c
2017-05-14 14:42:49 +07:00
bulaza 476553223b Fixing issues with const_generator.py (#832) 2017-05-14 00:16:48 +07: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
bulaza e95edd37f3 Update unicorn.h (#821)
Further clarifying the comments I PRed last week.
2017-05-06 22:32:00 +08:00
Ryan Hileman 187b470245 add arm64 CPACR_EL1 register support (#814) 2017-05-02 14:51:19 +08:00
bulaza c09a52e803 Update comments on UC_MEM_*_UNMAPPED (#811)
Updated the comment on UC_MEM_*_UNMAPPED to clarify what happens if "true" is returned
2017-04-27 09:29:01 +08:00
bulaza f6908f03a9 Updated uc_close comment to clarify usage (#805) 2017-04-24 23:55:18 +08:00
Nguyen Anh Quynh dd07ae607c bump extra version to 2 2017-04-21 15:30:40 +08:00
Nguyen Anh Quynh e917c9de10 Merge branch 'master' into msvc2 2017-04-21 01:17:00 +08:00
Nguyen Anh Quynh 5dbc640b9a bump UC_VERSION_EXTRA to 1 2017-04-20 14:14:24 +08:00
Nguyen Anh Quynh 3b6779479e cleanup uc_priv.h 2017-03-30 15:59:13 +08:00
Nguyen Anh Quynh 094ca80092 fix conflicts 2017-03-30 12:23:24 +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
Nguyen Anh Quynh f4325f8c4e bindings: update to support X86 MSR id 2017-02-24 21:51:01 +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
fG! d5870ff47d Update unicorn.h (#753)
Make it clear that only very few instructions can be hooked
2017-02-21 10:22:17 +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
Nguyen Anh Quynh b616115df1 update ChangeLog 2017-01-25 12:00:18 +08:00
Parker Thompson 053ecd7bf4 Added ARM coproc registers (#684)
* Added ARM coproc registers

* Added regression test for vfp
2017-01-25 11:56:19 +08:00
xorstream 2a941e3efb Finalise MSVC port (#739)
* Fix for MIPS issue.

* Sparc support added.

* M68K support added.

* Arm support ported.

* Fix issue with VS2015 shlobj.h file

* Arm issue fix.

* Finalise MSVC port.
2017-01-24 22:09:33 +08:00
xorstream 8e45102b43 Arm support ported. (#736)
* Fix for MIPS issue.

* Sparc support added.

* M68K support added.

* Arm support ported.

* Fix issue with VS2015 shlobj.h file
2017-01-23 23:30:57 +08:00
Nguyen Anh Quynh a0f7b526bd cleanup include/unicorn/*.h 2017-01-22 06:02:07 +08:00
xorstream 9fac29d154 Changed some MSVC compatibility defines based on MSVC version. (#724) 2017-01-21 20:21:27 +08:00
Nguyen Anh Quynh e98a396e68 fix include path of platform.h 2017-01-21 11:31:29 +08:00
Nguyen Anh Quynh 330e7cb87b cleanup platform.h 2017-01-21 11:02:59 +08:00
xorstream 770c5616e2 Automated leading tab to spaces conversion. 2017-01-21 12:28:22 +11:00
xorstream 429bfca48e Fixes for MSVC native support to still work with GCC/GNU. 2017-01-21 01:07:10 +11:00
xorstream fac6a66860 platform.h move #3 2017-01-21 00:13:21 +11:00
xorstream f4b375c651 platform.h moved. 2017-01-21 00:03:50 +11:00