Skip to content

Commit 2585bbc

Browse files
committed
Initial commit
0 parents  commit 2585bbc

File tree

5 files changed

+247
-0
lines changed

5 files changed

+247
-0
lines changed

.gitignore

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Generated by Cargo
2+
# will have compiled files and executables
3+
debug/
4+
target/
5+
6+
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
7+
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
8+
Cargo.lock
9+
10+
# These are backup files generated by rustfmt
11+
**/*.rs.bk
12+
13+
# MSVC Windows builds of rustc generate these, which store debugging information
14+
*.pdb

Cargo.toml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[package]
2+
name = "csgo-inv-patcher"
3+
version = "1.0.0"
4+
authors = ["Toa Toastrejn <[email protected]>"]
5+
edition = "2021"
6+
description = "Patcher tool for CS:GO Legacy to allows you to use your skins. "
7+
repository = "https://github.com/toaaa/csgo-inv-patcher"
8+
license-file = "LICENSE.md"
9+
10+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
11+
12+
[dependencies]
13+
walkdir = "2.5.0"
14+
rayon = "1.10.0"
15+
dialoguer = "0.11.0"

LICENSE.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 Toa
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# CS:GO Inv Patcher
2+
3+
Have you ever wanted to use your inventory and skins in CS:GO Legacy because CS2 just sucks? No problem! With the CS:GO Inv Patcher you can!
4+
5+
Just install the CS:GO Legacy version, [run the patcher](#usage), select `CS:GO` and wait. Now you can use your inventory and skins in CS:GO and play with your friends.
6+
7+
> If you encounter any issues or bugs, please report them by creating an [issue](https://github.com/Toaaa/csgo-inv-patcher/issues/new). Include as much detail as possible.
8+
9+
## Features
10+
11+
- **Patch to CS:GO**: Updates the `ClientVersion` to enable playing the legacy Counter-Strike: Global Offensive and use your Inventory and Skins.
12+
- **Patch back to CS2**: Updates the `ClientVersion` to enable playing Counter-Strike 2.
13+
14+
## Usage
15+
16+
1. Run the [compiled binary](#installation).
17+
18+
2. Follow the Prompt: When the patcher runs, it will ask you which version you want to patch. In our case, we want to patch the CS:GO version, so we select CS:GO.
19+
20+
```
21+
? Which version would you like to patch to? ›
22+
❯ Patch to CS:GO
23+
Patch back to CS2
24+
```
25+
26+
The patcher will now scan all available drives on your PC and find the CS(GO) installation and apply the patch.
27+
28+
```
29+
✔ Which version would you like to patch to? · Patch to CS:GO
30+
Scanning all possible drives on your PC...
31+
Scanning: C:\..
32+
Scanning: D:\..
33+
Scanning: E:\..
34+
```
35+
36+
If the patch has been successfully applied, you will see a confirmation message. If everything went well, you can now start CS:GO Legacy and use your inventory and skins.
37+
38+
```csgo message
39+
File successfully patched to version: CS:GO.
40+
You should now be able to use your skins in CS:GO Legacy. You shouldn't play CS2 while this is active.
41+
```
42+
43+
> [!IMPORTANT]\
44+
> It's important to mention: While the CS:GO patch is applied, YOU SHOULD NOT PLAY CS2!
45+
46+
If you want to play CS2 again (for whatever reason), you can simply start the patcher again and select `CS2` this time.
47+
48+
## Installation
49+
50+
Currently, there is a [precompiled version](https://github.com/Toaaa/csgo-inv-patcher/releases/latest) for **Windows only**.
51+
52+
### Requirements
53+
54+
- A working installation of the Rust toolchain (typically installed via [rustup](https://rustup.rs/)).
55+
- The CS:GO Legacy version [installed on your computer](https://bo3.gg/news/how-to-download-csgo-in-steam-after-cs2-release).
56+
57+
If you want to build it from source, clone this repository and navigate to its directory:
58+
59+
```bash
60+
git clone https://github.com/toaaa/csgo-inv-patcher.git
61+
cd csgo-inv-patcher
62+
```
63+
64+
Next, build the application using Cargo:
65+
66+
```bash
67+
cargo build --release
68+
```
69+
70+
Once the build process is complete, you can find the executable file in the `target/release` directory.
71+
Alternatively, you can run it using:
72+
73+
```sh
74+
cargo run --release
75+
```
76+
77+
## Contributing
78+
79+
Contributions are welcome! Please fork the repository and submit a pull request with your improvements or bug fixes.
80+
81+
***Note**: This tool modifies game files and should be used responsibly. Ensure that you have backups of any files before making modifications in case something goes wrong.*

src/main.rs

+116
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
use dialoguer::{theme::ColorfulTheme, Select};
2+
use rayon::prelude::*;
3+
use std::fs::{self, OpenOptions};
4+
use std::io::{BufRead, BufReader};
5+
use std::path::Path;
6+
use walkdir::WalkDir;
7+
8+
fn main() {
9+
let options: Vec<&str> = vec!["Patch to CS:GO", "Patch back to CS2"];
10+
let selection: usize = Select::with_theme(&ColorfulTheme::default())
11+
.with_prompt("Which version would you like to patch to?")
12+
.default(0)
13+
.items(&options)
14+
.interact()
15+
.expect("Failed to read input");
16+
17+
let version: &str = if selection == 0 { "2000303" } else { "2000370" }; // 2000303 = CS:GO Legacy, 2000370 = CS2
18+
19+
let drives: Vec<String> = get_drives();
20+
21+
println!("Scanning all possible drives on your PC...");
22+
23+
let found_file = drives.par_iter().find_map_any(|drive: &String| {
24+
println!("Scanning: {}..", drive);
25+
find_file(drive, "steam.inf", "csgo")
26+
});
27+
28+
match found_file {
29+
Some(file_path) => {
30+
// println!("File found at: {}", file_path.display()); // just for debugging
31+
32+
let version_name: &str = match version {
33+
"2000303" => "CSGO",
34+
"2000370" => "CS2",
35+
_ => version,
36+
};
37+
38+
if patch_file(&file_path, version) {
39+
println!("File successfully patched to version: {}.", version_name);
40+
41+
let note: &str = if version == "2000303" {
42+
"You should now be able to use your skins in CSGO Legacy. You shouldn't play CS2 while this is active."
43+
} else {
44+
"You can now play CS2 (again)."
45+
};
46+
47+
println!("{}", note);
48+
// open_in_notepad(&file_path); // This was only used for testing reasons and is not (longer) necessary.
49+
} else {
50+
println!("Failed to patch the file.");
51+
}
52+
}
53+
None => {
54+
println!("File not found on any drive.");
55+
}
56+
}
57+
}
58+
59+
fn get_drives() -> Vec<String> {
60+
let drives: Vec<&str> = vec!["C:\\", "D:\\", "E:\\", "F:\\", "G:\\"];
61+
drives
62+
.into_iter()
63+
.filter(|d: &&str| fs::metadata(d).is_ok())
64+
.map(String::from)
65+
.collect()
66+
}
67+
68+
fn find_file(dir: &str, file_name: &str, parent_dir: &str) -> Option<std::path::PathBuf> {
69+
for entry in WalkDir::new(dir).into_iter().filter_map(Result::ok) {
70+
if entry
71+
.file_name()
72+
.to_str()
73+
.map_or(false, |name: &str| name.eq_ignore_ascii_case(file_name))
74+
{
75+
if let Some(parent) = entry.path().parent() {
76+
if parent
77+
.file_name()
78+
.map_or(false, |n| n.eq_ignore_ascii_case(parent_dir))
79+
{
80+
return Some(entry.path().to_path_buf());
81+
}
82+
}
83+
}
84+
}
85+
None
86+
}
87+
88+
fn patch_file(file_path: &Path, version: &str) -> bool {
89+
let file: fs::File = OpenOptions::new()
90+
.read(true)
91+
.write(true)
92+
.open(file_path)
93+
.expect("Failed to open file");
94+
let reader = BufReader::new(&file);
95+
let mut contents: Vec<String> = reader.lines().filter_map(Result::ok).collect();
96+
97+
for line in &mut contents {
98+
if line.starts_with("ClientVersion=") {
99+
*line = format!("ClientVersion={}", version);
100+
break;
101+
}
102+
}
103+
104+
let new_contents: String = contents.join("\n");
105+
fs::write(file_path, new_contents).is_ok()
106+
}
107+
108+
/* This was only used for testing reasons and is not (longer) necessary. */
109+
110+
// // Function to open the file in Notepad
111+
// fn open_in_notepad(file_path: &Path) {
112+
// Command::new("notepad.exe")
113+
// .arg(file_path)
114+
// .spawn()
115+
// .expect("Failed to open Notepad");
116+
// }

0 commit comments

Comments
 (0)