public void TestNtWriteVirtualMemory() { var syscall = new Syscall <Signatures.NtWriteVirtualMemory>(); Span <byte> bytes = stackalloc byte[sizeof(int)]; MemoryMarshal.Write(bytes, ref Unsafe.AsRef(_testValue)); var status = syscall.Method(_process.SafeHandle, _testAddress, in bytes[0], bytes.Length, out _); if (status != NtStatus.Success) { throw new Win32Exception(Ntdll.RtlNtStatusToDosError(status)); } Assert.Equal(_testValue, Marshal.ReadInt32(_testAddress)); }
public void TestNtReadVirtualMemory() { const int testNumber = 1024; Marshal.WriteInt32(_testAddress, testNumber); var syscall = new Syscall <Delegates.ReadProcessMemory>(); Span <byte> bytes = stackalloc byte[sizeof(int)]; var status = syscall.Method(_process.SafeHandle, _testAddress, out bytes[0], bytes.Length, out _); if (status != NtStatus.Success) { throw new Win32Exception(Ntdll.RtlNtStatusToDosError(status)); } Assert.Equal(testNumber, MemoryMarshal.Read <int>(bytes)); }