Fix small naming inconsistencies

This commit is contained in:
a2x 2024-04-06 12:47:06 +10:00
parent a59331af1f
commit 6d72c517ed
6 changed files with 31 additions and 22 deletions

View File

@ -42,13 +42,14 @@ fn read_buttons(
) -> Result<Vec<Button>> {
let mut buttons = Vec::new();
let mut key_ptr = Pointer64::<KeyButton>::from(process.read_addr64(list_addr)?);
let mut cur_button = Pointer64::<KeyButton>::from(process.read_addr64(list_addr)?);
while !key_ptr.is_null() {
let key = key_ptr.read(process)?;
let name = key.name.read_string(process)?.to_string();
while !cur_button.is_null() {
let button = cur_button.read(process)?;
let name = button.name.read_string(process)?.to_string();
let value = ((key_ptr.address() - module.base) + offset_of!(KeyButton.state) as i64) as u32;
let value =
((cur_button.address() - module.base) + offset_of!(KeyButton.state) as i64) as u32;
debug!(
"found button: {} at {:#X} ({} + {:#X})",
@ -60,7 +61,7 @@ fn read_buttons(
buttons.push(Button { name, value });
key_ptr = key.next;
cur_button = button.next;
}
// Sort buttons by name.

View File

@ -185,7 +185,7 @@ fn read_class_binding_metadata(
let var_value = network_value.u.var_value;
let name = var_value.name.read_string(process)?.to_string();
let type_name = var_value.ty.read_string(process)?.replace(" ", "");
let type_name = var_value.type_name.read_string(process)?.replace(" ", "");
ClassMetadata::NetworkVarNames { name, type_name }
},
@ -305,6 +305,14 @@ fn read_type_scopes(
.filter_map(|ptr| read_enum_binding(process, *ptr).ok())
.collect();
debug!(
"found type scope: {} at {:#X} (classes count: {}) (enums count: {})",
name,
type_scope_ptr.to_umem(),
classes.len(),
enums.len()
);
Ok(TypeScope {
name,
classes,

View File

@ -1,5 +1,7 @@
use thiserror::Error;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug, Error)]
pub enum Error {
#[error(transparent)]
@ -27,5 +29,3 @@ impl<T> From<memflow::error::PartialError<T>> for Error {
Error::Memflow(err.into())
}
}
pub type Result<T> = std::result::Result<T, Error>;

View File

@ -131,7 +131,7 @@ pub struct SchemaEnumInfoData {
pub alignment: u8,
pad_0019: [u8; 0x3],
pub size: u16,
pub static_metadata_count: u16,
pub num_static_metadata: u16,
pub enum_info: Pointer64<SchemaEnumeratorInfoData>,
pub static_metadata: Pointer64<SchemaMetadataEntryData>,
pub type_scope: Pointer64<SchemaSystemTypeScope>,

View File

@ -4,7 +4,7 @@ use memflow::prelude::v1::*;
#[derive(Pod)]
#[repr(C)]
pub struct InterfaceReg {
pub create_fn: Pointer64<()>,
pub name: Pointer64<ReprCString>,
pub next: Pointer64<InterfaceReg>,
pub create_fn: Pointer64<()>, // 0x0000
pub name: Pointer64<ReprCString>, // 0x0008
pub next: Pointer64<InterfaceReg>, // 0x0010
}

View File

@ -19,7 +19,7 @@ unsafe impl<D: 'static> Pod for HashAllocatedBlob<D> {}
pub struct HashBucket<D, K> {
pad_0000: [u8; 0x18], // 0x0000,
pub first: Pointer64<HashFixedData<D, K>>, // 0x0018
pub first_uncommited: Pointer64<HashFixedData<D, K>>, // 0x0020
pub first_uncommitted: Pointer64<HashFixedData<D, K>>, // 0x0020
}
#[repr(C)]
@ -45,21 +45,23 @@ pub struct UtlTsHash<D, const C: usize = 256, K = u64> {
impl<D: Pod + IsNull, const C: usize, K: Pod> UtlTsHash<D, C, K> {
/// Returns all elements in the hash table.
pub fn elements(&self, process: &mut IntoProcessInstanceArcBox<'_>) -> Result<Vec<D>> {
// TODO: Refactor this.
let mut elements: Vec<_> = self
.buckets
.iter()
.flat_map(|bucket| {
let mut element_ptr = bucket.first;
let mut cur_element = bucket.first;
let mut list = Vec::new();
while !element_ptr.is_null() {
if let Ok(element) = element_ptr.read(process) {
while !cur_element.is_null() {
if let Ok(element) = cur_element.read(process) {
if !element.data.is_null() {
list.push(element.data);
}
element_ptr = element.next;
cur_element = element.next;
}
}
@ -87,8 +89,6 @@ impl<D: Pod + IsNull, const C: usize, K: Pod> UtlTsHash<D, C, K> {
}
}
// TODO: Separate allocated and unallocated data.
Ok(elements)
}
}