use new poggers and more modular

This commit is contained in:
anna 2023-03-21 00:26:29 +00:00
parent 79814d17e1
commit 220547f87e
No known key found for this signature in database
GPG Key ID: 020F70A824FB8206
7 changed files with 119 additions and 110 deletions

78
Cargo.lock generated
View File

@ -909,6 +909,7 @@ version = "0.1.2"
dependencies = [ dependencies = [
"eframe", "eframe",
"egui", "egui",
"gdke",
"poggers", "poggers",
] ]
@ -1469,7 +1470,7 @@ dependencies = [
[[package]] [[package]]
name = "poggers" name = "poggers"
version = "0.2.3" version = "0.4.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"ctor", "ctor",
@ -1477,7 +1478,8 @@ dependencies = [
"log", "log",
"mach", "mach",
"thiserror", "thiserror",
"windows 0.44.0", "widestring",
"windows 0.46.0",
] ]
[[package]] [[package]]
@ -2194,6 +2196,12 @@ dependencies = [
"cc", "cc",
] ]
[[package]]
name = "widestring"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "653f141f39ec16bba3c5abe400a0c60da7468261cc2cbf36805022876bc721a8"
[[package]] [[package]]
name = "winapi" name = "winapi"
version = "0.3.9" version = "0.3.9"
@ -2242,19 +2250,19 @@ checksum = "0286ba339aa753e70765d521bb0242cc48e1194562bfa2a2ad7ac8a6de28f5d5"
dependencies = [ dependencies = [
"windows-implement", "windows-implement",
"windows_aarch64_gnullvm", "windows_aarch64_gnullvm",
"windows_aarch64_msvc 0.42.1", "windows_aarch64_msvc 0.42.2",
"windows_i686_gnu 0.42.1", "windows_i686_gnu 0.42.2",
"windows_i686_msvc 0.42.1", "windows_i686_msvc 0.42.2",
"windows_x86_64_gnu 0.42.1", "windows_x86_64_gnu 0.42.2",
"windows_x86_64_gnullvm", "windows_x86_64_gnullvm",
"windows_x86_64_msvc 0.42.1", "windows_x86_64_msvc 0.42.2",
] ]
[[package]] [[package]]
name = "windows" name = "windows"
version = "0.44.0" version = "0.46.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e745dab35a0c4c77aa3ce42d595e13d2003d6902d6b08c9ef5fc326d08da12b" checksum = "cdacb41e6a96a052c6cb63a144f24900236121c6f63f4f8219fef5977ecb0c25"
dependencies = [ dependencies = [
"windows-targets", "windows-targets",
] ]
@ -2290,12 +2298,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7"
dependencies = [ dependencies = [
"windows_aarch64_gnullvm", "windows_aarch64_gnullvm",
"windows_aarch64_msvc 0.42.1", "windows_aarch64_msvc 0.42.2",
"windows_i686_gnu 0.42.1", "windows_i686_gnu 0.42.2",
"windows_i686_msvc 0.42.1", "windows_i686_msvc 0.42.2",
"windows_x86_64_gnu 0.42.1", "windows_x86_64_gnu 0.42.2",
"windows_x86_64_gnullvm", "windows_x86_64_gnullvm",
"windows_x86_64_msvc 0.42.1", "windows_x86_64_msvc 0.42.2",
] ]
[[package]] [[package]]
@ -2309,24 +2317,24 @@ dependencies = [
[[package]] [[package]]
name = "windows-targets" name = "windows-targets"
version = "0.42.1" version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7" checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071"
dependencies = [ dependencies = [
"windows_aarch64_gnullvm", "windows_aarch64_gnullvm",
"windows_aarch64_msvc 0.42.1", "windows_aarch64_msvc 0.42.2",
"windows_i686_gnu 0.42.1", "windows_i686_gnu 0.42.2",
"windows_i686_msvc 0.42.1", "windows_i686_msvc 0.42.2",
"windows_x86_64_gnu 0.42.1", "windows_x86_64_gnu 0.42.2",
"windows_x86_64_gnullvm", "windows_x86_64_gnullvm",
"windows_x86_64_msvc 0.42.1", "windows_x86_64_msvc 0.42.2",
] ]
[[package]] [[package]]
name = "windows_aarch64_gnullvm" name = "windows_aarch64_gnullvm"
version = "0.42.1" version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608" checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8"
[[package]] [[package]]
name = "windows_aarch64_msvc" name = "windows_aarch64_msvc"
@ -2336,9 +2344,9 @@ checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47"
[[package]] [[package]]
name = "windows_aarch64_msvc" name = "windows_aarch64_msvc"
version = "0.42.1" version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7" checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43"
[[package]] [[package]]
name = "windows_i686_gnu" name = "windows_i686_gnu"
@ -2348,9 +2356,9 @@ checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6"
[[package]] [[package]]
name = "windows_i686_gnu" name = "windows_i686_gnu"
version = "0.42.1" version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640" checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f"
[[package]] [[package]]
name = "windows_i686_msvc" name = "windows_i686_msvc"
@ -2360,9 +2368,9 @@ checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024"
[[package]] [[package]]
name = "windows_i686_msvc" name = "windows_i686_msvc"
version = "0.42.1" version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605" checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060"
[[package]] [[package]]
name = "windows_x86_64_gnu" name = "windows_x86_64_gnu"
@ -2372,15 +2380,15 @@ checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1"
[[package]] [[package]]
name = "windows_x86_64_gnu" name = "windows_x86_64_gnu"
version = "0.42.1" version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45" checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36"
[[package]] [[package]]
name = "windows_x86_64_gnullvm" name = "windows_x86_64_gnullvm"
version = "0.42.1" version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463" checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3"
[[package]] [[package]]
name = "windows_x86_64_msvc" name = "windows_x86_64_msvc"
@ -2390,9 +2398,9 @@ checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680"
[[package]] [[package]]
name = "windows_x86_64_msvc" name = "windows_x86_64_msvc"
version = "0.42.1" version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0"
[[package]] [[package]]
name = "winit" name = "winit"

View File

@ -8,12 +8,18 @@ lto = true
strip = true strip = true
opt-level = "z" opt-level = "z"
codegen-units = 1 codegen-units = 1
[profile.debuga]
inherits = "release"
debug = true
strip = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
poggers = {version = "0.2.*", path = "../poggers"} poggers = {version = "*", path = "../poggers"}
[workspace] [workspace]
members = [ members = [
"gdke-gui", "gdke-gui",
] ]

View File

@ -13,4 +13,5 @@ codegen-units = 1
[dependencies] [dependencies]
egui = "0.21.0" egui = "0.21.0"
eframe = { version = "0.21.3" } eframe = { version = "0.21.3" }
poggers = {version = "0.2.*", path = "../../poggers"} poggers = {version = "*", path = "../../poggers"}
gdke = {path= ".."}

View File

@ -2,14 +2,14 @@ use std::{borrow::BorrowMut, ops::Deref, sync::mpsc::{Receiver, Sender}, rc::Rc,
use eframe::CreationContext; use eframe::CreationContext;
use egui::{TextStyle, TextEdit}; use egui::{TextStyle, TextEdit};
use poggers::external::process::{ExPartialProcess, ExProcess}; use poggers::external::{process::{ExProcess}, create_snapshot::{STProcess, ToolSnapshot}};
use crate::Data; use crate::Data;
#[derive(Debug)] #[derive(Debug)]
pub struct gdkeApp { pub struct gdkeApp {
procs : Rc<RefCell<Vec<ExPartialProcess>>>, procs : Rc<RefCell<Vec<STProcess>>>,
selected: Option<ExPartialProcess>, selected: Option<STProcess>,
awaiting: bool, awaiting: bool,
last_key: String, last_key: String,
process: Option<ExProcess>, process: Option<ExProcess>,
@ -19,7 +19,7 @@ pub struct gdkeApp {
} }
impl Default for gdkeApp { impl Default for gdkeApp {
fn default() -> Self { fn default() -> Self {
let procs = if let Ok(procs) = ExProcess::get_processes() { let procs = if let Ok(procs) = ToolSnapshot::new_process().map(|x| x.collect()) {
procs procs
} else { } else {
Vec::new() Vec::new()
@ -85,7 +85,7 @@ impl eframe::App for gdkeApp {
let text_style = TextStyle::Body; let text_style = TextStyle::Body;
let row_height = ui.text_style_height(&text_style); let row_height = ui.text_style_height(&text_style);
if ui.button("refresh processes").clicked() { if ui.button("refresh processes").clicked() {
procs.clone().borrow_mut().replace(if let Ok(procs) = ExProcess::get_processes() { procs.clone().borrow_mut().replace(if let Ok(procs) = ToolSnapshot::new_process().map(|x| x.collect()) {
procs procs
} else { } else {
Vec::new() Vec::new()
@ -93,8 +93,8 @@ impl eframe::App for gdkeApp {
} }
let mut procsrn = procs.clone(); let mut procsrn = procs.clone();
let proca = procsrn.borrow(); let proca = procsrn.borrow();
let filtered_procs = if self.search_query.is_empty() {proca.iter().collect::<Vec::<&ExPartialProcess>>()} else {proca.iter() let filtered_procs = if self.search_query.is_empty() {proca.iter().collect::<Vec::<&STProcess>>()} else {proca.iter()
.filter(|p| p.name.contains(&self.search_query) || p.pid.to_string().contains(&self.search_query)).collect() .filter(|p| p.exe_path.contains(&self.search_query) || p.id.to_string().contains(&self.search_query)).collect()
}; };
let selval = selected.clone(); let selval = selected.clone();
ui.separator(); ui.separator();
@ -103,14 +103,14 @@ impl eframe::App for gdkeApp {
for row in row_range { for row in row_range {
if let Some(proc) = (&filtered_procs).get(row) { if let Some(proc) = (&filtered_procs).get(row) {
let owner_proc = proc.deref(); let owner_proc = proc.deref();
ui.selectable_value(selected, Some(owner_proc.clone()) , proc.name.clone()); ui.selectable_value(selected, Some(owner_proc.clone()) , &proc.exe_path);
} }
} }
}); });
if let Some(selected) = selval { if let Some(selected) = selval {
ui.separator(); ui.separator();
if ui.button(format!("get key for {}",selected.name)).clicked() { if ui.button(format!("get key for {}",selected.exe_path)).clicked() {
tx.as_ref().unwrap().send(Data::Pid(selected.pid)).unwrap(); tx.as_ref().unwrap().send(Data::Pid(selected.id)).unwrap();
*awaiting = true; *awaiting = true;
last_key.clear(); last_key.clear();
} }

View File

@ -7,13 +7,6 @@ use std::error::Error;
use gdke_gui::{app::gdkeApp, Data}; use gdke_gui::{app::gdkeApp, Data};
use poggers::{external::process::ExProcess, traits::Mem}; use poggers::{external::process::ExProcess, traits::Mem};
const SIGS: [&str; 4] = [
"48 8D 3D ? ? ? ? 48 85 C0 74 3B",
"48 8D 05 ? ? ? ? 41 8A 04 04",
"48 8D 05 ? ? ? ? 0F B6 ? 03",
"4C 8D 05 ? ? ? ? 0F 1F 40 00",
];
fn main() { fn main() {
let (stx, srx) = std::sync::mpsc::channel::<Data>(); let (stx, srx) = std::sync::mpsc::channel::<Data>();
let (ctx, crx) = std::sync::mpsc::channel::<Data>(); let (ctx, crx) = std::sync::mpsc::channel::<Data>();
@ -25,36 +18,10 @@ fn main() {
Data::Pid(pid) => { Data::Pid(pid) => {
println!("Got pid: {}", pid); println!("Got pid: {}", pid);
match (|| -> Result<(), Box<dyn Error>> { match (|| -> Result<(), Box<dyn Error>> {
let proc = ExProcess::new_from_pid(pid)?; let key = gdke::get_from_pid(pid)?;
let bm = proc.get_base_module()?; stx.send(Data::Key(key)).unwrap();
for sig in SIGS.iter() { Ok(())
let res = unsafe { bm.scan_virtual(sig) }; // Err("Failed to find key".into())
if let Some(x) = res {
let data = unsafe { bm.resolve_relative_ptr(x + 3, 4) };
if let Ok(x) = data {
println!("found key @ {:X}", x);
let key_data = unsafe { bm.read_sized(x, 32) };
if let Ok(x) = key_data {
// print!("Key: ");
let mut data_string = String::new();
for i in x {
data_string.push_str(&format!("{:02X}", i));
}
println!("sending data {}", data_string);
stx.send(Data::Key(data_string)).unwrap();
return Ok(());
}
} else {
return Err("Unable to resolve lea relative ptr".into());
}
// println!("Found sig: {:X}", x);
} else {
println!("Failed to find with sig: {}", sig);
// return Err("Failed to find with sig".into());
}
}
// Ok(())
Err("Failed to find key".into())
})() { })() {
Ok(_) => {} Ok(_) => {}
Err(er) => { Err(er) => {

43
src/lib.rs Normal file
View File

@ -0,0 +1,43 @@
use std::error::Error;
use poggers::{external::process::ExProcess, traits::Mem};
pub const SIGS: [&str; 5] = [
"48 8D 1D ? ? ? ? 4C 8D 2D ? ? ? ? 48 8D 35", // godot 4.0.0
"48 8D 3D ? ? ? ? 48 85 C0 74 3B",
"48 8D 05 ? ? ? ? 41 8A 04 04",
"48 8D 05 ? ? ? ? 0F B6 ? 03",
"4C 8D 05 ? ? ? ? 0F 1F 40 00",
];
pub fn get_from_pid(pid:u32) -> Result<String,Box<dyn Error>> {
let proc = ExProcess::new_from_pid(pid)?;
let bm = proc.get_base_module()?;
for sig in &SIGS {
let res = unsafe { bm.scan_virtual(sig) };
if let Some(x) = res {
let data = unsafe { bm.resolve_relative_ptr(x + 3, 4) };
if let Ok(x) = data {
println!("found key @ {:X}", x);
let mut key_data = [0u8;32];
if unsafe { bm.raw_read(x, &mut key_data as *mut u8,32) }.is_ok() && !key_data.is_empty() {
let mut data_string = String::new();
for i in &key_data[..] {
data_string.push_str(&format!("{:02X}", i));
}
return Ok(data_string);
}
} else {
return Err("Unable to resolve lea relative ptr".into());
}
// println!("Found sig: {:X}", x);
} else {
println!("Failed to find with sig: {}", sig);
// return Err("Failed to find with sig".into());
}
}
// Ok(())
Err("Failed to find key".into())
}

View File

@ -1,29 +1,13 @@
use poggers::mem::{external::process::ExProcess, traits::Mem}; use poggers::{external::process::ExProcess, traits::Mem};
const SIGS: [&str; 3] = ["48 8D 05 ? ? ? ? 41 8A 04 04","48 8D 05 ? ? ? ? 0F B6 ? 03","4C 8D 05 ? ? ? ? 0F 1F 40 00"];
fn main() { fn main() {
let proc = ExProcess::new_from_name("SoundSpacePlus.exe".to_string()).unwrap(); let mut pid = 0;
let bm = proc.get_base_module().unwrap(); {
for sig in SIGS.iter() { let proc = ExProcess::new_from_name("4 Test.exe".to_string()).unwrap();
let res = unsafe {bm.scan_virtual(sig)}; pid = proc.get_pid();
if let Some(x) = res {
let data = unsafe {bm.resolve_relative_ptr(x+3, 4)};
if let Ok(x) = data {
println!("found key @ {:X}", x);
let key_data = unsafe {bm.read_sized(x, 32)};
if let Ok(x) = key_data {
print!("Key: ");
for i in x {
print!("{:02X}", i);
}
}
} else {
println!("Unable to resolve lea relative ptr");
}
// println!("Found sig: {:X}", x);
} else {
println!("Failed to find with sig: {}", sig);
}
} }
let key = gdke::get_from_pid(pid).expect("unable to find key");
println!("Key: {}", key);
} }