Go to file
Robert Xiao aa430587cc Rewrite the Java bindings.
This brings the Java API up to par with Python feature-wise and substantially
simplifies the hook implementation, enabling proper bounds-checked hooks.

The rewrite strives for compatibility with the previous API, but there are some
breaking changes. It is possible to push closer to full backwards compatibility
if required, at the cost of reintroducing some of the suboptimal designs. Here
are the main points of breakage:

- ReadHook and WriteHook are gone, replaced simply by MemHook. Hooking valid
  memory accesses now requires a type parameter. This enables fetch and
  read-after hooks with a unified API and a single callback object.
- mem_read now takes an int, not a long. We are unable to allocate more than 2GB
  in a single request anyway (Java limitation).
- Instruction hooks now require specifying the instruction explicitly, instead
  of guessing based on the hook type. This is necessary to distinguish
  sysenter/syscall and ARM64 mrs/msr/sys/sysl, without excessively bloating the
  library with redundant hook types. Bounds must also be specified, to support
  bounds-checked instruction hooks.
- Reading object-type registers (any register larger than 64 bits, or registers
  with special formats) requires a second argument to reg_read. This allows us
  to provide a fast reg_read that returns a long for the common cases, while
  still supporting a more general reg_read for other registers.
- mem_map_ptr is rewritten to take a *direct* java.nio.Buffer, which enables
  many more use cases than a simple byte array, and improves performance (a
  byte array cannot really be used as a mapped buffer without GC-pinning it,
  which hurts the GC performance).
- Context handling API is redesigned to be safer and more object-oriented.

A lot of bugs are fixed with this implementation:
- Unicorn instances can be properly garbage-collected, instead of hanging around
  forever in the Unicorn.unicorns table.
- Hooks no longer fire outside of their bounds (#1164), and in fact, hook bounds
  are properly respected (previously, all hooks were just registered globally to
  all addresses).
- Hooks are substantially faster, as they are now dispatched directly via a
  single method call rather than being indirected through invokeCallbacks.
- Loading vector registers works now, rather than crashing the VM (#1539).

Several features are now enabled in the Java implementation:

- All of the current ctl_* calls are implemented.
- mmio_map is implemented.
- New virtual TLB mode is implemented.
- reading/writing Context registers is implemented.
- New hook types are added: TcgOpcodeHook, EdgeGeneratedHook,
  InvalidInstructionHook, TlbFillHook, and the instruction hooks Arm64SysHook,
  CpuidHook.
- All known special registers are supported.
2023-06-17 14:19:10 -07:00
.github/workflows Add apt update 2023-05-23 13:18:57 -07:00
bindings Rewrite the Java bindings. 2023-06-17 14:19:10 -07:00
docs Update FAQ 2023-03-28 21:16:19 +08:00
glib_compat build: Fixes for Haiku 2023-03-22 13:58:10 -05:00
include Return new UC_ERR_OVERFLOW instead of UC_ERR_NOMEM when reg buffer is too small 2023-06-16 15:30:59 -07:00
msvc Reformat code with format.sh 2023-06-16 15:23:41 -07:00
qemu Return new UC_ERR_OVERFLOW instead of UC_ERR_NOMEM when reg buffer is too small 2023-06-16 15:30:59 -07:00
samples Reformat code with format.sh 2023-06-16 15:23:41 -07:00
tests Fix RISCV test_riscv32_fp_move test 2023-06-16 15:23:43 -07:00
.clang-format Add clang-format and format code to qemu code style 2021-10-29 12:44:49 +02:00
.gitignore Add TriCore constants to Rust bindings 2022-05-11 17:29:03 +08:00
.gitmodules Change git url to https url to avoid git submodule clone error 2022-01-18 21:09:01 +01:00
AUTHORS.TXT
CMakeLists.txt add virtuall tlb 2023-03-28 13:50:11 +02:00
COPYING
COPYING.LGPL2
COPYING_GLIB
CREDITS.TXT Merge branch 'dev' into patch 2021-10-17 18:18:09 +08:00
Cargo.toml Merge branch 'dev' into zig-bindgen 2023-03-23 16:17:55 -03:00
ChangeLog Update ChangeLog 2022-11-22 21:55:02 +01:00
README.md new binding 2023-03-23 16:15:33 -03:00
SECURITY.md Update SECURITY.md 2022-10-31 12:35:37 +08:00
TODO
bundle_static.cmake Merge remote-tracking branch 'origin/dev' into mrexodia-msvc-find-lib 2022-05-03 00:08:47 +02:00
format.sh Format unicorn_arm and unicorn_aarch64 2021-11-01 10:17:58 +01:00
go.mod add rpath and go.mod 2021-11-07 20:24:50 +01:00
list.c Fix possible leak in hooks 2022-02-12 16:28:43 +01:00
mingw-w64.cmake
symbols.sh Simplify reg_read/reg_write, obtaining a perf boost. 2023-06-16 15:23:42 -07:00
uc.c Return new UC_ERR_OVERFLOW instead of UC_ERR_NOMEM when reg buffer is too small 2023-06-16 15:30:59 -07:00

README.md

Unicorn Engine

pypi downloads Fuzzing Status

Unicorn is a lightweight, multi-platform, multi-architecture CPU emulator framework, based on QEMU.

Unicorn offers some unparalleled features:

  • Multi-architecture: ARM, ARM64 (ARMv8), M68K, MIPS, PowerPC, RISCV, SPARC, S390X, TriCore and X86 (16, 32, 64-bit)
  • Clean/simple/lightweight/intuitive architecture-neutral API
  • Implemented in pure C language, with bindings for Crystal, Clojure, Visual Basic, Perl, Rust, Ruby, Python, Java, .NET, Go, Delphi/Free Pascal, Haskell, Pharo, Lua and Zig.
  • Native support for Windows & *nix (with Mac OSX, Linux, Android, *BSD & Solaris confirmed)
  • High performance via Just-In-Time compilation
  • Support for fine-grained instrumentation at various levels
  • Thread-safety by design
  • Distributed under free software license GPLv2

Further information is available at http://www.unicorn-engine.org

License

This project is released under the GPL license.

Compilation & Docs

See docs/COMPILE.md file for how to compile and install Unicorn.

More documentation is available in docs/README.md.

Contact

Contact us via mailing list, email or twitter for any questions.

Contribute

If you want to contribute, please pick up something from our Github issues.

We also maintain a list of more challenged problems in milestones for our regular release.

CREDITS.TXT records important contributors of our project.