Is it possible to be notified immediately when an external party changes your programs process affinity? Without polling GetProcessAffinityMask(). For example if a user decides to change it via the task manager.
Asked
Active
Viewed 38 times
1 Answers
-1
EDIT: This answer happened before the edit that added "Without polling GetProcessAffinityMask()" and did not specify the language of the check.
Yes, it's doable with a PowerShell for example. Set some base data once and make comparisons every once in a while.
You can get processes with Get-Process
(documentation) which returns System.Diagnostics.Process
object (documentation) with Process.ProcessorAffinity
(documentation) property.
So getting the affinity would look like:
Get-Process PROCESS | Select-Object ProcessorAffinity
And with that - you can set your notifications (either mail, desktop or any other).

Karolina Ochlik
- 908
- 6
- 8
-
I actually wanted to know if it is possible to be notified immediately within my C++ program if someone has tampered with my processes affinity, ideally without polling it – iam Jun 16 '21 at 10:00
-
*"Without polling GetProcessAffinityMask()."* – IInspectable Jun 16 '21 at 19:15
-
@IInspectable this was answered 9 hrs ago, before the edit with the _"Without polling GetProcessAffinityMask()."_ happened. Check please before minusing. – Karolina Ochlik Jun 16 '21 at 19:18
-
The original question asked for a *"notification"*. Polling is not a notification. – IInspectable Jun 16 '21 at 19:20
-
I understand notification as a mail, tooltip, message box or anything else that notifies me of a change. Note the sentence at the end of my answer: _"And with that - you can set your notifications (either mail, desktop or any other)."_ – Karolina Ochlik Jun 16 '21 at 19:21
-
You do **not** get reliably notified using a strategy based on sampling. If changes happen between two sample points, you aren't observing them. Notifications, particularly on Windows, have a very distinct meaning: Events you can subscribe to, that don't exhibit the issues you get with sampling. – IInspectable Jun 16 '21 at 20:14