Fix FLS FiberManager writing last_error to a dead attribute#1646
Open
w1tcher wants to merge 1 commit into
Open
Fix FLS FiberManager writing last_error to a dead attribute#1646w1tcher wants to merge 1 commit into
w1tcher wants to merge 1 commit into
Conversation
FiberManager.free/set/get set `self.last_error` on the FiberManager instance, but nothing ever reads that attribute. The Windows last-error that GetLastError returns lives on `ql.os.last_error`, so FlsFree, FlsSetValue and FlsGetValue never actually reported ERROR_INVALID_PARAMETER for an invalid FLS index. Route the three writes to `self.ql.os.last_error`, consistent with every other kernel32 hook. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
FiberManager(qiling/os/windows/fiber.py) reportsERROR_INVALID_PARAMETERfor an invalid FLS index by writing
self.last_errorinfree(),set()andget(). Butself.last_erroris a plain attribute on theFiberManagerinstance that nothing ever reads — it is written in three places and read
in none.
The Windows last-error that
GetLastErrorreturns lives onql.os.last_error(
hook_GetLastErrorreturns it,hook_SetLastErrorwrites it, and every otherkernel32 hook sets errors via
ql.os.last_error = ...). Because the FLS codewrote the wrong object,
FlsFree/FlsSetValue/FlsGetValuenever actuallysurfaced
ERROR_INVALID_PARAMETERto the emulated program: a guest calling oneof these with a bad index, then
GetLastError()to disambiguate the result,would see a stale/zero error code.
Fix
Route the three writes to
self.ql.os.last_error(theFiberManageralreadyholds
self.ql), making the FLS error path consistent with the rest ofkernel32. No API surface or signature changes; 3 lines in one file.
This is independent of #1637 (which adds
FlsGetValue2/get_noerr). It is worthnoting the two interact: only once the last-error actually lands on
ql.os.last_errordoes the intendedFlsGetValue(sets error on bad index) vsFlsGetValue2(does not) distinction become observable to the guest.Checklist
Which kind of PR do you create?
Coding convention?
Extra tests?
Changelog?
Target branch?
One last thing