Release 1.1.4

This commit is contained in:
a2x
2023-10-26 15:41:34 +10:00
parent 631668429c
commit 239c872b65
37 changed files with 1905 additions and 1308 deletions

View File

@@ -1,40 +1,73 @@
use anyhow::Result;
use crate::mem::Address;
use crate::remote::Process;
use super::SchemaType;
/// Represents a class field in a schema.
use crate::util::{Address, Process};
use anyhow::Result;
/// Represents data for a field in a schema class.
pub struct SchemaClassFieldData<'a> {
process: &'a Process,
/// Address of the class field.
addr: Address,
address: Address,
}
impl<'a> SchemaClassFieldData<'a> {
pub fn new(process: &'a Process, addr: Address) -> Self {
Self { process, addr }
/// Creates a new `SchemaClassFieldData` instance.
///
/// # Arguments
///
/// * `process` - A reference to the `Process` struct.
/// * `address` - The address of the `SchemaClassFieldData` instance.
///
/// # Returns
///
/// * `SchemaClassFieldData` - The new `SchemaClassFieldData` instance.
pub fn new(process: &'a Process, address: Address) -> Self {
Self { process, address }
}
/// Returns the name of the field.
///
/// # Arguments
///
/// * `&self` - A reference to the `SchemaClassFieldData` struct.
///
/// # Returns
///
/// * `Result<String>` - The name of the field.
pub fn name(&self) -> Result<String> {
let name_ptr = self.process.read_memory::<usize>(self.addr + 0x0)?;
let name_ptr = self.process.read_memory::<usize>(self.address)?;
self.process.read_string_len(name_ptr.into(), 64)
self.process.read_string_length(name_ptr.into(), 64)
}
/// Returns the type of the field.
/// Returns the `SchemaType` of the field.
///
/// # Arguments
///
/// * `&self` - A reference to the `SchemaClassFieldData` struct.
///
/// # Returns
///
/// * `Result<SchemaType>` - The `SchemaType` of the field.
pub fn r#type(&self) -> Result<SchemaType> {
Ok(SchemaType::new(
self.process,
self.process.read_memory::<usize>(self.addr + 0x8)?.into(),
self.process
.read_memory::<usize>(self.address + 0x8)?
.into(),
))
}
/// Returns the offset of the field.
///
/// # Arguments
///
/// * `&self` - A reference to the `SchemaClassFieldData` struct.
///
/// # Returns
///
/// * `Result<u16>` - The offset of the field.
pub fn offset(&self) -> Result<u16> {
self.process.read_memory::<u16>(self.addr + 0x10)
self.process.read_memory::<u16>(self.address + 0x10)
}
}