remove serde / serialization & failure msg

This commit is contained in:
anna 2023-02-16 20:17:43 +00:00
parent c798de768c
commit 7c7066e58e
No known key found for this signature in database
GPG Key ID: C72F3433D1A673B4
6 changed files with 804 additions and 430 deletions

1100
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -3,6 +3,11 @@ name = "gdke"
version = "0.1.0" version = "0.1.0"
edition = "2021" edition = "2021"
[profile.release]
lto = true
strip = true
opt-level = "z"
codegen-units = 1
# 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]

View File

@ -1,12 +1,16 @@
[package] [package]
name = "gdke-gui" name = "gdke-gui"
version = "0.1.1" version = "0.1.2"
edition = "2021" edition = "2021"
[profile.release]
lto = true
strip = true
opt-level = "z"
codegen-units = 1
# 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]
egui = "0.20.1" egui = "0.21.0"
eframe = { version = "0.20.1", features = ["persistence"] } eframe = { version = "0.21.3" }
serde = { version = "1", features = ["derive"] } # You only need this if you want app persistence
poggers = {version = "0.2.*", path = "../../poggers"} poggers = {version = "0.2.*", path = "../../poggers"}

View File

@ -6,22 +6,15 @@ use poggers::external::process::{ExPartialProcess, ExProcess};
use crate::Data; use crate::Data;
#[derive(serde::Deserialize, serde::Serialize,Debug)] #[derive(Debug)]
pub struct gdkeApp { pub struct gdkeApp {
#[serde(skip)]
procs : Rc<RefCell<Vec<ExPartialProcess>>>, procs : Rc<RefCell<Vec<ExPartialProcess>>>,
#[serde(skip)]
selected: Option<ExPartialProcess>, selected: Option<ExPartialProcess>,
#[serde(skip)]
awaiting: bool, awaiting: bool,
#[serde(skip)]
last_key: String, last_key: String,
#[serde(skip)]
process: Option<ExProcess>, process: Option<ExProcess>,
search_query: String, search_query: String,
#[serde(skip)]
rx: Option<std::sync::mpsc::Receiver<Data>>, rx: Option<std::sync::mpsc::Receiver<Data>>,
#[serde(skip)]
tx: Option<std::sync::mpsc::Sender<Data>> tx: Option<std::sync::mpsc::Sender<Data>>
} }
impl Default for gdkeApp { impl Default for gdkeApp {
@ -45,29 +38,12 @@ impl Default for gdkeApp {
} }
impl gdkeApp { impl gdkeApp {
pub fn new(cc: &CreationContext<'_>, rx: Receiver<Data>,tx: Sender<Data>) -> gdkeApp { pub fn new(cc: &CreationContext<'_>, rx: Receiver<Data>,tx: Sender<Data>) -> gdkeApp {
if let Some(stor) = cc.storage {
if let Some(data) = eframe::get_value::<Self>(stor, "d") {
println!("Loaded data: {:?}", data);
return Self {
tx: Some(tx),
rx: Some(rx),
..Default::default()
}
} else {
Self { Self {
tx: Some(tx), tx: Some(tx),
rx: Some(rx), rx: Some(rx),
..Default::default() ..Default::default()
} }
} }
} else {
Self {
tx: Some(tx),
rx: Some(rx),
..Default::default()
}
}
}
} }
impl eframe::App for gdkeApp { impl eframe::App for gdkeApp {
fn update(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame) { fn update(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame) {
@ -75,8 +51,9 @@ impl eframe::App for gdkeApp {
egui::CentralPanel::default().show(ctx, |ui| { egui::CentralPanel::default().show(ctx, |ui| {
ui.heading("GDKE"); ui.heading("GDKE");
ui.separator(); ui.separator();
egui::Window::new("Key").open(awaiting).show(ctx, |ui| { egui::Window::new("Key").collapsible(false).resizable(true).open(awaiting).show(ctx, |ui| {
ui.label("Getting key, please wait..."); ui.label("Getting key, please wait...");
if !last_key.is_empty() { if !last_key.is_empty() {
let mut keyda = last_key.clone(); let mut keyda = last_key.clone();
TextEdit::singleline(&mut keyda).show(ui); TextEdit::singleline(&mut keyda).show(ui);
@ -87,10 +64,18 @@ impl eframe::App for gdkeApp {
Data::Key(key) => { Data::Key(key) => {
println!("Got key: {}", key); println!("Got key: {}", key);
*last_key = key; *last_key = key;
},
Data::Failure(e) => {
println!("Failed to get key");
*last_key = format!("Failed to get key: {}", e);
} }
_ =>{ } Data::Pid(_) => {unreachable!()}
}
} else{
ui.centered_and_justified(|ui| {
ui.spinner();
});
} }
};
}); });
if !*awaiting { if !*awaiting {
@ -113,7 +98,7 @@ impl eframe::App for gdkeApp {
}; };
let selval = selected.clone(); let selval = selected.clone();
ui.separator(); ui.separator();
egui::ScrollArea::vertical().max_height(260f32).auto_shrink([false;2]) egui::ScrollArea::vertical().max_height(if selval.is_none() {f32::INFINITY} else {260f32}).auto_shrink([false;2])
.show_rows(ui, row_height, filtered_procs.len(), move |ui,row_range| { .show_rows(ui, row_height, filtered_procs.len(), move |ui,row_range| {
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) {
@ -122,8 +107,8 @@ impl eframe::App for gdkeApp {
} }
} }
}); });
ui.separator();
if let Some(selected) = selval { if let Some(selected) = selval {
ui.separator();
if ui.button(format!("get key for {}",selected.name)).clicked() { if ui.button(format!("get key for {}",selected.name)).clicked() {
tx.as_ref().unwrap().send(Data::Pid(selected.pid)).unwrap(); tx.as_ref().unwrap().send(Data::Pid(selected.pid)).unwrap();
*awaiting = true; *awaiting = true;
@ -133,7 +118,4 @@ impl eframe::App for gdkeApp {
} }
}); });
} }
fn save(&mut self, storage: &mut dyn eframe::Storage) {
eframe::set_value(storage, "d", &self)
}
} }

View File

@ -1,8 +1,10 @@
use std::error::Error;
pub mod app; pub mod app;
pub enum Data { pub enum Data {
Pid(u32), Pid(u32),
Key(String), Key(String),
Failure(String)
} }

View File

@ -2,6 +2,8 @@
all(not(debug_assertions), target_os = "windows"), all(not(debug_assertions), target_os = "windows"),
windows_subsystem = "windows" windows_subsystem = "windows"
)] )]
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};
@ -19,9 +21,10 @@ fn main() {
match x { match x {
Data::Pid(pid) => { Data::Pid(pid) => {
println!("Got pid: {}", pid); println!("Got pid: {}", pid);
match (|| -> Result<(),Box<dyn Error>> {
let proc = ExProcess::new_from_pid(pid).unwrap(); let proc = ExProcess::new_from_pid(pid)?;
let bm = proc.get_base_module().unwrap(); let bm = proc.get_base_module()?;
for sig in SIGS.iter() { for sig in SIGS.iter() {
let res = unsafe {bm.scan_virtual(sig)}; let res = unsafe {bm.scan_virtual(sig)};
if let Some(x) = res { if let Some(x) = res {
@ -37,14 +40,26 @@ fn main() {
} }
println!("sending data {}", data_string); println!("sending data {}", data_string);
stx.send(Data::Key(data_string)).unwrap(); stx.send(Data::Key(data_string)).unwrap();
break; return Ok(());
} }
} else { } else {
println!("Unable to resolve lea relative ptr"); return Err("Unable to resolve lea relative ptr".into());
} }
// println!("Found sig: {:X}", x); // println!("Found sig: {:X}", x);
} else { } else {
println!("Failed to find with sig: {}", sig); println!("Failed to find with sig: {}", sig);
// return Err("Failed to find with sig".into());
}
}
// Ok(())
Err("Failed to find key".into())
})() {
Ok(_) => {},
Err(er) => {
println!("Error: {}", er);
stx.send(Data::Failure(er.to_string())).unwrap();
continue;
} }
} }
}, },