Esempio n. 1
0
        public Galgsbl(MbbsModule module, PointerDictionary <SessionBase> channelDictionary) : base(module, channelDictionary)
        {
            _startDate = DateTime.Now;
            Module.Memory.AllocateVariable("BTURNO", 9);

            //Check for Module Specific Activation #
            var bturno = _configuration["GSBL.Activation"];

            if (!string.IsNullOrEmpty(_configuration[$"GSBL.Activation.{Module.ModuleIdentifier}"]))
            {
                bturno = _configuration[$"GSBL.Activation.{Module.ModuleIdentifier}"];
                _logger.Info($"Found Module Specific Activation # for {Module.ModuleIdentifier}. Setting BTURNO to: {bturno}");
            }

            //Sanity Check
            if (bturno.Length > 8)
            {
                bturno = bturno.Substring(0, 8);
            }

            Module.Memory.SetArray("BTURNO", Encoding.ASCII.GetBytes($"{bturno}\0"));
            Module.Memory.AllocateVariable("TICKER", 0x02); //ushort increments once per second

            MonitoredChannel2 = 0xFFFF;
            MonitoredChannel  = 0xFFFF;

            new Thread(Timer1Hz).Start();
        }
Esempio n. 2
0
        internal Galme(MbbsModule module, PointerDictionary <SessionBase> channelDictionary) : base(module,
                                                                                                    channelDictionary)
        {
            var txtlenPointer = Module.Memory.AllocateVariable("TXTLEN", 0x2);

            Module.Memory.SetWord(txtlenPointer, 0x400);
        }
Esempio n. 3
0
        protected override void OnPointerMoved(PointerRoutedEventArgs e)
        {
            base.OnPointerMoved(e);
            PointerPoint point = e.GetCurrentPoint(this);
            Crossline    line  = points.Find(s => s.Tag == point.PointerId);

            if (line == null)
            {
                return;
            }
            line.Point = point;
            if (PointerDictionary.ContainsKey(point.PointerId))
            {
                //PointerDictionary[point.PointerId].Points.Add(new Point(point.Position.X,point.Position.Y-Config.TOUCH_Y_OFFSET));
                PointerDictionary[point.PointerId].Points.Add(new Point(point.Position.X, point.Position.Y));
            }
            if (Config.isShowCoord.Value)
            {
                TextBlock textBlock = textBlocks.Find(s => Convert.ToUInt16(s.Tag) == point.PointerId);
                if (textBlock != null)
                {
                    textBlock.Text = string.Format("Point{0}:  x:{1:N0} y:{2:N0}", textBlocks.IndexOf(textBlock) + 1, point.Position.X * Config.scaleFactor,
                                                   point.Position.Y * Config.scaleFactor);
                }
            }
        }
        protected virtual void Reset()
        {
            mbbsEmuCpuRegisters.Zero();
            mbbsEmuCpuCore.Reset();
            mbbsEmuMemoryCore.Clear();
            mbbsEmuCpuRegisters.CS = CODE_SEGMENT;
            mbbsEmuCpuRegisters.IP = 0;

            testSessions = new PointerDictionary <SessionBase>();
            testSessions.Allocate(new TestSession(null));
            testSessions.Allocate(new TestSession(null));

            //Redeclare to re-allocate memory values that have been cleared
            majorbbs = new HostProcess.ExportedModules.Majorbbs(
                _serviceResolver.GetService <ILogger>(),
                _serviceResolver.GetService <AppSettings>(),
                _serviceResolver.GetService <IFileUtility>(),
                _serviceResolver.GetService <IGlobalCache>(),
                mbbsModule,
                testSessions,
                _serviceResolver.GetService <IAccountKeyRepository>(),
                _serviceResolver.GetService <IAccountRepository>());

            galgsbl = new HostProcess.ExportedModules.Galgsbl(
                _serviceResolver.GetService <ILogger>(),
                _serviceResolver.GetService <AppSettings>(),
                _serviceResolver.GetService <IFileUtility>(),
                _serviceResolver.GetService <IGlobalCache>(),
                mbbsModule,
                testSessions);
        }
        protected ExportedModuleTestBase(string modulePath)
        {
            mbbsEmuMemoryCore   = new MemoryCore();
            mbbsEmuCpuRegisters = new CpuRegisters();
            mbbsEmuCpuCore      = new CpuCore();
            mbbsModule          = new MbbsModule(FileUtility.CreateForTest(), _serviceResolver.GetService <ILogger>(), null, modulePath, mbbsEmuMemoryCore);

            testSessions = new PointerDictionary <SessionBase>();
            testSessions.Allocate(new TestSession(null));
            testSessions.Allocate(new TestSession(null));

            majorbbs = new HostProcess.ExportedModules.Majorbbs(
                _serviceResolver.GetService <ILogger>(),
                _serviceResolver.GetService <AppSettings>(),
                _serviceResolver.GetService <IFileUtility>(),
                _serviceResolver.GetService <IGlobalCache>(),
                mbbsModule,
                testSessions,
                _serviceResolver.GetService <IAccountKeyRepository>(),
                _serviceResolver.GetService <IAccountRepository>());

            galgsbl = new HostProcess.ExportedModules.Galgsbl(
                _serviceResolver.GetService <ILogger>(),
                _serviceResolver.GetService <AppSettings>(),
                _serviceResolver.GetService <IFileUtility>(),
                _serviceResolver.GetService <IGlobalCache>(),
                mbbsModule,
                testSessions);

            mbbsEmuCpuCore.Reset(mbbsEmuMemoryCore, mbbsEmuCpuRegisters, ExportedFunctionDelegate);
        }
