private void CreateMemoryDomain(LibSameboy.MemoryAreas which, string name) { IntPtr data = IntPtr.Zero; int length = 0; if (!LibSameboy.sameboy_getmemoryarea(SameboyState, which, ref data, ref length)) { throw new Exception($"{nameof(LibSameboy.sameboy_getmemoryarea)}() failed!"); } // if length == 0, it's an empty block; (usually rambank on some carts); that's ok if (data != IntPtr.Zero && length > 0) { _memoryDomains.Add(new MemoryDomainIntPtr(name, MemoryDomain.Endian.Little, data, length, true, 1)); } }