mirror of
https://github.com/a2x/cs2-dumper.git
synced 2025-07-06 20:09:42 +08:00
Compare commits
3 Commits
11d99ac058
...
86dc0fa8f6
Author | SHA1 | Date | |
---|---|---|---|
|
86dc0fa8f6 | ||
|
ef5ff1c5f4 | ||
|
4a10ad3ba6 |
10
README.md
10
README.md
@ -19,20 +19,16 @@ toolchain must be installed.
|
||||
- For Linux: `config_linux.json`
|
||||
- For Windows: `config_win.json`
|
||||
|
||||
When running the executable without providing an optional memflow connector name, it will default to using the
|
||||
memflow-native cross-platform OS layer to read the game's memory. However, any existing memflow connectors should work
|
||||
out of the box.
|
||||
Just pass the `connector` and optional `connector-args` arguments to the program.
|
||||
When running the executable without providing an optional memflow connector name, it will default to using the [memflow-native](https://github.com/memflow/memflow-native) cross-platform OS layer to read the memory of the game process. If you wish to use an existing memflow connector instead, pass the `connector` and optional `connector-args` arguments to the program.
|
||||
|
||||
E.g. `cs2-dumper.exe -c pcileech -a device=fpga -vvv`
|
||||
E.g. `./cs2-dumper -c kvm -vvv`
|
||||
|
||||
### Available Arguments
|
||||
|
||||
- `-v...`: Increase logging verbosity. Can be specified multiple times.
|
||||
- `-c, --connector <connector>`: The name of the memflow connector to use.
|
||||
- `-a, --connector-args <connector-args>`: Additional arguments to supply to the connector.
|
||||
- `-o, --os <os>`: The name of the target operating system.
|
||||
- `-d, --directory <directory>`: The output directory to write the generated files to. Default: `output`.
|
||||
- `-o, --output <output>`: The output directory to write the generated files to. Default: `output`.
|
||||
- `-i, --indent-size <indent-size>`: The number of spaces to use per indentation level. Default: `4`.
|
||||
- `-h, --help`: Print help.
|
||||
- `-V, --version`: Print version.
|
||||
|
@ -5,16 +5,16 @@ use std::{env, fs};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
pub static CONFIG: LazyLock<Config> = LazyLock::new(|| {
|
||||
let file_name = match env::consts::OS {
|
||||
"linux" => "config_linux.json",
|
||||
"windows" => "config_win.json",
|
||||
os => panic!("unsupported os: {}", os),
|
||||
};
|
||||
let file_name = get_config_file_name();
|
||||
|
||||
let content = fs::read_to_string(file_name).expect("unable to read config file");
|
||||
let config: Config = serde_json::from_str(&content).expect("unable to parse config file");
|
||||
let content = fs::read_to_string(&file_name).unwrap_or_else(|_| {
|
||||
panic!(
|
||||
"unable to read config file: {}\nmake sure the file is placed in the same directory as the cs2-dumper executable",
|
||||
file_name
|
||||
)
|
||||
});
|
||||
|
||||
config
|
||||
serde_json::from_str(&content).expect("unable to parse config file")
|
||||
});
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
@ -59,3 +59,18 @@ pub struct Signature {
|
||||
/// List of operations to perform on the matched address.
|
||||
pub operations: Vec<Operation>,
|
||||
}
|
||||
|
||||
/// Returns the correct config file name, depending on the target OS.
|
||||
fn get_config_file_name() -> &'static str {
|
||||
// Assume that if the user has provided a connector name, they are targetting the Windows
|
||||
// version of the game.
|
||||
if env::args().any(|arg| arg.starts_with("--connector") || arg.starts_with("-c")) {
|
||||
"config_win.json"
|
||||
} else {
|
||||
match env::consts::OS {
|
||||
"linux" => "config_linux.json",
|
||||
"windows" => "config_win.json",
|
||||
os => panic!("unsupported os: {}", os),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
34
src/main.rs
34
src/main.rs
@ -26,7 +26,7 @@ fn main() -> Result<()> {
|
||||
let start_time = Instant::now();
|
||||
|
||||
let matches = parse_args();
|
||||
let (conn_name, conn_args, os_name, indent_size, out_dir) = extract_args(&matches)?;
|
||||
let (conn_name, conn_args, indent_size, out_dir) = extract_args(&matches)?;
|
||||
|
||||
// Create the output directory if it doesn't exist.
|
||||
fs::create_dir_all(&out_dir)?;
|
||||
@ -38,7 +38,7 @@ fn main() -> Result<()> {
|
||||
.builder()
|
||||
.connector(&conn_name)
|
||||
.args(conn_args)
|
||||
.os(&os_name)
|
||||
.os("win32")
|
||||
.build()?
|
||||
} else {
|
||||
// Fallback to the native OS layer if no connector name was provided.
|
||||
@ -86,17 +86,10 @@ fn parse_args() -> ArgMatches {
|
||||
.required(false),
|
||||
)
|
||||
.arg(
|
||||
Arg::new("os")
|
||||
.help("The name of the target operating system.")
|
||||
.long("os")
|
||||
.short('o')
|
||||
.required(false),
|
||||
)
|
||||
.arg(
|
||||
Arg::new("directory")
|
||||
Arg::new("output")
|
||||
.help("The output directory to write the generated files to.")
|
||||
.long("directory")
|
||||
.short('d')
|
||||
.long("output")
|
||||
.short('o')
|
||||
.default_value("output")
|
||||
.value_parser(value_parser!(PathBuf))
|
||||
.required(false),
|
||||
@ -113,9 +106,7 @@ fn parse_args() -> ArgMatches {
|
||||
.get_matches()
|
||||
}
|
||||
|
||||
fn extract_args(
|
||||
matches: &ArgMatches,
|
||||
) -> Result<(Option<String>, ConnectorArgs, String, usize, &PathBuf)> {
|
||||
fn extract_args(matches: &ArgMatches) -> Result<(Option<String>, ConnectorArgs, usize, &PathBuf)> {
|
||||
use std::str::FromStr;
|
||||
|
||||
let log_level = match matches.get_count("verbose") {
|
||||
@ -144,17 +135,8 @@ fn extract_args(
|
||||
.map(|s| ConnectorArgs::from_str(&s).expect("unable to parse connector arguments"))
|
||||
.unwrap_or_default();
|
||||
|
||||
let os_name = matches
|
||||
.get_one::<String>("os")
|
||||
.map(|s| s.to_string())
|
||||
.unwrap_or_else(|| match env::consts::OS {
|
||||
"linux" => "linux".to_string(),
|
||||
"windows" => "win32".to_string(),
|
||||
os => panic!("unsupported os: {}", os),
|
||||
});
|
||||
|
||||
let indent_size = *matches.get_one::<usize>("indent-size").unwrap();
|
||||
let out_dir = matches.get_one::<PathBuf>("directory").unwrap();
|
||||
let out_dir = matches.get_one::<PathBuf>("output").unwrap();
|
||||
|
||||
Ok((conn_name, conn_args, os_name, indent_size, out_dir))
|
||||
Ok((conn_name, conn_args, indent_size, out_dir))
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user