Esempio n. 6
0
 public SocketServer(ILogger logger, IMbbsHost host, AppSettings configuration, PointerDictionary <SessionBase> channelDictionary)
 {
     _logger            = logger;
     _host              = host;
     _configuration     = configuration;
     _channelDictionary = channelDictionary;
 }
Esempio n. 7
0
 public RloginSession(IMbbsHost host, ILogger logger, Socket rloginConnection, PointerDictionary <SessionBase> channelDictionary, AppSettings configuration, ITextVariableService textVariableService, string moduleIdentifier = null) : base(host, logger, rloginConnection, textVariableService)
 {
     ModuleIdentifier   = moduleIdentifier;
     _channelDictionary = channelDictionary;
     _configuration     = configuration;
     SessionType        = EnumSessionType.Rlogin;
     SessionState       = EnumSessionState.Negotiating;
 }
Esempio n. 8
0
 public MenuRoutines(IResourceManager resourceManager, IAccountRepository accountRepository, AppSettings configuration, IGlobalCache globalCache, IAccountKeyRepository accountKeyRepository, PointerDictionary <SessionBase> channelDictionary)
 {
     _resourceManager      = resourceManager;
     _accountRepository    = accountRepository;
     _accountKeyRepository = accountKeyRepository;
     _configuration        = configuration;
     _globalCache          = globalCache;
     _channelDictionary    = channelDictionary;
 }
Esempio n. 9
0
        private void appbar_backClick(object sender, RoutedEventArgs e)
        {
            List <uint> keys     = PointerDictionary.Keys.ToList();
            uint        key      = keys.Max();
            Polyline    polyline = PointerDictionary[key];

            CanvasLine.Children.Remove(polyline);
            TempPointerDictionary.AddValue(key, polyline);
            PointerDictionary.RemoveValue(key);
        }
Esempio n. 10
0
 //这些判断非常不理想,应该用Bind比较合适
 private void appbar_deleteClick(object sender, RoutedEventArgs e)
 {
     this.CanvasLine.Children.Clear();
     PointerDictionary.ClearValue();
     TempPointerDictionary.ClearValue();
     points.Clear();
     if (StackPanelCoords.Children.Count > 0)
     {
         textBlocks.Clear();
         StackPanelCoords.Children.Clear();
     }
 }
Esempio n. 11
0
        private protected ExportedModuleBase(ILogger logger, AppSettings configuration, IFileUtility fileUtility, IGlobalCache globalCache, MbbsModule module, PointerDictionary <SessionBase> channelDictionary)
        {
            _logger        = logger;
            _configuration = configuration;
            _fileFinder    = fileUtility;
            _globalCache   = globalCache;

            Module            = module;
            ChannelDictionary = channelDictionary;

            FilePointerDictionary = new PointerDictionary <FileStream>(1, int.MaxValue);
            McvPointerDictionary  = new PointerDictionary <McvFile>();
        }
Esempio n. 12
0
        private protected static readonly byte[] NEW_LINE          = { (byte)'\r', (byte)'\n' }; //Just easier to read

        private protected ExportedModuleBase(MbbsModule module, PointerDictionary <SessionBase> channelDictionary)
        {
            _logger        = ServiceResolver.GetService <ILogger>();
            _configuration = ServiceResolver.GetService <IConfiguration>();
            _fileFinder    = ServiceResolver.GetService <IFileUtility>();
            _globalCache   = ServiceResolver.GetService <IGlobalCache>();

            Module            = module;
            ChannelDictionary = channelDictionary;

            FilePointerDictionary       = new PointerDictionary <FileStream>(1, int.MaxValue);
            McvPointerDictionary        = new PointerDictionary <McvFile>();
            BtrievePointerDictionaryNew = new Dictionary <IntPtr16, BtrieveFileProcessor>();
        }
