mirror of
https://github.com/IntQuant/noita_entangled_worlds.git
synced 2025-12-07 13:49:46 +00:00
Attempt to track allocations that doesn't actually work cuz I can't get it loaded
This commit is contained in:
parent
70af6cfdef
commit
487a334e5d
6 changed files with 65 additions and 0 deletions
1
.vscode/settings.json
vendored
1
.vscode/settings.json
vendored
|
|
@ -19,5 +19,6 @@
|
|||
"rust-analyzer.linkedProjects": [
|
||||
"ewext/Cargo.toml",
|
||||
"noita-proxy/Cargo.toml",
|
||||
"extra/malloc_probe/Cargo.toml",
|
||||
]
|
||||
}
|
||||
2
extra/malloc_probe/.cargo/config.toml
Normal file
2
extra/malloc_probe/.cargo/config.toml
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
[build]
|
||||
target = "i686-pc-windows-gnu"
|
||||
7
extra/malloc_probe/Cargo.lock
generated
Normal file
7
extra/malloc_probe/Cargo.lock
generated
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "malloc_probe"
|
||||
version = "0.1.0"
|
||||
20
extra/malloc_probe/Cargo.toml
Normal file
20
extra/malloc_probe/Cargo.toml
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
[package]
|
||||
name = "malloc_probe"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib"]
|
||||
|
||||
[profile.dev]
|
||||
panic = "abort"
|
||||
|
||||
[profile.release]
|
||||
lto = true
|
||||
panic = "abort"
|
||||
split-debuginfo = "packed"
|
||||
incremental=true
|
||||
codegen-units=1
|
||||
opt-level = 3
|
||||
|
||||
[dependencies]
|
||||
3
extra/malloc_probe/build.rs
Normal file
3
extra/malloc_probe/build.rs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
fn main() {
|
||||
println!("cargo:rustc-link-arg=-Wl,-eDllMain");
|
||||
}
|
||||
32
extra/malloc_probe/src/lib.rs
Normal file
32
extra/malloc_probe/src/lib.rs
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
use std::{
|
||||
alloc::{self, Layout},
|
||||
ffi::c_void,
|
||||
};
|
||||
|
||||
unsafe extern "cdecl" fn operator_new(size: usize) -> *mut c_void {
|
||||
let buffer =
|
||||
unsafe { alloc::alloc(Layout::from_size_align_unchecked(size + 4, 4)).cast::<usize>() };
|
||||
unsafe { buffer.write(size) };
|
||||
unsafe { buffer.offset(1).cast() }
|
||||
}
|
||||
|
||||
unsafe extern "cdecl" fn operator_delete(pointer: *mut c_void) {
|
||||
let ptr = unsafe { pointer.cast::<usize>().offset(-1) };
|
||||
let size = unsafe { ptr.read() };
|
||||
unsafe {
|
||||
alloc::dealloc(
|
||||
pointer.cast(),
|
||||
Layout::from_size_align_unchecked(size + 4, 4),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
unsafe extern "C" fn dummy() {}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub extern "stdcall" fn DllMain(_: *const u8, _: u32, _: *const u8) -> u32 {
|
||||
// unsafe { ((0x00f07500) as *mut *const usize).write(operator_new as *const usize) };
|
||||
// unsafe { ((0x00f07504) as *mut *const usize).write(operator_delete as *const usize) };
|
||||
1
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue