コード例 #1
0
        private void LoadAndRun()
        {
            string fileName = vm.PhysicalMemory.GetString(vm.Processor.DS, (ushort)vm.Processor.DX, 256, 0);
            var    filePath = new VirtualPath(fileName);

            var program = ProgramImage.Load(fileName, this.vm);

            if (vm.Processor.ES == 0)
            {
                LoadImage(program);
            }
            else
            {
                ushort envSegment     = vm.PhysicalMemory.GetUInt16(vm.Processor.ES, (ushort)vm.Processor.BX);
                ushort cmdLineOffset  = vm.PhysicalMemory.GetUInt16(vm.Processor.ES, (ushort)vm.Processor.BX + 2u);
                ushort cmdLineSegment = vm.PhysicalMemory.GetUInt16(vm.Processor.ES, (ushort)vm.Processor.BX + 4u);

                string cmdLineArgs = null;
                if (cmdLineSegment != 0)
                {
                    int count = vm.PhysicalMemory.GetByte(cmdLineSegment, cmdLineOffset);
                    if (count > 0)
                    {
                        cmdLineArgs = vm.PhysicalMemory.GetString(cmdLineSegment, cmdLineOffset + 1u, count);
                    }
                }

                LoadImage(program, envSegment, cmdLineArgs);
            }
        }
コード例 #2
0
        private void LoadOverlay()
        {
            string fileName = vm.PhysicalMemory.GetString(vm.Processor.DS, (ushort)vm.Processor.DX, 256, 0);
            var    program  = ProgramImage.Load(fileName, vm);

            if (!(program is ExeFile))
            {
                throw new InvalidOperationException();
            }

            ushort overlaySegment   = vm.PhysicalMemory.GetUInt16(vm.Processor.ES, (ushort)vm.Processor.BX);
            short  relocationFactor = (short)vm.PhysicalMemory.GetUInt16(vm.Processor.ES, (ushort)vm.Processor.BX + 2u);

            program.LoadOverlay(vm, overlaySegment, relocationFactor);
        }