Jssembly is a library that allows you to execute native assembly from Java.

Related tags

Native jssembly
Overview

jssembly

Jssembly is a library that allows you to execute native assembly from Java via a JNI bridge. The goal is to provide wrappers and parsers for Windows/*NIX/OSX/Android. Most of the work currently consists of writing ANTLR parsers for

  • x86 assembly
  • amd64 assembly
  • ARMv7/v8 assembly

However, with great power comes great responsibility.

WARNING: Jssembly can (and will) crash your VM if you don't know what you're doing. The current pre-alpha state is in no way meant to be used in production code. You have been warned.

Usage

Jssembly emulates __asm syntax found in Visual Studio or GCC in Java. Currently, a few proofs of concept work on Android and Windows x64 systems. x84 and *NIX support is currently in development.

Jssembly jsm = new Jssembly();

Blocks

Jssembly uses executable code "blocks" as its primary invokable piece of native code. There are two types of blocks: raw and assembly. Raw blocks contain opcodes whereas assembly blocks contain (you guessed it) platform-specific assembly. For example, here is a raw block called test1:

jsm.define("test1", new Block(raw) {{
	__asm(
		0x31, 0xC0, 0x48, 0xFF, 0xC0 ... 0xC3
	);
}});

And here is an x64 assembly block called test2:

jsm.define("test2", new Block(x64) {{
	__asm("nop");
	__asm("mov rax, rdi")
	__asm("ret");
}});

We invoke test1 by calling jsm.get("test1").invoke(argument1, argument2 ... argN) or we can invoke a block in-place like so:

jsm.define("test3", new Block(x64) {{
	__asm(
		"nop",  // no-op
		"ret"   // return
	);
}}).invoke();

Here we see yet another flavor of the ___asm syntax. Note that the parser is called when the Block constructor is called. In case of a syntax error, we should see an exception when a new definition occurs.

Arguments

We can also pass a variable number of arguments to the invoke() method. These arguments can be accessed through platform-specific assembly.

Return types

In the works, although invoke() currently returns void.

Invocation woes

Great care must be taken with raw blocks as no viable run-time checks can be done on them. Make sure that the right raw code is executed on the right platform -- otherwise, the VM will crash. Naive checks are in the works for assembly blocks.

License

MIT.

You might also like...

Log analyser / visualiser for Java HotSpot JIT compiler. Inspect inlining decisions, hot methods, bytecode, and assembly. View results in the JavaFX user interface.

JITWatch Log analyser and visualiser for the HotSpot JIT compiler. Video introduction to JITWatch video Slides from my LJC lightning talk on JITWatch

Jan 3, 2023

With react-native-update-in-app library you can easily implement in-app updates in your React Native app using CDN or any other file server

React Native In-App update With react-native-update-in-app library you can easily implement in-app updates in your React Native app using CDN or any o

Dec 21, 2022

FundurASM - A Assembly-like language interpreter

FundurASM - A Assembly-like language interpreter This interpreter was written by LordBurtz Licensed under GPLv2, all rights reserved Running it Downlo

Jan 31, 2022

A short assembly macro-processor script to simulate the process and show the different stages

A short assembly macro-processor script to simulate the process and show the different stages

Mar 9, 2022

Spring Native provides beta support for compiling Spring applications to native executables using GraalVM native-image compiler.

Spring Native provides beta support for compiling Spring applications to native executables using GraalVM native-image compiler.

Spring Native provides beta support for compiling Spring applications to native executables using GraalVM native-image compiler.

Jan 6, 2023

A Camunda Process Engine Plugin to execute Clojure Functions from Activities

camunda-clojure-plugin A Camunda Process Engine Plugin to execute Clojure Functions as Delegates Why do we need this? While Camunda is tightly integra

Oct 11, 2022

Cadence is a distributed, scalable, durable, and highly available orchestration engine to execute asynchronous long-running business logic in a scalable and resilient way.

Cadence This repo contains the source code of the Cadence server and other tooling including CLI, schema tools, bench and canary. You can implement yo

Jan 4, 2023

httpx is a CLI to execute requests from JetBrains Http File.

httpx: CLI for run http file httpx is a CLI to execute requests from JetBrains Http File. How to use? Create index.http file with following code, then

Dec 29, 2022

Google Mr4c GNU Lesser 3 Google Mr4c MR4C is an implementation framework that allows you to run native code within the Hadoop execution framework. License: GNU Lesser 3, .

Introduction to the MR4C repo About MR4C MR4C is an implementation framework that allows you to run native code within the Hadoop execution framework.

Dec 9, 2022

Allows you to duplicate items via the server kicking you. (Credits to TheTroll2001)

CloseConnection Dupe (1.12.2-1.17.1) Allows you to duplicate items via the server kicking you. (Credits to TheTroll2001) Usage Type .dupe method pa

Nov 15, 2022

A Pomodoro Timer that allows you to collect Pokemon as you work.

Pomodoro: The Pokémon Collecting Game! A fun take on the Pomodoro Technique So, what does this application do? This application utilizes the famous Po

Jan 29, 2022

React native wrapper for Jitsi Meet SDK Library that rely on the native view (Activity / ViewController)

react-native-jitsi-meet-sdk React native wrapper for Jitsi Meet SDK Library. This Library implements the Jitsi SDK with a native activity on the Andro

May 2, 2022

JPassport works like Java Native Access (JNA) but uses the Foreign Linker API instead of JNI. Similar to JNA, you declare a Java interface that is bound to the external C library using method names.

JPassport works like Java Native Access (JNA) but uses the Foreign Linker API instead of JNI. Similar to JNA, you declare a Java interface that is bound to the external C library using method names.

JPassport works like Java Native Access (JNA) but uses the Foreign Linker API instead of JNI. Similar to JNA, you declare a Java interface t

Dec 30, 2022

Jansi is a small java library that allows you to use ANSI escape sequences to format your console output which works even on windows.

Description Jansi is a small java library that allows you to use ANSI escape codes to format your console output which works even on Windows. It also

Dec 28, 2022

JCLR (JavaColor) is a library that allows you to write colored text in your terminal. It use the ANSI color system. Go check the README.md file to see how to use it.

JCLR (JavaColor) is a library that allows you to write colored text in your terminal. It use the ANSI color system. Go check the README.md file to see how to use it.

JCLR JCLR (JavaColor) is a library that allows you to write colored text in your terminal. It use the ANSI color system. To start using it, go to the

Aug 21, 2021

An Android library that allows you to easily create applications with slide-in menus.

An Android library that allows you to easily create applications with slide-in menus. You may use it in your Android apps provided that you cite this project and include the license in your app. Thanks!

Jan 4, 2023

Scaffolding is a library for Minestom that allows you to load and place schematics.

This library is very early in development and has too many bugs to count. For your own safety, you should not use it in a production environment.

Nov 29, 2022

Android library that allows you to determine your location in a few of lines!

Android library that allows you to determine your location in a few of lines!

locsimple Android library that allows you to determine your location in some lines! Benefits: automatic processing of permissions processing of enabli

Aug 31, 2022
Comments
  • Joining jssembly

    Joining jssembly

    Hi, just wondering if this project's still alive since I'm looking for a project to contribute to in my limited free time. Noticed it hasn't been committed to in the past couple of months. Let me know if it's still being worked on.

    All the best, Max.

    opened by maxamel 2
  • Fix broken headings in Markdown files

    Fix broken headings in Markdown files

    GitHub changed the way Markdown headings are parsed, so this change fixes it.

    See bryant1410/readmesfix for more information.

    Tackles bryant1410/readmesfix#1

    opened by bryant1410 0
  • Changed 'bytecode' to 'opcodes' in description of raw blocks

    Changed 'bytecode' to 'opcodes' in description of raw blocks

    See http://en.wikipedia.org/wiki/Machine_code#Relationship_to_bytecode; bytecode is what e.g. Java class files contain, while opcodes (machine code) are what an assembler produces. Opcodes hence might be a more suitable term than bytecode.

    opened by logicchains 0
  • Compile/Run

    Compile/Run

    • dependent thirdparty lib Antlr v3.5.2 runtime .jar necessary to compile
    • delete: jni/src/com_polyfx_jssembly_Jssembly_Function.h
    • in core/src/com/polyfx/jssembly/Jssembly.java, static { System.loadLibrary("Jssembly"); } is cross-platform
    • only x64 is implemented via ANTLR, although unit test in Main.java fail catastrophically, producing core dump
    • raw is fine, even works for shellcode 👍

    compile

    find -name "*.java" -type f >src.txt
    mkdir -p bin
    javac -cp ".:lib/*" -d bin @src.txt
    rm -f src.txt
    javah -cp bin -jni -d ../jni/src com.polyfx.jssembly.Jssembly
    gcc-8 -I"$JAVA_HOME/include" -I"$JAVA_HOME/include/darwin/" -o bin/libjssembly.jnilib -shared src/Jssembly.c
    javac -cp ".:core/bin:core/lib/*" Main.java
    

    run: java -cp ".:core/bin:core/lib/*" -Djava.library.path=jni/bin Main

    opened by evandrix 0
Owner
David Titarenco
Startup addict, Silicon Beach engineer, digital nomad. Early contributor to Google Go.
David Titarenco
The missing bridge between Java and native C++

JavaCPP Commercial support: Introduction JavaCPP provides efficient access to native C++ inside Java, not unlike the way some C/C++ compilers interact

Bytedeco 4k Jan 8, 2023
Java Native Access

Java Native Access (JNA) The definitive JNA reference (including an overview and usage details) is in the JavaDoc. Please read the overview. Questions

Java Native Access 7.6k Jan 1, 2023
Compile Java byte-code to native CPU's.

Java Grinder Compile Java bytecode to microcontroller assembly. Currently supporting MSP430, dsPIC, 6502/6510, 68000, MIPS, TMS9900, and Z80 with plat

Michael Kohn 396 Dec 23, 2022
Java Abstracted Foreign Function Layer

jnr-ffi jnr-ffi is a Java library for loading native libraries without writing JNI code by hand, or using tools such as SWIG. Example package hellowor

The Java Native Runtime Project 1.1k Dec 31, 2022
Java Bindings for V8

J2V8 J2V8 is a set of Java bindings for V8. J2V8 focuses on performance and tight integration with V8. It also takes a 'primitive first' approach, mea

EclipseSource 2.3k Jan 4, 2023
Low-overhead, non-blocking I/O, external Process implementation for Java

NuProcess NuProcess is proud to power Facebook's Buck build. A low-overhead, non-blocking I/O, external Process execution implementation for Java. It

Brett Wooldridge 644 Dec 29, 2022
BukkitRCEElevator - Allows you to execute Linux commands on panels like Multicraft.

BukkitRCEElevator A plugin that lets you execute linux commands thru Minecraft console. This only works on panels that do not use docker like Multicra

Pace 2 Dec 27, 2021
MixStack lets you connects Flutter smoothly with Native pages, supports things like Multiple Tab Embeded Flutter View, Dynamic tab changing, and more. You can enjoy a smooth transition from legacy native code to Flutter with it.

中文 README MixStack MixStack lets you connects Flutter smoothly with Native pages, supports things like Multiple Tab Embeded Flutter View, Dynamic tab

Yuewen Engineering 80 Dec 19, 2022
Log analyser / visualiser for Java HotSpot JIT compiler. Inspect inlining decisions, hot methods, bytecode, and assembly. View results in the JavaFX user interface.

JITWatch Log analyser and visualiser for the HotSpot JIT compiler. Video introduction to JITWatch video Slides from my LJC lightning talk on JITWatch

AdoptOpenJDK 2.8k Jan 3, 2023