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

Linux 515.1633+ compat, add signature checking function for development #92

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
3 changes: 3 additions & 0 deletions auxtools/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ rust-version.workspace = true
repository.workspace = true
license.workspace = true

[lib]
crate-type = ["lib", "cdylib"]

[build-dependencies]
cc = "1.0"

Expand Down
39 changes: 33 additions & 6 deletions auxtools/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,11 @@ signatures! {
..1584 => (call, "E8 ?? ?? ?? ?? 8B 00 89 04 24 E8 ?? ?? ?? ?? 8B 00 89 44 24 ?? 8D 45 ??")
),
get_string_id => universal_signature!("55 89 E5 57 56 89 CE 53 89 D3 83 EC 5C 8B 55 ?? 85 C0 88 55 ?? 0F 84 ?? ?? ?? ??"),
call_proc_by_id => universal_signature!(call, "E8 ?? ?? ?? ?? 8B 45 ?? 8B 55 ?? 89 45 ?? 89 55 ?? 8B 55 ?? 8B 4D ?? 8B 5D ??"),
get_variable => universal_signature!("55 89 E5 81 EC C8 00 00 00 8B 55 ?? 89 5D ?? 8B 5D ?? 89 75 ?? 8B 75 ??"),
call_proc_by_id => version_dependent_signature!(
1633.. => (call, "E8 ?? ?? ?? ?? 8B 45 ?? 8B 55 ?? 89 45 ?? 89 55 ?? 83 EC 04 8B 55"),
..1633 => (call, "E8 ?? ?? ?? ?? 8B 45 ?? 8B 55 ?? 89 45 ?? 89 55 ?? 8B 55 ?? 8B 4D ?? 8B 5D ??")
),
get_variable => universal_signature!("55 89 E5 81 EC ?? 00 00 00 8B 55 ?? 89 5D ?? 8B 5D"),
set_variable => version_dependent_signature!(
1560.. => (call, "E8 ?? ?? ?? ?? 8B 45 ?? 8D 65 ?? 5B 5E 5F 5D C3 8D B4 26 00 00 00 00 8B 40 ??"),
1543..1560 => "55 89 E5 81 EC A8 00 00 00 8B 55 ?? 89 5D ?? 8B 4D ?? 89 7D ?? 8B 5D ??",
Expand All @@ -156,8 +159,9 @@ signatures! {

get_string_table_entry => universal_signature!("55 89 E5 83 EC 18 8B 45 ?? 39 05 ?? ?? ?? ?? 76 ?? 8B 15 ?? ?? ?? ?? 8B 04 ??"),
call_datum_proc_by_name => version_dependent_signature!(
1606.. => "55 89 E5 57 56 89 CE 53 89 D3 83 EC ?? 0F B6 55 ?? 89 45 ?? 8B 45 ?? 8B 7D ?? C6 45 E7 ?? 0F B6 CA 89 45 B0 8D 45 ?? 89 44 24 ?? 8B 45 ?? 89 ?? BC 31 C9 88 ?? BB 8B 55 ?? C7 44 24 ?? 01 00 00 00",
..1606 => "55 89 E5 57 56 53 83 EC 5C 8B 55 ?? 0F B6 45 ?? 8B 4D ?? 8B 5D ?? 89 14 24 8B 55 ?? 88 45 ?? 0F B6 F8 8B 75 ?? 8D 45 ?? 89 44 24 ?? 89 F8 89 4C 24 ?? 31 C9 C6 45 ?? 00 C7 44 24 ?? 01 00 00 00"
1633.. => "55 89 E5 57 56 53 83 EC 7C 8B 45 ?? 0F B6 55 ?? 8B 7D ?? 8B 5D ?? 89 45 ?? 8D 45 ?? 8B 75 ?? 89 44 24 ?? 8B 45 ?? 0F B6 CA 89 4D ?? 31 C9 88 55 ?? 8B 55 ?? C6 45 ?? ?? 89 44 24 ?? 8B 45 ?? C7 44 24 ?? 01 00 00 00",
1603..1633 => "55 89 E5 57 56 89 CE 53 89 D3 83 EC ?? 0F B6 55 ?? 89 45 ?? 8B 45 ?? 8B 7D ?? C6 45 E7 ?? 0F B6 CA 89 45 B0 8D 45 ?? 89 44 24 ?? 8B 45 ?? 89 ?? BC 31 C9 88 ?? BB 8B 55 ?? C7 44 24 ?? 01 00 00 00",
..1603 => "55 89 E5 57 56 53 83 EC 5C 8B 55 ?? 0F B6 45 ?? 8B 4D ?? 8B 5D ?? 89 14 24 8B 55 ?? 88 45 ?? 0F B6 F8 8B 75 ?? 8D 45 ?? 89 44 24 ?? 89 F8 89 4C 24 ?? 31 C9 C6 45 ?? 00 C7 44 24 ?? 01 00 00 00"
),

dec_ref_count => version_dependent_signature!(
Expand All @@ -166,12 +170,14 @@ signatures! {
),
inc_ref_count => universal_signature!(call, "E8 ?? ?? ?? ?? 8B 43 ?? 80 48 ?? 04 8B 5D ?? 8B 75 ?? 8B 7D ?? 89 EC 5D"),
get_assoc_element => version_dependent_signature!(
1602.. => "55 89 E5 83 EC ?? ?? ?? ?? ?? 5D F4 89 D3 89 75 F8 89 D6 89 7D FC 89 CF 89 45 B4 0F 84 B7 00 00 ??",
1633.. => "55 89 E5 83 EC 58 89 5D ?? 8B 5D ?? 89 75 ?? 8B 75 ?? 89 7D ?? 80 FB 3C",
1602..1633 => "55 89 E5 83 EC ?? ?? ?? ?? ?? 5D F4 89 D3 89 75 F8 89 D6 89 7D FC 89 CF 89 45 B4 0F 84 B7 00 00 ??",
..1602 => "55 89 E5 83 EC 68 89 4D ?? B9 7B 00 00 00 89 5D ?? 89 D3 89 75 ?? 89 C6"
),

set_assoc_element => version_dependent_signature!(
1602.. => "55 89 E5 83 EC 68 89 75 F8 8B 75 08 89 5D F4 89 C3 8B 45 0C 89 7D FC 80 FB 3C 89 D7 88 5D BF 89 ??",
1633.. => "55 89 E5 83 EC 68 89 5D ?? 8B 5D ?? 89 75 ?? 8B 75 ?? 8B 45",
1602..1633 => "55 89 E5 83 EC 68 89 75 F8 8B 75 08 89 5D F4 89 C3 8B 45 0C 89 7D FC 80 FB 3C 89 D7 88 5D BF 89 ??",
..1602 => "55 B9 7C 00 00 00 89 E5 83 EC 58 89 7D ?? 8B 7D ?? 89 5D ?? 89 C3 8B 45 ??"
),

Expand Down Expand Up @@ -406,3 +412,24 @@ byond_ffi_fn! { auxtools_full_shutdown(_input) {
};
Some("SUCCESS".to_owned())
} }

byond_ffi_fn! { auxtools_check_signatures(_input) {
let byondcore = match sigscan::Scanner::for_module(BYONDCORE) {
Some(v) => v,
None => return Some("FAILED (Couldn't create scanner for byondcore.dll)".to_owned())
};
if let Err(e) = version::init() {
return Some(format!("FAILED ({})", e));
}
let mut missing = Vec::<&'static str>::new();
for (name, found) in SIGNATURES0.check_all(&byondcore) {
if !found {
missing.push(name);
}
}
if missing.is_empty() {
Some("SUCCESS".to_owned())
} else {
Some(format!("MISSING: {}", missing.join(", ")))
}
} }
15 changes: 15 additions & 0 deletions auxtools/src/sigscan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,28 @@ macro_rules! signature {
};
}

#[macro_export]
macro_rules! count {
() => (0usize);
( $x:tt $($xs:tt)* ) => (1_usize + count!($($xs)*));
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trust me you do not want to see this in cargo expand

}

#[macro_export]
macro_rules! signatures {
( $( $name:ident => $sig:expr ),*) => {
struct Signatures {
$( pub $name: $crate::sigscan::SignatureMap, )*
}

impl Signatures {
pub fn check_all(&self, scanner: &$crate::sigscan::Scanner) -> [(&'static str, bool); count!($($name)*)] {
let version = $crate::version::get().1;
[$(
(stringify!($name), self.$name.find(scanner, version).is_some()),
)*]
}
}

static SIGNATURES0: $crate::sigscan::once_cell::sync::Lazy<Signatures> = $crate::sigscan::once_cell::sync::Lazy::new(|| Signatures {
$( $name: $sig, )*
});
Expand Down
Loading