18 lines
540 B
Rust
18 lines
540 B
Rust
//! Process-wide state the implementations need.
|
|||
|
|
|
||
|
|
use std::sync::atomic::{AtomicUsize, Ordering};
|
||
|
|
|
||
|
|
static MAIN_IMAGE_BASE: AtomicUsize = AtomicUsize::new(0);
|
||
|
|
|
||
|
|
/// Records where the title's main image is mapped. The title expects
|
||
|
|
/// `GetModuleHandle(NULL)` and friends to return this, not our own exe.
|
||
|
|
pub fn set_main_image(base: usize) {
|
||
|
|
MAIN_IMAGE_BASE.store(base, Ordering::Release);
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn main_image() -> Option<usize> {
|
||
|
|
match MAIN_IMAGE_BASE.load(Ordering::Acquire) {
|
||
|
|
0 => None,
|
||
|
|
base => Some(base),
|
||
|
|
}
|
||
|
|
}
|