mirror of
https://github.com/a2x/cs2-dumper.git
synced 2025-10-08 05:10:02 +08:00
Improve schema parsing
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
use memflow::prelude::v1::*;
|
||||
|
||||
/// Represents a keyboard button.
|
||||
#[derive(Pod)]
|
||||
#[repr(C)]
|
||||
pub struct KeyboardKey {
|
||||
pub struct KeyButton {
|
||||
pad_0000: [u8; 0x8], // 0x0000
|
||||
pub name: Pointer64<ReprCString>, // 0x0008
|
||||
pad_0010: [u8; 0x20], // 0x0010
|
||||
pub state: u32, // 0x0030
|
||||
pad_0034: [u8; 0x54], // 0x0034
|
||||
pub next: Pointer64<KeyboardKey>, // 0x0088
|
||||
pub next: Pointer64<KeyButton>, // 0x0088
|
||||
}
|
||||
|
||||
unsafe impl Pod for KeyboardKey {}
|
||||
|
@@ -1,27 +1,242 @@
|
||||
pub use schema_base_class_info_data::*;
|
||||
pub use schema_class_field_data::*;
|
||||
pub use schema_class_info_data::*;
|
||||
pub use schema_declared_class::*;
|
||||
pub use schema_enum_info_data::*;
|
||||
pub use schema_enumerator_info_data::*;
|
||||
pub use schema_metadata_entry_data::*;
|
||||
pub use schema_static_field_data::*;
|
||||
pub use schema_system::*;
|
||||
pub use schema_system_type_scope::*;
|
||||
pub use schema_type::*;
|
||||
pub use schema_type_declared_class::*;
|
||||
pub use schema_type_declared_enum::*;
|
||||
use std::ffi::c_char;
|
||||
|
||||
pub mod schema_base_class_info_data;
|
||||
pub mod schema_class_field_data;
|
||||
pub mod schema_class_info_data;
|
||||
pub mod schema_declared_class;
|
||||
pub mod schema_enum_info_data;
|
||||
pub mod schema_enumerator_info_data;
|
||||
pub mod schema_metadata_entry_data;
|
||||
pub mod schema_static_field_data;
|
||||
pub mod schema_system;
|
||||
pub mod schema_system_type_scope;
|
||||
pub mod schema_type;
|
||||
pub mod schema_type_declared_class;
|
||||
pub mod schema_type_declared_enum;
|
||||
use memflow::prelude::v1::*;
|
||||
|
||||
use super::{UtlTsHash, UtlVector};
|
||||
|
||||
pub type SchemaClassBinding = SchemaClassInfoData;
|
||||
pub type SchemaEnumBinding = SchemaEnumInfoData;
|
||||
pub type SchemaTypeDeclaredClass = SchemaType;
|
||||
pub type SchemaTypeDeclaredEnum = SchemaType;
|
||||
|
||||
#[repr(u8)]
|
||||
pub enum SchemaAtomicCategory {
|
||||
Basic = 0,
|
||||
T,
|
||||
CollectionOfT,
|
||||
TF,
|
||||
TT,
|
||||
TTF,
|
||||
I,
|
||||
None,
|
||||
}
|
||||
|
||||
#[repr(u8)]
|
||||
pub enum SchemaTypeCategory {
|
||||
BuiltIn = 0,
|
||||
Ptr,
|
||||
Bitfield,
|
||||
FixedArray,
|
||||
Atomic,
|
||||
DeclaredClass,
|
||||
DeclaredEnum,
|
||||
None,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
#[repr(C)]
|
||||
pub struct SchemaArrayT {
|
||||
pub array_size: u32, // 0x0000
|
||||
pad_0004: [u8; 0x4], // 0x0004
|
||||
pub element: Pointer64<SchemaType>, // 0x0008
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
#[repr(C)]
|
||||
pub struct SchemaAtomicI {
|
||||
pad_0000: [u8; 0x10], // 0x0000
|
||||
pub value: u64, // 0x0010
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
#[repr(C)]
|
||||
pub struct SchemaAtomicT {
|
||||
pub element: Pointer64<SchemaType>, // 0x0000
|
||||
pad_0008: [u8; 0x8], // 0x0008
|
||||
pub template: Pointer64<SchemaType>, // 0x0010
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
#[repr(C)]
|
||||
pub struct SchemaAtomicTT {
|
||||
pad_0000: [u8; 0x10], // 0x0000
|
||||
pub templates: [Pointer64<SchemaType>; 2], // 0x0010
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
#[repr(C)]
|
||||
pub struct SchemaAtomicTF {
|
||||
pad_0000: [u8; 0x10], // 0x0000
|
||||
pub template: Pointer64<SchemaType>, // 0x0010
|
||||
pub size: i32, // 0x0018
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
#[repr(C)]
|
||||
pub struct SchemaAtomicTTF {
|
||||
pad_0000: [u8; 0x10], // 0x0000
|
||||
pub templates: [Pointer64<SchemaType>; 2], // 0x0010
|
||||
pub size: i32, // 0x0020
|
||||
}
|
||||
|
||||
#[derive(Pod)]
|
||||
#[repr(C)]
|
||||
pub struct SchemaBaseClassInfoData {
|
||||
pub offset: u32, // 0x0000
|
||||
pad_0004: [u8; 0x4], // 0x0004
|
||||
pub prev: Pointer64<SchemaClassInfoData>, // 0x0008
|
||||
}
|
||||
|
||||
#[derive(Pod)]
|
||||
#[repr(C)]
|
||||
pub struct SchemaClassFieldData {
|
||||
pub name: Pointer64<ReprCString>, // 0x0000
|
||||
pub type_: Pointer64<SchemaType>, // 0x0008
|
||||
pub offset: u32, // 0x0010
|
||||
pub num_metadata: u32, // 0x0014
|
||||
pub metadata: Pointer64<SchemaMetadataEntryData>, // 0x0018
|
||||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
#[derive(Pod)]
|
||||
#[repr(C)]
|
||||
pub struct SchemaClassInfoData {
|
||||
pub base: Pointer64<SchemaClassInfoData>, // 0x0000
|
||||
pub name: Pointer64<ReprCString>, // 0x0008
|
||||
pub module_name: Pointer64<ReprCString>, // 0x0010
|
||||
pub size: u32, // 0x0018
|
||||
pub num_fields: u16, // 0x001C
|
||||
pub num_static_fields: u16, // 0x001E
|
||||
pub num_static_metadata: u16, // 0x0020
|
||||
pub alignment: u8, // 0x0022
|
||||
pub has_base_class: u8, // 0x0023
|
||||
pub total_class_size: u16, // 0x0024
|
||||
pub derived_class_size: u16, // 0x0026
|
||||
pub fields: Pointer64<SchemaClassFieldData>, // 0x0028
|
||||
pub static_fields: Pointer64<SchemaStaticFieldData>, // 0x0030
|
||||
pub base_classes: Pointer64<SchemaBaseClassInfoData>, // 0x0038
|
||||
pad_0040: [u8; 0x8], // 0x0040
|
||||
pub static_metadata: Pointer64<SchemaMetadataEntryData>, // 0x0048
|
||||
pub type_scope: Pointer64<SchemaSystemTypeScope>, // 0x0050
|
||||
pub type_: Pointer64<SchemaType>, // 0x0058
|
||||
pad_0060: [u8; 0x10], // 0x0060
|
||||
}
|
||||
|
||||
#[derive(Pod)]
|
||||
#[repr(C)]
|
||||
pub struct SchemaEnumInfoData {
|
||||
pub base: Pointer64<SchemaEnumInfoData>,
|
||||
pub name: Pointer64<ReprCString>,
|
||||
pub module_name: Pointer64<ReprCString>,
|
||||
pub alignment: u8,
|
||||
pad_0019: [u8; 0x3],
|
||||
pub size: u16,
|
||||
pub static_metadata_count: u16,
|
||||
pub enum_info: Pointer64<SchemaEnumeratorInfoData>,
|
||||
pub static_metadata: Pointer64<SchemaMetadataEntryData>,
|
||||
pub type_scope: Pointer64<SchemaSystemTypeScope>,
|
||||
pad_0038: [u8; 0x10],
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct SchemaEnumeratorInfoData {
|
||||
pub name: Pointer64<ReprCString>, // 0x0000
|
||||
pub u: SchemaEnumeratorInfoDataUnion, // 0x0008
|
||||
pub num_metadata: u32, // 0x0010
|
||||
pub metadata: Pointer64<SchemaMetadataEntryData>, // 0x0018
|
||||
}
|
||||
|
||||
unsafe impl Pod for SchemaEnumeratorInfoData {}
|
||||
|
||||
#[repr(C)]
|
||||
pub union SchemaEnumeratorInfoDataUnion {
|
||||
pub uchar: u8,
|
||||
pub ushort: u16,
|
||||
pub uint: u32,
|
||||
pub ulong: u64,
|
||||
}
|
||||
|
||||
#[derive(Pod)]
|
||||
#[repr(C)]
|
||||
pub struct SchemaMetadataEntryData {
|
||||
pub name: Pointer64<ReprCString>, // 0x0000
|
||||
pub network_value: Pointer64<SchemaNetworkValue>, // 0x0008
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct SchemaNetworkValue {
|
||||
pub u: SchemaNetworkValueUnion, // 0x0000
|
||||
}
|
||||
|
||||
unsafe impl Pod for SchemaNetworkValue {}
|
||||
|
||||
#[repr(C)]
|
||||
pub union SchemaNetworkValueUnion {
|
||||
pub name_ptr: Pointer64<ReprCString>,
|
||||
pub int_value: i32,
|
||||
pub float_value: f32,
|
||||
pub ptr: Pointer64<()>,
|
||||
pub var_value: SchemaVarName,
|
||||
pub name_value: [c_char; 32],
|
||||
}
|
||||
|
||||
#[derive(Pod)]
|
||||
#[repr(C)]
|
||||
pub struct SchemaStaticFieldData {
|
||||
pub name: Pointer64<ReprCString>, // 0x0000
|
||||
pub type_: Pointer64<SchemaType>, // 0x0008
|
||||
pub instance: Pointer64<()>, // 0x0010
|
||||
pad_0018: [u8; 0x10], // 0x0018
|
||||
}
|
||||
|
||||
#[derive(Pod)]
|
||||
#[repr(C)]
|
||||
pub struct SchemaSystem {
|
||||
pad_0000: [u8; 0x190], // 0x0000
|
||||
pub type_scopes: UtlVector<Pointer64<SchemaSystemTypeScope>>, // 0x0190
|
||||
pad_01a0: [u8; 0x120], // 0x01A0
|
||||
pub num_registrations: u32, // 0x02C0
|
||||
pad_02c4: [u8; 0x4], // 0x02C4
|
||||
}
|
||||
|
||||
#[derive(Pod)]
|
||||
#[repr(C)]
|
||||
pub struct SchemaSystemTypeScope {
|
||||
pad_0000: [u8; 0x8], // 0x0000
|
||||
pub name: [c_char; 256], // 0x0008
|
||||
pub global_scope: Pointer64<SchemaSystemTypeScope>, // 0x0108
|
||||
pad_0110: [u8; 0x4B0], // 0x0110
|
||||
pub class_bindings: UtlTsHash<Pointer64<SchemaClassBinding>>, // 0x05C0
|
||||
pub enum_bindings: UtlTsHash<Pointer64<SchemaEnumBinding>>, // 0x2E50
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct SchemaType {
|
||||
pad_0000: [u8; 0x8], // 0x0000
|
||||
pub name: Pointer64<ReprCString>, // 0x0008
|
||||
pub type_scope: Pointer64<SchemaSystemTypeScope>, // 0x0010
|
||||
pub type_category: SchemaTypeCategory, // 0x0018
|
||||
pub atomic_category: SchemaAtomicCategory, // 0x0019
|
||||
pub u: SchemaTypeUnion, // 0x0020
|
||||
}
|
||||
|
||||
unsafe impl Pod for SchemaType {}
|
||||
|
||||
pub union SchemaTypeUnion {
|
||||
pub schema_type: Pointer64<SchemaType>,
|
||||
pub class_binding: Pointer64<SchemaClassBinding>,
|
||||
pub enum_binding: Pointer64<SchemaEnumBinding>,
|
||||
pub array: SchemaArrayT,
|
||||
pub atomic: SchemaAtomicT,
|
||||
pub atomic_tt: SchemaAtomicTT,
|
||||
pub atomic_tf: SchemaAtomicTF,
|
||||
pub atomic_ttf: SchemaAtomicTTF,
|
||||
pub atomic_i: SchemaAtomicI,
|
||||
}
|
||||
|
||||
#[derive(Pod, Clone, Copy)]
|
||||
#[repr(C)]
|
||||
pub struct SchemaVarName {
|
||||
pub name: Pointer64<ReprCString>, // 0x0000
|
||||
pub type_name: Pointer64<ReprCString>, // 0x0008
|
||||
}
|
||||
|
@@ -1,12 +0,0 @@
|
||||
use memflow::prelude::v1::*;
|
||||
|
||||
use super::SchemaClassInfoData;
|
||||
|
||||
#[repr(C)]
|
||||
pub struct SchemaBaseClassInfoData {
|
||||
pub offset: u32, // 0x0000
|
||||
pad_0004: [u8; 0x4], // 0x0004
|
||||
pub prev: Pointer64<SchemaClassInfoData>, // 0x0008
|
||||
}
|
||||
|
||||
unsafe impl Pod for SchemaBaseClassInfoData {}
|
@@ -1,14 +0,0 @@
|
||||
use memflow::prelude::v1::*;
|
||||
|
||||
use super::{SchemaMetadataEntryData, SchemaType};
|
||||
|
||||
#[repr(C)]
|
||||
pub struct SchemaClassFieldData {
|
||||
pub name: Pointer64<ReprCString>, // 0x0000
|
||||
pub type_: Pointer64<SchemaType>, // 0x0008
|
||||
pub offset: u32, // 0x0010
|
||||
pub num_metadata: u32, // 0x0014
|
||||
pub metadata: Pointer64<SchemaMetadataEntryData>, // 0x0018
|
||||
}
|
||||
|
||||
unsafe impl Pod for SchemaClassFieldData {}
|
@@ -1,34 +0,0 @@
|
||||
use memflow::prelude::v1::*;
|
||||
|
||||
use super::{
|
||||
SchemaBaseClassInfoData, SchemaClassFieldData, SchemaMetadataEntryData, SchemaStaticFieldData,
|
||||
SchemaSystemTypeScope, SchemaType,
|
||||
};
|
||||
|
||||
pub type SchemaClassBinding = SchemaClassInfoData;
|
||||
|
||||
#[rustfmt::skip]
|
||||
#[repr(C)]
|
||||
pub struct SchemaClassInfoData {
|
||||
pub base: Pointer64<SchemaClassInfoData>, // 0x0000
|
||||
pub name: Pointer64<ReprCString>, // 0x0008
|
||||
pub module_name: Pointer64<ReprCString>, // 0x0010
|
||||
pub size: u32, // 0x0018
|
||||
pub num_fields: u16, // 0x001C
|
||||
pub num_static_fields: u16, // 0x001E
|
||||
pub num_static_metadata: u16, // 0x0020
|
||||
pub alignment: u8, // 0x0022
|
||||
pub has_base_class: bool, // 0x0023
|
||||
pub total_class_size: u16, // 0x0024
|
||||
pub derived_class_size: u16, // 0x0026
|
||||
pub fields: Pointer64<SchemaClassFieldData>, // 0x0028
|
||||
pub static_fields: Pointer64<SchemaStaticFieldData>, // 0x0030
|
||||
pub base_classes: Pointer64<SchemaBaseClassInfoData>, // 0x0038
|
||||
pad_0040: [u8; 0x8], // 0x0040
|
||||
pub static_metadata: Pointer64<SchemaMetadataEntryData>, // 0x0048
|
||||
pub type_scope: Pointer64<SchemaSystemTypeScope>, // 0x0050
|
||||
pub type_: Pointer64<SchemaType>, // 0x0058
|
||||
pad_0060: [u8; 0x10], // 0x0060
|
||||
}
|
||||
|
||||
unsafe impl Pod for SchemaClassInfoData {}
|
@@ -1,21 +0,0 @@
|
||||
use memflow::prelude::v1::*;
|
||||
|
||||
use super::SchemaSystemTypeScope;
|
||||
|
||||
#[repr(C)]
|
||||
pub struct SchemaDeclaredClass {
|
||||
pad_0000: [u8; 0x8], // 0x0000
|
||||
pub name: Pointer64<ReprCString>, // 0x0008
|
||||
pub type_scope: Pointer64<SchemaSystemTypeScope>, // 0x0010
|
||||
pad_0018: [u8; 0x10], // 0x0018
|
||||
}
|
||||
|
||||
unsafe impl Pod for SchemaDeclaredClass {}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct SchemaDeclaredClassEntry {
|
||||
pad_0000: [u8; 0x10], // 0x0000
|
||||
pub declared_class: Pointer64<SchemaDeclaredClass>, // 0x0010
|
||||
}
|
||||
|
||||
unsafe impl Pod for SchemaDeclaredClassEntry {}
|
@@ -1,23 +0,0 @@
|
||||
use memflow::prelude::v1::*;
|
||||
|
||||
use super::{SchemaEnumeratorInfoData, SchemaMetadataEntryData, SchemaSystemTypeScope};
|
||||
|
||||
pub type SchemaEnumBinding = SchemaEnumInfoData;
|
||||
|
||||
#[rustfmt::skip]
|
||||
#[repr(C)]
|
||||
pub struct SchemaEnumInfoData {
|
||||
pub base: Pointer64<SchemaEnumInfoData>, // 0x0000
|
||||
pub name: Pointer64<ReprCString>, // 0x0008
|
||||
pub module_name: Pointer64<ReprCString>, // 0x0010
|
||||
pub alignment: u8, // 0x0018
|
||||
pad_0019: [u8; 0x3], // 0x0019
|
||||
pub size: u16, // 0x001C
|
||||
pub num_static_metadata: u16, // 0x001E
|
||||
pub enum_info: Pointer64<SchemaEnumeratorInfoData>, // 0x0020
|
||||
pub static_metadata: Pointer64<SchemaMetadataEntryData>, // 0x0028
|
||||
pub type_scope: Pointer64<SchemaSystemTypeScope>, // 0x0030
|
||||
pad_0038: [u8; 0x10], // 0x0038
|
||||
}
|
||||
|
||||
unsafe impl Pod for SchemaEnumInfoData {}
|
@@ -1,21 +0,0 @@
|
||||
use memflow::prelude::v1::*;
|
||||
|
||||
use super::SchemaMetadataEntryData;
|
||||
|
||||
#[repr(C)]
|
||||
pub struct SchemaEnumeratorInfoData {
|
||||
pub name: Pointer64<ReprCString>, // 0x0000
|
||||
pub u: SchemaEnumeratorInfoDataUnion, // 0x0008
|
||||
pub num_metadata: u32, // 0x0010
|
||||
pub metadata: Pointer64<SchemaMetadataEntryData>, // 0x0018
|
||||
}
|
||||
|
||||
unsafe impl Pod for SchemaEnumeratorInfoData {}
|
||||
|
||||
#[repr(C)]
|
||||
pub union SchemaEnumeratorInfoDataUnion {
|
||||
pub uchar: u8,
|
||||
pub ushort: u16,
|
||||
pub uint: u32,
|
||||
pub ulong: u64,
|
||||
}
|
@@ -1,35 +0,0 @@
|
||||
use std::ffi::c_char;
|
||||
|
||||
use memflow::prelude::v1::*;
|
||||
|
||||
#[repr(C)]
|
||||
pub struct SchemaMetadataEntryData {
|
||||
pub name: Pointer64<ReprCString>, // 0x0000
|
||||
pub network_value: Pointer64<SchemaNetworkValue>, // 0x0008
|
||||
}
|
||||
|
||||
unsafe impl Pod for SchemaMetadataEntryData {}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct SchemaNetworkValue {
|
||||
pub u: SchemaNetworkValueUnion, // 0x0000
|
||||
}
|
||||
|
||||
unsafe impl Pod for SchemaNetworkValue {}
|
||||
|
||||
#[repr(C)]
|
||||
pub union SchemaNetworkValueUnion {
|
||||
pub name_ptr: Pointer64<ReprCString>,
|
||||
pub int_value: i32,
|
||||
pub float_value: f32,
|
||||
pub ptr: Pointer64<()>,
|
||||
pub var_value: SchemaVarName,
|
||||
pub name_value: [c_char; 32],
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
#[repr(C)]
|
||||
pub struct SchemaVarName {
|
||||
pub name: Pointer64<ReprCString>, // 0x0000
|
||||
pub ty: Pointer64<ReprCString>, // 0x0008
|
||||
}
|
@@ -1,13 +0,0 @@
|
||||
use memflow::prelude::v1::*;
|
||||
|
||||
use super::SchemaType;
|
||||
|
||||
#[repr(C)]
|
||||
pub struct SchemaStaticFieldData {
|
||||
pub name: Pointer64<ReprCString>, // 0x0000
|
||||
pub type_: Pointer64<SchemaType>, // 0x0008
|
||||
pub instance: Address, // 0x0010
|
||||
pad_0018: [u8; 0x10], // 0x0018
|
||||
}
|
||||
|
||||
unsafe impl Pod for SchemaStaticFieldData {}
|
@@ -1,15 +0,0 @@
|
||||
use memflow::prelude::v1::*;
|
||||
|
||||
use super::SchemaSystemTypeScope;
|
||||
|
||||
use crate::source2::UtlVector;
|
||||
|
||||
#[repr(C)]
|
||||
pub struct SchemaSystem {
|
||||
pad_0000: [u8; 0x190], // 0x0000
|
||||
pub type_scopes: UtlVector<Pointer64<SchemaSystemTypeScope>>, // 0x0190
|
||||
pad_01a0: [u8; 0x120], // 0x01A0
|
||||
pub num_registrations: u32, // 0x02C0
|
||||
}
|
||||
|
||||
unsafe impl Pod for SchemaSystem {}
|
@@ -1,18 +0,0 @@
|
||||
use std::ffi::c_char;
|
||||
|
||||
use memflow::prelude::v1::*;
|
||||
|
||||
use super::SchemaDeclaredClassEntry;
|
||||
|
||||
#[repr(C)]
|
||||
pub struct SchemaSystemTypeScope {
|
||||
pad_0000: [u8; 0x8], // 0x0000
|
||||
pub name: [c_char; 256], // 0x0008
|
||||
pub global_scope: Pointer64<SchemaSystemTypeScope>, // 0x0108
|
||||
pad_0110: [u8; 0x3C0], // 0x0110
|
||||
pub declared_class: Pointer64<SchemaDeclaredClassEntry>, // 0x04D0
|
||||
pad_04d8: [u8; 0xe], // 0x04D8
|
||||
pub num_declared_classes: u16, // 0x04E6
|
||||
}
|
||||
|
||||
unsafe impl Pod for SchemaSystemTypeScope {}
|
@@ -1,99 +0,0 @@
|
||||
use memflow::prelude::v1::*;
|
||||
|
||||
use super::{SchemaClassBinding, SchemaEnumBinding, SchemaSystemTypeScope};
|
||||
|
||||
#[derive(Debug, Eq, Ord, PartialEq, PartialOrd)]
|
||||
#[repr(u8)]
|
||||
pub enum SchemaAtomicCategory {
|
||||
Basic = 0,
|
||||
T,
|
||||
CollectionOfT,
|
||||
TF,
|
||||
TT,
|
||||
TTF,
|
||||
I,
|
||||
None,
|
||||
}
|
||||
|
||||
#[derive(Debug, Eq, Ord, PartialEq, PartialOrd)]
|
||||
#[repr(u8)]
|
||||
pub enum SchemaTypeCategory {
|
||||
BuiltIn = 0,
|
||||
Ptr,
|
||||
Bitfield,
|
||||
FixedArray,
|
||||
Atomic,
|
||||
DeclaredClass,
|
||||
DeclaredEnum,
|
||||
None,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
#[repr(C)]
|
||||
pub struct SchemaArray {
|
||||
pub array_size: u32, // 0x0000
|
||||
pad_0004: [u8; 0x4], // 0x0004
|
||||
pub element_type: Pointer64<SchemaType>, // 0x0008
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
#[repr(C)]
|
||||
pub struct SchemaAtomic {
|
||||
pub element_type: Pointer64<SchemaType>, // 0x0000
|
||||
pad_0008: [u8; 0x8], // 0x0008
|
||||
pub template_type: Pointer64<SchemaType>, // 0x0010
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
#[repr(C)]
|
||||
pub struct SchemaAtomicI {
|
||||
pad_0000: [u8; 0x10], // 0x0000
|
||||
pub value: u64, // 0x0010
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
#[repr(C)]
|
||||
pub struct SchemaAtomicTF {
|
||||
pad_0000: [u8; 0x10], // 0x0000
|
||||
pub template_type: Pointer64<SchemaType>, // 0x0010
|
||||
pub size: u32, // 0x0018
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
#[repr(C)]
|
||||
pub struct SchemaAtomicTT {
|
||||
pad_0000: [u8; 0x10], // 0x0000
|
||||
pub templates: [Pointer64<SchemaType>; 2], // 0x0010
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
#[repr(C)]
|
||||
pub struct SchemaAtomicTTF {
|
||||
pad_0000: [u8; 0x10], // 0x0000
|
||||
pub templates: [Pointer64<SchemaType>; 2], // 0x0010
|
||||
pub size: u32, // 0x0020
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct SchemaType {
|
||||
pad_0000: [u8; 0x8], // 0x0000
|
||||
pub name: Pointer64<ReprCString>, // 0x0008
|
||||
pub type_scope: Pointer64<SchemaSystemTypeScope>, // 0x0010
|
||||
pub type_category: SchemaTypeCategory, // 0x0018
|
||||
pub atomic_category: SchemaAtomicCategory, // 0x0019
|
||||
}
|
||||
|
||||
unsafe impl Pod for SchemaType {}
|
||||
|
||||
#[repr(C)]
|
||||
pub union SchemaTypeUnion {
|
||||
pub schema_type: Pointer64<SchemaType>,
|
||||
pub class_binding: Pointer64<SchemaClassBinding>,
|
||||
pub enum_binding: Pointer64<SchemaEnumBinding>,
|
||||
pub array: SchemaArray,
|
||||
pub atomic: SchemaAtomic,
|
||||
pub atomic_tt: SchemaAtomicTT,
|
||||
pub atomic_tf: SchemaAtomicTF,
|
||||
pub atomic_ttf: SchemaAtomicTTF,
|
||||
pub atomic_i: SchemaAtomicI,
|
||||
}
|
@@ -1,15 +0,0 @@
|
||||
use memflow::prelude::v1::*;
|
||||
|
||||
use super::{SchemaClassBinding, SchemaSystemTypeScope};
|
||||
|
||||
#[repr(C)]
|
||||
pub struct SchemaTypeDeclaredClass {
|
||||
pad_0000: [u8; 0x8], // 0x0000
|
||||
pub name: Pointer64<ReprCString>, // 0x0008
|
||||
pub type_scope: Pointer64<SchemaSystemTypeScope>, // 0x0010
|
||||
pad_0018: [u8; 0x8], // 0x0018
|
||||
pub binding: Pointer64<SchemaClassBinding>, // 0x0020
|
||||
pad_0028: [u8; 0x8], // 0x0028
|
||||
}
|
||||
|
||||
unsafe impl Pod for SchemaTypeDeclaredClass {}
|
@@ -1,15 +0,0 @@
|
||||
use memflow::prelude::v1::*;
|
||||
|
||||
use super::{SchemaEnumBinding, SchemaSystemTypeScope};
|
||||
|
||||
#[repr(C)]
|
||||
pub struct SchemaTypeDeclaredEnum {
|
||||
pad_0000: [u8; 0x8], // 0x0000
|
||||
pub name: Pointer64<ReprCString>, // 0x0008
|
||||
pub type_scope: Pointer64<SchemaSystemTypeScope>, // 0x0010
|
||||
pad_0018: [u8; 0x8], // 0x0018
|
||||
pub binding: Pointer64<SchemaEnumBinding>, // 0x0020
|
||||
pad_0028: [u8; 0x8], // 0x0028
|
||||
}
|
||||
|
||||
unsafe impl Pod for SchemaTypeDeclaredEnum {}
|
@@ -1,10 +1,10 @@
|
||||
use memflow::prelude::v1::*;
|
||||
|
||||
/// Represents a node in the linked list of exposed interfaces.
|
||||
#[derive(Pod)]
|
||||
#[repr(C)]
|
||||
pub struct InterfaceReg {
|
||||
pub create_fn: Address, // 0x0000
|
||||
pub name: Pointer64<ReprCString>, // 0x0008
|
||||
pub next: Pointer64<InterfaceReg>, // 0x0010
|
||||
pub create_fn: Pointer64<()>,
|
||||
pub name: Pointer64<ReprCString>,
|
||||
pub next: Pointer64<InterfaceReg>,
|
||||
}
|
||||
|
||||
unsafe impl Pod for InterfaceReg {}
|
||||
|
@@ -1,7 +1,11 @@
|
||||
pub use interface::*;
|
||||
pub use utl_rb_tree::*;
|
||||
pub use utl_memory::*;
|
||||
pub use utl_memory_pool::*;
|
||||
pub use utl_ts_hash::*;
|
||||
pub use utl_vector::*;
|
||||
|
||||
pub mod interface;
|
||||
pub mod utl_rb_tree;
|
||||
pub mod utl_memory;
|
||||
pub mod utl_memory_pool;
|
||||
pub mod utl_ts_hash;
|
||||
pub mod utl_vector;
|
||||
|
37
src/source2/tier1/utl_memory.rs
Normal file
37
src/source2/tier1/utl_memory.rs
Normal file
@@ -0,0 +1,37 @@
|
||||
use memflow::prelude::v1::*;
|
||||
|
||||
use crate::error::{Error, Result};
|
||||
|
||||
/// Represents a growable memory class that doubles in size by default.
|
||||
#[repr(C)]
|
||||
pub struct UtlMemory<T> {
|
||||
pub mem: Pointer64<[T]>, // 0x0000
|
||||
pub alloc_count: i32, // 0x0008
|
||||
pub grow_size: i32, // 0x000C
|
||||
}
|
||||
|
||||
impl<T: Pod> UtlMemory<T> {
|
||||
/// Returns the number of allocated elements.
|
||||
#[inline]
|
||||
pub fn count(&self) -> i32 {
|
||||
self.alloc_count
|
||||
}
|
||||
|
||||
/// 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"));
|
||||
}
|
||||
|
||||
self.mem.at(idx as _).read(process).map_err(Into::into)
|
||||
}
|
||||
|
||||
/// Returns `true` if the memory is externally allocated.
|
||||
#[inline]
|
||||
pub fn is_externally_allocated(&self) -> bool {
|
||||
self.grow_size < 0
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<T: 'static> Pod for UtlMemory<T> {}
|
30
src/source2/tier1/utl_memory_pool.rs
Normal file
30
src/source2/tier1/utl_memory_pool.rs
Normal file
@@ -0,0 +1,30 @@
|
||||
/// Represents an optimized pool memory allocator.
|
||||
#[repr(C)]
|
||||
pub struct UtlMemoryPool {
|
||||
pub block_size: i32, // 0x0000
|
||||
pub blocks_per_blob: i32, // 0x0004
|
||||
pub grow_mode: i32, // 0x0008
|
||||
pub blocks_alloc: i32, // 0x000C
|
||||
pub block_alloc_size: i32, // 0x0010
|
||||
pub peak_alloc: i32, // 0x0014
|
||||
}
|
||||
|
||||
impl UtlMemoryPool {
|
||||
/// Returns the size of a block.
|
||||
#[inline]
|
||||
pub fn block_size(&self) -> i32 {
|
||||
self.block_size
|
||||
}
|
||||
|
||||
/// Returns the number of allocated blocks per blob.
|
||||
#[inline]
|
||||
pub fn count(&self) -> i32 {
|
||||
self.blocks_per_blob
|
||||
}
|
||||
|
||||
/// Returns the maximum number of allocated blocks.
|
||||
#[inline]
|
||||
pub fn peak_count(&self) -> i32 {
|
||||
self.peak_alloc
|
||||
}
|
||||
}
|
@@ -1,27 +0,0 @@
|
||||
use memflow::prelude::v1::*;
|
||||
|
||||
use crate::source2::SchemaTypeDeclaredClass;
|
||||
|
||||
#[repr(C)]
|
||||
pub struct UtlRbTree {
|
||||
pad_0000: [u8; 0x8], // 0x0000
|
||||
pub elements: Pointer64<[UtlRbTreeNode]>, // 0x0008
|
||||
pad_0010: [u8; 0x8], // 0x0010
|
||||
pub root: u16, // 0x0018
|
||||
pub num_elements: u16, // 0x001A
|
||||
pad_001c: [u8; 0x10], // 0x001C
|
||||
}
|
||||
|
||||
unsafe impl Pod for UtlRbTree {}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct UtlRbTreeNode {
|
||||
pub left: u16, // 0x0000
|
||||
pub right: u16, // 0x0002
|
||||
pub parent: u16, // 0x0004
|
||||
pub tag: u16, // 0x0006
|
||||
pad_0008: [u8; 0x4], // 0x0008
|
||||
pub data: Pointer64<()>, // 0x000A
|
||||
}
|
||||
|
||||
unsafe impl Pod for UtlRbTreeNode {}
|
96
src/source2/tier1/utl_ts_hash.rs
Normal file
96
src/source2/tier1/utl_ts_hash.rs
Normal file
@@ -0,0 +1,96 @@
|
||||
use memflow::prelude::v1::*;
|
||||
|
||||
use super::UtlMemoryPool;
|
||||
|
||||
use crate::error::Result;
|
||||
use crate::mem::IsNull;
|
||||
|
||||
#[repr(C)]
|
||||
pub struct HashAllocatedBlob<D> {
|
||||
pub next: Pointer64<HashAllocatedBlob<D>>, // 0x0000
|
||||
pad_0008: [u8; 0x8], // 0x0008
|
||||
pub data: D, // 0x0010
|
||||
pad_0018: [u8; 0x8], // 0x0018
|
||||
}
|
||||
|
||||
unsafe impl<D: 'static> Pod for HashAllocatedBlob<D> {}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct HashBucket<D, K> {
|
||||
pad_0000: [u8; 0x18], // 0x0000,
|
||||
pub first: Pointer64<HashFixedData<D, K>>, // 0x0018
|
||||
pub first_uncommited: Pointer64<HashFixedData<D, K>>, // 0x0020
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct HashFixedData<D, K> {
|
||||
pub ui_key: K, // 0x0000
|
||||
pub next: Pointer64<HashFixedData<D, K>>, // 0x0008
|
||||
pub data: D, // 0x0010
|
||||
}
|
||||
|
||||
unsafe impl<D: 'static, K: 'static> Pod for HashFixedData<D, K> {}
|
||||
|
||||
/// Represents a thread-safe hash table.
|
||||
#[repr(C)]
|
||||
pub struct UtlTsHash<D, const C: usize = 256, K = u64> {
|
||||
pub entry_mem: UtlMemoryPool, // 0x0000
|
||||
pad_0018: [u8; 0x8], // 0x0018
|
||||
pub blobs: Pointer64<HashAllocatedBlob<D>>, // 0x0020
|
||||
pad_0028: [u8; 0x58], // 0x0028
|
||||
pub buckets: [HashBucket<D, K>; C], // 0x0080
|
||||
pad_2880: [u8; 0x10], // 0x2880
|
||||
}
|
||||
|
||||
impl<D: Pod + IsNull, const C: usize, K: Pod> UtlTsHash<D, C, K> {
|
||||
/// Returns all elements in the hash table.
|
||||
pub fn elements(&self, process: &mut IntoProcessInstanceArcBox<'_>) -> Result<Vec<D>> {
|
||||
let mut elements: Vec<_> = self
|
||||
.buckets
|
||||
.iter()
|
||||
.flat_map(|bucket| {
|
||||
let mut element_ptr = bucket.first;
|
||||
|
||||
let mut list = Vec::new();
|
||||
|
||||
while !element_ptr.is_null() {
|
||||
if let Ok(element) = element_ptr.read(process) {
|
||||
if !element.data.is_null() {
|
||||
list.push(element.data);
|
||||
}
|
||||
|
||||
element_ptr = element.next;
|
||||
}
|
||||
}
|
||||
|
||||
list
|
||||
})
|
||||
.collect();
|
||||
|
||||
if let Ok(blob) = self.blobs.read(process) {
|
||||
let mut unallocated_data = blob.next;
|
||||
|
||||
if !unallocated_data.is_null() {
|
||||
if !blob.data.is_null() {
|
||||
elements.push(blob.data);
|
||||
}
|
||||
|
||||
while !unallocated_data.is_null() {
|
||||
if let Ok(element) = unallocated_data.read(process) {
|
||||
if !element.data.is_null() {
|
||||
elements.push(element.data);
|
||||
}
|
||||
|
||||
unallocated_data = element.next;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Separate allocated and unallocated data.
|
||||
|
||||
Ok(elements)
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<D: 'static, const C: usize, K: 'static> Pod for UtlTsHash<D, C, K> {}
|
@@ -1,29 +1,30 @@
|
||||
use std::mem;
|
||||
|
||||
use memflow::prelude::v1::*;
|
||||
|
||||
use crate::error::{Error, Result};
|
||||
|
||||
/// Represents a growable array class that doubles in size by default.
|
||||
#[repr(C)]
|
||||
pub struct UtlVector<T: Copy + Sized + Pod> {
|
||||
pub size: u32, // 0x0000
|
||||
pub mem: Pointer64<T>, // 0x0008
|
||||
pub struct UtlVector<T> {
|
||||
pub size: i32, // 0x0000
|
||||
pub mem: Pointer64<[T]>, // 0x0008
|
||||
}
|
||||
|
||||
impl<T: Copy + Sized + Pod> UtlVector<T> {
|
||||
impl<T: Pod> UtlVector<T> {
|
||||
/// Returns the number of elements in the vector.
|
||||
#[inline]
|
||||
pub fn get(&self, process: &mut IntoProcessInstanceArcBox<'_>, idx: usize) -> Result<T> {
|
||||
if idx >= self.size as usize {
|
||||
return Err(Error::OutOfBounds {
|
||||
idx,
|
||||
len: self.size as usize,
|
||||
});
|
||||
pub fn count(&self) -> i32 {
|
||||
self.size
|
||||
}
|
||||
|
||||
/// 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"));
|
||||
}
|
||||
|
||||
let ptr = Pointer64::from(self.mem.address() + (idx * mem::size_of::<T>()));
|
||||
|
||||
Ok(ptr.read(process)?)
|
||||
self.mem.at(idx as _).read(process).map_err(Into::into)
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<T: Copy + Sized + Pod> Pod for UtlVector<T> {}
|
||||
unsafe impl<T: 'static> Pod for UtlVector<T> {}
|
||||
|
Reference in New Issue
Block a user