From 8b1ecb7afbfb4a90645f4dd93254610bc1bd8a58 Mon Sep 17 00:00:00 2001 From: a2x <45197573+a2x@users.noreply.github.com> Date: Wed, 10 Apr 2024 00:53:17 +1000 Subject: [PATCH] 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` --- README.md | 7 +- src/analysis/buttons.rs | 1 - src/analysis/interfaces.rs | 1 - src/analysis/mod.rs | 34 ++- src/analysis/offsets.rs | 6 +- src/analysis/schemas.rs | 18 +- src/main.rs | 72 +++-- src/output/buttons.rs | 109 +++----- src/output/formatter.rs | 20 +- src/output/interfaces.rs | 144 +++++----- src/output/mod.rs | 274 ++++++++---------- src/output/offsets.rs | 132 ++++----- src/output/schemas.rs | 402 +++++++++++++-------------- src/source2/client/input.rs | 1 - src/source2/tier1/interface.rs | 1 - src/source2/tier1/utl_memory.rs | 1 - src/source2/tier1/utl_memory_pool.rs | 1 - src/source2/tier1/utl_ts_hash.rs | 3 +- src/source2/tier1/utl_vector.rs | 1 - 19 files changed, 559 insertions(+), 669 deletions(-) diff --git a/README.md b/README.md index e88ecf0..3107a83 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # cs2-dumper -An external offset/interface dumper for Counter-Strike 2, with support for both Windows & Linux. +An external offset/interface dumper for Counter-Strike 2, with support for both Windows & Linux (soon). Powered by [memflow](https://github.com/memflow/memflow). @@ -21,11 +21,12 @@ E.g. `./cs2-dumper -c pcileech -a device=fpga -vvv` ### Available Arguments -- `-v...`: Increase logging verbosity. Can be specified multiple times. - `-c, --connector `: The name of the memflow connector to use. -- `-a, --connector-args `: Additional arguments to supply to the connector. +- `-a, --connector-args `: Additional arguments to pass to the connector. +- `-f, --file-types `: The types of files to generate. Default: `cs`, `hpp`, `json`, `rs`. - `-o, --output `: The output directory to write the generated files to. Default: `output`. - `-i, --indent-size `: The number of spaces to use per indentation level. Default: `4`. +- `-v...`: Increase logging verbosity. Can be specified multiple times. - `-h, --help`: Print help. - `-V, --version`: Print version. diff --git a/src/analysis/buttons.rs b/src/analysis/buttons.rs index 2eb6689..5fc577b 100644 --- a/src/analysis/buttons.rs +++ b/src/analysis/buttons.rs @@ -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, diff --git a/src/analysis/interfaces.rs b/src/analysis/interfaces.rs index 6e12b8f..bbe5ccf 100644 --- a/src/analysis/interfaces.rs +++ b/src/analysis/interfaces.rs @@ -14,7 +14,6 @@ use crate::source2::InterfaceReg; pub type InterfaceMap = BTreeMap>; -/// Represents an exposed interface. #[derive(Debug, Deserialize, Serialize)] pub struct Interface { pub name: String, diff --git a/src/analysis/mod.rs b/src/analysis/mod.rs index 56793a9..619bef9 100644 --- a/src/analysis/mod.rs +++ b/src/analysis/mod.rs @@ -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