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

@@ -11,6 +11,7 @@ use crate::error::{Error, Result};
use super::Module;
#[derive(Debug)]
pub struct Process {
process_id: u32,
process_handle: HANDLE,
@@ -157,13 +158,14 @@ impl Process {
self.write_memory_raw(address, &value as *const _ as *const _, mem::size_of::<T>())
}
pub fn read_string(&self, address: usize, length: usize) -> Result<String> {
let mut buffer: Vec<u8> = vec![0; length];
pub fn read_string(&self, address: usize) -> Result<String> {
let mut buffer = Vec::new();
self.read_memory_raw(address, buffer.as_mut_ptr() as *mut _, length)?;
if let Some(end) = buffer.iter().position(|&x| x == 0) {
buffer.truncate(end);
for i in 0.. {
match self.read_memory::<u8>(address + i) {
Ok(byte) if byte != 0 => buffer.push(byte),
_ => break,
}
}
Ok(String::from_utf8(buffer)?)