Print field types

This commit is contained in:
a2x
2023-10-01 14:43:48 +10:00
parent 18e90bcf8c
commit 6d04af2758
73 changed files with 40045 additions and 39911 deletions

View File

@@ -2,6 +2,7 @@ pub use schema_class_field_data::SchemaClassFieldData;
pub use schema_class_info::SchemaClassInfo;
pub use schema_system::SchemaSystem;
pub use schema_system_type_scope::SchemaSystemTypeScope;
pub use schema_type::SchemaType;
pub use schema_type_declared_class::SchemaTypeDeclaredClass;
pub use utl_ts_hash::UtlTsHash;
@@ -9,5 +10,6 @@ pub mod schema_class_field_data;
pub mod schema_class_info;
pub mod schema_system;
pub mod schema_system_type_scope;
pub mod schema_type;
pub mod schema_type_declared_class;
pub mod utl_ts_hash;

View File

@@ -1,6 +1,8 @@
use crate::error::Result;
use crate::remote::Process;
use super::SchemaType;
pub struct SchemaClassFieldData<'a> {
process: &'a Process,
address: usize,
@@ -12,9 +14,15 @@ impl<'a> SchemaClassFieldData<'a> {
}
pub fn name(&self) -> Result<String> {
let name_ptr = self.process.read_memory::<usize>(self.address)?;
self.process
.read_string(self.process.read_memory::<usize>(self.address)?)
}
self.process.read_string(name_ptr, 64)
pub fn r#type(&self) -> Result<SchemaType> {
Ok(SchemaType::new(
self.process,
self.process.read_memory::<usize>(self.address + 0x8)?,
))
}
pub fn offset(&self) -> Result<u16> {

View File

@@ -28,13 +28,13 @@ impl<'a> SchemaClassInfo<'a> {
let fields: Vec<SchemaClassFieldData> = (0..count as usize)
.filter_map(|i| {
let field = self
let address = self
.process
.read_memory::<usize>(self.address + 0x28)
.ok()?
+ (i * 0x20);
(field != 0).then(|| SchemaClassFieldData::new(self.process, field))
(address != 0).then(|| SchemaClassFieldData::new(self.process, address))
})
.collect();

View File

@@ -35,6 +35,6 @@ impl<'a> SchemaSystemTypeScope<'a> {
}
pub fn module_name(&self) -> Result<String> {
self.process.read_string(self.address + 0x8, 256)
self.process.read_string(self.address + 0x8)
}
}

18
src/sdk/schema_type.rs Normal file
View File

@@ -0,0 +1,18 @@
use crate::error::Result;
use crate::remote::Process;
pub struct SchemaType<'a> {
process: &'a Process,
address: usize,
}
impl<'a> SchemaType<'a> {
pub fn new(process: &'a Process, address: usize) -> Self {
Self { process, address }
}
pub fn name(&self) -> Result<String> {
self.process
.read_string(self.process.read_memory::<usize>(self.address + 0x8)?)
}
}

View File

@@ -12,8 +12,7 @@ impl<'a> SchemaTypeDeclaredClass<'a> {
}
pub fn name(&self) -> Result<String> {
let name_ptr = self.process.read_memory::<usize>(self.address + 0x8)?;
self.process.read_string(name_ptr, 64)
self.process
.read_string(self.process.read_memory::<usize>(self.address + 0x8)?)
}
}