Esempio n. 13
0
        private void appbar_nextClick(object sender, RoutedEventArgs e)
        {
            if (TempPointerDictionary.Count == 0)
            {
                return;
            }
            List <uint> keys     = TempPointerDictionary.Keys.ToList();
            uint        key      = keys.Min();
            Polyline    polyline = TempPointerDictionary[key];

            CanvasLine.Children.Add(polyline);
            PointerDictionary.AddValue(key, polyline);
            TempPointerDictionary.RemoveValue(key);
        }
Esempio n. 14
0
        public MbbsHost(ILogger logger, IEnumerable <IHostRoutines> mbbsRoutines, IConfiguration configuration)
        {
            _logger        = logger;
            _mbbsRoutines  = mbbsRoutines;
            _configuration = configuration;

            _logger.Info("Constructing MBBSEmu Host...");

            _channelDictionary = new PointerDictionary <SessionBase>();
            _modules           = new Dictionary <string, MbbsModule>();
            _exportedFunctions = new Dictionary <string, IExportedModule>();
            _realTimeStopwatch = Stopwatch.StartNew();
            _incomingSessions  = new Queue <SessionBase>();

            _logger.Info("Constructed MBBSEmu Host!");
        }
Esempio n. 15
0
        protected ExportedModuleTestBase(string modulePath)
        {
            _serviceResolver = new ServiceResolver(fakeClock, SessionBuilder.ForTest($"MBBSDb_{RANDOM.Next()}"));
            var textVariableService = _serviceResolver.GetService <ITextVariableService>();

            mbbsEmuMemoryCore   = mbbsEmuProtectedModeMemoryCore = new ProtectedModeMemoryCore(_serviceResolver.GetService <ILogger>());
            mbbsEmuCpuCore      = new CpuCore(_serviceResolver.GetService <ILogger>());
            mbbsEmuCpuRegisters = mbbsEmuCpuCore;

            var testModuleConfig = new ModuleConfiguration {
                ModulePath = modulePath, ModuleEnabled = true
            };

            mbbsModule = new MbbsModule(FileUtility.CreateForTest(), fakeClock, _serviceResolver.GetService <ILogger>(), testModuleConfig, mbbsEmuProtectedModeMemoryCore);

            testSessions = new PointerDictionary <SessionBase>();
            testSessions.Allocate(new TestSession(null, textVariableService));
            testSessions.Allocate(new TestSession(null, textVariableService));

            majorbbs = new HostProcess.ExportedModules.Majorbbs(
                _serviceResolver.GetService <IClock>(),
                _serviceResolver.GetService <ILogger>(),
                _serviceResolver.GetService <AppSettings>(),
                _serviceResolver.GetService <IFileUtility>(),
                _serviceResolver.GetService <IGlobalCache>(),
                mbbsModule,
                testSessions,
                _serviceResolver.GetService <IAccountKeyRepository>(),
                _serviceResolver.GetService <IAccountRepository>(),
                textVariableService);

            galgsbl = new HostProcess.ExportedModules.Galgsbl(
                _serviceResolver.GetService <IClock>(),
                _serviceResolver.GetService <ILogger>(),
                _serviceResolver.GetService <AppSettings>(),
                _serviceResolver.GetService <IFileUtility>(),
                _serviceResolver.GetService <IGlobalCache>(),
                mbbsModule,
                testSessions,
                textVariableService);

            mbbsEmuCpuCore.Reset(
                mbbsEmuMemoryCore,
                (ordinal, functionOrdinal) => ExportedFunctionDelegate(ordinal, functionOrdinal, offsetsOnly: false),
                null,
                null);
        }
