Repository: GuillaumeGomez/sysinfo (language: rust)

Issue:
Process parent is `None` if the target process of `refresh_process_specifics()` is a WoW64 process
https://github.com/GuillaumeGomez/sysinfo/blob/1f17db7428fb568a2c3af803fc3d550dd924b5b3/src/windows/process.rs#L805-L829

If the target process is a WoW64 process, `NtQueryInformationProcess(ProcessBasicInformation)` is skipped and `process.parent` is not set. However, `NtQueryInformationProcess(ProcessBasicInformation)` actually works fine for WoW64 processes, at least for the `InheritedFromUniqueProcessId` part.

Simply moving this `NtQueryInformationProcess` out of the if guard seems to solve the problem. If needed, I can make a PR for this change.

OS: Windows 24H2 26100.1000

sysinfo: 0.30.13


Discussion / hints:
It would be very appreciated! :)

Fix patch:
diff --git a/src/windows/process.rs b/src/windows/process.rs
index fe0ff978e..95eba115a 100644
--- a/src/windows/process.rs
+++ b/src/windows/process.rs
@@ -802,9 +802,9 @@ unsafe fn get_process_params(
     }
     let pwow32info = pwow32info.assume_init();
 
-    if pwow32info.is_null() {
-        // target is a 64 bit process
-
+    // Get parent and PEB64 from PROCESS_BASIC_INFORMATION
+    // PEB64 will only be used if the target is 64 bit process
+    let pinfo = if refresh_parent || pwow32info.is_null() {
         let mut pbasicinfo = MaybeUninit::<PROCESS_BASIC_INFORMATION>::uninit();
         if NtQueryInformationProcess(
             handle,
@@ -832,6 +832,16 @@ unsafe fn get_process_params(
             return;
         }
 
+        Some(pinfo)
+    } else {
+        None
+    };
+
+    if pwow32info.is_null() {
+        // target is a 64 bit process
+
+        let Some(pinfo) = pinfo else { return };
+
         let mut peb = MaybeUninit::<PEB>::uninit();
         if ReadProcessMemory(
             handle,


Test patch: