Skip to content

Commit 7fb4967

Browse files
committed
User-Experience Overhaul: Implement interactive console mode and drag-and-drop support for standard users
1 parent 2d60ff1 commit 7fb4967

2 files changed

Lines changed: 71 additions & 11 deletions

File tree

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ The compiled binary will be available at `./target/release/gpupatch` (or `gpupat
2929

3030
## Usage
3131

32+
### 🔥 For Standard Users (Easy Mode)
33+
The application includes an interactive mode designed for ease of use:
34+
1. **Double-click** the downloaded `gpupatch.exe` binary to launch the console window.
35+
2. **Drag and drop** your target game or application executable directly onto the window.
36+
3. Hit **Enter**. That's it! 🎉
37+
*(Alternatively, you can simply drag and drop an executable file directly onto the `gpupatch.exe` icon in Windows Explorer).*
38+
39+
### 💻 For Power Users (CLI Mode)
3240
To force an executable to utilize the dedicated high-performance GPU:
3341
```bash
3442
gpupatch <input.exe> [<output.exe>]

src/main.rs

Lines changed: 63 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,33 @@ fn align_to(val: u32, alignment: u32) -> u32 {
4848

4949
fn main() -> Result<(), Box<dyn Error>> {
5050
let args: Vec<String> = std::env::args().collect();
51-
if args.len() < 2 {
52-
println!("Usage: nvpatch-rs <inputfile> [<outputfile>] [--disable]");
53-
return Ok(());
54-
}
51+
let mut is_interactive = false;
52+
53+
let input_path = if args.len() < 2 {
54+
is_interactive = true;
55+
println!("╔══════════════════════════════════════════════╗");
56+
println!("║ GPU Performance Patcher ║");
57+
println!("╚══════════════════════════════════════════════╝");
58+
println!("\nInstructions:");
59+
println!("▶ Drag & Drop a .exe file directly into this window.");
60+
println!("▶ Or type the path to the executable manually.\n");
61+
print!("Target File: ");
62+
use std::io::Write;
63+
std::io::stdout().flush()?;
64+
65+
let mut input = String::new();
66+
std::io::stdin().read_line(&mut input)?;
67+
let trimmed = input.trim().trim_matches('\"').trim_matches('\'').to_string();
68+
if trimmed.is_empty() {
69+
println!("❌ Aborted: No input provided.");
70+
return Ok(());
71+
}
72+
trimmed
73+
} else {
74+
args[1].clone()
75+
};
5576

56-
let input_path = &args[1];
57-
let mut output_path = input_path;
77+
let mut output_path = input_path.clone();
5878
let mut disable = false;
5979

6080
if args.contains(&"--disable".to_string()) {
@@ -63,16 +83,48 @@ fn main() -> Result<(), Box<dyn Error>> {
6383

6484
for arg in args.iter().skip(2) {
6585
if !arg.starts_with("--") {
66-
output_path = arg;
86+
output_path = arg.clone();
6787
break;
6888
}
6989
}
7090

71-
let bytes = fs::read(input_path)?;
72-
let patched = patch_pe(&bytes, disable, Path::new(input_path).file_name().and_then(|n| n.to_str()).unwrap_or("output.exe"))?;
91+
let bytes = match fs::read(&input_path) {
92+
Ok(b) => b,
93+
Err(e) => {
94+
println!("❌ Error reading file '{}': {}", input_path, e);
95+
if is_interactive {
96+
println!("\nPress Enter to exit...");
97+
let mut _b = String::new();
98+
std::io::stdin().read_line(&mut _b)?;
99+
}
100+
return Err(e.into());
101+
}
102+
};
103+
104+
let patch_result = patch_pe(
105+
&bytes,
106+
disable,
107+
Path::new(&input_path).file_name().and_then(|n| n.to_str()).unwrap_or("output.exe")
108+
);
109+
110+
match patch_result {
111+
Ok(patched) => {
112+
fs::write(&output_path, patched)?;
113+
println!("\n✨ SUCCESS: Successfully patched -> {}", output_path);
114+
println!("🚀 The executable is now forced to high-performance GPU mode.");
115+
}
116+
Err(e) => {
117+
println!("\n❌ PATCH FAILED: {}", e);
118+
}
119+
}
73120

74-
fs::write(output_path, patched)?;
75-
println!("Successfully patched {}", output_path);
121+
// Keep the console window open if was run interactively or by drag-n-dropping onto EXE icon
122+
// (Windows closes the window immediately after binary completion otherwise)
123+
if is_interactive || args.len() == 2 {
124+
println!("\nPress Enter to close...");
125+
let mut _final_input = String::new();
126+
std::io::stdin().read_line(&mut _final_input)?;
127+
}
76128

77129
Ok(())
78130
}

0 commit comments

Comments
 (0)