Commit Graph

620 Commits

Author SHA1 Message Date
Robert Xiao
4764d54250 Javadoc updates 2023-06-17 14:19:10 -07:00
Robert Xiao
3fab8abca7 Restore some of the less problematic old APIs for backwards compatibility. 2023-06-17 14:19:10 -07:00
Robert Xiao
b8bd25030e Javadoc updates 2023-06-17 14:19:10 -07:00
Robert Xiao
78de584409 Switch samples to use long instead of Long for registers 2023-06-17 14:19:10 -07:00
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
Robert Xiao
8777bb6ae6 Make close() idempotent and fix Unicorn memory leak. 2023-06-17 14:19:10 -07:00
Robert Xiao
66c8965f96 Set up testing infrastructure ("make test") 2023-06-17 14:19:10 -07:00
Robert Xiao
4b471e16e9 Remove redundant Makefile 2023-06-17 14:19:10 -07:00
Robert Xiao
9cdb5cb745 Reformat Java bindings. 2023-06-17 14:17:57 -07:00
Robert Xiao
06a76e98c4 Add __repr__ to all ctypes.Structure subclasses 2023-05-10 12:58:25 -07:00
Robert Xiao
d27ca4530b Minor Python fixes.
- Match the types of UC_HOOK_CODE_CB and UC_HOOK_INSN_SYS_CB to C
- Avoid building a new namedtuple class in every call to _hook_insn_sys_cb
2023-05-07 09:08:20 -07:00
Robert Xiao
a998231a0e Fix sample_ctl.py.
Commit 640251e1aa added a size parameter to uc_hook_tcg_op_2, but this was not
reflected in the Python bindings.

Commit fbf4078d65 added a len parameter to ctl_remove_cache, but this was not
reflected in sample_ctl.py.
2023-05-07 09:08:20 -07:00
Philipp Takacs
a9f0dabc64 rust add tlb callback 2023-04-05 18:57:22 +02:00
Philipp Takacs
0729dc0312 rust update uc_ctl_flush_tlb and add uc_ctl_tlb_mode 2023-04-05 18:57:15 +02:00
Kevin Schneider
5ff654c77b add rust bindings for uc_ctl 2023-04-05 18:48:39 +02:00
Mio
0ba69d6b2f Add tlb_mode for python 2023-03-28 14:20:55 +02:00
Mio
9c01d23ed3 Update bindings const 2023-03-28 14:20:55 +02:00
Xeonacid
f2a236126f
Add missing import const in python binding (#1807) 2023-03-27 01:15:56 +08:00
Matheus C. França
e9e7e0b6cf
Merge branch 'dev' into zig-bindgen 2023-03-23 16:17:55 -03:00
Matheus C. França
c6158b8628 zig consts 2023-03-23 10:09:41 -03:00
Choongwoo Han
b4b6caf57c [dotnet] Support HookDel with native bindings call 2023-03-11 08:51:01 -08:00
Audrey Dutcher
cef7d7d0fb Use libunicorn.so.2 as fallback path 2023-03-02 19:14:25 -07:00
Choongwoo Han
03a793e934 [dotnet] Fix garbage collected hooks and wrong signature 2023-02-28 19:35:38 -08:00
Choongwoo Han
b961ebc9cb [dotnet] Set begin > end address for hooks 2023-02-26 08:41:01 -08:00
mio
9c9356da6c
Bump to 2.0.2-rc1 for csharp 2023-02-07 10:40:30 +01:00
mio
3af2775039
Merge branch 'cs_dev' into dev 2023-02-07 10:08:09 +01:00
Nguyen Anh Quynh
7ca4769f2a bindings: update version to 2.0.2 2023-02-04 13:01:33 +08:00
Nguyen Anh Quynh
6e9c6aea5f bump version to 2.0.2 2023-02-04 13:00:58 +08:00
lazymio
7e4754ad00
Merge pull request #1754 from edsky/master
Add arch list feature control in Rust
2023-01-24 21:49:18 +01:00
lazymio
a07a83ac75
Merge pull request #1767 from PhilippTakacs/rustcallback
rust only add mmio callback funktion, if callback is requested
2023-01-24 21:46:40 +01:00
Takacs, Philipp
ed9164e47a rust only add mmio callback funktion, if callback is requested
The C function uc_mmio_map() allows to add seperate callback functions
and userdata for read and write. When the callback functions are NULL
unicorn don't try to call this functions.

Previous this patch, when i.e. read_callback was None the callback was set
to mmio_read_callback_proxy and the userdata was set to NULL. On a callback
the mmio_read_callback_proxy then tried to dereference the userdata and
caused a segfault.

fixes #1762
2023-01-23 13:22:55 +01:00
Luca Gladiator
aded30f5a8 Fix insn_in_hook_proxy return type 2023-01-21 13:50:11 +01:00
Luca Gladiator
014cee5bd1 Fix Rust binding memory leak 2023-01-18 10:52:35 +01:00
Dominik Maier
549f34f098
Fix warning for ./setup.py (#1756) 2023-01-06 01:10:09 +08:00
deadash
ca74497911 Add arch list feature control in Rust
Signed-off-by: deadash <dead.ash@hotmail.com>
2022-12-29 15:13:31 +08:00
lazymio
5625102285
Merge pull request #1736 from ks0777/dev
add riscv constants to python binding module
2022-11-22 14:31:36 +01:00
mio
e9c1c17f6d
Fix endianess detection 2022-11-16 15:16:49 +01:00
Kevin Schneider
8edffe048e add riscv constants to python binding module 2022-11-14 19:59:38 +01:00
TSR Berry
2e6a888052
dotnet: Add native unicorn libraries to nuget package 2022-11-05 02:40:50 +01:00
TSR Berry
1d12e8778b
bindings: Rename dotnet project to UnicornEngine
Add a few more properties to prepare a nuget package
2022-11-02 14:46:08 +01:00
Nguyen Anh Quynh
a16f4ff911 python: update list of supported archs in setup.py 2022-11-02 00:28:40 +08:00
mio
db9ddabf9e
Update bindings 2022-11-01 10:06:34 +01:00
mio
bdd9f4fa9a
Bump version to 2.0.1 2022-11-01 10:06:22 +01:00
Nguyen Anh Quynh
8ac20e2012 python: add some more comments for samples 2022-10-31 12:37:18 +08:00
lazymio
c30a712058
Merge pull request #1723 from TSRBerry/update-dotnet
bindings: Refactor and update .NET bindings
2022-10-20 22:01:22 +02:00
TSR Berry
040146e059
dotnet: Target .NET 6.0 2022-10-20 21:31:46 +02:00
TSR Berry
0522f728b6
dotnet: Remove faulty property groups 2022-10-20 20:35:54 +02:00
TSR Berry
7b8b75b9f8
bindings: Adjust consts 2022-10-14 17:33:07 +02:00
TSR Berry
b1af49f72b
dotnet: Adapt README.md to recent changes 2022-10-14 17:16:57 +02:00
TSR Berry
ff1f0a5c1a
dotnet: Refactor .NET bindings for .NET5.0 2022-10-14 16:57:46 +02:00