Skip to content

Commit

Permalink
revert new way of reading os and arch, since that was broken for some…
Browse files Browse the repository at this point in the history
… games
  • Loading branch information
Raicuparta committed Jan 3, 2024
1 parent d5922c2 commit 38747b5
Showing 1 changed file with 18 additions and 20 deletions.
38 changes: 18 additions & 20 deletions backend/src/game_executable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,29 +70,27 @@ pub fn read_linux_binary(file: &[u8]) -> Result<(Option<OperatingSystem>, Option
pub fn get_os_and_architecture(
file_path: &Path,
) -> Result<(Option<OperatingSystem>, Option<Architecture>)> {
let mut file = File::open(file_path)?;
let mut header_buffer = [0u8; 400];
file.read_exact(&mut header_buffer)?;

let pe_result = read_windows_binary(&header_buffer);
if pe_result.is_ok() {
return pe_result;
}
fs::read(file_path).map(|file| {
let elf_result = read_linux_binary(&file);
if elf_result.is_ok() {
return elf_result;
}

let elf_result = read_linux_binary(&header_buffer);
if elf_result.is_ok() {
return elf_result;
}
let pe_result = read_windows_binary(&file);
if pe_result.is_ok() {
return pe_result;
}

error!("Failed to parse exe as ELF or PE");
if let Err(err) = elf_result {
error!("ELF error: {err}");
}
if let Err(err) = pe_result {
error!("PE error: {err}");
}
error!("Failed to parse exe as ELF or PE");
if let Err(err) = elf_result {
error!("ELF error: {err}");
}
if let Err(err) = pe_result {
error!("PE error: {err}");
}

Ok((None, None))
Ok((None, None))
})?
}

impl GameExecutable {
Expand Down

0 comments on commit 38747b5

Please sign in to comment.