A DWORD
es un uint
y WORD
es un ushort
.
[StructLayout(LayoutKind.Sequential)]
struct CACHE_DESCRIPTOR
{
public byte Level;
public byte Associativity;
public ushort LineSize;
public uint Size;
public PROCESSOR_CACHE_TYPE Type;
}
enum PROCESSOR_CACHE_TYPE
{
Unified = 0,
Instruction = 1,
Data = 2,
Trace = 3,
}
A union
es una estructura con un diseño de Explicit
y FieldOffset
.
[StructLayout(LayoutKind.Sequential)]
struct SYSTEM_LOGICAL_PROCESSOR_INFORMATION
{
public UIntPtr ProcessorMask;
public LOGICAL_PROCESSOR_RELATIONSHIP Relationship;
public ProcessorRelationUnion RelationUnion;
}
[StructLayout(LayoutKind.Explicit)]
struct ProcessorRelationUnion
{
[FieldOffset(0)] public CACHE_DESCRIPTOR Cache;
[FieldOffset(0)] public uint NumaNodeNumber;
[FieldOffset(0)] public byte ProcessorCoreFlags;
[FieldOffset(0)] private UInt64 Reserved1;
[FieldOffset(8)] private UInt64 Reserved2;
}
[StructLayout(LayoutKind.Sequential)]
struct CACHE_DESCRIPTOR
{
public byte Level;
public byte Associativity;
public ushort LineSize;
public uint Size;
public PROCESSOR_CACHE_TYPE Type;
}
enum LOGICAL_PROCESSOR_RELATIONSHIP : uint
{
ProcessorCore = 0,
NumaNode = 1,
RelationCache = 2,
}
Un ULONGLONG
es una UInt64
. Se trata de alinear la estructura con un límite de 8 bytes (24 bytes). Como David señaló en los comentarios, es necesario y por alguna razón faltaba en la biblioteca Microsoft Interop.
Actualización: Se han agregado las estructuras faltantes y se ha vinculado a la biblioteca de Windows Interop de Microsoft Research.
Fuente: WindowsInteropLib/Kernel32.cs
¿Alguna de las razones del downvote? – VMAtm