Skip to content

Commit

Permalink
Allocate a console on first install to show installation status
Browse files Browse the repository at this point in the history
  • Loading branch information
TimMisiak committed Jul 9, 2023
1 parent 1ff2d71 commit 3462948
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ features = [
"Win32_Security_WinTrust",
"Win32_Security_Cryptography",
"Win32_System_Environment",
"Win32_System_Console",
]
4 changes: 3 additions & 1 deletion src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,9 @@ pub fn check_for_new_version(install_dir: &Path, current_version: Option<String>
let elapsed = start.elapsed();
println!("Time to download: {:?}", elapsed);

println!("Verifying certificates");
drop(dest_file);

println!("Verifying certificates on {}", dest_path.as_path().to_str().unwrap());
let start = std::time::Instant::now();
if !verify_archive(dest_path.as_path()) {
return None;
Expand Down
15 changes: 13 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
use windows::{Win32::System::{Threading::{PROCESS_CREATION_FLAGS, CreateProcessW, STARTUPINFOEXW, PROCESS_INFORMATION, WaitForSingleObject, INFINITE}, Environment::GetCommandLineW}, core::PWSTR};
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]

use windows::{Win32::System::{Threading::{PROCESS_CREATION_FLAGS, CreateProcessW, STARTUPINFOEXW, PROCESS_INFORMATION, WaitForSingleObject, INFINITE}, Environment::GetCommandLineW, Console::{AllocConsole, FreeConsole}}, core::PWSTR};
use std::{path::Path, ffi::OsString, os::windows::{ffi::OsStrExt, prelude::OsStringExt}};
use std::io::Read;

mod range_reader;
mod install;
Expand Down Expand Up @@ -103,17 +106,25 @@ fn main() {
run_dbgx_shell(&version_path);
});


// Check for new versions in the background
check_for_new_version(&install_dir, current_version);

thread.join().unwrap();
} else {
unsafe { AllocConsole() };
let new_version = check_for_new_version(&install_dir, current_version);

if let Some(new_version) = new_version {
let version_install_dir = install_dir.join(&new_version);
// Now that we're installed, run DbgX.Shell.exe with the given parameters
run_dbgx_shell(&version_install_dir);
} else {
println!("Install failed. Press enter to close this window.");
let mut stdin = std::io::stdin();
let _ = stdin.read(&mut [0u8]).unwrap();
}

unsafe { FreeConsole() };
}
}

0 comments on commit 3462948

Please sign in to comment.