mirror of
https://github.com/par274/sharpemu.git
synced 2026-07-22 19:06:15 +08:00
[SystemService] Write notice skip flag as byte (#346)
The Gen5 caller supplies a one-byte flag. Preserve pointer and memory-fault behavior while writing only that byte, and cover a seeded guest-memory boundary that rejects the former four-byte write.
This commit is contained in:
@@ -38,8 +38,8 @@ public static class SystemServiceExports
|
||||
}
|
||||
|
||||
// No system notice screen to skip in the emulator; report "do not skip".
|
||||
Span<byte> flagBytes = stackalloc byte[sizeof(int)];
|
||||
BinaryPrimitives.WriteInt32LittleEndian(flagBytes, 0);
|
||||
Span<byte> flagBytes = stackalloc byte[1];
|
||||
flagBytes[0] = 0;
|
||||
return ctx.Memory.TryWrite(flagAddress, flagBytes)
|
||||
? ctx.SetReturn(0)
|
||||
: ctx.SetReturn((int)OrbisGen2Result.ORBIS_GEN2_ERROR_MEMORY_FAULT);
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
// Copyright (C) 2026 SharpEmu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
using SharpEmu.HLE;
|
||||
using SharpEmu.Libs.SystemService;
|
||||
using Xunit;
|
||||
|
||||
namespace SharpEmu.Libs.Tests.SystemService;
|
||||
|
||||
public sealed class SystemServiceExportsTests
|
||||
{
|
||||
private const ulong MemoryBase = 0x1_0000_0000;
|
||||
|
||||
[Fact]
|
||||
public void GetNoticeScreenSkipFlagWritesOneByteAtMemoryBoundary()
|
||||
{
|
||||
var memory = new FakeCpuMemory(MemoryBase, 1);
|
||||
var context = new CpuContext(memory, Generation.Gen5);
|
||||
Assert.True(memory.TryWrite(MemoryBase, new byte[] { 0xA5 }));
|
||||
context[CpuRegister.Rdi] = MemoryBase;
|
||||
|
||||
Assert.Equal(0, SystemServiceExports.SystemServiceGetNoticeScreenSkipFlag(context));
|
||||
Assert.Equal(0UL, context[CpuRegister.Rax]);
|
||||
|
||||
Span<byte> flag = stackalloc byte[1];
|
||||
Assert.True(memory.TryRead(MemoryBase, flag));
|
||||
Assert.Equal(0, flag[0]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user