mirror of
https://github.com/a2x/cs2-dumper.git
synced 2025-11-18 04:50:01 +08:00
Merge dev branch into main
This commit is contained in:
29
src/source_engine/tier1/utl_vector.rs
Normal file
29
src/source_engine/tier1/utl_vector.rs
Normal file
@@ -0,0 +1,29 @@
|
||||
use std::mem;
|
||||
|
||||
use memflow::prelude::v1::*;
|
||||
|
||||
use crate::error::{Error, Result};
|
||||
|
||||
#[repr(C)]
|
||||
pub struct UtlVector<T: Sized + Pod> {
|
||||
pub size: u32,
|
||||
pub mem: Pointer64<T>,
|
||||
}
|
||||
|
||||
impl<T: Sized + Pod> UtlVector<T> {
|
||||
#[inline]
|
||||
pub fn get(&self, process: &mut IntoProcessInstanceArcBox<'_>, idx: usize) -> Result<T> {
|
||||
if idx >= self.size as usize {
|
||||
return Err(Error::IndexOutOfBounds {
|
||||
idx,
|
||||
len: self.size as usize,
|
||||
});
|
||||
}
|
||||
|
||||
let ptr = Pointer64::from(self.mem.address() + (idx * mem::size_of::<T>()));
|
||||
|
||||
Ok(process.read_ptr(ptr)?)
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<T: Sized + Pod> Pod for UtlVector<T> {}
|
||||
Reference in New Issue
Block a user