Skip to content

fix: idle process CPU and i686 Go to Process - #25

Merged
cursor[bot] merged 2 commits into
mainfrom
cursor/idle-cpu-and-findproc-i686-31a1
Oct 19, 2026
Merged

cursor[bot] merged 2 commits into
mainfrom
cursor/idle-cpu-and-findproc-i686-31a1

Conversation

@JamesLinYJ

Copy link
Copy Markdown
Owner

Summary

Fixes two process-page correctness bugs. No dependency or target changes.

  • Process refresh now reads CPU, creation time, memory, handles, threads, session, and base priority from one NtQuerySystemInformation(SystemProcessInformation) query on the existing worker. The System Idle Process and processes that refuse OpenProcess get real counters and a ProcIdentity of pid plus creation time. A bad counter or image name keeps the other rows and sets row_error. Unknown architecture stays unknown.
  • Steady-state refresh no longer opens a handle per process. A creation-time-checked limited open still runs once for a new verified process so the architecture column and primary-token user name can be learned, then is cached. Access-denied identities are not opened again; their CPU row remains.
  • Go to Process no longer puts creation_time_100ns in LPARAM. WM_FINDPROC carries 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

  • Idle and an inaccessible row take their CPU share from system counters, including a zero creation time for Idle, without a process handle.
  • A corrupt counter keeps sibling rows and does not seed a zero baseline that would later show 100%.
  • A reused PID does not inherit the previous CPU baseline.
  • A synthetic SystemProcessInformation buffer checks Idle counters, memory fields, and a bad image name beside valid rows.
  • On Windows, the live query must include Idle CPU time even though OpenProcess(0) fails, must match the current process creation time from GetProcessTimes, and must keep counters for any row that refuses both process opens.
  • Creation times that do not fit in an i686 LPARAM survive WM_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 -- --check passed. cargo clippy --all-targets --locked -- -D warnings passed for x86_64-pc-windows-msvc, i686-pc-windows-msvc, and aarch64-pc-windows-msvc (metadata only; resources via host llvm-rc; not linked and not executed). cargo test and cargo build --release were 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.

Open in Web Open in Cursor 

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>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-19T16:34:00.355359Z 70b35ec PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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() };

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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>
@cursor
cursor Bot merged commit aa0f920 into main Oct 19, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants