Repository navigation
fix: idle process CPU and i686 Go to Process - #25
Conversation
Read process CPU, creation time, and memory from one SystemProcessInformation query so Idle and processes that refuse OpenProcess get real counters. Pass WM_FINDPROC the full 64-bit creation time by pointer so i686 no longer truncates or sign-extends ProcIdentity. Co-authored-by: jameslincn <jameslincn@outlook.sg>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 70b35ec064
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // keeps alive until the synchronous `SendMessageW` returns. This copies the two fields | ||
| // before that payload goes out of scope. The pointer is aligned because it came from a | ||
| // reference to `FindProcPayload`. | ||
| let payload = unsafe { (lparam as *const FindProcPayload).read() }; |
There was a problem hiding this comment.
Avoid dereferencing an untrusted window-message pointer
When another process, or any in-process caller not using find_proc_lparam, sends WM_FINDPROC with a nonzero LPARAM, this reads that value as an address in the receiving process. Custom window messages do not validate or marshal such pointers, so a value such as 1 causes an access violation before the PID check and crashes the application. Pass a receiver-owned stable identifier or use a properly marshalled mechanism instead of dereferencing message data.
AGENTS.md reference: AGENTS.md:L51-L51
Useful? React with 👍 / 👎.
u64::MAX survives the old 32-bit sign-extend because the low half is already all ones. The test now locks the values that cast corrupts and still requires the payload path to round-trip every sample, including u64::MAX. Co-authored-by: jameslincn <jameslincn@outlook.sg>
Summary
Fixes two process-page correctness bugs. No dependency or target changes.
NtQuerySystemInformation(SystemProcessInformation)query on the existing worker. The System Idle Process and processes that refuseOpenProcessget real counters and aProcIdentityof pid plus creation time. A bad counter or image name keeps the other rows and setsrow_error. Unknown architecture stays unknown.creation_time_100nsinLPARAM.WM_FINDPROCcarries a pointer to a stack payload with the full 64-bit creation time, which round-trips on both i686 and x86_64. The old i686 cast truncated the high half and sign-extended bit 31.Tests
SystemProcessInformationbuffer checks Idle counters, memory fields, and a bad image name beside valid rows.OpenProcess(0)fails, must match the current process creation time fromGetProcessTimes, and must keep counters for any row that refuses both process opens.LPARAMsurviveWM_FINDPROC, including values whose low half has the sign bit set. Unverified and mismatched identities are rejected. The i686 build also round-trips the pointer through a 32-bit slot.Verification
This host is Linux.
cargo fmt --all -- --checkpassed.cargo clippy --all-targets --locked -- -D warningspassed forx86_64-pc-windows-msvc,i686-pc-windows-msvc, andaarch64-pc-windows-msvc(metadata only; resources via hostllvm-rc; not linked and not executed).cargo testandcargo build --releasewere not run here because this machine cannot execute or link Windows PE binaries.That is not a Windows device test. CI on this PR is the Windows run of fmt, tests, and release builds.