### Formatter Example Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/output_api.md Example demonstrating how to create a Formatter and write a line of code with indentation. Requires a mutable String and indent size. ```rust let mut output = String::new(); let mut fmt = Formatter::new(&mut output, 4); writeln!(fmt, "pub const value = 42;")?; ``` -------------------------------- ### Run cs2-dumper with pcileech connector Source: https://github.com/a2x/cs2-dumper/blob/main/README.md Example of running the cs2-dumper executable with the pcileech connector and additional arguments. Ensure the connector is installed and managed via memflowup. Elevated privileges may be required. ```bash cs2-dumper -c pcileech -a :device=FPGA -vv ``` -------------------------------- ### PCILeech Connector Arguments Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/configuration.md Example of passing specific arguments to the PCILeech connector, such as setting the device to FPGA. ```bash -a ":device=FPGA" ``` -------------------------------- ### Print cs2-dumper version Source: https://github.com/a2x/cs2-dumper/blob/main/README.md Example of running cs2-dumper to display its version information. ```bash cs2-dumper --version ``` -------------------------------- ### Print cs2-dumper help message Source: https://github.com/a2x/cs2-dumper/blob/main/README.md Example of running cs2-dumper to display the help message, which lists all available arguments. ```bash cs2-dumper --help ``` -------------------------------- ### WinIO Connector Arguments (Windows) Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/configuration.md Example of passing arguments to the WinIO connector on Windows, such as setting specific flags. ```bash -a ":flags=0x1" ``` -------------------------------- ### KVM Connector Arguments (Linux) Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/configuration.md Example of passing arguments to the KVM connector on Linux, specifying the socket path. ```bash -a ":socket=/var/run/kvm.sock" ``` -------------------------------- ### Basic CS2 Dumper Usage Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/configuration.md Launches CS2 Dumper with default settings. This is the simplest way to start the dumping process. ```bash cs2-dumper ``` -------------------------------- ### Run cs2-dumper with custom process name Source: https://github.com/a2x/cs2-dumper/blob/main/README.md Example of running cs2-dumper and specifying a custom process name for the game. ```bash cs2-dumper -p my_cs2_process.exe ``` -------------------------------- ### Run cs2-dumper with custom output directory and file types Source: https://github.com/a2x/cs2-dumper/blob/main/README.md Example of running cs2-dumper with custom output directory and specifying the file types to generate. ```bash cs2-dumper -o my_output -f cs,hpp ``` -------------------------------- ### Example Class JSON Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/data_structures.md Illustrates the JSON structure for a game class, showing its name, module, parent, and fields with their types and offsets. ```json { "name": "C_BaseEntity", "module_name": "client.dll", "parent_name": null, "metadata": [], "fields": [ { "name": "m_pGameSceneNode", "type_name": "CGameSceneNode*", "offset": 16 }, { "name": "m_vecAbsOrigin", "type_name": "Vector", "offset": 32 } ] } ``` -------------------------------- ### Info File JSON Structure Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/integration_guide.md Example structure of the info.json file, containing metadata like timestamp and build number. ```json { "timestamp": "2025-02-15T10:30:45.123456Z", "build_number": 15421 } ``` -------------------------------- ### Pattern Syntax Examples Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/analysis_submodules.md Illustrates various Pelite pattern syntaxes used for defining memory signatures, including byte sequences, wildcards, and relative offset placeholders. ```plaintext 488b15${'} 4885d2 ``` ```plaintext 488905${'} 0f57c0 ``` ```plaintext u4 ``` ```plaintext [4] ``` ```plaintext ${'} ``` ```plaintext ${} ``` -------------------------------- ### Example Usage of Offsets Function Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/analysis_submodules.md Demonstrates how to call the `offsets` function and iterate through the returned `OffsetMap` to print module names and their associated offsets. ```rust let offsets = analysis::offsets(&mut process)?; for (module, offset_map) in offsets { println!(ירת{}:", module); for (name, rva) in offset_map { println!(" {} = 0x{:X}", name, rva); } } ``` -------------------------------- ### C++: Read Offset Chain Example Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/integration_guide.md Illustrates reading a value through multiple pointer dereferences using C++ and offset chains. ```cpp // Read a value through multiple pointer dereferencing uintptr_t entity_list = *(uintptr_t*)(client_base + offsets::client::dwEntityList); uintptr_t entity = *(uintptr_t*)(entity_list + i * 0x10); uintptr_t health_component = *(uintptr_t*)(entity + offsets::client::m_health_component); uint32_t health = *(uint32_t*)(health_component + 0x10); ``` -------------------------------- ### Example Enum JSON Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/data_structures.md Demonstrates the JSON representation of an enumeration, including its name, alignment, size, and members with their values. ```json { "name": "RenderMotionBlurType_t", "alignment": 4, "size": 3, "members": [ { "name": "RMAT_DISABLE", "value": 0 }, { "name": "RMAT_FORWARD", "value": 1 }, { "name": "RMAT_BACKWARD", "value": 2 } ] } ``` -------------------------------- ### C++: Schema Field Access Example Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/integration_guide.md Demonstrates using schema information to calculate member addresses within a C++ struct. ```cpp // Use schema to calculate member addresses struct C_BaseEntity { void* pGameSceneNode; // offset 0x10 }; void read_player_origin(uintptr_t entity_addr, float* origin) { uintptr_t scene_node = *(uintptr_t*)(entity_addr + 0x10); memcpy(origin, (void*)(scene_node + 0x20), sizeof(float) * 3); } ``` -------------------------------- ### Example Usage of interfaces() Function Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/analysis_submodules.md Demonstrates how to use the `interfaces` function to retrieve a map of modules and their registered interfaces. It then iterates through the map to print the module name, interface name, and its RVA. ```rust let interfaces = analysis::interfaces(&mut process)?; for (module, ifaces) in interfaces { for (iface_name, rva) in ifaces { println!("{}: {} = 0x{:X}", module, iface_name, rva); } } ``` -------------------------------- ### Example: RIP-Relative `mov` Instruction Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/pattern_scanning.md Illustrates offset calculation for a `mov [rip+offset], value` instruction, showing how to determine the absolute address and RVA from the pattern's displacement. ```plaintext Instruction: 488905 AABBCCDD save[1] = 0xAABBCCDD (4-byte displacement) instruction_end = pattern_address + 3 + 4 = pattern_address + 7 abs_address = instruction_end + rel32 RVA = abs_address - module.base ``` -------------------------------- ### Run cs2-dumper with increased logging verbosity Source: https://github.com/a2x/cs2-dumper/blob/main/README.md Example of running cs2-dumper with increased logging verbosity by specifying the -v flag multiple times. ```bash cs2-dumper -vvv ``` -------------------------------- ### Run cs2-dumper with default connector Source: https://github.com/a2x/cs2-dumper/blob/main/README.md Example of running the cs2-dumper executable without specifying a memflow connector. It will default to using the memflow-native OS layer. ```bash cs2-dumper ``` -------------------------------- ### Example Usage of schemas() (Rust) Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/analysis_submodules.md Demonstrates how to call the `schemas()` function and iterate through the returned schema map to print module names, class counts, enum counts, and class field details. This is useful for inspecting game data structures. ```rust let schemas = analysis::schemas(&mut process)?; for (module, (classes, enums)) in schemas { println!("{}:", module); println!(" {} classes", classes.len()); println!(" {} enums", enums.len()); for class in classes { println!(" {}", class.name); for field in class.fields { println!(" {} @ 0x{:X}", field.name, field.offset); } } } ``` -------------------------------- ### Callback Pattern for dwCSGOInput and dwViewAngles Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/pattern_scanning.md Similar to the previous example, this callback finds dwViewAngles by performing a secondary scan relative to the dwCSGOInput pattern. The offset is derived and added to the primary RVA. ```rust "dwCSGOInput" => pattern!("488905${"} 0f57c0 0f1105") => Some(|view, map, rva| { let mut save = [0; 2]; if view.scanner().finds_code(pattern!("f2420f108428u4"), &mut save) { map.insert("dwViewAngles".to_string(), rva + save[1]); } }), ``` -------------------------------- ### Resolve Interface in C++ Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/integration_guide.md Demonstrates how to resolve game interfaces using their factory function RVAs from the generated interfaces file. This involves getting the CreateInterface export and calling the factory. ```cpp #include "cs2_dumper/interfaces.hpp" typedef void* (*CreateInterfaceFn)(const char*, int*); void* get_interface(uintptr_t module_base, const char* interface_name) { // Read CreateInterface export CreateInterfaceFn create_interface = (CreateInterfaceFn) GetProcAddress((HMODULE)module_base, "CreateInterface"); // Call to instantiate return create_interface(interface_name, nullptr); } void example(uintptr_t client_base) { // Use known interface offset uintptr_t factory = client_base + cs2_dumper::interfaces::client[0]; // Example // Call factory function void* interface = ((void*(*)())factory)(); } ``` -------------------------------- ### Callback Function for Derived Offsets Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/analysis_submodules.md An example of a callback function used with `pattern_map!`. It receives the PE view, current offset map, and found pattern RVA to calculate and insert secondary offsets. ```rust "dwPrediction" => pattern!(...) => Some(|view, map, rva| { // Callback receives: // - view: PE binary view // - map: Current offset map to add to // - rva: Found pattern RVA // Use scanner to find secondary pattern // Calculate derived offset relative to rva // Insert into map }), ``` -------------------------------- ### Create Output Instance Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/output_api.md Instantiates an Output object, ensuring the output directory exists. Specify target file types, indentation size, output directory, and analysis results. ```rust let file_types = vec!["json", "rs"].into_iter().map(|s| s.to_string()).collect::>(); let output = Output::new(&file_types, 4, Path::new("output"), &analysis_result)?; ``` -------------------------------- ### Use Build Info from info.json (Python) Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/integration_guide.md Reads the info.json file to access build number and timestamp, then prints formatted information about the dump. ```python import json from datetime import datetime with open('output/info.json') as f: info = json.load(f) build = info['build_number'] timestamp = datetime.fromisoformat(info['timestamp'].replace('Z', '+00:00')) print(f"Dump from build {build} at {timestamp}") ``` -------------------------------- ### Rust: Usage Pattern for Offsets Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/integration_guide.md Demonstrates how to use imported offsets to calculate memory addresses in Rust. ```rust use cs2_dumper::offsets; let addr = module_base + offsets::client::dwLocalPlayerController; ``` -------------------------------- ### Project File List Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/MANIFEST.md Lists all documentation files and their primary purpose. ```text 1. README.md - Entry point and navigation guide 2. INDEX.md - Master index and architecture overview 3. Configuration.md - CLI and environment setup 4. Overview.md - Project identity 5. Analysis API.md - Core APIs 6. Analysis Sub-modules.md - Algorithm details 7. Output API.md - Code generation system 8. Memory API.md - Address utilities 9. Source2 Types.md - Binary structures 10. Data Structures.md - Result types 11. Pattern Scanning.md - Offset discovery 12. Integration Guide.md - Using the output 13. Errors & Edge Cases.md - Troubleshooting 14. MANIFEST.md - This file ``` -------------------------------- ### Use PCILeech Connector with Arguments Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/configuration.md Attaches to the CS2 process using the PCILeech connector with specific arguments, increasing logging verbosity to info level. ```bash cs2-dumper -c pcileech -a ":device=FPGA" -vv ``` -------------------------------- ### Output::new() Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/output_api.md Creates an Output instance and ensures the output directory exists. It takes a list of target file types, indentation size, output directory path, and the analysis result. ```APIDOC ## Output::new() ### Description Creates an Output instance and ensures the output directory exists. ### Method `Output::new()` ### Parameters - **file_types** (&[String]) - List of file type names to generate - **indent_size** (usize) - Indentation width - **out_dir** (&Path) - Target directory (created if missing) - **result** (&AnalysisResult) - Analysis data to output ### Returns `Result>` ### Errors - Directory creation fails (permission denied, invalid path) ### Example ```rust let file_types = vec!["json", "rs"].into_iter().map(|s| s.to_string()).collect::>(); let output = Output::new(&file_types, 4, Path::new("output"), &analysis_result)?; ``` ``` -------------------------------- ### Check for Null Pointer in Linked List Node Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/errors_and_edge_cases.md Safely traverse a linked list by checking for null pointers before dereferencing. This example also includes a check for the list terminator. ```rust if button_ptr.is_null() { break; } let button = mem.read_ptr(button_ptr).data_part()?; if button.next.is_null() && button_ptr.address() != previous { debug!("list terminator found"); } ``` -------------------------------- ### Use KVM Connector on Linux Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/configuration.md Launches CS2 Dumper on Linux using the KVM connector, specifying the process name and increasing logging verbosity to info level. Requires root privileges. ```bash sudo cs2-dumper -c kvm -p cs2 -vv ``` -------------------------------- ### C#: Usage Pattern for Offsets Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/integration_guide.md Demonstrates accessing game offsets using the CS2 Dumper C# namespace. ```csharp using CS2Dumper.Offsets; IntPtr addr = clientBase + Client.dwLocalPlayerController; ``` -------------------------------- ### Zig: Usage Pattern for Offsets Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/integration_guide.md Shows how to access game offsets using the CS2 Dumper Zig module structure. ```zig const offset = cs2_dumper.offsets.client.dwBuildNumber; ``` -------------------------------- ### Dump All Output Files Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/output_api.md Generates and writes all specified output files (buttons, interfaces, offsets, schemas, info.json) to the configured directory. Requires a process handle to read the build number for info.json. ```rust let mut process = os.process_by_name("cs2.exe")?; output.dump_all(&mut process)?; println!("Files written to output/"); ``` -------------------------------- ### Read Button State in Rust Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/integration_guide.md Reads button states like 'in_jump' using the generated buttons module. This example requires a MemoryView trait implementation and handles potential errors with Result. ```rust use cs2_dumper::buttons; fn read_button_state(process: &mut impl MemoryView, client_base: Address) -> Result<()> { let jump_state: u32 = process.read(client_base + buttons::in_jump).data_part()?; if jump_state != 0 { println!("Jump key is pressed"); } Ok(()) } ``` -------------------------------- ### Create Output Directory in Rust Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/errors_and_edge_cases.md Ensures the output directory exists before writing files. Errors if creation fails due to permissions or other I/O issues. ```rust fs::create_dir_all(&out_dir)?; ``` -------------------------------- ### Perform Full Analysis Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/analysis_api.md Use this function as the entry point for a complete analysis pass. It sequentially calls sub-analysis functions and logs summary statistics. Partial results are returned if individual analyses fail. ```rust pub fn analyze_all(process: &mut P) -> Result ``` ```rust let mut process = os.process_by_name("cs2.exe")?; let result = analysis::analyze_all(&mut process)?; println!("Found {} buttons", result.buttons.len()); println!("Found {} interfaces", result.interfaces.iter() .map(|(_, m)| m.len()) .sum::()); ``` -------------------------------- ### Project Size Summary Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/MANIFEST.md Provides a summary of the documentation's size and structure. ```text Total Lines: 3,673 Total Size: 124 KB Document Count: 13 Average Document: 280 lines Largest Document: INDEX.md (440 lines) Smallest Document: Overview.md (60 lines) ``` -------------------------------- ### interfaces Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/analysis_api.md Scans all modules for CreateInterface export and resolves interface registry linked lists. ```APIDOC ## interfaces ### Description Scans all modules for CreateInterface export and resolves interface registry linked lists. ### Signature ```rust pub fn interfaces(process: &mut P) -> Result ``` ### Parameters - **process** (`&mut P`): Mutable process handle from memflow with MemoryView trait. ### Returns - `Result`: A map of resolved interfaces. ``` -------------------------------- ### C++: Usage Pattern for Offsets Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/integration_guide.md Shows how to access game offsets using the CS2 Dumper C++ headers. ```cpp #include "cs2_dumper/offsets.hpp" uintptr_t addr = module_base + cs2_dumper::offsets::client::dwBuildNumber; ``` -------------------------------- ### Info Output - JSON Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/output_api.md Generates JSON output for general information, including timestamp and build number. Useful for tracking build details. ```json { "timestamp": "2025-02-15T10:30:45.123456Z", "build_number": 15421 } ``` -------------------------------- ### CS2 Dumper Architecture Overview Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/INDEX.md This diagram illustrates the main components and flow of the CS2 Dumper project, from argument parsing to data output. ```text main.rs ├─ Parse CLI arguments (Args via clap) ├─ Initialize logging (simplelog) ├─ Create memflow process handle │ └─ analysis::analyze_all(&mut process) ├─ analysis::buttons() → ButtonMap │ └─ Pattern scan client.dll for button list ├─ analysis::interfaces() → InterfaceMap │ └─ Enumerate CreateInterface per module ├─ analysis::offsets() → OffsetMap │ └─ 5 modules with pre-defined patterns └─ analysis::schemas() → SchemaMap └─ Walk SchemaSystem singleton └─ Output::new() and dump_all() ├─ For each file type (cs, hpp, json, rs, zig) │ ├─ Format buttons → buttons.{ext} │ ├─ Format interfaces → interfaces.{ext} │ ├─ Format offsets → offsets.{ext} │ └─ Format schemas → {module}.{ext} └─ Serialize metadata → info.json ``` -------------------------------- ### Rust: Conditional Offset Usage Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/integration_guide.md Shows how to use different offsets based on game state in Rust. ```rust // Use different offsets based on game state let offset = if is_local_player { offsets::client::dwLocalPlayerPawn } else { offsets::client::dwEntityList }; let addr = client_base + offset; ``` -------------------------------- ### Run cs2-dumper tests Source: https://github.com/a2x/cs2-dumper/blob/main/README.md Command to execute the provided basic tests for the cs2-dumper project. The --nocapture flag ensures that test output is displayed. ```bash cargo test -- --nocapture ``` -------------------------------- ### Run CS2 Dumper Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/README.md Execute the CS2 dumper tool with specified output directory and verbosity level. Refer to the Configuration Reference for all available options. ```bash cs2-dumper -o ./dumps -vv ``` -------------------------------- ### analyze_all Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/analysis_api.md Entry point for a complete analysis pass of the CS2 process. It sequentially calls sub-analysis functions and logs summary statistics. Partial results are returned if individual analyses fail. ```APIDOC ## analyze_all ### Description Entry point for complete analysis pass. Calls analyze() on buttons, interfaces, offsets, and schemas in sequence. Logs summary statistics and returns partial results if individual analyses fail. ### Signature ```rust pub fn analyze_all(process: &mut P) -> Result ``` ### Parameters - **process** (`&mut P`): Mutable process handle from memflow with MemoryView trait. ### Returns - `Result`: Containing all extracted data or an error. ### Behavior - Calls analyze() on buttons, interfaces, offsets, and schemas in sequence. - Logs summary statistics (button count, interface/offset counts per module, class/enum counts). - Returns partial results if individual analyses fail (empty maps instead of error propagation). - Each sub-analysis failure is logged at ERROR level. ### Errors - Process module list unavailable. - Binary format unreadable (not a PE). - Schema system unreachable or outdated patterns. ### Example ```rust let mut process = os.process_by_name("cs2.exe")?; let result = analysis::analyze_all(&mut process)?; println!("Found {} buttons", result.buttons.len()); println!("Found {} interfaces", result.interfaces.iter() .map(|(_, m)| m.len()) .sum::()); ``` ``` -------------------------------- ### Inspect JSON Schema for C_BaseEntity Fields (Python) Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/integration_guide.md Loads a JSON schema file (e.g., client_dll.json) and prints the fields and their offsets for a specified class, such as C_BaseEntity. ```python import json with open('output/client_dll.json') as f: schema = json.load(f) classes = schema['client.dll']['classes'] # Find class C_BaseEntity if 'C_BaseEntity' in classes: entity_class = classes['C_BaseEntity'] print(f"Fields in C_BaseEntity:") for field_name, field_offset in entity_class['fields'].items(): print(f" {field_name} @ 0x{field_offset:X}") ``` -------------------------------- ### File Organization Overview Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/README.md This tree structure outlines the organization of the CS2 Dumper project's documentation files, categorizing them into User, API, and Developer documentation. ```plaintext . ├── INDEX.md (START HERE for navigation) ├── README.md (this file) │ ├── User Documentation │ ├── overview.md (what the project does) │ ├── configuration.md (how to run it) │ └── integration_guide.md (how to use the output) │ ├── API Documentation │ ├── analysis_api.md (core entry point) │ ├── output_api.md (code generation) │ ├── memory_api.md (address utilities) │ └── source2_types.md (binary structures) │ └── Developer Documentation ├── analysis_submodules.md (implementation details) ├── data_structures.md (type definitions) ├── pattern_scanning.md (pattern discovery) └── errors_and_edge_cases.md (troubleshooting) ``` -------------------------------- ### Output::dump_all() Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/output_api.md Generates all output files including buttons, interfaces, offsets, per-module schemas, and info.json. It requires a mutable process handle for reading the build number. ```APIDOC ## Output::dump_all() ### Description Generates all output files (buttons, interfaces, offsets, per-module schemas, info.json). ### Method `Output::dump_all()` ### Parameters - **process** (&mut P) - Process handle for reading build number for info.json ### Returns `Result<()>` ### Errors - File write fails - Build number offset unreachable - JSON serialization fails ### Output Files - For each file type in self.file_types: - buttons.{type} - interfaces.{type} - offsets.{type} - {module_name}.{type} (one per schema module) - info.json (timestamp, build number) ### Example ```rust let mut process = os.process_by_name("cs2.exe")?; output.dump_all(&mut process)?; println!("Files written to output/"); ``` ``` -------------------------------- ### Python: Batch Offset Application Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/integration_guide.md Applies all offsets from a module to a base address and stores them in a dictionary for later reference in Python. ```python # Apply all offsets from a module offsets_dict = offsets['client.dll'] addresses = { name: client_base + rva for name, rva in offsets_dict.items() } # Later, reference by name entity_list_addr = addresses['dwEntityList'] ``` -------------------------------- ### offsets Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/analysis_api.md Uses pattern map macro to find predefined offsets in various game DLLs. ```APIDOC ## offsets ### Description Uses pattern map macro to find predefined offsets in client.dll, engine2.dll, inputsystem.dll, matchmaking.dll, and soundsystem.dll. ### Signature ```rust pub fn offsets(process: &mut P) -> Result ``` ### Parameters - **process** (`&mut P`): Mutable process handle from memflow with MemoryView trait. ### Returns - `Result`: A map of discovered offsets. ``` -------------------------------- ### Rust: Import Offsets Module Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/integration_guide.md Import the necessary modules for accessing button, offset, and interface definitions in Rust. ```rust mod cs2_dumper { pub mod buttons { ... } pub mod offsets { ... } pub mod interfaces { ... } } ``` -------------------------------- ### C++: Include Headers Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/integration_guide.md Include necessary headers for using CS2 Dumper offsets and definitions in C++. ```cpp #pragma once #include #include namespace cs2_dumper { namespace offsets { ... } namespace buttons { ... } } ``` -------------------------------- ### Python: JSON Offset Loading Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/integration_guide.md Loads game offsets from a JSON file and accesses specific client offsets in Python. ```python import json with open('output/offsets.json') as f: offsets = json.load(f) client_offsets = offsets['client.dll'] value = client_offsets['dwBuildNumber'] ``` -------------------------------- ### Check Game Build Number Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/integration_guide.md Compare the current game's build number with the one used for dumping to detect potential offset mismatches due to game updates. ```python current_build = dump_build = info['build_number'] if current_build != dump_build: print(f"Build mismatch: game {current_build} vs dump {dump_build}") ``` -------------------------------- ### TypeScope to SchemaMap Conversion Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/data_structures.md Demonstrates how to convert a collection of TypeScope objects into a SchemaMap using an iterator. ```rust SchemaMap::from_iter( type_scopes.into_iter().map(|ts| { (ts.module_name, (ts.classes, ts.enums)) }) ) ``` -------------------------------- ### Read Game State Offsets in Rust Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/integration_guide.md Demonstrates reading module-specific offsets like dwBuildNumber and dwLocalPlayerController using the generated offsets module. Requires a MemoryView and handles module lookup errors. ```rust use cs2_dumper::offsets; fn read_game_state(process: &mut impl MemoryView) -> Result<()> { // Get module bases let client = process.module_by_name("client.dll")?; let engine = process.module_by_name("engine2.dll")?; // Read build number let build: u32 = process.read( engine.base + offsets::engine2::dwBuildNumber ).data_part()?; // Read local player controller let controller: u64 = process.read( client.base + offsets::client::dwLocalPlayerController ).data_part()?; println!("Build: {}, Controller: 0x{:X}", build, controller); Ok(()) } ``` -------------------------------- ### JSON Representation of Schema Data Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/data_structures.md Illustrates the expected JSON output format for schema data, showing module name, classes, and enums. ```json { "client.dll": { "classes": { "C_BaseEntity": { "module_name": "client.dll", "parent_name": null, "metadata": [], "fields": { "m_pGameSceneNode": 0x10, "m_vecAbsOrigin": 0x20 } } }, "enums": { ... } } } ``` -------------------------------- ### Analyze Offsets Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/analysis_api.md Uses pattern map macro to find predefined offsets in core game DLLs including client.dll, engine2.dll, inputsystem.dll, matchmaking.dll, and soundsystem.dll. Requires a mutable process handle with the MemoryView trait. ```rust pub fn offsets(process: &mut P) -> Result ``` -------------------------------- ### interfaces() - Discover CreateInterface Interfaces Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/analysis_submodules.md Discovers all CreateInterface-registered interfaces across all loaded modules in a process. It returns a map where keys are module names and values are maps of interface names to their instance function RVAs. ```APIDOC ## interfaces(process: &mut P) -> Result ### Description Discovers all CreateInterface-registered interfaces across all loaded modules. ### Parameters #### Path Parameters - **process** (Process handle) - Required - The process handle to inspect. ### Returns - **Result** - A map of modules and their interfaces. The map is structured as `module name` -> (`interface name` -> `instance function RVA`). ### Example Usage ```rust let interfaces = analysis::interfaces(&mut process)?; for (module, ifaces) in interfaces { for (iface_name, rva) in ifaces { println!("{}: {} = 0x{:X}", module, iface_name, rva); } } ``` ``` -------------------------------- ### Specify Custom Output Directory Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/configuration.md Configures CS2 Dumper to write generated files to a specific directory. The directory will be created if it does not exist. ```bash cs2-dumper -o ./dumps ``` -------------------------------- ### Check Module Base Address and Size Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/errors_and_edge_cases.md Verify the base address and size of a module by name. This is crucial for diagnosing issues where the module base address might be wrong or the binary is corrupted. ```rust let module = process.module_by_name("client.dll")?; println!("Module: {} base=0x{:X} size=0x{:X}", module.name, module.base, module.size); ``` -------------------------------- ### Read Game State Offsets in C++ Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/integration_guide.md Reads various game state offsets including dwEntityList, dwViewMatrix, dwWindowWidth, and dwWindowHeight using the generated offsets header. Requires base addresses for client and engine modules. ```cpp #include "cs2_dumper/offsets.hpp" void read_game_state(uintptr_t client_base, uintptr_t engine_base) { // Read entity list uintptr_t entity_list = *(uintptr_t*)(client_base + cs2_dumper::offsets::client::dwEntityList); // Read view matrix float* view_matrix = (float*)(client_base + cs2_dumper::offsets::client::dwViewMatrix); // Read window dimensions uint32_t width = *(uint32_t*)(engine_base + cs2_dumper::offsets::engine2::dwWindowWidth); uint32_t height = *(uint32_t*)(engine_base + cs2_dumper::offsets::engine2::dwWindowHeight); printf("Window: %u x %u\n", width, height); } ``` -------------------------------- ### Analyze Interfaces Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/analysis_api.md Scans all modules for the CreateInterface export and resolves interface registry linked lists. Requires a mutable process handle with the MemoryView trait. ```rust pub fn interfaces(process: &mut P) -> Result ``` -------------------------------- ### Absolute Address Calculation Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/INDEX.md Demonstrates the calculation of an absolute memory address using a module's base address and a Relative Virtual Address (RVA). This is crucial as modules load at different addresses per process. ```text absolute_address = module_base + rva ``` -------------------------------- ### Extract Button State Offsets Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/analysis_submodules.md Extracts keyboard button state offsets from client.dll. Requires a process handle with memory access. Errors may occur if client.dll is not loaded, the PE format is invalid, or patterns are not found. ```rust pub type ButtonMap = BTreeMap; pub fn buttons(process: &mut P) -> Result ``` ```rust let buttons = analysis::buttons(&mut process)?; for (name, rva) in buttons { println!("{}: 0x{:X}", name, rva); } ``` -------------------------------- ### Callback Pattern for dwPrediction and dwLocalPlayerPawn Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/pattern_scanning.md Uses a callback to find dwLocalPlayerPawn by performing a secondary scan relative to the primary dwPrediction pattern. The offset is calculated and inserted into the map. ```rust "dwPrediction" => pattern!("488d05${"} c3 cccccccccccccccc 405356 4154") => Some(|view, map, rva| { let mut save = [0; 2]; if view.scanner().finds_code(pattern!("4c39b6u4 74? 4488be"), &mut save) { map.insert("dwLocalPlayerPawn".to_string(), rva + save[1]); } }), ``` -------------------------------- ### Lookup Interfaces in JSON using Python Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/integration_guide.md Parses the generated interfaces.json file to find and print interface names and their corresponding RVAs for a specific module like 'client.dll'. ```python import json with open('output/interfaces.json') as f: interfaces = json.load(f) # Find all interfaces in client.dll client_interfaces = interfaces.get('client.dll', {}) for iface_name, rva in client_interfaces.items(): print(f"{iface_name}: 0x{rva:X}") ``` -------------------------------- ### Zig: Module Structure Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/integration_guide.md Defines the module structure for CS2 Dumper offsets in Zig. ```zig pub const cs2_dumper = struct { pub const offsets = struct { pub const client = struct { pub const dwBuildNumber: usize = 0x...; }; }; }; ``` -------------------------------- ### Use Offsets in Rust Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/README.md Integrate CS2 dumper offsets within a Rust project to access game memory addresses. Ensure the `cs2_dumper` crate is added as a dependency. ```rust use cs2_dumper::offsets; let addr = client_base + offsets::client::dwLocalPlayerController; ``` -------------------------------- ### buttons Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/analysis_api.md Scans client.dll for the button linked list and returns all discovered buttons with their state field offsets. ```APIDOC ## buttons ### Description Scans client.dll for the button linked list and returns all discovered buttons with their state field offsets. ### Signature ```rust pub fn buttons(process: &mut P) -> Result ``` ### Parameters - **process** (`&mut P`): Mutable process handle from memflow with MemoryView trait. ### Returns - `Result`: A map of discovered buttons and their state field offsets. ``` -------------------------------- ### Use Fallback Offsets Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/integration_guide.md Implement logic to try an alternative offset if the primary one is found to be invalid. This provides resilience against minor game updates that might shift specific addresses. ```rust let addr = if is_valid_offset(offset1) { base + offset1 } else { // Try alternative offset base + offset2 }; ``` -------------------------------- ### schemas Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/analysis_api.md Reads SchemaSystem from schemasystem.dll and walks class/enum bindings to extract type information. ```APIDOC ## schemas ### Description Reads SchemaSystem from schemasystem.dll and walks class/enum bindings to extract type information. ### Signature ```rust pub fn schemas(process: &mut P) -> Result ``` ### Parameters - **process** (`&mut P`): Mutable process handle from memflow with MemoryView trait. ### Returns - `Result`: A map of extracted type information. ``` -------------------------------- ### Analyze Buttons Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/analysis_api.md Scans client.dll for the button linked list to discover all buttons and their state field offsets. Requires a mutable process handle with the MemoryView trait. ```rust pub fn buttons(process: &mut P) -> Result ``` -------------------------------- ### Pattern Match to Interface Creation Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/memory_api.md Finds an interface registry pointer using a pattern match and resolves it. This is useful for dynamically discovering interface implementations. ```rust // Pattern matcher found: mov rax, [rel interface_registry] let pattern_address: Address = 0x140050000.into(); let registry_ptr = memory::address::resolve_rip(&mut process, pattern_address)?; let registry_head = process.read_addr64(registry_ptr).data_part()?; ``` -------------------------------- ### Generate Specific File Types Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/configuration.md Configures CS2 Dumper to generate only Rust and JSON output files. ```bash cs2-dumper -f rs,json ``` -------------------------------- ### Read C-Style String (UTF-8 Lossy) Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/source2_types.md Read a C-compatible string (`ReprCString`) from memory as UTF-8, with lossy conversion for invalid sequences. Specify the maximum buffer size. ```rust let name = process.read_utf8_lossy(cstring_pointer.address(), 128).data_part()?; ``` -------------------------------- ### Define Patterns with `pattern_map!` Macro Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/pattern_scanning.md Use the `pattern_map!` macro to define offsets for different modules. Patterns can include capture groups (`${'}`) and optional callbacks for derived offset computation. ```rust pattern_map! { client => { "dwLocalPlayerController" => pattern!("488b05${'} 4189be") => None, "dwPrediction" => pattern!("488d05${'} c3 cccccccccccccccc 405356") => Some(|view, map, rva| { // Callback to compute derived offsets }), }, engine2 => { "dwBuildNumber" => pattern!("8905${'} 488d0d${} ff15") => None, }, } ``` -------------------------------- ### Buttons Output - Zig Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/output_api.md Generates Zig code for button constants. Use this to define button inputs in a Zig project. ```zig pub const cs2_dumper = struct { pub const buttons = struct { pub const in_forward: usize = 0x12345678; pub const in_back: usize = 0x12345680; }; }; ``` -------------------------------- ### Read Button State in C++ Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/integration_guide.md Reads the state of a button, such as 'in_jump', using the generated buttons.hpp file. Ensure you include the necessary headers for C++ types and printf. ```cpp #include "cs2_dumper/buttons.hpp" #include void read_button_state(uintptr_t client_base) { // Read the "in_jump" button state const uintptr_t jump_addr = client_base + cs2_dumper::buttons::in_jump; uint32_t state = *(uint32_t*)jump_addr; if (state != 0) { printf("Jump key is pressed\n"); } } ``` -------------------------------- ### Verify Game Build Number Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/errors_and_edge_cases.md Check if the read build number is within a valid range to detect outdated dumps. This helps identify potential version mismatches. ```rust let build: u32 = process.read(module_base + offset).data_part()?; if build == 0 || build > 100_000 { eprintln!("Build number appears invalid: {}", build); eprintln!("Dump may be outdated"); } ``` -------------------------------- ### follow_call Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/memory_api.md Resolves the target of a `call rel32` instruction by calculating the absolute address from a RIP-relative offset. ```APIDOC ## follow_call() ### Description Resolves the target of a `call rel32` instruction. ### Signature ```rust pub fn follow_call(mem: &mut impl MemoryView, base: Address) -> Result
``` ### Parameters #### Path Parameters - **mem** (impl MemoryView) - Required - Memory view for reading instruction bytes. - **base** (Address) - Required - Address of the CALL instruction opcode (not the offset). ### Returns `Result
` - Target address of the call. ### Behavior - Reads 32-bit signed displacement at offset +0x1 (skips 0xE8 opcode). - Interprets as RIP-relative offset from end of instruction. - Calculates: `(base + 0x1 + sizeof::()) + rel32` to get absolute target. ### Example ```rust // At address 0x140000100: E8 A5 02 00 00 (call rel32) // Resolves to target address of called function let target = follow_call(&mut process, 0x140000100.into())?; ``` ``` -------------------------------- ### follow_jmp Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/memory_api.md Resolves the target of a `jmp rel32` instruction, similar to `follow_call`. ```APIDOC ## follow_jmp() ### Description Resolves the target of a `jmp rel32` instruction. ### Signature ```rust pub fn follow_jmp(mem: &mut impl MemoryView, base: Address) -> Result
``` ### Parameters #### Path Parameters - **mem** (impl MemoryView) - Required - Memory view for reading instruction bytes. - **base** (Address) - Required - Address of the JMP instruction opcode. ### Returns `Result
` - Target address of the jump. ### Behavior - Identical to follow_call() - same instruction encoding for rel32 operand. - Reads 32-bit signed displacement at offset +0x1 (skips 0xE9 opcode). - Used for pattern-based offset discovery when pattern resolves to jmp trampoline. ### Example ```rust let trampoline_target = follow_jmp(&mut process, pattern_address)?; ``` ``` -------------------------------- ### buttons() Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/analysis_submodules.md Extracts all keyboard button state offsets from client.dll. It scans for a specific pattern to locate the button list and iterates through it to collect button names and their corresponding state field RVAs. ```APIDOC ## buttons() ### Description Extracts all keyboard button state offsets from client.dll. ### Signature ```rust pub fn buttons(process: &mut P) -> Result ``` ### Parameters - **process** (`&mut P`): Process handle with memory access. ### Returns - `Result`: A map of button names to state field RVAs. ### Example Usage ```rust let buttons = analysis::buttons(&mut process)?; for (name, rva) in buttons { println!("{}: 0x{:X}", name, rva); } ``` ``` -------------------------------- ### Validate Offsets with Known Values Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/integration_guide.md Verify memory offsets by reading a known constant value (like the build number) at the expected address. This helps confirm if offsets are still valid after a game update. ```cpp // Known constant value at offset uint32_t build = *(uint32_t*)(engine_base + offsets::engine2::dwBuildNumber); if (build != EXPECTED_BUILD) { fprintf(stderr, "Offset mismatch!\n"); } ``` -------------------------------- ### Generate Per-Module Scanner Function Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/pattern_scanning.md The `pattern_map!` macro generates scanner functions like `offsets` which iterates through defined patterns, finds them in the PE view, and extracts RVAs. ```rust pub fn offsets(view: PeView<'_>) -> BTreeMap { let mut map = BTreeMap::new(); for (&name, (pat, callback)) in &PATTERNS { let mut save = vec![0; save_len(pat)]; if !view.scanner().finds_code(pat, &mut save) { error!("outdated pattern: {}", name); continue; } let rva = save[1]; map.insert(name.to_string(), rva); if let Some(callback) = callback { callback(&view, &mut map, rva); } } map } ``` -------------------------------- ### Pattern Matching with Memory Access Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/memory_api.md Use this snippet to find instruction pointers using pelite's pattern matching and resolve them to absolute addresses using the memory API. Ensure the 'process' and 'module' variables are correctly initialized. ```rust use pelite::pattern; let mut save = [0; 2]; if view.scanner().finds_code(pattern!("488d0d${\'}" 48c1e006"), &mut save) { // save[1] now contains RVA of instruction let instruction_addr = module.base + save[1]; let target = memory::address::resolve_rip(&mut process, instruction_addr)?; } ``` -------------------------------- ### Follow Call Instruction Source: https://github.com/a2x/cs2-dumper/blob/main/_autodocs/memory_api.md Resolves the target of a call instruction. This is useful for enumerating callbacks or understanding function call destinations. ```rust // Enumerate callbacks in structure via call instructions let callback_addr = memory::address::follow_call(&mut process, struct_field_addr)?; ```