Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
Signed-off-by: Alan Jowett <[email protected]>
  • Loading branch information
Alan Jowett committed Apr 20, 2024
1 parent 335852d commit d4c89ff
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/ke.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,12 @@ KeSetSystemAffinityThreadEx(KAFFINITY affinity)
{
GROUP_AFFINITY old_affinity;
usersim_get_current_thread_group_affinity(&old_affinity);
// Reject affinities that are not valid for the current group.
// Assume that the affinity mask is contiguous.
KAFFINITY valid_affinity_mask = (1 << KeQueryMaximumProcessorCountEx(old_affinity.Group)) - 1;
if ((affinity & valid_affinity_mask) == 0) {
return 0;
}
_usersim_thread_affinity.Group = old_affinity.Group;
_usersim_thread_affinity.Mask = affinity;
if (KeGetCurrentIrql() < DISPATCH_LEVEL && SetThreadAffinityMask(GetCurrentThread(), affinity) == 0) {
Expand Down

0 comments on commit d4c89ff

Please sign in to comment.