Esempio n. 16
0
        protected override void OnPointerPressed(PointerRoutedEventArgs e)
        {
            base.OnPointerPressed(e);
            if (this.cVsCover.Visibility == Visibility.Visible)
            {
                this.cVsCover.Visibility = Visibility.Collapsed;
            }
            PointerPoint point = e.GetCurrentPoint(this);
            var          line  = new Crossline(Colors.White, point);

            line.Tag = point.PointerId;
            Color color = colors[random.Next(0, colors.Count - 1)];

            line.LineColor = color;
            CanvasLine.Children.Add(line.HorizontalPath);
            CanvasLine.Children.Add(line.VerticalPath);
            points.Add(line);
            if (points.Count > Config.supportMaxTouchs.Value)
            {
                Config.supportMaxTouchs.Value = points.Count;
            }
            if (Config.isNeedShowTrace.Value)
            {
                //var pointForTrace = new Point(point.Position.X, point.Position.Y - Config.TOUCH_Y_OFFSET);
                var pointForTrace = new Point(point.Position.X, point.Position.Y);
                var polyline      = new Polyline();
                polyline.Stroke          = new SolidColorBrush(color);
                polyline.StrokeThickness = Config.TraceThickness.Value;
                CanvasLine.Children.Add(polyline);
                PointerDictionary.AddValue(point.PointerId, polyline);
            }
            if (Config.isShowCoord.Value)
            {
                TextBlock textBlock = new TextBlock();
                textBlock.TextWrapping = TextWrapping.Wrap;
                textBlock.Width        = StackPanelCoords.Width;
                textBlock.Height       = 40;
                textBlock.Tag          = point.PointerId;
                textBlock.Foreground   = new SolidColorBrush(color);
                textBlocks.Add(textBlock);
                textBlock.Text = string.Format("Point{0}:  x:{1:N0} y:{2:N0}", textBlocks.IndexOf(textBlock) + 1, point.Position.X * Config.scaleFactor,
                                               point.Position.Y * Config.scaleFactor);
                StackPanelCoords.Children.Add(textBlock);
            }
        }
Esempio n. 17
0
        public MbbsHost(ILogger logger, IEnumerable <IHostRoutine> mbbsRoutines, IConfiguration configuration, IEnumerable <IGlobalRoutine> globalRoutines)
        {
            _logger         = logger;
            _mbbsRoutines   = mbbsRoutines;
            _configuration  = configuration;
            _globalRoutines = globalRoutines;

            _logger.Info("Constructing MBBSEmu Host...");

            _channelDictionary = new PointerDictionary <SessionBase>();
            _modules           = new Dictionary <string, MbbsModule>();
            _exportedFunctions = new Dictionary <string, IExportedModule>();
            _realTimeStopwatch = Stopwatch.StartNew();
            _incomingSessions  = new Queue <SessionBase>();
            _cleanupTime       = ParseCleanupTime();
            _timer             = new Timer(unused => _performCleanup = true, this, NowUntil(_cleanupTime), TimeSpan.FromDays(1));

            _logger.Info("Constructed MBBSEmu Host!");
        }
Esempio n. 18
0
        protected override void OnPointerReleased(PointerRoutedEventArgs e)
        {
            base.OnPointerReleased(e);
            PointerPoint point = e.GetCurrentPoint(this);
            Crossline    line  = points.Find(s => s.Tag == point.PointerId);

            if (line == null)
            {
                return;
            }
            this.CanvasLine.Children.Remove(line.HorizontalPath);
            this.CanvasLine.Children.Remove(line.VerticalPath);
            points.Remove(line);
            if (!Config.isReserveTrace.Value)
            {
                if (PointerDictionary.ContainsKey(point.PointerId))
                {
                    CanvasLine.Children.Remove(PointerDictionary[point.PointerId]);
                    PointerDictionary.RemoveValue(point.PointerId);
                }
            }
            if (Config.isReserveTrace.Value)
            {
                this.AppBarButtonClear.Visibility = Visibility.Visible;
                if (PointerDictionary.Count > 0)
                {
                    BarButtonBack.Visibility = Visibility.Visible;
                }
            }
            if (Config.isShowCoord.Value)
            {
                TextBlock textBlock = textBlocks.Find(s => Convert.ToUInt16(s.Tag) == point.PointerId);
                if (textBlock != null)
                {
                    StackPanelCoords.Children.Remove(textBlock);
                    textBlocks.Remove(textBlock);
                }
            }
        }
Esempio n. 19
0
        public MbbsHost(ILogger logger, IGlobalCache globalCache, IFileUtility fileUtility, IEnumerable <IHostRoutine> mbbsRoutines, AppSettings configuration, IEnumerable <IGlobalRoutine> globalRoutines, IAccountKeyRepository accountKeyRepository, IAccountRepository accountRepository, PointerDictionary <SessionBase> channelDictionary)
        {
            Logger                = logger;
            _globalCache          = globalCache;
            _fileUtility          = fileUtility;
            _mbbsRoutines         = mbbsRoutines;
            _configuration        = configuration;
            _globalRoutines       = globalRoutines;
            _channelDictionary    = channelDictionary;
            _accountKeyRepository = accountKeyRepository;
            _accountRepository    = accountRepository;

            Logger.Info("Constructing MBBSEmu Host...");

            _modules           = new Dictionary <string, MbbsModule>();
            _exportedFunctions = new Dictionary <string, IExportedModule>();
            _realTimeStopwatch = Stopwatch.StartNew();
            _incomingSessions  = new Queue <SessionBase>();
            _cleanupTime       = _configuration.CleanupTime;
            _timer             = new Timer(unused => _performCleanup = true, this, NowUntil(_cleanupTime), TimeSpan.FromDays(1));
            Logger.Info("Constructed MBBSEmu Host!");
        }
