mirror of
https://github.com/a2x/cs2-dumper.git
synced 2025-10-08 05:10:02 +08:00
Reorganize schema system structures into separate files
This commit is contained in:
@@ -51,7 +51,7 @@ fn read_buttons(
|
||||
((cur_button.address() - module.base) + offset_of!(KeyButton.state) as i64) as u32;
|
||||
|
||||
debug!(
|
||||
"found button: {} at {:#X} ({} + {:#X})",
|
||||
"found button: {} @ {:#X} ({} + {:#X})",
|
||||
name,
|
||||
value as u64 + module.base.to_umem(),
|
||||
module.name,
|
||||
@@ -63,7 +63,6 @@ fn read_buttons(
|
||||
cur_button = button.next;
|
||||
}
|
||||
|
||||
// Sort buttons by name.
|
||||
buttons.sort_unstable_by(|a, b| a.name.cmp(&b.name));
|
||||
|
||||
Ok(buttons)
|
||||
|
@@ -58,10 +58,11 @@ fn read_interfaces(
|
||||
while !cur_reg.is_null() {
|
||||
let reg = cur_reg.read(process)?;
|
||||
let name = reg.name.read_string(process)?.to_string();
|
||||
|
||||
let value = (reg.create_fn.address() - module.base) as u32;
|
||||
|
||||
debug!(
|
||||
"found interface: {} at {:#X} ({} + {:#X})",
|
||||
"found interface: {} @ {:#X} ({} + {:#X})",
|
||||
name,
|
||||
value as u64 + module.base.to_umem(),
|
||||
module.name,
|
||||
@@ -73,7 +74,6 @@ fn read_interfaces(
|
||||
cur_reg = reg.next;
|
||||
}
|
||||
|
||||
// Sort interfaces by name.
|
||||
ifaces.sort_unstable_by(|a, b| a.name.cmp(&b.name));
|
||||
|
||||
Ok(ifaces)
|
||||
|
@@ -12,7 +12,6 @@ mod interfaces;
|
||||
mod offsets;
|
||||
mod schemas;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct AnalysisResult {
|
||||
pub buttons: Vec<Button>,
|
||||
pub interfaces: InterfaceMap,
|
||||
|
@@ -53,7 +53,7 @@ macro_rules! pattern_map {
|
||||
|
||||
for (name, value) in &map {
|
||||
debug!(
|
||||
"found offset: {} at {:#X} ({}.dll + {:#X})",
|
||||
"found offset: {} @ {:#X} ({}.dll + {:#X})",
|
||||
name,
|
||||
*value as u64 + view.optional_header().ImageBase,
|
||||
stringify!($module),
|
||||
|
@@ -42,7 +42,7 @@ pub struct ClassField {
|
||||
pub struct Enum {
|
||||
pub name: String,
|
||||
pub alignment: u8,
|
||||
pub size: i16,
|
||||
pub size: u16,
|
||||
pub members: Vec<EnumMember>,
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ fn read_class_binding(
|
||||
let metadata = read_class_binding_metadata(process, &binding)?;
|
||||
|
||||
debug!(
|
||||
"found class: {} at {:#X} (module name: {}) (parent name: {:?}) (metadata count: {}) (fields count: {})",
|
||||
"found class: {} @ {:#X} (module name: {}) (parent name: {:?}) (metadata count: {}) (fields count: {})",
|
||||
name,
|
||||
binding_ptr.to_umem(),
|
||||
module_name,
|
||||
@@ -140,7 +140,7 @@ fn read_class_binding_fields(
|
||||
return Ok(Vec::new());
|
||||
}
|
||||
|
||||
(0..binding.num_fields).try_fold(Vec::new(), |mut acc, i| {
|
||||
(0..binding.field_count).try_fold(Vec::new(), |mut acc, i| {
|
||||
let field = binding.fields.at(i as _).read(process)?;
|
||||
|
||||
if field.schema_type.is_null() {
|
||||
@@ -156,7 +156,7 @@ fn read_class_binding_fields(
|
||||
acc.push(ClassField {
|
||||
name,
|
||||
type_name,
|
||||
offset: field.offset,
|
||||
offset: field.single_inheritance_offset,
|
||||
});
|
||||
|
||||
Ok(acc)
|
||||
@@ -171,24 +171,28 @@ fn read_class_binding_metadata(
|
||||
return Ok(Vec::new());
|
||||
}
|
||||
|
||||
(0..binding.num_static_metadata).try_fold(Vec::new(), |mut acc, i| {
|
||||
(0..binding.static_metadata_count).try_fold(Vec::new(), |mut acc, i| {
|
||||
let metadata = binding.static_metadata.at(i as _).read(process)?;
|
||||
|
||||
if metadata.network_value.is_null() {
|
||||
if metadata.data.is_null() {
|
||||
return Ok(acc);
|
||||
}
|
||||
|
||||
let name = metadata.name.read_string(process)?.to_string();
|
||||
let network_value = metadata.network_value.read(process)?;
|
||||
let network_value = metadata.data.read(process)?;
|
||||
|
||||
let metadata = match name.as_str() {
|
||||
"MNetworkChangeCallback" => unsafe {
|
||||
let name = network_value.u.name_ptr.read_string(process)?.to_string();
|
||||
let name = network_value
|
||||
.value
|
||||
.name_ptr
|
||||
.read_string(process)?
|
||||
.to_string();
|
||||
|
||||
ClassMetadata::NetworkChangeCallback { name }
|
||||
},
|
||||
"MNetworkVarNames" => unsafe {
|
||||
let var_value = network_value.u.var_value;
|
||||
let var_value = network_value.value.var_value;
|
||||
|
||||
let name = var_value.name.read_string(process)?.to_string();
|
||||
let type_name = var_value.type_name.read_string(process)?.replace(" ", "");
|
||||
@@ -214,7 +218,7 @@ fn read_enum_binding(
|
||||
let members = read_enum_binding_members(process, &binding)?;
|
||||
|
||||
debug!(
|
||||
"found enum: {} at {:#X} (alignment: {}) (members count: {})",
|
||||
"found enum: {} @ {:#X} (alignment: {}) (members count: {})",
|
||||
name,
|
||||
binding_ptr.to_umem(),
|
||||
binding.alignment,
|
||||
@@ -224,7 +228,7 @@ fn read_enum_binding(
|
||||
Ok(Enum {
|
||||
name,
|
||||
alignment: binding.alignment,
|
||||
size: binding.num_enumerators,
|
||||
size: binding.enumerator_count,
|
||||
members,
|
||||
})
|
||||
}
|
||||
@@ -237,13 +241,13 @@ fn read_enum_binding_members(
|
||||
return Ok(Vec::new());
|
||||
}
|
||||
|
||||
(0..binding.num_enumerators).try_fold(Vec::new(), |mut acc, i| {
|
||||
(0..binding.enumerator_count).try_fold(Vec::new(), |mut acc, i| {
|
||||
let enumerator = binding.enumerators.at(i as _).read(process)?;
|
||||
let name = enumerator.name.read_string(process)?.to_string();
|
||||
|
||||
acc.push(EnumMember {
|
||||
name,
|
||||
value: unsafe { enumerator.u.ulong } as i64,
|
||||
value: unsafe { enumerator.value.ulong } as i64,
|
||||
});
|
||||
|
||||
Ok(acc)
|
||||
@@ -307,7 +311,7 @@ fn read_type_scopes(
|
||||
}
|
||||
|
||||
debug!(
|
||||
"found type scope: {} at {:#X} (classes count: {}) (enums count: {})",
|
||||
"found type scope: {} @ {:#X} (classes count: {}) (enums count: {})",
|
||||
module_name,
|
||||
type_scope_ptr.to_umem(),
|
||||
classes.len(),
|
||||
|
Reference in New Issue
Block a user