snes waterbox: fix a leaky pointer which was breaking xorstate integrity

This commit is contained in:
nattthebear 2017-06-10 17:19:18 -04:00
parent 0bcdeee1e7
commit ba7543c19a
2 changed files with 10 additions and 2 deletions

View File

@ -33,12 +33,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
}
}
private PeRunner _exe;
private CoreImpl _core;
private bool _disposed;
private CommStruct* _comm;
private readonly Dictionary<string, IntPtr> _sharedMemoryBlocks = new Dictionary<string, IntPtr>();
private bool _sealed = false;
public void Enter()
{
@ -110,6 +110,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
/// </summary>
public void SetBytes(int id, byte[] bytes, Action andThen)
{
if (_sealed)
throw new InvalidOperationException("Init period is over");
fixed (byte* bp = bytes)
{
_core.SetBuffer(id, bp, bytes.Length);
@ -122,6 +124,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
/// </summary>
public void SetAscii(int id, string str, Action andThen)
{
if (_sealed)
throw new InvalidOperationException("Init period is over");
fixed (byte* cp = System.Text.Encoding.ASCII.GetBytes(str + "\0"))
{
_core.SetBuffer(id, cp, str.Length + 1);
@ -345,7 +349,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
public void Seal()
{
_core.SetBuffer(0, null, 0);
_core.SetBuffer(1, null, 0);
_core.SetBuffer(2, null, 0);
_exe.Seal();
_sealed = true;
}
public void SaveStateBinary(BinaryWriter writer)

View File

@ -173,7 +173,7 @@ struct CommStruct
//===========================================================
//private stuff
void* privbuf[2]; //TODO remember to tidy this..
void* privbuf[3]; //TODO remember to tidy this..
void CopyBuffer(int id, void* ptr, int32 size)
{