From fd9d1ce342a7c36363114b251e5e27626cdee733 Mon Sep 17 00:00:00 2001 From: Andy Nguyen Date: Mon, 25 Oct 2021 09:36:45 +0200 Subject: [PATCH] Make constants public as well. --- com/bdjb/API.java | 16 ++++++++-------- com/bdjb/JIT.java | 15 ++++++++------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/com/bdjb/API.java b/com/bdjb/API.java index 3967d41..82a9129 100644 --- a/com/bdjb/API.java +++ b/com/bdjb/API.java @@ -14,16 +14,16 @@ import java.lang.reflect.Method; /** API class to access native data and execute native code. */ public final class API { - static final int INT8_SIZE = 1; - static final int INT16_SIZE = 2; - static final int INT32_SIZE = 4; - static final int INT64_SIZE = 8; + public static final int INT8_SIZE = 1; + public static final int INT16_SIZE = 2; + public static final int INT32_SIZE = 4; + public static final int INT64_SIZE = 8; - static final long RTLD_DEFAULT = -2; + public static final long RTLD_DEFAULT = -2; - static final long LIBC_MODULE_HANDLE = 0x2; - static final long LIBKERNEL_MODULE_HANDLE = 0x2001; - static final long LIBJAVA_MODULE_HANDLE = 0x4A; + public static final long LIBC_MODULE_HANDLE = 0x2; + public static final long LIBKERNEL_MODULE_HANDLE = 0x2001; + public static final long LIBJAVA_MODULE_HANDLE = 0x4A; private static final String UNSUPPORTED_DLOPEN_OPERATION_STRING = "Unsupported dlopen() operation"; diff --git a/com/bdjb/JIT.java b/com/bdjb/JIT.java index d75c30a..4a3b967 100644 --- a/com/bdjb/JIT.java +++ b/com/bdjb/JIT.java @@ -14,11 +14,10 @@ import java.io.RandomAccessFile; * executable memory. */ public final class JIT { - static final int BDJ_MODULE_HANDLE = 0; - - static final int MAX_JIT_SIZE = 24 * 1024 * 1024; // Actually max is 30MB, but let's be safe. - static final int PAGE_SIZE = 0x4000; - static final int ALIGNMENT = 0x100000; + // We actually have 32MB of code memory, but reserve 8MB for Java JIT. + public static final int MAX_CODE_SIZE = 24 * 1024 * 1024; + public static final int PAGE_SIZE = 0x4000; + public static final int ALIGNMENT = 0x100000; private static final int CHUNK_SIZE = 0x30; @@ -40,6 +39,8 @@ public final class JIT { private static final String WRITE_SYMBOL = "write"; private static final String READ_SYMBOL = "read"; + private static final int BDJ_MODULE_HANDLE = 0; + private static JIT instance; private final API api; @@ -116,9 +117,9 @@ public final class JIT { RandomAccessFile file = new RandomAccessFile(path, "r"); // TODO: Currently we just use maximum size so that the address is predictable. - long size = MAX_JIT_SIZE; + long size = MAX_CODE_SIZE; // long size = file.length() + 0x88 + ALIGNMENT - 1; - // if (size >= MAX_JIT_SIZE) { + // if (size >= MAX_CODE_SIZE) { // throw new IllegalArgumentException("Payload is too big."); // }