mbbsemu / MBBSEmu

The MajorBBS Emulation Project is an Open Source, Cross-Platform emulator for easily running The MajorBBS & Worldgroup Modules
https://www.mbbsemu.com
MIT License
134 stars 13 forks source link

[ELWBAK] Pro Backgammon - Crashes when entering module #112

Closed tuday2 closed 4 years ago

tuday2 commented 4 years ago

Module Information

Describe the bug Crashes when entering module

To Reproduce Steps to reproduce the behavior:

  1. Load module
  2. Enter module from MBBSEmu menu

Expected behavior Play Backgammon

Screenshots

Unhandled exception. System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter 'Unknown Exported Function Ordinal in MAJORBBS: 960')
   at MBBSEmu.HostProcess.ExportedModules.Majorbbs.Invoke(UInt16 ordinal, Boolean offsetsOnly)
   at MBBSEmu.HostProcess.ExecutionUnits.ExecutionUnit.ExternalFunctionDelegate(UInt16 ordinal, UInt16 functionOrdinal)
   at MBBSEmu.CPU.CpuCore.Tick()
   at MBBSEmu.HostProcess.ExecutionUnits.ExecutionUnit.Execute(IntPtr16 entryPoint, UInt16 channelNumber, Boolean simulateCallFar, Boolean bypassState, Queue`1 initialStackValues, UInt16 initialStackPointer)
   at MBBSEmu.Module.MbbsModule.Execute(IntPtr16 entryPoint, UInt16 channelNumber, Boolean simulateCallFar, Boolean bypassSetState, Queue`1 initialStackValues, UInt16 initialStackPointer)
   at MBBSEmu.HostProcess.MbbsHost.WorkerThread()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

Software Information:

enusbaum commented 4 years ago

MAJORBBS.960 is STP4CS which strips the buffer for C/S output. Because MBBSEmu doesn't support C/S mode, we can probably just return the same buffer.

This one will need to be investigated a little bit as I'm concerned the emulator is being sent down a logic path where the module THINKS the user is using the Client-Server component when it is in fact not. I suspect there might be a key/flag we're not setting properly to tell the module it's not in Worldgroup Client-Server mode.

enusbaum commented 4 years ago

It looks like STP4CS strips specific characters from a given string. I haven't been able to determine which characters get stripped yet, but this might be more benign than I previously thought.

enusbaum commented 4 years ago

Wrote a quick test module that looked at stp4cs and it appears to strip any ASCII character <= 32 and >= 127 (so only printable characters).

void EXPORT stp4cs_test()
{
    char buf[2];
    int i;
    for (i = 1; i < 128; i++)
    {
        buf[0] = (char)i;
        buf[1] = 0;
        if(strlen(stp4cs(buf)) == 0)
        {
            shocst("Stripped", "Stripped: %d", i);
        }
    }

}

I'll get this ordinal implemented and pushed.