Esempio n. 20
0
        protected ExportedModuleTestBase(string modulePath)
        {
            _serviceResolver = new ServiceResolver(fakeClock, SessionBuilder.ForTest($"MBBSDb_{RANDOM.Next()}"));
            var textVariableService = _serviceResolver.GetService <ITextVariableService>();

            mbbsEmuMemoryCore   = new MemoryCore();
            mbbsEmuCpuRegisters = new CpuRegisters();
            mbbsEmuCpuCore      = new CpuCore();
            mbbsModule          = new MbbsModule(FileUtility.CreateForTest(), fakeClock, _serviceResolver.GetService <ILogger>(), null, modulePath, mbbsEmuMemoryCore);

            testSessions = new PointerDictionary <SessionBase>();
            testSessions.Allocate(new TestSession(null, textVariableService));
            testSessions.Allocate(new TestSession(null, textVariableService));

            majorbbs = new HostProcess.ExportedModules.Majorbbs(
                _serviceResolver.GetService <IClock>(),
                _serviceResolver.GetService <ILogger>(),
                _serviceResolver.GetService <AppSettings>(),
                _serviceResolver.GetService <IFileUtility>(),
                _serviceResolver.GetService <IGlobalCache>(),
                mbbsModule,
                testSessions,
                _serviceResolver.GetService <IAccountKeyRepository>(),
                _serviceResolver.GetService <IAccountRepository>());

            galgsbl = new HostProcess.ExportedModules.Galgsbl(
                _serviceResolver.GetService <IClock>(),
                _serviceResolver.GetService <ILogger>(),
                _serviceResolver.GetService <AppSettings>(),
                _serviceResolver.GetService <IFileUtility>(),
                _serviceResolver.GetService <IGlobalCache>(),
                mbbsModule,
                testSessions);

            mbbsEmuCpuCore.Reset(mbbsEmuMemoryCore, mbbsEmuCpuRegisters, ExportedFunctionDelegate, null);
        }
Esempio n. 21
0
        public Galgsbl(IClock clock, ILogger logger, AppSettings configuration, IFileUtility fileUtility, IGlobalCache globalCache, MbbsModule module, PointerDictionary <SessionBase> channelDictionary) : base(
                clock, logger, configuration, fileUtility, globalCache, module, channelDictionary)
        {
            _startDate = clock.Now;
            Module.Memory.AllocateVariable("BTURNO", 9);

            //Check for Module Specific BTURNO #
            var bturno = configuration.GSBLBTURNO;

            if (!string.IsNullOrEmpty(_configuration.GetBTURNO(Module.ModuleIdentifier)))
            {
                bturno = _configuration.GetBTURNO(Module.ModuleIdentifier);
                _logger.Info($"{Module.ModuleIdentifier} Found Module Specific BTURNO # -- Setting BTURNO to: {bturno}");
            }

            //Sanity Check
            if (bturno.Length > 8)
            {
                bturno = bturno.Substring(0, 8);
            }

            Module.Memory.SetArray("BTURNO", Encoding.ASCII.GetBytes($"{bturno}\0"));
            Module.Memory.AllocateVariable("TICKER", 0x02); //ushort increments once per second

            MonitoredChannel2 = 0xFFFF;
            MonitoredChannel  = 0xFFFF;

            TimeSpan timeSpan = TimeSpan.FromSeconds(1);

            _timer = new Timer(OnTimerCallback, this, timeSpan, timeSpan);
        }
Esempio n. 22
0
 internal Doscalls(MbbsModule module, PointerDictionary <SessionBase> channelDictionary) : base(module,
                                                                                                channelDictionary)
 {
 }
Esempio n. 23
0
        public bool ProcessCommand(ReadOnlySpan <byte> command, ushort channelNumber, PointerDictionary <SessionBase> sessions, Dictionary <string, MbbsModule> modules)
        {
            var commandString = Encoding.ASCII.GetString(command).TrimEnd('\0');

            if (commandString == "/#")
            {
                sessions[channelNumber].SendToClient("|RESET|\r\n|B||GREEN|LINE  USER-ID                    ....... OPTION SELECTED|RESET|\r\n".EncodeToANSIArray());
                foreach (var s in sessions.Values)
                {
                    var sessionInfo = s.SessionState.GetSessionState();

                    var userOptionSelected = sessionInfo.UserOptionSelected;
                    var userName           = sessionInfo.userName;

                    if (sessionInfo.userSession)
                    {
                        userName = s.Username;
                    }

                    if (sessionInfo.moduleSession)
                    {
                        userOptionSelected = s.CurrentModule.ModuleDescription;
                    }

                    sessions[channelNumber].SendToClient($"|YELLOW||B| {s.Channel:D2}   {userName,-31}... {userOptionSelected}|RESET|\r\n".EncodeToANSIArray());
                }

                return(true);
            }

            return(false);
        }
