Beispiel #1
0
        public TestVM ExecuteTestVM(string testCode)
        {
            CompilationContext context = CmCompiler.CompileText(testCode);

            byte[] objectCode;

            using (var s = new MemoryStream())
            {
                CmCompiler.CreateObjectCode(s, new RIVMArchitecture(), context.GetIR(), context.GetStringConstants(), context.GetGlobalVariables(), context.GetFunctions());
                objectCode = s.GetBuffer();
            }

            byte[] executableCode;

            using (var s = new MemoryStream())
            {
                CmLinker.Link(s, new List <byte[]> {
                    objectCode
                }, false, SystemMemoryMap.BIOS_ROM_START);
                executableCode = s.GetBuffer();
            }

            var bios = new BIOS(executableCode);

            var mmu = new MMU(SystemMemoryMap.BIOS_STACK_END, bios, null, null);

            var cpu = new CPU(mmu);

            cpu.Start();

            return(new TestVM(cpu));
        }
Beispiel #2
0
        /// <summary>
        /// Конструктор класса
        /// </summary>
        /// <param name="app">Ссылка на платформу</param>
        /// <param name="pBios">Ссылка на подсистему ввода/вывода платформы</param>
        public MainForm(IApplication app, IEpromIO pBios, IProtocol protocol)
        {
            InitializeComponent();
            textInserter = new TextInsert(InsertToText);

            oldValue = new object();
            newValue = new object();

            oldValue = "0";
            newValue = "0";

            bios  = new BIOS(app, pBios);
            proto = protocol;

            currentState = new ObjectCurrentState();

            for (int i = 0; i < 11; i++)
            {
                DataGridViewRow r = new DataGridViewRow();
                if ((i % 2) == 0)
                {
                    r.DefaultCellStyle.BackColor = Color.WhiteSmoke;
                }
                dataGridViewCalibrationTable.Rows.Add(r);
            }

            syncker         = new Sync();
            packetSyncMutex = new Mutex(false);

            gr = new GraphicCalibration(CreateGraphics(), new Rectangle(12, 38, 422, 267));
            gr.CalculateScale();
        }
Beispiel #3
0
        public List <BIOS> GetBiosList()
        {
            List <BIOS> biosList = new List <BIOS>();

            using ManagementObjectSearcher mos = new ManagementObjectSearcher("SELECT * FROM Win32_BIOS");

            foreach (ManagementObject mo in mos.Get())
            {
                BIOS bios = new BIOS
                {
                    Caption           = GetPropertyString(mo["Caption"]),
                    Description       = GetPropertyString(mo["Description"]),
                    Manufacturer      = GetPropertyString(mo["Manufacturer"]),
                    Name              = GetPropertyString(mo["Name"]),
                    ReleaseDate       = GetPropertyString(mo["ReleaseDate"]),
                    SerialNumber      = GetPropertyString(mo["SerialNumber"]),
                    SoftwareElementID = GetPropertyString(mo["SoftwareElementID"]),
                    Version           = GetPropertyString(mo["Version"])
                };

                biosList.Add(bios);
            }

            return(biosList);
        }
        public List <BIOS> GetBiosList()
        {
            List <BIOS> biosList = new List <BIOS>();

            BIOS bios = new BIOS();

            biosList.Add(bios);

            return(biosList);
        }
    public virtual bool Assert(ComputerSystem computer, BIOS bios, IEnumerable <DiskDrive> disks, IEnumerable <PnPEntity> devices, IEnumerable <string> processes, IEnumerable <WindowsService> services)
    {
#if DEBUG
        Console.WriteLine();
        Console.WriteLine("--------------------------------------------------------------");
        Console.WriteLine("Asserting {0}", this.GetType().Name);
#endif

        bool computerIsVirtual      = IsVirtual(computer);
        bool biosIsVirtual          = IsVirtual(bios);
        bool containsVirtualDisk    = ContainsDisk(disks);
        bool containsVirtualDevice  = ContainsDevice(devices);
        bool containsVirtualProcess = ContainsProcess(processes);
        bool containsVirtualService = ContainsService(services);

#if DEBUG
        if (computerIsVirtual)
        {
            Console.WriteLine("Detected as virtual machine given key computer information.");
        }

        if (biosIsVirtual)
        {
            Console.WriteLine("Detected as virtual machine given bios information.");
        }

        if (containsVirtualDisk)
        {
            Console.WriteLine("Detected as virtual machine given hard disk information.");
        }

        if (containsVirtualDevice)
        {
            Console.WriteLine("Detected as virtual machine given PnP devices information.");
        }

        if (containsVirtualProcess)
        {
            Console.WriteLine("Detected as virtual machine given processes information.");
        }

        if (containsVirtualService)
        {
            Console.WriteLine("Detected as virtual machine given Windows services information.");
        }
#endif

        return(computerIsVirtual ||
               biosIsVirtual ||
               containsVirtualDisk ||
               containsVirtualDevice ||
               containsVirtualProcess ||
               containsVirtualService);
    }
