diff --git a/src/main.rs b/src/main.rs index 39a45e0..54e6742 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,7 +6,7 @@ use windows_sys::{ Win32::System::{Diagnostics::Debug::*, Threading::*}, }; -use std::ptr::null; +use std::{ptr::null, mem::MaybeUninit}; mod command; mod eval; @@ -265,7 +265,7 @@ fn main() { let mut si: STARTUPINFOEXW = unsafe { std::mem::zeroed() }; si.StartupInfo.cb = std::mem::size_of::() as u32; - let mut pi: PROCESS_INFORMATION = unsafe { std::mem::zeroed() }; + let mut pi: MaybeUninit = MaybeUninit::uninit(); let ret = unsafe { CreateProcessW( null(), @@ -277,7 +277,7 @@ fn main() { null(), null(), &mut si.StartupInfo, - &mut pi, + pi.as_mut_ptr(), ) }; @@ -285,6 +285,8 @@ fn main() { panic!("CreateProcessW failed"); } + let pi = unsafe { pi.assume_init() }; + unsafe { CloseHandle(pi.hThread) }; // Later, we'll need to pass in a process handle. diff --git a/src/module.rs b/src/module.rs index 6dea642..bd7a3f0 100644 --- a/src/module.rs +++ b/src/module.rs @@ -36,6 +36,7 @@ pub enum ExportTarget { Forwarder(String) } +#[derive(Default)] #[repr(C)] pub struct PdbInfo { pub signature: u32, @@ -44,12 +45,6 @@ pub struct PdbInfo { // Null terminated name goes after the end } -impl ::core::default::Default for PdbInfo { - fn default() -> Self { - unsafe { ::core::mem::zeroed() } - } -} - impl ::core::marker::Copy for PdbInfo {} impl ::core::clone::Clone for PdbInfo { fn clone(&self) -> Self {