Esempio n. 24
0
 internal Phapi(IClock clock, ILogger logger, AppSettings configuration, IFileUtility fileUtility, IGlobalCache globalCache, MbbsModule module, PointerDictionary <SessionBase> channelDictionary) : base(
         clock, logger, configuration, fileUtility, globalCache, module, channelDictionary)
 {
 }
Esempio n. 25
0
 internal Phapi(MbbsModule module, PointerDictionary <SessionBase> channelDictionary) : base(module, channelDictionary)
 {
 }
Esempio n. 26
0
        public bool ProcessCommand(ReadOnlySpan <byte> command, ushort channelNumber, PointerDictionary <SessionBase> sessions, Dictionary <string, MbbsModule> modules)
        {
            //Fast Return
            if (command.Length < 6)
            {
                return(false);
            }

            //Verify it's a /SYSOP command
            if (!Encoding.ASCII.GetString(command).ToUpper().StartsWith("/SYSOP"))
            {
                return(false);
            }

            //Verify the user has SYSOP key
            if (_accountKeyRepository.GetAccountKeysByUsername(sessions[channelNumber].Username)
                .Count(x => x.accountKey == "SYSOP") == 0)
            {
                return(false);
            }

            //Set Class Variables
            _sessions      = sessions;
            _channelNumber = channelNumber;

            //Verify the command has at least one action
            if (command.IndexOf((byte)' ') == -1)
            {
                Help();
                return(true);
            }

            var commandSequence = Encoding.ASCII.GetString(command).TrimEnd('\0').Split(' ');

            switch (commandSequence[1].ToUpper())
            {
            case "LISTACCOUNTS":
            {
                ListAccounts();
                break;
            }

            case "REMOVEACCOUNT":
            {
                RemoveAccount(commandSequence);
                break;
            }

            case "RESETPASSWORD":
            {
                ResetPassword(commandSequence);
                break;
            }

            case "ADDKEY":
            {
                AddKey(commandSequence);
                break;
            }

            case "REMOVEKEY":
            {
                RemoveKey(commandSequence);
                break;
            }

            case "LISTKEYS":
            {
                ListKeys(commandSequence);
                break;
            }

            case "CLEANUP":
            {
                _globalCache.Set("SYSOPGLOBAL-CLEANUP", true);
                break;
            }

            case "BROADCAST":
            {
                Broadcast(commandSequence);
                break;
            }

            case "KICK":
            {
                Kick(commandSequence);
                break;
            }

            case "HELP":
            {
                Help();
                break;
            }

            default:
                return(false);
            }

            return(true);
        }
Esempio n. 27
0
        internal Galme(IClock clock, ILogger logger, AppSettings configuration, IFileUtility fileUtility, IGlobalCache globalCache, MbbsModule module, PointerDictionary <SessionBase> channelDictionary, ITextVariableService textVariableService) : base(
                clock, logger, configuration, fileUtility, globalCache, module, channelDictionary, textVariableService)
        {
            var txtlenPointer = Module.Memory.AllocateVariable("TXTLEN", 0x2);

            Module.Memory.SetWord(txtlenPointer, 0x400);
        }
Esempio n. 28
0
 internal Doscalls(ILogger logger, AppSettings configuration, IFileUtility fileUtility, IGlobalCache globalCache, MbbsModule module, PointerDictionary <SessionBase> channelDictionary) : base(
         logger, configuration, fileUtility, globalCache, module, channelDictionary)
 {
 }