Beispiel #6
0
        public void funcPopulateBIOSes()
        {
            SelectQuery QueryBIOSes        = new SelectQuery("SELECT * FROM Win32_BIOS");
            ManagementObjectCollection moc = new ManagementObjectSearcher(QueryBIOSes).Get();

            Parallel.ForEach(moc.Cast <ManagementObject>(), mo =>
            {
                BIOS temp = new BIOS(mo);

                listBIOS.Add(temp);
            });
        }
Beispiel #7
0
        public List <BIOS> GetBiosList()
        {
            List <BIOS> biosList = new List <BIOS>();

            BIOS bios = new BIOS
            {
                ReleaseDate  = TryReadFileText("/sys/class/dmi/id/bios_date"),
                Version      = TryReadFileText("/sys/class/dmi/id/bios_version"),
                Manufacturer = TryReadFileText("/sys/class/dmi/id/bios_vendor")
            };

            biosList.Add(bios);

            return(biosList);
        }
Beispiel #8
0
    public virtual bool Assert(ComputerSystem computer, BIOS bios, IEnumerable <DiskDrive> disks, IEnumerable <PnPEntity> devices, IEnumerable <string> processes, IEnumerable <WindowsService> services)
    {
        bool computerIsVirtual      = IsVirtual(computer);
        bool biosIsVirtual          = IsVirtual(bios);
        bool containsVirtualDisk    = ContainsDisk(disks);
        bool containsVirtualDevice  = ContainsDevice(devices);
        bool containsVirtualProcess = ContainsProcess(processes);
        bool containsVirtualService = ContainsService(services);

        return(computerIsVirtual ||
               biosIsVirtual ||
               containsVirtualDisk ||
               containsVirtualDevice ||
               containsVirtualProcess ||
               containsVirtualService);
    }
Beispiel #9
0
        public async void AsyncUpdateBiosInformation()
        {
            IsModelInformationBeingUpdated = true;

            ModelInformationUpdateProgress = "Loading BIOS data...";
            Bios = await Task.Run(() =>
            {
                IServiceFactory sf = ServiceFactoryProducer.GetServiceFactory();

                IBIOSService bs = sf.CreateBIOSService();

                return(bs.GetBIOS());
            });

            IsModelInformationBeingUpdated = false;
        }
Beispiel #10
0
        public LoadeForm(BIOS bios, ObjectCurrentState currentState)
        {
            InitializeComponent();

            pBios   = bios;
            pObject = currentState;

            pBios.eCompleteReadEpromLine  += new EventHandler(pBios_eCompleteReadEpromLine);
            pBios.eMorePopitReadEpromLine += new EventHandler(pBios_eMorePopitReadEpromLine);
            pBios.eTimeoutReadEpromLine   += new EventHandler(pBios_eTimeoutReadEpromLine);

            incer  = new Incer(IncP);
            initer = new Initer(InitProgressBar);

            mes = new Messeger(ShowMessage);
            obj = new object();
        }
