Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various minor fixes #93

Merged
merged 7 commits into from
Oct 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
814 changes: 417 additions & 397 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions auxtools-impl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ license.workspace = true

[lib]
proc-macro = true
doctest = false

[dependencies]
proc-macro2 = "1.0"
Expand Down
7 changes: 4 additions & 3 deletions auxtools-impl/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![deny(clippy::complexity, clippy::correctness, clippy::perf, clippy::style)]
#![warn(clippy::complexity, clippy::correctness, clippy::perf, clippy::style)]

use proc_macro::TokenStream;
use quote::quote;
Expand Down Expand Up @@ -180,7 +180,8 @@ pub fn pin_dll(attr: TokenStream) -> TokenStream {
///
/// Here we define a hook that multiplies a number passed to it by two.
/// It can now be used to hook procs, for example
/// `hooks::hook("/proc/double_up", double_up);` ```ignore
/// `hooks::hook("/proc/double_up", double_up);`
/// ```ignore
/// #[hook]
/// fn double_up(num: Value) {
/// if let Some(num) = num.as_number() {
Expand All @@ -189,7 +190,7 @@ pub fn pin_dll(attr: TokenStream) -> TokenStream {
/// Value::null()
/// }
/// ```
///
///
/// This function is used to hook `/mob/proc/on_honked`.
/// By specifying the proc path, we hook the proc immediately upon startup.
/// ```ignore
Expand Down
3 changes: 3 additions & 0 deletions auxtools/src/byond_ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ thread_local! {
}

pub unsafe fn parse_args<'a>(argc: c_int, argv: *const *const c_char) -> Vec<Cow<'a, str>> {
if argc == 0 || argv.is_null() {
return Vec::new();
}
slice::from_raw_parts(argv, argc as usize)
.iter()
.map(|ptr| CStr::from_ptr(*ptr))
Expand Down
2 changes: 1 addition & 1 deletion auxtools/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![deny(clippy::complexity, clippy::correctness, clippy::perf, clippy::style)]
#![warn(clippy::complexity, clippy::correctness, clippy::perf, clippy::style)]

//! For when BYOND is not enough. Probably often.

Expand Down
4 changes: 2 additions & 2 deletions auxtools/src/sigscan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,9 @@ impl Signature {
scanner.find(&self.bytes).map(|address| unsafe {
match self.treatment {
SignatureTreatment::NoOffset | SignatureTreatment::OffsetByInt(0) => std::mem::transmute(address as *const std::ffi::c_void),
SignatureTreatment::OffsetByInt(i) => *(address.offset(i) as *const *const std::ffi::c_void),
SignatureTreatment::OffsetByInt(i) => (address.offset(i) as *const *const std::ffi::c_void).read_unaligned(),
SignatureTreatment::OffsetByCall => {
let offset = *(address.offset(1) as *const isize);
let offset = (address.offset(1) as *const isize).read_unaligned();
address.offset(5).offset(offset) as *const () as *const std::ffi::c_void
}
}
Expand Down
2 changes: 1 addition & 1 deletion auxtools/src/string_intern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ macro_rules! byond_string {
($s:literal) => {
unsafe {
static mut STORE: $crate::InternedString = $crate::InternedString($s, std::cell::UnsafeCell::new(None));
$crate::inventory::submit!(unsafe { &STORE });
$crate::inventory::submit!(unsafe { &*::std::ptr::addr_of!(STORE) });
let x = &*STORE.1.get();
x.as_ref().unwrap()
}
Expand Down
2 changes: 1 addition & 1 deletion debug_server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ fn enable_debugging(mode: Value, port: Value) {
unsafe {
*DEBUG_SERVER.get() = Some(server);
debug_server_instruction_hook = DebugServerInstructionHook {
debug_server: &mut DEBUG_SERVER
debug_server: &mut *std::ptr::addr_of_mut!(DEBUG_SERVER)
};

INSTRUCTION_HOOKS.get_mut().push(Box::new(debug_server_instruction_hook));
Expand Down