Commit Graph

152 Commits

Author SHA1 Message Date
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
Robert Xiao
f55e7834ba Replace javah by javac -h, only write new constant files if something changes.
The const_generator changes help to ensure that e.g. Java rebuilds don't keep
rebuilding everything.
2023-07-06 20:12:36 -07:00
Robert Xiao
763d04127c Switch Java bindings to reg2 API.
This is mostly an extra safety measure; the front-end Unicorn.java should always
be sending an appropriately-sized buffer.
2023-06-29 16:37:42 -07:00
Robert Xiao
dfdc8e7e8e Switch to Maven to build the Java bits.
Maven is now used to update the constants, build the Java code, call make to
build the native library, and run all the tests. I have removed the "install"
and "uninstall" targets; instead, the expectation will be that the JNI library
will be placed somewhere on java.library.path and the JAR file will be used as
usual (e.g. in a downstream Maven project, or placed on the classpath of your
project).

Since Maven is now running our tests, this eliminates the need to bundle test
dependencies in `testdep`, and makes the project structured more like a typical
Java project.
2023-06-29 16:08:18 -07:00
Robert Xiao
2198ea4f69 Add comment about unicorn_Unicorn.h to the .c file 2023-06-17 14:34:25 -07:00
Robert Xiao
d9407c9041 Add a link to the relevant issue for ARM PAC handling 2023-06-17 14:22:56 -07:00
Robert Xiao
05f6fb9bf3 Properly check return value of makeHookWrapper 2023-06-17 14:19:10 -07:00
Robert Xiao
98f70d3213 Port sample_batch_reg.c to Java, incidentally finding a bug in the generic register implementation. 2023-06-17 14:19:10 -07:00
Robert Xiao
edd80ddeda Port sample_x86_32_gdt_and_seg_regs over to Sample_x86_mmr 2023-06-17 14:19:10 -07:00
Robert Xiao
4f563490e2 Update Java samples to match C samples.
Also add all of the samples as Java tests, referencing the output of the C
samples.
2023-06-17 14:19:10 -07:00
Robert Xiao
3739c7e3e0 Write some code to test out ARM64 CP register handling. 2023-06-17 14:19:10 -07:00
Robert Xiao
910bb572d3 Accept unsigned BigIntegers, and produce unsigned BigIntegers by default.
Unsigned BigIntegers are a bit more ergonomic, particularly for bitwise
operations. reg_write still accepts negative BigIntegers (and will automatically
sign extend them), but reg_read will produce unsigned BigIntegers by default.
2023-06-17 14:19:10 -07:00
Robert Xiao
d4df61b4c5 Refactor tests and add a few more 2023-06-17 14:19:10 -07:00
Robert Xiao
77d4a1d8b1 Fix definition of uc_version 2023-06-17 14:19:10 -07:00
Robert Xiao
32e638dcf4 Add more deprecated APIs for backwards compat 2023-06-17 14:19:10 -07:00
Robert Xiao
48870c4cc3 Reintroduce hook_del(Hook), since it seems useful.
This also improves backwards compatibility a bit.
2023-06-17 14:19:10 -07:00
Robert Xiao
e787f49d21 Use an incrementing handle instead of returning a raw pointer to the user. 2023-06-17 14:19:10 -07:00
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
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
Eric Poole
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 <mio@lazym.io>
2022-04-29 23:11:34 +02:00
lazymio
cdae57fb3d
Generate bindings 2022-04-26 01:17:58 +02:00
JeroenRobbenFirmalyzer1
36011e145c
Add Java binding for ctl set_cpu_model (#1600)
Add Java binding for ctl set_cpu_model
2022-04-24 13:29:48 +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