Beispiel #11
0
    static VirtualMachineDetector()
    {
        _detectors = new IVirtualEnvironment[]
        {
            new VmWarePlayer(),
            new HyperVMachine(),
            new QEmuMachine(),
            new VirtualBoxMachine(),
        };

        _computer    = Create <ComputerSystem>("Win32_ComputerSystem");
        _bios        = Create <BIOS>("Win32_BIOS");
        _motherboard = Create <MotherboardDevice>("Win32_MotherboardDevice");
        _devices     = CreateList <PnPEntity>("Win32_PnPEntity");
        _disks       = CreateList <DiskDrive>("Win32_DiskDrive");
        _services    = GetWindowsServices();
    }
Beispiel #12
0
        public SaveForm(BIOS bios, ObjectCurrentState currentState)
        {
            InitializeComponent();

            incer  = new Incer(IncP);
            initer = new Initer(InitProgressBar);

            DialogResult = DialogResult.OK;

            pBios   = bios;
            pObject = currentState;

            pBios.eSaveCompleteReadEpromLine  += new EventHandler(pBios_eSaveCompleteReadEpromLine);
            pBios.eSaveMorePopitReadEpromLine += new EventHandler(pBios_eSaveMorePopitReadEpromLine);
            pBios.eSaveTimeoutReadEpromLine   += new EventHandler(pBios_eSaveTimeoutReadEpromLine);

            mes = new Messeger(ShowMessage);
        }
Beispiel #13
0
        /// <summary>
        /// Gets the BIOS information
        /// </summary>
        /// <returns>The BIOS information</returns>
        public BIOS GetBIOS()
        {
            BIOS bios = new BIOS();

            try
            {
                ManagementObjectSearcher   mos = new ManagementObjectSearcher(_BIOS_SEARCH_STRING);
                ManagementObjectCollection moc = mos.Get();

                foreach (ManagementObject mo in moc)
                {
                    bios.BuildNumber = Convert.ToString(mo["BuildNumber"]);

                    UInt16[] capabilities = (UInt16[])mo["BiosCharacteristics"];
                    foreach (UInt16 capability in capabilities)
                    {
                        if (_BIOS_CHARACTERISTICS_DICTIONARY.ContainsKey(capability))
                        {
                            bios.Capabilities.Add(_BIOS_CHARACTERISTICS_DICTIONARY[capability]);
                        }
                    }

                    bios.CurrentLanguage    = Convert.ToString(mo["CurrentLanguage"]);
                    bios.IsPrimaryBIOS      = Convert.ToBoolean(mo["PrimaryBIOS"]);
                    bios.Manufacturer       = Convert.ToString(mo["Manufacturer"]);
                    bios.Name               = Convert.ToString(mo["Name"]);
                    bios.ReleaseDate        = ManagementDateTimeConverter.ToDateTime(Convert.ToString(mo["ReleaseDate"]));
                    bios.SerialNumber       = Convert.ToString(mo["SerialNumber"]);
                    bios.SmBIOSBIOSVersion  = Convert.ToString(mo["SMBIOSBIOSVersion"]);
                    bios.SmBIOSMajorVersion = Convert.ToUInt16(mo["SMBIOSMajorVersion"]);
                    bios.SmBIOSMinorVersion = Convert.ToUInt16(mo["SMBIOSMinorVersion"]);
                    bios.Version            = Convert.ToString(mo["Version"]);
                }
            }
            catch (Exception exc)
            {
                MyDebugger.Instance.LogMessage(exc, DebugVerbocity.Exception);
            }

            return(bios);
        }
Beispiel #14
0
 private void InitBIOS()
 {
     Console.WriteLine("Initializing BIOS.");
     BIOS_Image = new BIOS();
 }
