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

[MBMGEMP] Galactic Empire - Crashes on startup #58

Closed tuday2 closed 3 years ago

tuday2 commented 3 years ago

Module Information

Describe the bug Game crashes on startup of MBBSemu

To Reproduce Steps to reproduce the behavior:

  1. Attempt to load game

Expected behavior Game loads

Screenshots

2020-08-24 04:52:40.1280 Warn MBBSEmu.Module.MbbsModule.Execute MBMGEMP exhausted execution Units, creating additional
Critical Exception has occured:
System.FormatException: Input string was not in a correct format.
   at System.Number.ThrowOverflowOrFormatException(ParsingStatus status, TypeCode type)
   at System.Int16.Parse(ReadOnlySpan`1 s, NumberStyles style, IFormatProvider provider)
   at MBBSEmu.Module.McvFile.GetNumeric(Int32 ordinal)
   at MBBSEmu.HostProcess.ExportedModules.Majorbbs.numopt()
   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.AddModule(MbbsModule module)
   at MBBSEmu.Program.Run(String[] args)

Software Information:

tuday2 commented 3 years ago

{"UniqueIdentifier":"MBMGEMP","File":"MBMGEMP.DLL","Imports":{"DOSCALLS":[89],"PHAPI":[32,49,16],"MAJORBBS":[11,737,226,43,441,650,659,389,566,94,520,456,492,589,331,559,437,654,658,133,455,544,65,604,107,543,469,602,522,313,53,485,534,463,628,476,624,335,434,417,516,484,162,134,601,560,409,574,429,430,435,582,621,656,113,629,474,117,119,565,444,170,577,77,225,205,210,625,350,401,550,403,511,603,167,462,267,266,578,349,460,352,593,510,505,475,712,428,581,459,468,665,657,661,348,449,377,399,486,55,351,400,366,411,230],"GALMSG":[30],"GALGSBL":[40,21,36,72]}}

enusbaum commented 3 years ago

This might have been fixed by #89 which better handles numeric values in MCV files that are preceded by ASCII characters, which this error appears to be. Please re-test and report back! 👍

tuday2 commented 3 years ago

BUILD: 090320-8

Different Error:


Critical Exception has occurred:
System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter 'Unsupported OpCode: In')
   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.AddModule(MbbsModule module)
   at MBBSEmu.Program.Run(String[] args)```
enusbaum commented 3 years ago

Looks like Galactic Empire has some pretty sophisticated methods for protected the key + keygen portions of the code, including inline Assembly to prevent debuggers from intercepting.

https://github.com/bsimser/ge/blob/9bf8e3a2125b0a0b33cf3910c629da92214e091f/mbmgemp/SECURE.C#L431

The PHAPI Ordinals are also going to need implementing for memory reservations as well.

enusbaum commented 3 years ago

Ok! I was able to work through the PHAPI swamp and get Galactic Empire actually initializing in MBBSEmu.

image

image

I'm cleaning up the code right now but should have PR by tonight that'll close this issue 👍

tuday2 commented 3 years ago

Same error as ELWGOLF @enusbaum @paladine

2020-09-14 20:03:08.6741 Warn MBBSEmu.Module.MbbsModule.Execute MBMGEMP exhausted execution Units, creating additional
Critical Exception has occurred:
System.Exception: Type Requested not UInt16
   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.AddModule(MbbsModule module)
   at MBBSEmu.Program.Run(String[] args)
tuday2 commented 3 years ago

Not working in latest build

2020-10-31 07:32:46.2120 Info MBBSEmu.Btrieve.BtrieveFileProcessor.LoadSqlite Opening sqlite DB D:\MbbsX64\modules\GEMPIRE\MBMGEPLT.DB
2020-10-31 07:32:46.2120 Info MBBSEmu.HostProcess.ExportedModules.Phapi.DosAllocRealSeg Allocating 64 in Real-Mode memory at 2007:0000
2020-10-31 07:32:46.2120 Info MBBSEmu.HostProcess.ExportedModules.Phapi.DosAllocRealSeg Allocating 665 in Real-Mode memory at 2008:0000
2020-10-31 07:32:46.2290 Info MBBSEmu.HostProcess.ExportedModules.Phapi.DosAllocRealSeg Allocating 31 in Real-Mode memory at 2009:0000
Critical Exception has occurred:
System.ArgumentException: Bad unsigned integer key length 6
   at MBBSEmu.Btrieve.BtrieveKey.KeyDataToSqliteObject(ReadOnlySpan`1 keyData)
   at MBBSEmu.Btrieve.BtrieveFileProcessor.Insert(Byte[] record)
   at MBBSEmu.HostProcess.ExportedModules.Majorbbs.dinsbtv()
   at MBBSEmu.HostProcess.ExportedModules.Majorbbs.insbtv()
   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(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.AddModule(MbbsModule module)
   at MBBSEmu.HostProcess.MbbsHost.Start(List`1 moduleConfigurations)
   at MBBSEmu.Program.Run(String[] args)