📦 Game Update 13966 (2)

This commit is contained in:
a2x
2023-11-03 17:39:02 +10:00
parent 1d32f72cd5
commit 2378c280ab
79 changed files with 344 additions and 307 deletions

View File

@@ -9,7 +9,7 @@ pub enum Operation {
/// `value` is the value to add.
Add { value: usize },
/// Represents a dereference operation with optional parameters for the number of times to dereference
/// Represents a "dereference" operation with optional parameters for the number of times to dereference
/// and the size of the resulting value.
///
/// `times` is the number of times to dereference the address. If `None`, the number of times will be `1`.
@@ -19,31 +19,33 @@ pub enum Operation {
size: Option<usize>,
},
/// Represents a jump instruction with an optional offset and length.
/// Represents an operation to resolve the absolute address of a relative "jmp" with an optional
/// offset and length.
///
/// `offset` is the offset of the displacement value. If `None`, the offset will be `0x1`.
/// `length` is the length of the instruction. If `None`, the length will be `0x5`.
Jmp {
ResolveJmp {
offset: Option<usize>,
length: Option<usize>,
},
/// Represents a relative instruction pointer (RIP) with an optional offset and length.
/// Represents an operation to resolve the absolute address of a RIP-relative address with an optional
/// offset and length.
///
/// `offset` is the offset of the displacement value. If `None`, the offset will be `0x3`.
/// `length` is the length of the instruction. If `None`, the length will be `0x7`.
RipRelative {
ResolveRip {
offset: Option<usize>,
length: Option<usize>,
},
/// Represents a slice operation with a start and end index.
/// Represents a "slice" operation with a start and end index.
///
/// `start` is the start index of the slice.
/// `end` is the end index of the slice.
Slice { start: usize, end: usize },
/// Represents a subtract operation with a given value.
/// Represents a "subtract" operation with a given value.
///
/// `value` is the value to subtract.
Subtract { value: usize },

View File

@@ -74,12 +74,12 @@ pub fn dump_offsets(
)?;
}
}
Jmp { offset, length } => {
ResolveJmp { offset, length } => {
address = process
.resolve_jmp(address, offset.unwrap_or(0x1), length.unwrap_or(0x5))?
.into()
}
RipRelative { offset, length } => {
ResolveRip { offset, length } => {
address = process
.resolve_rip(address, offset.unwrap_or(0x3), length.unwrap_or(0x7))?
.into()
@@ -216,7 +216,7 @@ mod tests {
.expect("Failed to find client.dll")
.base();
let global_vars = process.read_memory::<*const GlobalVarsBase>(client_base + 0x16AB2E0)?;
let global_vars = process.read_memory::<*const GlobalVarsBase>(client_base + 0x16AB2D0)?;
let current_map_name = unsafe {
(*global_vars)
@@ -238,7 +238,7 @@ mod tests {
.expect("Failed to find client.dll")
.base();
let local_player_controller = process.read_memory::<usize>(client_base + 0x17F9C18)?;
let local_player_controller = process.read_memory::<usize>(client_base + 0x17F9C08)?;
let player_name = process.read_string((local_player_controller + 0x610).into())?;

View File

@@ -8,7 +8,7 @@ use goblin::pe::options::ParseOptions;
use goblin::pe::section_table::SectionTable;
use goblin::pe::PE;
/// Represents a module loaded into the process.
/// Represents a module loaded in a Windows process.
pub struct Module<'a> {
/// The name of the module.
pub name: &'a str,

View File

@@ -229,8 +229,7 @@ impl Process {
Ok(String::from_utf8(buffer)?)
}
/// Resolves a jump instruction at the given address by calculating the target address based on the
/// displacement value at the given offset.
/// Resolves the absolute address of relative "jmp".
///
/// # Arguments
///
@@ -243,12 +242,13 @@ impl Process {
///
/// * `Result<Address>` - A `Result` containing the absolute address if successful, or an error if the memory read fails.
pub fn resolve_jmp(&self, address: Address, offset: usize, length: usize) -> Result<Address> {
// The displacement value can be negative.
let displacement = self.read_memory::<i32>(address.add(offset))?;
Ok(((address.add(length).0 as isize + displacement as isize) as usize).into())
}
/// Resolves the absolute address of a relative instruction pointer (RIP) address.
/// Resolves the absolute address of a RIP-relative address.
///
/// # Arguments
///
@@ -261,6 +261,7 @@ impl Process {
///
/// * `Result<Address>` - A `Result` containing the absolute address if successful, or an error if the memory read fails.
pub fn resolve_rip(&self, address: Address, offset: usize, length: usize) -> Result<Address> {
// The displacement value can be negative.
let displacement = self.read_memory::<i32>(address.add(offset))?;
Ok(((address.add(length).0 as isize + displacement as isize) as usize).into())