From 900e5d2acce16124c4ec4325d27c32b3e2848585 Mon Sep 17 00:00:00 2001 From: Janek <development@superyu.xyz> Date: Wed, 3 Apr 2024 20:02:36 +0200 Subject: [PATCH] feat: skip version Allows to skip the game buiold number version check. Related to #13. --- src/cli.rs | 4 ++++ src/dma/context/mod.rs | 6 ++++-- src/dma/mod.rs | 4 ++-- src/main.rs | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index 8ccfe9c..500c96b 100755 --- a/src/cli.rs +++ b/src/cli.rs @@ -28,6 +28,10 @@ pub struct Cli { /// Verbosity level for logging to the console #[arg(value_enum, long, short, ignore_case = true, default_value_t = Loglevel::Warn)] pub loglevel: Loglevel, + + /// Skip the dwBuildNumber check, allows for running with *possibly* outdated offsets. + #[arg(long)] + pub skip_version: bool, } fn version() -> String { diff --git a/src/dma/context/mod.rs b/src/dma/context/mod.rs index 50ede3c..256b4b5 100755 --- a/src/dma/context/mod.rs +++ b/src/dma/context/mod.rs @@ -31,7 +31,7 @@ impl DmaCtx { Ok(()) } - pub fn setup(connector: Connector, pcileech_device: String) -> anyhow::Result<DmaCtx> { + pub fn setup(connector: Connector, pcileech_device: String, skip_version: bool) -> anyhow::Result<DmaCtx> { let inventory = Inventory::scan(); let os = { @@ -66,7 +66,9 @@ impl DmaCtx { engine_module, }; - ctx.check_version()?; + if !skip_version { + ctx.check_version()?; + } Ok(ctx) } diff --git a/src/dma/mod.rs b/src/dma/mod.rs index 7f2c5a0..63f0288 100755 --- a/src/dma/mod.rs +++ b/src/dma/mod.rs @@ -12,8 +12,8 @@ mod cs2dumper; pub use context::Connector; -pub async fn run(radar_data: ArcRwlockRadarData, connector: Connector, pcileech_device: String) -> anyhow::Result<()> { - let mut ctx = DmaCtx::setup(connector, pcileech_device)?; +pub async fn run(radar_data: ArcRwlockRadarData, connector: Connector, pcileech_device: String, skip_version: bool) -> anyhow::Result<()> { + let mut ctx = DmaCtx::setup(connector, pcileech_device, skip_version)?; let mut data = CsData::default(); // For read timing diff --git a/src/main.rs b/src/main.rs index caa9d9b..2d9619b 100755 --- a/src/main.rs +++ b/src/main.rs @@ -30,7 +30,7 @@ async fn main() -> anyhow::Result<()> { let radar_clone = radar_data.clone(); let dma_handle = tokio::spawn(async move { - if let Err(err) = dma::run(radar_clone, cli.connector, cli.pcileech_device).await { + if let Err(err) = dma::run(radar_clone, cli.connector, cli.pcileech_device, cli.skip_version).await { log::error!("Error in dma thread: [{}]", err.to_string()); } else { println!("CS2 Process exited, exiting program...")