lundi 30 mars 2015

GetProcessAffinityMask returns null process affinity



In a very simple test console application, I tried to get process' affinity mask:



#include <cstdlib>
#include <cstdio>
#include <windows.h>

int main()
{
while (1)
{
DWORD dwProcessAffinityMask = 0;
DWORD dwSystemAffinityMask = 0;

BOOL res = GetProcessAffinityMask(
GetCurrentProcess(),
(PDWORD_PTR)&dwProcessAffinityMask,
(PDWORD_PTR)&dwSystemAffinityMask);

printf("%d 0x%X 0x%X\n",
res,
dwProcessAffinityMask,
dwSystemAffinityMask);

Sleep(1000);
}

return 0;
}


Here is the output (64-bit executable, 64-bit system, meaning I do not fall into the WoW64 special case):



1 0x0 0x3
1 0x0 0x3
...


Running on my laptop, which has a 2 cores CPU, the resulting system's mask looks correct. But I don't understand the meaning of the dwProcessAffinityMask value I get here. Just for the sake of it, I also tried to toy around with the Task Manager by changing the process' affinity mask but the output remains the same.


This behavior doesn't seem to be documented.




Aucun commentaire:

Enregistrer un commentaire