forked from BynBang/OpenPrestige
UPDATE
Add Linux and macOS support, batch class transformations with a disk cache, and add cross-platform release packaging. Also improve runtime namespace handling, keybind editing, and startup behavior.
This commit is contained in:
1 parent
910a126f04
commit
38ff6d387c
29 files changed
+2234
-491
No files matched your search
@@ -10,14 +10,18 @@ mod worker;
|
||||
|
||||
use std::ffi::c_void;
|
||||
|
||||
#[cfg(windows)]
|
||||
const DLL_PROCESS_ATTACH: u32 = 1;
|
||||
|
||||
#[cfg(windows)]
|
||||
extern "system" {
|
||||
fn DisableThreadLibraryCalls(module: *mut c_void) -> i32;
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
pub(crate) static mut MODULE: *mut c_void = std::ptr::null_mut();
|
||||
|
||||
#[cfg(windows)]
|
||||
#[no_mangle]
|
||||
pub extern "system" fn DllMain(module: *mut c_void, reason: u32, _reserved: *mut c_void) -> i32 {
|
||||
if reason == DLL_PROCESS_ATTACH {
|
||||
@@ -30,3 +34,30 @@ pub extern "system" fn DllMain(module: *mut c_void, reason: u32, _reserved: *mut
|
||||
}
|
||||
1
|
||||
}
|
||||
|
||||
/// The JavaVM handed to Agent_OnAttach / Agent_OnLoad by the JVM (unix); read by the worker.
|
||||
#[cfg(unix)]
|
||||
pub(crate) static VM: std::sync::atomic::AtomicPtr<c_void> = std::sync::atomic::AtomicPtr::new(std::ptr::null_mut());
|
||||
|
||||
#[cfg(unix)]
|
||||
fn start_worker(vm: *mut c_void) -> i32 {
|
||||
VM.store(vm, std::sync::atomic::Ordering::SeqCst);
|
||||
match std::thread::Builder::new().name("prestige-loader".into()).spawn(worker::run) {
|
||||
Ok(_) => 0,
|
||||
Err(_) => -1,
|
||||
}
|
||||
}
|
||||
|
||||
/// Called by HotSpot when the library is loaded through the attach protocol (JVMTI.agent_load).
|
||||
#[cfg(unix)]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Agent_OnAttach(vm: *mut c_void, _options: *mut std::ffi::c_char, _reserved: *mut c_void) -> i32 {
|
||||
start_worker(vm)
|
||||
}
|
||||
|
||||
/// Called by the JVM when the library is given as -agentpath at start-up.
|
||||
#[cfg(unix)]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Agent_OnLoad(vm: *mut c_void, _options: *mut std::ffi::c_char, _reserved: *mut c_void) -> i32 {
|
||||
start_worker(vm)
|
||||
}
|
||||
Reference in new issue
Block a user