+ NTSTATUS Status;
+ SYSTEM_NUMA_INFORMATION NumaInformation;
+ ULONG Length;
+ ULONG Node;
+ ULONGLONG Proc;
+
+ /* Can't handle processor number >= 32 */
+ if (Processor >= 0x20)
+ {
+ *NodeNumber = -1;
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+
+ /* Query NUMA information */
+ Status = NtQuerySystemInformation(SystemNumaProcessorMap,
+ &NumaInformation,
+ sizeof(NumaInformation),
+ &Length);
+ if (!NT_SUCCESS(Status))
+ {
+ *NodeNumber = -1;
+ BaseSetLastNTError(Status);
+ return FALSE;
+ }
+
+ /* Find ourselves */
+ Node = 0;
+ Proc = (1ULL << Processor) >> 0x20;
+ while ((Proc & NumaInformation.ActiveProcessorsAffinityMask[Node]) == 0ULL)
+ {
+ ++Node;
+ /* Out of options */
+ if (Node > NumaInformation.HighestNodeNumber)
+ {
+ *NodeNumber = -1;
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+ }
+
+ /* Return found node */
+ *NodeNumber = Node;
+ return TRUE;