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
128 stars 14 forks source link

[RCIROSE] The Rose Council of Guardians - Module loads successfully, MBBSEmu crashes on Ordinal #410

Closed tuday2 closed 3 years ago

tuday2 commented 3 years ago

Module Information

Describe the bug Module loads successfully, MBBSEmu crashes on first rtick

To Reproduce Steps to reproduce the behavior:

  1. Add Module to modulesConfig.json
  2. Start MBBSEmu
  3. On first rtick, RCIROSE tries to write its log file
  4. See error

Expected behavior Game/MBBSEmu stay loaded and able to login

Screenshots

2021-02-21 15:54:34.4747 Warn MBBSEmu.HostProcess.ExportedModules.Doscalls.DosGetModHandle (RCIROSE) Getting External Modules is currently not supported
2021-02-21 15:54:34.4888 Warn MBBSEmu.HostProcess.ExportedModules.Doscalls.DosGetProcAddr (RCIROSE) Getting External Procedures is currently not supported
2021-02-21 15:54:38.9275 Info MBBSEmu.HostProcess.ExportedModules.Majorbbs.f_open (RCIROSE) Creating new file RCIROSE.LOG
2021-02-21 15:54:39.3014 Error MBBSEmu.HostProcess.ExportedModules.Majorbbs.Invoke Unknown Exported Function Ordinal in MAJORBBS: 1012:SETMODE
Unhandled exception. System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter 'Unknown Exported Function Ordinal in MAJORBBS: 1012:SETMODE')
   at MBBSEmu.HostProcess.ExportedModules.Majorbbs.Invoke(UInt16 ordinal, Boolean offsetsOnly)
   at MBBSEmu.HostProcess.ExecutionUnits.ExecutionUnit.ExternalFunctionDelegate(UInt16 ordinal, UInt16 functionOrdinal)
   at MBBSEmu.CPU.CpuCore.Op_Call()
   at MBBSEmu.CPU.CpuCore.Tick()
   at MBBSEmu.HostProcess.ExecutionUnits.ExecutionUnit.Execute(FarPtr entryPoint, UInt16 channelNumber, Boolean simulateCallFar, Boolean bypassState, Queue`1 initialStackValues, UInt16 initialStackPointer)
   at MBBSEmu.Module.MbbsModule.Execute(FarPtr 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 ---
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

Software Information:

tuday2 commented 3 years ago

SETMODE Ordinal: 1012 Signature: int setmode(int handle, int mode); Description: setmode - sets mode of open file

enusbaum commented 3 years ago

image

Based on this documentation, we might just need to change the value on the FileStruct.flags value. Where we'd set/unset EnumFileFlags.Binary based on the specified mode.

tuday2 commented 3 years ago

https://www.rpi.edu/dept/cis/software/g77-mingw32/include/fcntl.h

/* Specifiy one of these flags to define the access mode. */
#define _O_RDONLY   0
#define _O_WRONLY   1
#define _O_RDWR     2

/* Mask for access mode bits in the _open flags. */
#define _O_ACCMODE  (_O_RDONLY|_O_WRONLY|_O_RDWR)

#define _O_APPEND   0x0008  /* Writes will add to the end of the file. */

#define _O_RANDOM   0x0010
#define _O_SEQUENTIAL   0x0020
#define _O_TEMPORARY    0x0040  /* Make the file dissappear after closing.
                 * WARNING: Even if not created by _open! */
#define _O_NOINHERIT    0x0080

#define _O_CREAT    0x0100  /* Create the file if it does not exist. */
#define _O_TRUNC    0x0200  /* Truncate the file if it does exist. */
#define _O_EXCL     0x0400  /* Open only if the file does not exist. */

/* NOTE: Text is the default even if the given _O_TEXT bit is not on. */
#define _O_TEXT     0x4000  /* CR-LF in file becomes LF in memory. */
#define _O_BINARY   0x8000  /* Input and output is not translated. */
#define _O_RAW      _O_BINARY