Esempio n. 29
0
        /// <summary>
        ///     Constructor for MbbsModule
        ///
        ///     Pass in an empty/blank moduleIdentifier for a Unit Test/Fake Module
        /// </summary>
        /// <param name="logger"></param>
        /// <param name="moduleIdentifier">Will be null in a test</param>
        /// <param name="path"></param>
        /// <param name="memoryCore"></param>
        /// <param name="fileUtility"></param>
        public MbbsModule(IFileUtility fileUtility, IClock clock, ILogger logger, string moduleIdentifier, string path = "", MemoryCore memoryCore = null)
        {
            _fileUtility = fileUtility;
            _logger      = logger;
            _clock       = clock;

            ModuleIdentifier = moduleIdentifier;
            ModuleDlls       = new List <MbbsDll>();


            //Sanitize and setup Path
            if (string.IsNullOrEmpty(path))
            {
                path = Directory.GetCurrentDirectory();
            }

            if (!Path.EndsInDirectorySeparator(path))
            {
                path += Path.DirectorySeparatorChar;
            }

            ModulePath = path;

            // will be null in tests
            if (string.IsNullOrEmpty(ModuleIdentifier))
            {
                Mdf = MdfFile.createForTest();
                ModuleDlls.Add(new MbbsDll(fileUtility, logger)
                {
                    File = NEFile.createForTest()
                });
            }
            else
            {
                //Verify MDF File Exists
                var mdfFile         = fileUtility.FindFile(ModulePath, $"{ModuleIdentifier}.MDF");
                var fullMdfFilePath = Path.Combine(ModulePath, mdfFile);
                if (!System.IO.File.Exists(fullMdfFilePath))
                {
                    throw new FileNotFoundException($"Unable to locate Module: {fullMdfFilePath}");
                }

                Mdf = new MdfFile(fullMdfFilePath);
                var moduleDll = new MbbsDll(fileUtility, logger);
                moduleDll.Load(Mdf.DLLFiles[0].Trim(), ModulePath);
                ModuleDlls.Add(moduleDll);


                if (Mdf.Requires.Count > 0)
                {
                    foreach (var r in Mdf.Requires)
                    {
                        var requiredDll = new MbbsDll(fileUtility, logger);
                        if (requiredDll.Load(r.Trim(), ModulePath))
                        {
                            requiredDll.SegmentOffset = (ushort)(ModuleDlls.Sum(x => x.File.SegmentTable.Count) + 1);
                            ModuleDlls.Add(requiredDll);
                        }
                    }
                }

                if (Mdf.MSGFiles.Count > 0)
                {
                    Msgs = new List <MsgFile>(Mdf.MSGFiles.Count);
                    foreach (var m in Mdf.MSGFiles)
                    {
                        Msgs.Add(new MsgFile(ModulePath, m));
                    }
                }
            }

            //Set Initial Values
            RtkickRoutines           = new PointerDictionary <RealTimeRoutine>();
            RtihdlrRoutines          = new PointerDictionary <RealTimeRoutine>();
            TaskRoutines             = new PointerDictionary <RealTimeRoutine>();
            TextVariables            = new Dictionary <string, FarPtr>();
            GlobalCommandHandlers    = new List <FarPtr>();
            ExportedModuleDictionary = new Dictionary <ushort, IExportedModule>(6);
            ExecutionUnits           = new Queue <ExecutionUnit>(2);

            Memory = memoryCore ?? new MemoryCore();

            //Declare PSP Segment
            var psp = new PSPStruct {
                NextSegOffset = 0x9FFF, EnvSeg = 0xFFFF
            };

            Memory.AddSegment(0x4000);
            Memory.SetArray(0x4000, 0, psp.Data);

            Memory.AllocateVariable("Int21h-PSP", sizeof(ushort));
            Memory.SetWord("Int21h-PSP", 0x4000);

            //Find _INIT_ values if any
            foreach (var dll in ModuleDlls)
            {
                //If it's a Test, setup a fake _INIT_
                if (string.IsNullOrEmpty(ModuleIdentifier))
                {
                    dll.EntryPoints["_INIT_"] = null;
                    return;
                }

                //Setup _INIT_ Entrypoint
                FarPtr initEntryPointPointer;
                var    initResidentName = dll.File.ResidentNameTable.FirstOrDefault(x => x.Name.StartsWith("_INIT__"));
                if (initResidentName == null)
                {
                    //This only happens with MajorMUD -- I have no idea why it's a special little snowflake ¯\_(ツ)_/¯
                    _logger.Warn($"({moduleIdentifier}) Unable to locate _INIT_ in Resident Name Table, checking Non-Resident Name Table...");

                    var initNonResidentName = dll.File.NonResidentNameTable.FirstOrDefault(x => x.Name.StartsWith("_INIT__"));

                    if (initNonResidentName == null)
                    {
                        throw new Exception("Unable to locate _INIT__ entry in Resident Name Table");
                    }

                    var initEntryPoint = dll.File.EntryTable.First(x => x.Ordinal == initNonResidentName.IndexIntoEntryTable);

                    initEntryPointPointer = new FarPtr((ushort)(initEntryPoint.SegmentNumber + dll.SegmentOffset), initEntryPoint.Offset);
                }
                else
                {
                    var initEntryPoint = dll.File.EntryTable.First(x => x.Ordinal == initResidentName.IndexIntoEntryTable);
                    initEntryPointPointer = new FarPtr((ushort)(initEntryPoint.SegmentNumber + dll.SegmentOffset), initEntryPoint.Offset);
                }


                _logger.Debug($"({ModuleIdentifier}) Located _INIT__: {initEntryPointPointer}");
                dll.EntryPoints["_INIT_"] = initEntryPointPointer;
            }
        }
