Skip to content

Commit

Permalink
yoo... ubuntu???
Browse files Browse the repository at this point in the history
  • Loading branch information
lsaa committed Sep 10, 2021
1 parent 321a6bf commit 75698eb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ fn main() {
);

let _ui_thread =
UiThread::create_and_start(last_poll.clone(), logs.clone(), game_connected.clone());
UiThread::create_and_start(last_poll.clone(), logs.clone(), game_connected.clone());

loop {
if let Ok(new_log) = log_recevicer.try_recv() {
Expand Down
24 changes: 10 additions & 14 deletions src/mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,32 +75,28 @@ fn is_elf(start_bytes: &[u8; 4]) -> bool {

#[cfg(target_os = "linux")]
pub fn get_base_address(pid: Pid) -> Result<usize, std::io::Error> {
use std::io::Read;
use scan_fmt::scan_fmt;

let f = BufReader::new(File::open(format!("/proc/{}/maps", pid))?);
let mut exe = BufReader::new(File::open(format!("/proc/{}/cmdline", pid))?);
let mut exe_buf = Vec::<u8>::new();
exe.read_to_end(&mut exe_buf).expect("FUN");
let exe = String::from_utf8(exe_buf).unwrap_or(String::from("HAHAHA"));
let mut chars = exe.chars();
chars.next_back();
let exe = chars.as_str();
let handle = pid.try_into_process_handle().expect(":::");
let mut magic_buf = [0u8; 4];

for line in f.lines() {
if let Ok(line) = line {
let (start, _end, _perms, mod_path) = scan_fmt!(&line, "{x}-{x} {} {*} {*} {*} {[^\t\n]}\n", [hex usize], [hex usize], String, String).unwrap();
handle.copy_address(start, &mut magic_buf).unwrap();
if is_elf(&magic_buf) {
log::info!("ELF: {} -> {}", start, mod_path);
//return Ok(start);
if let Ok((start, _end, perms, mod_path)) = scan_fmt!(&line, "{x}-{x} {} {*} {*} {*} {[^\t\n]}\n", [hex usize], [hex usize], String, String)
{
let r = handle.copy_address(start, &mut magic_buf);
if r.is_err() {
continue;
}
if is_elf(&magic_buf) && mod_path.contains(DD_PROCESS) && perms.contains("x") {
log::info!("ELF: {} -> {}", start, mod_path);
return Ok(start);
}
}
}
}


Err(std::io::Error::new(
std::io::ErrorKind::NotFound,
"No base address",
Expand Down
6 changes: 4 additions & 2 deletions src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,8 @@ fn create_homing_rows(data: &StatsBlockWithFrames, style: SizeStyle) -> Vec<Row>
"{} [MAX {} at {:.4}s]",
data.block.homing, data.block.max_homing, data.block.time_max_homing
),
]).style(normal_style)]
])
.style(normal_style)]
}
SizeStyle::Compact => {
vec![Row::new([
Expand All @@ -228,7 +229,8 @@ fn create_homing_rows(data: &StatsBlockWithFrames, style: SizeStyle) -> Vec<Row>
"{} [{} @ {:.4}s]",
data.block.homing, data.block.max_homing, data.block.time_max_homing
),
]).style(normal_style)]
])
.style(normal_style)]
}
SizeStyle::Minimal => {
vec![Row::new(["HOMING".into(), format!("{}", get_homing(&data))]).style(normal_style)]
Expand Down

0 comments on commit 75698eb

Please sign in to comment.