Skip to content

Commit ec36d56

Browse files
authored
Merge pull request #11 from swiftly-solution/dev
2 parents a7022b1 + 7a4d7f5 commit ec36d56

20 files changed

+2118
-2200
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,18 @@ This library mainly read data from original binary file instead of from memory,
1717
- Install trampoline to vtable with enough bytes padded with NOP (for safetyhook to hook empty virtual function)
1818
- Find all CEmbeddedNetworkVar NetworkStateChanged function index
1919
- Follow xref safely
20+
- Dump vtables
21+
- Dump entity classes (dumper)
22+
- Dump vtable diffs (dumper)
23+
- Dump game system overrides (dumper)
24+
- Dump network var vtables (dumper)
25+
2026

2127
## Project Layout
2228

2329
- `s2binlib`: core Rust library crate exposing safe APIs.
2430
- `s2binlib_binding`: C ABI wrapper crate that links to `s2binlib` and produces the `s2binlib` DLL/LIB artifacts.
31+
- `s2binlib_dumper`: A dumper based on s2binlib for dumping game related data.
2532

2633
## Compiling
2734

@@ -58,7 +65,7 @@ On windows, if you are seeing linking error like `"__imp_NtReadFile"`, you also
5865

5966
## Example
6067

61-
Example code:
68+
Example code:
6269

6370
```cpp
6471
#include <s2binlib.h>

s2binlib/src/s2binlib.rs

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -329,13 +329,6 @@ impl S2BinLib {
329329
))
330330
}
331331

332-
fn find_pattern_string(&self, binary_name: &str, string: &str) -> Result<u64> {
333-
let bytes = string.as_bytes().to_vec();
334-
// bytes.push(0); // null terminato
335-
336-
self.find_pattern_bytes(binary_name, &bytes)
337-
}
338-
339332
fn find_pattern_string_in_section(
340333
&self,
341334
binary_name: &str,
@@ -347,12 +340,6 @@ impl S2BinLib {
347340
self.find_pattern_bytes_in_section(binary_name, section_name, &bytes)
348341
}
349342

350-
fn find_pattern_bytes(&self, binary_name: &str, pattern: &[u8]) -> Result<u64> {
351-
let binary_data = self.get_binary(binary_name)?;
352-
let pattern_wildcard = vec![];
353-
find_pattern_simd(binary_data, pattern, &pattern_wildcard)
354-
}
355-
356343
fn find_pattern_int32_in_section(
357344
&self,
358345
binary_name: &str,
@@ -396,7 +383,7 @@ impl S2BinLib {
396383

397384
fn find_pattern_va(&self, binary_name: &str, pattern_string: &str) -> Result<u64> {
398385
let result = Cell::new(0);
399-
self.pattern_scan_all_va(binary_name, pattern_string, |index, address| {
386+
self.pattern_scan_all_va(binary_name, pattern_string, |_, address| {
400387
result.set(address);
401388
true
402389
})?;
@@ -848,17 +835,6 @@ impl S2BinLib {
848835
Ok(self.va_to_mem_address(binary_name, result)?)
849836
}
850837

851-
/// Dump cross-references from all executable sections
852-
///
853-
/// This function scans all executable sections in the binary, disassembles
854-
/// the instructions using iced-x86, and extracts cross-references (xrefs).
855-
/// The results are cached in the `xrefs_cache` HashMap.
856-
///
857-
/// # Arguments
858-
/// * `binary_name` - The name of the binary to analyze
859-
///
860-
/// # Returns
861-
/// Returns Ok(()) on success, or an error if the binary cannot be processed
862838
pub fn dump_xrefs(&mut self, binary_name: &str) -> Result<()> {
863839
let binary_data = self.get_binary(binary_name)?;
864840
let object = object::File::parse(binary_data)?;
@@ -981,17 +957,6 @@ impl S2BinLib {
981957
Ok(())
982958
}
983959

984-
/// Get cached cross-references for a target virtual address
985-
///
986-
/// Returns None if the binary hasn't been analyzed with `dump_xrefs` yet,
987-
/// or if there are no references to the target address.
988-
///
989-
/// # Arguments
990-
/// * `binary_name` - The name of the binary
991-
/// * `target_va` - The target virtual address to find references to
992-
///
993-
/// # Returns
994-
/// An optional reference to a vector of virtual addresses that reference the target
995960
pub fn find_xrefs_cached(&self, binary_name: &str, target_va: u64) -> Option<&Vec<u64>> {
996961
self.xrefs_cache
997962
.get(binary_name)
@@ -1239,7 +1204,7 @@ impl S2BinLib {
12391204

12401205
let success = Cell::new(false);
12411206

1242-
if (warmup < warmup_threshold) {
1207+
if warmup < warmup_threshold {
12431208
warmup += 1;
12441209
continue;
12451210
}

s2binlib/src/vtable.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
/************************************************************************************
2+
* S2BinLib - A static library that helps resolving memory from binary file
3+
* and map to absolute memory address, targeting source 2 game engine.
4+
* Copyright (C) 2025 samyyc
5+
*
6+
* This program is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
18+
***********************************************************************************/
19+
120
use std::collections::{HashMap, HashSet};
221

322
use anyhow::{anyhow, Result};

0 commit comments

Comments
 (0)