public MemoryAlloc ToMemory() { int requiredSize = 8 + _sizeOfLaa * _privileges.Count; MemoryAlloc memory = new MemoryAlloc(requiredSize); memory.WriteInt32(0, _privileges.Count); memory.WriteInt32(4, (int)_flags); for (int i = 0; i < _privileges.Count; i++) { memory.WriteStruct <LuidAndAttributes>(8, i, _privileges[i].ToLuidAndAttributes()); } return(memory); }