Expand win32k GDI/user syscall emulation - #22
Conversation
Adds broad win32k coverage with many new NtGdi/NtUser/Nt* syscall handlers, including bitmap blits, DIB transfer, region ops, timer APIs, deferred window positioning, cursor/icon metadata, window placement/state APIs, and additional process/misc NT calls. It also refactors message-queue behavior to be thread-aware, synthesizes WM_PAINT/WM_TIMER correctly, and tracks paint/update state more accurately. Rendering and text support were extended across hosts: a new Blit GDI primitive is wired through Win32/Linux/Android backends, font family enumeration is exposed through the window manager stack, and Android adds a new SwitcherView control. Supporting updates include safer Unicorn hook callback failure handling, drive-map reporting for ProcessDeviceMap, command-line/process launch fixes, and Android build script updates for .NET 10.
|
@claude review |
|
Claude finished @AdvDebug's task in 1m 7s —— View job Review completeTodo list
This is a large PR (86 files, +4288/-124), so I reviewed it in four parallel passes: win32k core state/message-queue logic, new High-severity findings (verified)1. Region-handle type confusion → cross-object memory corruption Concrete failure: a guest opens a DC via 2. Deleting the shared display-surface bitmap leaves it permanently dangling Concrete failure: guest calls Medium/low-severity findings
Not an issue
I did not run a build/test suite here — this environment doesn't have a verified build step configured; let me know if you'd like me to attempt one. |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 76634ccda5
ℹ️ 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".
| if (!State.DeviceContexts.TryGetValue(Hdc, out Win32kDeviceContext Dc)) | ||
| return 0; | ||
|
|
||
| return Dc.Display ? EnsureDisplaySurfaceBitmap(Instance, State) : Dc.SelectedBitmap; |
There was a problem hiding this comment.
Route display-DC blits through the display surface
When a guest draws to an HDC returned by NtGdiOpenDCW/CreateDC("DISPLAY"), this flag only changes GetDcSelectedBitmap. BlitBlockToDc instead probes TryGetDcBitmap, which still sees the 1-bit stock bitmap; it cannot blit there and, since this DC has Hwnd == 0, returns false. Consequently BitBlt, SetDIBitsToDevice, and StretchDIBits targeting a display DC fail rather than draw to the advertised display surface.
Useful? React with 👍 / 👎.
| if (Thread.WaitDeadline == -1 || Due < Thread.WaitDeadline) | ||
| Thread.WaitDeadline = Due; |
There was a problem hiding this comment.
Restrict timer deadline wakeups to eligible message waits
This assigns every newly created timer's deadline to every waiting GetMessage/WaitMessage thread without checking the timer's owner, HWND filter, or message range. For example, a thread waiting with GetMessage(hwndA, ...) receives the deadline for a timer on hwndB; when it expires, that timer cannot be dequeued by the filter, so the wait remains armed with an expired deadline and is repeatedly checked by the scheduler. Reuse the ownership/filter logic from GetNextTimerDue before updating each waiting thread.
Useful? React with 👍 / 👎.
| using IEnumerator<string> Entries = Directory.EnumerateFileSystemEntries(Root).GetEnumerator(); | ||
| if (Entries.MoveNext()) | ||
| Map |= 1u << Index; |
There was a problem hiding this comment.
Report empty mapped drives as available
An explicitly mapped drive is usable even when its host root is empty: SetDriveMapping creates and registers that directory, and path resolution uses it directly. This code sets the drive-map bit only after finding an entry, so an empty mapped D: is omitted from ProcessDeviceMap even though guest file operations can use it. Mark an existing mapped root as present rather than requiring it to contain a file.
Useful? React with 👍 / 👎.
|
@claude review |
|
Claude finished @AdvDebug's task in 2m 43s —— View job Review completeTodo list
This PR has already been through two review rounds (my earlier pass and Codex's), and commits Confirmed fixed
New finding (not covered by either previous round)
int Width = Math.Min(Header.Width, Bitmap.Width); // clamped, used for the copy
...
int Stride = ((Header.Width * Header.BitsPerPixel + 31) / 32) * 4; // uses raw Header.Width
Because Spans are bounds-checked this isn't a memory-corruption bug, and the Unicorn hook-failure handling added in this same PR ( Still open from the earlier rounds (unchanged, lower priority)
Not an issueEverything else from the original 87-file diff (region-combine math, |
|
@codex review |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Adds broad win32k coverage with many new NtGdi/NtUser/Nt* syscall handlers, including bitmap blits, DIB transfer, region ops, timer APIs, deferred window positioning, cursor/icon metadata, window placement/state APIs, and additional process/misc NT calls. It also refactors message-queue behavior to be thread-aware, synthesizes WM_PAINT/WM_TIMER correctly, and tracks paint/update state more accurately.
Rendering and text support were extended across hosts: a new Blit GDI primitive is wired through Win32/Linux/Android backends, font family enumeration is exposed through the window manager stack, and Android adds a new SwitcherView control. Supporting updates include safer Unicorn hook callback failure handling, drive-map reporting for ProcessDeviceMap, command-line/process launch fixes, and Android build script updates for .NET 10.