Esempio n. 1
0
        public static PlainMemory CreateFrom(DataRef data)
        {
            var memory = new PlainMemory(data.Size);

            memory.CopyFrom(data, 0, data.Size, 0);
            return(memory);
        }
Esempio n. 2
0
        public static void Copy(DataRef src, DataRef dst)
        {
            if (src.Size != dst.Size)
            {
                throw new InvalidOperationException("Memory regions must have the same length.");
            }

            _ = vcpu_memcpy(dst.Pointer, src.Pointer, src.Size);
        }
Esempio n. 3
0
        public void CopyFrom(DataRef src, int srcOffset, int length, int destOffset)
        {
            if (srcOffset >= src.Size)
            {
                throw new ArgumentOutOfRangeException(nameof(srcOffset));
            }

            var destSize = Data.Size;

            if (destOffset >= destSize)
            {
                throw new ArgumentOutOfRangeException(nameof(destOffset));
            }

            if (srcOffset + length > src.Size || destOffset + length > destSize)
            {
                throw new ArgumentOutOfRangeException(nameof(length));
            }

            Validation.ValidateResult(vcpu_memory_write(Inner, src.Pointer + srcOffset, destOffset, length));
        }
Esempio n. 4
0
 public void Run(DataRef instructions, Memory memory)
 => Validation.ValidateResult(vcpu_processor_run(_inner, instructions.Pointer, instructions.Size, memory.Inner));