mirror of
https://github.com/a2x/cs2-dumper.git
synced 2025-10-08 05:10:02 +08:00
Refactor code writer and fix minor things
Also added the ability to specify which files should be generated based on their file type. E.g. `cs2-dumper.exe -f hpp,json`
This commit is contained in:
@@ -10,7 +10,6 @@ use serde::{Deserialize, Serialize};
|
||||
use crate::error::{Error, Result};
|
||||
use crate::source2::KeyButton;
|
||||
|
||||
/// Represents a keyboard button.
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
pub struct Button {
|
||||
pub name: String,
|
||||
|
@@ -14,7 +14,6 @@ use crate::source2::InterfaceReg;
|
||||
|
||||
pub type InterfaceMap = BTreeMap<String, Vec<Interface>>;
|
||||
|
||||
/// Represents an exposed interface.
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
pub struct Interface {
|
||||
pub name: String,
|
||||
|
@@ -3,7 +3,33 @@ pub use interfaces::*;
|
||||
pub use offsets::*;
|
||||
pub use schemas::*;
|
||||
|
||||
pub mod buttons;
|
||||
pub mod interfaces;
|
||||
pub mod offsets;
|
||||
pub mod schemas;
|
||||
use memflow::prelude::v1::*;
|
||||
|
||||
use crate::error::Result;
|
||||
|
||||
mod buttons;
|
||||
mod interfaces;
|
||||
mod offsets;
|
||||
mod schemas;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct AnalysisResult {
|
||||
pub buttons: Vec<Button>,
|
||||
pub interfaces: InterfaceMap,
|
||||
pub offsets: OffsetMap,
|
||||
pub schemas: SchemaMap,
|
||||
}
|
||||
|
||||
pub fn analyze_all(process: &mut IntoProcessInstanceArcBox<'_>) -> Result<AnalysisResult> {
|
||||
let buttons = buttons(process)?;
|
||||
let interfaces = interfaces(process)?;
|
||||
let offsets = offsets(process)?;
|
||||
let schemas = schemas(process)?;
|
||||
|
||||
Ok(AnalysisResult {
|
||||
buttons,
|
||||
interfaces,
|
||||
offsets,
|
||||
schemas,
|
||||
})
|
||||
}
|
||||
|
@@ -98,9 +98,9 @@ pattern_map! {
|
||||
"dwNetworkGameClient" => pattern!("48893d${'} 488d15") => None,
|
||||
"dwNetworkGameClient_deltaTick" => pattern!("8983u4 40b7") => None,
|
||||
"dwNetworkGameClient_getLocalPlayer" => pattern!("4883c0u1 488d0440 458b04c7") => Some(|_view, map, rva| {
|
||||
// .text 48 83 C0 0A add rax, 0Ah
|
||||
// .text 48 8D 04 40 lea rax, [rax+rax*2]
|
||||
// .text 45 8B 04 C7 mov r8d, [r15+rax*8]
|
||||
// .text 48 83 C0 0A | add rax, 0Ah
|
||||
// .text 48 8D 04 40 | lea rax, [rax + rax * 2]
|
||||
// .text 45 8B 04 C7 | mov r8d, [r15 + rax * 8]
|
||||
map.insert("dwNetworkGameClient_getLocalPlayer".to_string(), (rva + (rva * 2)) * 8);
|
||||
}),
|
||||
"dwNetworkGameClient_getMaxClients" => pattern!("8b81u2?? c3cccccccccccccccccc 8b81${} ffc0") => None,
|
||||
|
@@ -15,14 +15,14 @@ use crate::source2::*;
|
||||
|
||||
pub type SchemaMap = BTreeMap<String, (Vec<Class>, Vec<Enum>)>;
|
||||
|
||||
#[derive(Clone, Deserialize, Serialize)]
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub enum ClassMetadata {
|
||||
Unknown { name: String },
|
||||
NetworkChangeCallback { name: String },
|
||||
NetworkVarNames { name: String, type_name: String },
|
||||
}
|
||||
|
||||
#[derive(Clone, Deserialize, Serialize)]
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct Class {
|
||||
pub name: String,
|
||||
pub module_name: String,
|
||||
@@ -31,14 +31,14 @@ pub struct Class {
|
||||
pub fields: Vec<ClassField>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Deserialize, Serialize)]
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct ClassField {
|
||||
pub name: String,
|
||||
pub type_name: String,
|
||||
pub offset: i32,
|
||||
}
|
||||
|
||||
#[derive(Clone, Deserialize, Serialize)]
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct Enum {
|
||||
pub name: String,
|
||||
pub alignment: u8,
|
||||
@@ -46,13 +46,13 @@ pub struct Enum {
|
||||
pub members: Vec<EnumMember>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Deserialize, Serialize)]
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct EnumMember {
|
||||
pub name: String,
|
||||
pub value: i64,
|
||||
}
|
||||
|
||||
#[derive(Clone, Deserialize, Serialize)]
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct TypeScope {
|
||||
pub module_name: String,
|
||||
pub classes: Vec<Class>,
|
||||
@@ -63,7 +63,7 @@ pub fn schemas(process: &mut IntoProcessInstanceArcBox<'_>) -> Result<SchemaMap>
|
||||
let schema_system = read_schema_system(process)?;
|
||||
let type_scopes = read_type_scopes(process, &schema_system)?;
|
||||
|
||||
let map: BTreeMap<_, _> = type_scopes
|
||||
let map = type_scopes
|
||||
.into_iter()
|
||||
.map(|type_scope| {
|
||||
(
|
||||
@@ -134,10 +134,10 @@ fn read_class_binding_fields(
|
||||
}
|
||||
|
||||
let name = field.name.read_string(process)?.to_string();
|
||||
let type_ = field.schema_type.read(process)?;
|
||||
let schema_type = field.schema_type.read(process)?;
|
||||
|
||||
// TODO: Parse this properly.
|
||||
let type_name = type_.name.read_string(process)?.replace(" ", "");
|
||||
let type_name = schema_type.name.read_string(process)?.replace(" ", "");
|
||||
|
||||
acc.push(ClassField {
|
||||
name,
|
||||
|
Reference in New Issue
Block a user