Beispiel #15
0
        public static void Main(string[] args)
        {
            CPUExecution context = CPUExecution.MORE_INSTRUCTIONS_AVAILABLE;
            string       outC, outD;
            char         keyPressed = ' ';

            // Initialize the BIOS
            bios = new BIOS(rootFolder + "VirtualDisk.img");

            // Load the binary code and initialize the CPU
            LoadBinaryCode();

            while (context != CPUExecution.FINISHED)
            {
                // Execute the next instruction
                context = cpu.SingleStep(out outC, out outD);

                if (context == CPUExecution.IN_A)
                {
                    // Pass the read character from the console into the CPU Input Port A...
                    cpu.XL.SetBits(Convert.ToByte(keyPressed));
                }

                if (context == CPUExecution.IN_B)
                {
                    ConsoleKeyInfo key = Console.ReadKey(true);
                    keyPressed = key.KeyChar;

                    // Set the Ready Bit on Input Port B when we have read the character from the console
                    cpu.XL.SetBits(1);
                }

                if (context == CPUExecution.INTERRUPT)
                {
                    // We have triggered a software based interrupt...
                    switch (cpu.XL.GetInt())
                    {
                    case 1:
                    {
                        // Interrupt 1 is used for accessing hard disks
                        HandleHardDiskInterrupt();
                        break;
                    }

                    default:
                        throw new ArgumentException("Invalid Interrupt Number!");
                    }

                    // After we have handled the interrupt, we continue program execution by incrementing the Program Counter...
                    cpu.ProgramCounter.Increment();
                    continue;
                }

                if (outC != string.Empty)
                {
                    Console.Write(Convert.ToChar(Helper.GetByte(outC)));
                }
            }

            Console.WriteLine();
            Console.WriteLine("Done");
            Console.ReadLine();
        }
    static VirtualMachineDetector()
    {
        _detectors = new IVirtualEnvironment[]
        {
            new VmWarePlayer(),
            new HyperVMachine(),
            new QEmuMachine(),
            new VirtualBoxMachine(),
        };

        _computer    = Create <ComputerSystem>("Win32_ComputerSystem");
        _bios        = Create <BIOS>("Win32_BIOS");
        _motherboard = Create <MotherboardDevice>("Win32_MotherboardDevice");
        _devices     = CreateList <PnPEntity>("Win32_PnPEntity");
        _disks       = CreateList <DiskDrive>("Win32_DiskDrive");
        _services    = GetWindowsServices();

        #region DEBUG PRINT
#if DEBUG
        Console.WriteLine();
        Console.WriteLine("MOTHERBOARD INFO");
        Console.WriteLine("================");
        Console.WriteLine(_motherboard);
        Console.WriteLine();

        Console.WriteLine("BIOS INFO");
        Console.WriteLine("=========");
        Console.WriteLine(_bios);
        Console.WriteLine();

        Console.WriteLine("COMPUTER INFO");
        Console.WriteLine("=============");
        Console.WriteLine(_computer);
        Console.WriteLine();

        Console.WriteLine("DEVICES INFO");
        Console.WriteLine("============");
        foreach (var device in _devices)
        {
            Console.WriteLine(device);
        }
        Console.WriteLine();

        Console.WriteLine("HARD DRIVES INFO");
        Console.WriteLine("================");
        foreach (var disk in _disks)
        {
            Console.WriteLine(disk);
        }
        Console.WriteLine();

        Console.WriteLine("WINDOWS SERVICES");
        Console.WriteLine("================");
        foreach (var service in _services)
        {
            Console.WriteLine(service);
        }
        Console.WriteLine();
#endif
        #endregion
    }
 public virtual bool IsVirtual(BIOS bios)
 {
     return(false);
 }
Beispiel #18
0
 public override bool IsVirtual(BIOS bios)
 {
     return(bios.SerialNumber.Contains("vmware"));
 }
Beispiel #19
0
 public Virtual8086()
 {
     bios            = new BIOS();
     ProcessorThread = new Thread(new ThreadStart(CpuLoop));
     ProcessorThread.Start();
 }