Repository navigation
fix: enable SeIncreaseBasePriorityPrivilege when setting High I/O priority - #65
Open
SA-Mousavichashmi wants to merge 1 commit into
Open
SA-Mousavichashmi wants to merge 1 commit into
SA-Mousavichashmi wants to merge 1 commit into
Conversation
… map privilege errors
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Owner
|
Thanks for the PR. Please scope SeIncreaseBasePriorityPrivilege to the NtSetInformationProcess operation. Capture PreviousState when calling AdjustTokenPrivileges and restore it in a finally block on both success and failure. Since this modifies the process-wide token, please also prevent overlapping callers from restoring the privilege while another call still needs it. Add a Windows integration test that verifies the original privilege state is restored. The existing fake-based tests do not exercise the native token path. |
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.
Description
When configuring process I/O priority to
High(ProcessIoPriority.High/ level 3), Windows NT requiresSeIncreaseBasePriorityPrivilegein the calling process's token.Even though ThreadPilot runs elevated as administrator, Windows administrative user tokens have
SeIncreaseBasePriorityPrivilegedisabled by default until explicitly enabled viaAdjustTokenPrivileges. Without enabling this privilege,NtSetInformationProcess(..., ProcessIoPriority, ...)fails with NTSTATUS0xC0000061(STATUS_PRIVILEGE_NOT_HELD). In ThreadPilot, this unmapped status previously produced a genericNativeApplyFailederror while leaving targeted processes stuck at default/throttled Low I/O priority.Changes
Privilege Adjustment P/Invoke:
OpenProcessToken,LookupPrivilegeValueW,AdjustTokenPrivileges) toProcessMemoryPriorityNativeMethods.TryEnablePrivilegeand exposedTryEnableProcessPrivilegeonIProcessMemoryPriorityNativeApi.Acquire Privilege on High I/O Priority:
ProcessMemoryPriorityService.SetIoPriorityAsyncto invokeTryEnableProcessPrivilege(SeIncreaseBasePriorityPrivilege)before callingSetIoPrioritywhen requestingProcessIoPriority.High.Status Code Mapping:
0xC0000061(STATUS_PRIVILEGE_NOT_HELD) alongside0xC0000022(STATUS_ACCESS_DENIED) toAffinityApplyErrorCodes.AccessDeniedand user-friendly access denied messaging.Unit Tests:
ProcessMemoryPriorityServiceTestsverifying thatProcessIoPriority.Highattempts to acquireSeIncreaseBasePriorityPrivilege.0xC0000061maps safely toAccessDenied.Verification
0xC0000061error mapping.