mirror of
https://github.com/a2x/cs2-dumper.git
synced 2025-01-07 02:52:54 +08:00
Rename IsNull
trait to PointerExt
This allows for more pointer extension methods to be added in the future.
This commit is contained in:
parent
4cdfd6c4a6
commit
05656b4f0b
10
src/mem.rs
10
src/mem.rs
@ -1,13 +1,13 @@
|
||||
use memflow::types::Pointer64;
|
||||
use memflow::types::{Pointer, PrimitiveAddress};
|
||||
|
||||
pub trait IsNull {
|
||||
pub trait PointerExt {
|
||||
/// Returns `true` if the pointer is null.
|
||||
fn is_null(&self) -> bool;
|
||||
}
|
||||
|
||||
impl<T> IsNull for Pointer64<T> {
|
||||
/// Returns `true` if the pointer is null.
|
||||
impl<U: PrimitiveAddress, T> PointerExt for Pointer<U, T> {
|
||||
#[inline]
|
||||
fn is_null(&self) -> bool {
|
||||
self.inner == 0
|
||||
self.inner.is_null()
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,6 @@ impl<T: Pod> UtlMemory<T> {
|
||||
|
||||
/// Returns the element at the specified index.
|
||||
pub fn element(&self, process: &mut IntoProcessInstanceArcBox<'_>, idx: usize) -> Result<T> {
|
||||
// Check if the index is out of bounds.
|
||||
if idx >= self.count() as usize {
|
||||
return Err(Error::Other("index out of bounds"));
|
||||
}
|
||||
@ -27,7 +26,7 @@ impl<T: Pod> UtlMemory<T> {
|
||||
self.mem.at(idx as _).read(process).map_err(Into::into)
|
||||
}
|
||||
|
||||
/// Returns `true` if the memory is externally allocated.
|
||||
/// Returns `true` if the memory was externally allocated.
|
||||
#[inline]
|
||||
pub fn is_externally_allocated(&self) -> bool {
|
||||
self.grow_size < 0
|
||||
|
@ -3,7 +3,7 @@ use memflow::prelude::v1::*;
|
||||
use super::UtlMemoryPoolBase;
|
||||
|
||||
use crate::error::Result;
|
||||
use crate::mem::IsNull;
|
||||
use crate::mem::PointerExt;
|
||||
|
||||
#[repr(C)]
|
||||
pub struct HashAllocatedBlob<D> {
|
||||
@ -17,7 +17,7 @@ unsafe impl<D: 'static> Pod for HashAllocatedBlob<D> {}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct HashBucket<D, K> {
|
||||
pad_0000: [u8; 0x18], // 0x0000,
|
||||
pad_0000: [u8; 0x18], // 0x0000
|
||||
pub first: Pointer64<HashFixedDataInternal<D, K>>, // 0x0018
|
||||
pub first_uncommitted: Pointer64<HashFixedDataInternal<D, K>>, // 0x0020
|
||||
}
|
||||
@ -40,7 +40,11 @@ pub struct UtlTsHash<D, const C: usize = 256, K = u64> {
|
||||
pad_2881: [u8; 0xF], // 0x2881
|
||||
}
|
||||
|
||||
impl<D: Pod + IsNull, const C: usize, K: Pod> UtlTsHash<D, C, K> {
|
||||
impl<D, const C: usize, K> UtlTsHash<D, C, K>
|
||||
where
|
||||
D: Pod + PointerExt,
|
||||
K: Pod,
|
||||
{
|
||||
/// Returns the number of allocated blocks.
|
||||
#[inline]
|
||||
pub fn blocks_alloc(&self) -> i32 {
|
||||
@ -77,7 +81,6 @@ impl<D: Pod + IsNull, const C: usize, K: Pod> UtlTsHash<D, C, K> {
|
||||
unallocated_list.push(element.data);
|
||||
}
|
||||
|
||||
// Check if we have too many elements.
|
||||
if unallocated_list.len() >= blocks_alloc {
|
||||
break;
|
||||
}
|
||||
@ -96,7 +99,6 @@ impl<D: Pod + IsNull, const C: usize, K: Pod> UtlTsHash<D, C, K> {
|
||||
allocated_list.push(blob.data);
|
||||
}
|
||||
|
||||
// Check if we have too many elements.
|
||||
if allocated_list.len() >= peak_alloc {
|
||||
break;
|
||||
}
|
||||
|
@ -18,7 +18,6 @@ impl<T: Pod> UtlVector<T> {
|
||||
|
||||
/// Returns the element at the specified index.
|
||||
pub fn element(&self, process: &mut IntoProcessInstanceArcBox<'_>, idx: usize) -> Result<T> {
|
||||
// Check if the index is out of bounds.
|
||||
if idx >= self.count() as usize {
|
||||
return Err(Error::Other("index out of bounds"));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user