106 Commits
Author SHA1 Message Date
unknown-1-0 09bd8e4f11 Regenerate constants for bindings (#2371)
Signed-off-by: Andrey Polivoda <[email protected]>
2026-08-28 17:01:46 +08:00
Richard Patel 1b3e80bebe Expose x86 XCR0 register (#2299)
Expose the XCR0 register for x86 to allow users to control XSAVE
behavior. This register is a bit odd. It's the only one of its type
(extended control register), and usually accessed via XGETBV/XSETBV.
2026-05-12 14:54:06 +08:00
Daniel Roethlisberger 0e42ecd47d arm64: Add PAuth helpers for signing, stripping and authentication of pointers (#2262)
* Make __ctl_wr work for an arbitrary number of parameters

* Rename test_arm64_v8_pac to test_arm64_v8_cas as it tests CAS not PAC

* Add PAuth helpers for signing, stripping and authentication of pointers

Add UC_CTL_PAUTH_SIGN, UC_CTL_PAUTH_STRIP and UC_CTL_PAUTH_AUTH as an
architecture-independent interface to pointer authentication operations
without having to execute instructions on the virtual CPU.  This is
useful in many scenarios, for instance when rebasing signed pointers as
part of loading code that runs with PAuth.

The C interfaces are covered by a unit test.  The Python interfaces have
been tested in a real world project.

* Fifth PR, add myself to CREDITS.TXT

* Remove static_assert for better portability

* Make test_arm64 slightly more robust

* Add test for vanilla PAuth without helpers and refactor tests

* Typecast arguments to PAuth uc_ctl_* macros

Fixes issue where literal arguments would be written to variable
argument memory as an int, but subsequently read from va_list as a
uint64_t, which on some platforms might be a different size and lead to
corruption of later arguments, breaking PAuth helper functionality or
causing segmentation faults.

* Clean up PAuth test init code for reuse by future tests
2026-01-17 23:34:14 +08:00
appleflyer 260e551e23 basic arm32 instruction hooking (#2242)
* feat: add basic arm32 support for instruction hooking with the wfi instruction

Signed-off-by: appleflyerv3 <[email protected]>

* feat: python bindings for ARM32 instruction hooking

Signed-off-by: appleflyerv3 <[email protected]>

* arm: add ARM_INS_* constants to all language bindings

Signed-off-by: appleflyerv3 <[email protected]>

* fix: break from stop_request, do not return

Signed-off-by: appleflyerv3 <[email protected]>

* feat: add unit tests for ARM32 instruction hooking

Signed-off-by: appleflyerv3 <[email protected]>

* ARM32 and ARM64 share the same wfi helper. therefore, implement the wfi insn hook on ARM64 too

Signed-off-by: appleflyerv3 <[email protected]>

* add arm64 wfi insn hook constant

Signed-off-by: appleflyerv3 <[email protected]>

* hack: seperate wfi calling and emu reached shutdown?

Signed-off-by: appleflyerv3 <[email protected]>

* unit tests for ARM64 wfi instr hooking

Signed-off-by: appleflyerv3 <[email protected]>

* change order of arm64 wfi hook and rename arm64 mrs test from test_arm64_mrs_hook -> test_arm64_hook_insn_mrs

Signed-off-by: appleflyerv3 <[email protected]>

* Revert "hack: seperate wfi calling and emu reached shutdown?"

This reverts commit 02d00fd509.

---------

Signed-off-by: appleflyerv3 <[email protected]>
2025-09-29 13:25:40 +08:00
mio 1730bd8d4c bump consts 2025-09-09 15:13:21 +08:00
mio 3620d70677 bump 2.1.4 2025-09-09 15:13:07 +08:00
lazymio e867b08c66 S390x registers (#2167)
* support more s390x registers

* update consts
2025-04-16 10:13:29 +08:00
Richard Liebigandr0b0t 455aae2a8e Remove the size limit for memory read and write (revamped) (#2144)
* modify uc_priv.h to use 64 bit hwaddr type for length for uc_write_mem_t and uc_read_mem_t

* propogate 64 bit address support to memory function inside unicorn.h

* modify physical memory functions to ensure 64 bit support for size parameters

* apply  uint64_t size handling inside the memory handling main functions

* remove INT_MAX size check as we now use a 64 bit address

* add @secretnonempty unit test for large memory addresses to avoid regression

* replace size_t in python3 bindings with u64

* adjust rust bindings

* use format.sh script to improve formatting

* small adjustments to java bindings, because jlong type is sometimes already used

* adjust dotnet bindings to reflect new type sizes

* adjust pascal bindings

* adjust ruby bindings

* adjust vb6 bindings

* adjust zig bindings for 64 bit size support

* fix build.zig.zon for newer zig versions

* add haskell binding support for 64 bit sizes

* use mlugg/setup-zig instead of goto-bus-stop/setup-zig github action to get access to current zig releases

* use uint64_t instead of size_t for uc_mem_unmap

* add whitespace between functions to preserver formatting

* add precompiler check for android and abort execution of testcase to avoid infinite low memory killer loop

* downgrade zig version to 0.14.0 again to ensure that pipeline can run through

* adjust rust mmio_unwrap type to use u64

* change ffi size type of uc_mem_map_ptr into u64

* add warning to rust slicing

* return read_mem_as_vec to earlier state, leave usize as argument because there cannot be larger vec![] anyway

* adjust regions inside MmioCallbackScope to use u64 for region sizes

* adjust regions inside MmioCallbackScope to use u64 for region sizes inside search vec

* finalize dotnet bindings inside IBinding.fs

* fix typo

* adjust types inside Unicorn.fs

* finalize type wrangling inside F# bindings, setting MemRead and MemWrite to correct types

* fix missing bracket inside bindings/rust/src/lib.rs

* replace ffi interface to hook interface inside rust lib

* fix testcases to use u64 for longer references

Co-authored-by: r0b0t <[email protected]>
2025-04-15 11:42:40 +08:00
Amaan Qureshi 3a7bde03b8 feat(arm): add an ESR register (#2155)
This allows users to read/write from the ARM syndrome value like in
AArch64.
2025-04-12 21:46:37 +08:00
Levente Polyak 143b352775 bindings: ruby: fix version identifier to 2.1.3 (#2142) 2025-04-05 22:17:04 +08:00
Levente Polyak 1aad423fe5 bindings: ruby: fix unexpected uc_query result pointer type (#1962)
uc_query expects a size_t *, while we are passing uc_arch *. This has
been working for a while as gcc just warned about this, however with
latest gcc this changed into an error:

unicorn.c:122:34: error: passing argument 3 of ‘uc_query’ from incompatible pointer type [-Wincompatible-pointer-types]
  206 |     uc_query(_uc, UC_QUERY_ARCH, &arch);
unicorn.h:689:60: note: expected ‘size_t *’ {aka ‘long unsigned int *’} but argument is of type ‘uc_arch *’
  689 | uc_err uc_query(uc_engine *uc, uc_query_type type, size_t *result);

Fix this issue by querying the result into a size_t and later downcast
the result into an uc_arch enum.
2025-04-05 06:05:43 +08:00
mio df75effba3 Generate m68k consts 2025-03-10 11:32:14 +08:00
mio 8dcaa33c66 Bump 2.1.3 2025-02-17 20:26:31 +08:00
mio b8e19b6eef CI(release): Bump 2.1.2 2025-02-10 22:11:12 +08:00
Martin Atkins 7d8fe2ab11 riscv: Expose privilege level as pseudo-register PRIV (#1989)
Unlike some other architectures, RISC-V does not expose the current
privilege mode in any architecturally-defined register. That is intentional
to make it easier to implement virtualization in software, but a Unicorn
caller operates outside of the emulated hart and so it can and should be
able to observe and change the current privilege mode in order to properly
emulate certain behaviors of a real CPU.

The current privilege level is therefore now exposed as a new
pseudo-register using the name "priv", which matches the name of the
virtual register used by RISC-V's debug extension to allow the debugger
to read and change the privilege mode while the hart is halted. Unicorn's
use of it is conceptually similar to a debugger.

The bit encoding of this register is the same as specified in RISC-V Debug
Specification v1.0-rc3 Section 4.10.1. It's defined as a "virtual"
register exposing a subset of fields from the dcsr register, although here
it's implemented directly inside the Unicorn code because QEMU doesn't
currently have explicit support for the CSRs from the debug specification.
If it supports "dcsr" in a future release then this implementation could
change to wrap reading and writing that CSR and then projecting the "prv"
and "v" bitfields into the correct locations for the virtual register.
2024-11-11 21:09:45 +08:00
mio 867770c7ef Tag and release 2.1.1 2024-09-26 18:44:51 +08:00
mio 67f08b1c27 Bump version and generate bindings 2024-09-21 23:00:57 +08:00
Mario Haustein 5983b399d8 use full prototypes for functions without parameters 2023-10-08 13:39:13 +02:00
Mio 9c01d23ed3 Update bindings const 2023-03-28 14:20:55 +02:00
Nguyen Anh Quynh 7ca4769f2a bindings: update version to 2.0.2 2023-02-04 13:01:33 +08:00
mio db9ddabf9e Update bindings 2022-11-01 10:06:34 +01:00
TSR Berry 7b8b75b9f8 bindings: Adjust consts 2022-10-14 17:33:07 +02:00
TSR Berry c787fa8e64 bindings: Update Arm64 consts 2022-10-14 15:18:16 +02:00
Nguyen Anh Quynh 1ec1352995 bindings: update consts 2022-07-07 23:48:01 +08:00
Mio af1c661a12 Update bindings 2022-07-06 09:33:45 +08:00
Lowly Worm 1d13a25320 check pkg-config for unicorn libraries
allow for non-standard install locations of unicorn engine
2022-05-08 19:17:36 -04:00
Bet4 dafdcd3f06 Fix outdated version 2022-05-04 21:31:53 +08:00
Eric Pooleandlazymio cfee2139a0 TriCore Support (#1568)
* TriCore Support

python sample

* Update sample_tricore.py

Correct attribution

* Update sample_tricore.py

Fixed byte code to execute properly.

* Update sample_tricore.py

Removed testing artifact

* Added tricore msvc config-file.h

* Added STATIC to tricore config and added helper methods to symbol file generation.

* Update op_helper.c

Use built in crc32

* Fix tricore samples and small code blocks are now handled properly

* Add CPU types

* Generate bindings

* Format code

Co-authored-by: lazymio <[email protected]>
2022-04-29 23:11:34 +02:00
lazymio cdae57fb3d Generate bindings 2022-04-26 01:17:58 +02:00
lazymio 185a6fec9e Bump bindings version to 2.0.0-rc7 2022-04-17 16:48:12 +02:00
lazymio 5a79d7879c Generate bindings 2022-04-16 17:50:32 +02:00
Ilya Leoshkevich 28c4c665f0 Add "holes" to where the removed x86 registers used to be
A number of x86 registers were removed for #1440, causing a change in
numbering for many other registers. This is causing inconveniences at
the moment, e.g. it's not possible to use the Unicorn2 shared library
as a drop-in replacement for the Unicorn1 one.

Restore the old numbering.

Fixes #1492.
2022-03-22 11:31:58 +01:00
lazymio dd96cab9bf Update bindings 2022-02-27 15:28:32 +01:00
Bet4 504b31b928 Update constants of bindings 2022-02-19 21:24:40 +08:00
lazymio 3ed9dbda13 Update bindings 2022-02-15 22:08:27 +01:00
lazymio c10639fd46 Bump version in bindings 2022-02-13 11:03:57 +01:00
lazymio 89a1da9a33 Update bindings 2022-02-11 22:42:31 +01:00
mio f57467e7ed Generate bindings 2022-01-19 20:10:09 +01:00
lazymio 459a595a98 Merge branch 'dev' into s390x
Mostly for bindings update.
2022-01-15 20:56:39 +01:00
lazymio dfb0446137 Update bindings 2022-01-15 20:56:24 +01:00
lazymio 71f044ca50 Merge branch 'dev' into s390x 2022-01-10 15:17:42 +01:00
lazymio c671efe798 Update bindings 2022-01-05 22:00:59 +01:00
lazymio c4b4189857 Update bindings 2022-01-04 21:12:52 +01:00
Nguyen Anh Quynh 6813e4a042 bindings: update const_generator.py, and update all binding constants 2022-01-01 09:24:28 +08:00
lazymio b9c0066a47 Format and naming 2021-11-04 20:04:57 +01:00
lazymio db90f39ac6 Generate bindings 2021-11-04 20:01:19 +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 9e1443013b Fix gen_const 2021-10-26 13:10:59 +02:00
lazymio e695686c15 Remove AFL Integration by reverting 2021-10-26 11:22:21 +02:00
lazymio f08b7d6b5b Make gen_const work and updates constants 2021-10-25 00:57:32 +02:00