Esempio n. 30
0
        /// <summary>
        ///     Constructor for MbbsModule
        ///
        ///     Pass in an empty/blank moduleIdentifier for a Unit Test/Fake Module
        /// </summary>
        /// <param name="moduleIdentifier"></param>
        /// <param name="path"></param>
        /// <param name="memoryCore"></param>
        public MbbsModule(string moduleIdentifier, string path = "", MemoryCore memoryCore = null)
        {
            ModuleIdentifier = moduleIdentifier;

            //Sanitize and setup Path
            if (string.IsNullOrEmpty(path))
            {
                path = Directory.GetCurrentDirectory();
            }

            if (!path.EndsWith(Path.DirectorySeparatorChar))
            {
                path += Path.DirectorySeparatorChar;
            }

            ModulePath = path;

            //Verify MDF File Exists
            if (!string.IsNullOrEmpty(ModuleIdentifier) && !System.IO.File.Exists($"{ModulePath}{ModuleIdentifier}.MDF"))
            {
                throw new FileNotFoundException($"Unable to locate Module: {ModulePath}{ModuleIdentifier}.MDF");
            }

            Mdf  = !string.IsNullOrEmpty(ModuleIdentifier) ? new MdfFile($"{ModulePath}{ModuleIdentifier}.MDF") : MdfFile.createForTest();
            File = !string.IsNullOrEmpty(ModuleIdentifier) ? new NEFile($"{ModulePath}{Mdf.DLLFiles[0].Trim()}.DLL") : NEFile.createForTest();

            if (Mdf.MSGFiles.Count > 0)
            {
                Msgs = new List <MsgFile>(Mdf.MSGFiles.Count);
                foreach (var m in Mdf.MSGFiles)
                {
                    Msgs.Add(new MsgFile(ModulePath, m));
                }
            }

            //Set Initial Values
            EntryPoints              = new Dictionary <string, IntPtr16>();
            RtkickRoutines           = new PointerDictionary <RealTimeRoutine>();
            RtihdlrRoutines          = new PointerDictionary <RealTimeRoutine>();
            TaskRoutines             = new PointerDictionary <RealTimeRoutine>();
            TextVariables            = new Dictionary <string, IntPtr16>();
            ExecutionUnits           = new Queue <ExecutionUnit>(2);
            ExportedModuleDictionary = new Dictionary <ushort, IExportedModule>(4);
            GlobalCommandHandlers    = new List <IntPtr16>();
            Memory = memoryCore ?? new MemoryCore();

            //If it's a Test, setup a fake _INIT_
            if (string.IsNullOrEmpty(ModuleIdentifier))
            {
                EntryPoints["_INIT_"] = null;
                return;
            }

            //Setup _INIT_ Entrypoint
            IntPtr16 initEntryPointPointer;
            var      initResidentName = File.ResidentNameTable.FirstOrDefault(x => x.Name.StartsWith("_INIT__"));

            if (initResidentName == null)
            {
                //This only happens with MajorMUD -- I have no idea why it's a special little snowflake ¯\_(ツ)_/¯
                _logger.Warn("Unable to locate _INIT_ in Resident Name Table, checking Non-Resident Name Table...");

                var initNonResidentName = File.NonResidentNameTable.FirstOrDefault(x => x.Name.StartsWith("_INIT__"));

                if (initNonResidentName == null)
                {
                    throw new Exception("Unable to locate _INIT__ entry in Resident Name Table");
                }

                var initEntryPoint = File.EntryTable.First(x => x.Ordinal == initNonResidentName.IndexIntoEntryTable);
                initEntryPointPointer = new IntPtr16(initEntryPoint.SegmentNumber, initEntryPoint.Offset);
            }
            else
            {
                var initEntryPoint = File.EntryTable.First(x => x.Ordinal == initResidentName.IndexIntoEntryTable);
                initEntryPointPointer = new IntPtr16(initEntryPoint.SegmentNumber, initEntryPoint.Offset);
            }


            _logger.Info($"Located _INIT__: {initEntryPointPointer}");
            EntryPoints["_INIT_"] = initEntryPointPointer;
        }