/// <summary> /// Initializes a new instance of the <see cref="VGAConsole"/> class. /// </summary> public VGAConsole(DisplayForm dislayForm) { ioBase = StandardIOBase; baseAddress = StandardAddressBase; width = 80; height = 27; //cursorX = 0; //cursorY = 0; cursorPosition = 0; lastCommand = 0; font = new Font("Lucida Console", 9, FontStyle.Regular); fontWidth = (int)font.SizeInPoints; fontHeight = (int)font.SizeInPoints + 5; palette = Mosa.DeviceSystem.ColorPalette.CreateStandard16ColorPalette(); this.dislayForm = dislayForm; dislayForm.SetSize(fontWidth * width + 12, fontHeight * height + 10); MemoryDispatch.RegisterMemory(baseAddress, StandardMemorySize, 2, Read8, Write8); Initialize(); }
/// <summary> /// Initializes a new instance of the <see cref="MemoryHandler"/> class. /// </summary> /// <param name="address">The address.</param> /// <param name="size">The size.</param> /// <param name="type">The type.</param> /// <param name="read8">The read8.</param> /// <param name="write8">The write8.</param> public MemoryHandler(uint address, uint size, uint type, MemoryDispatch.MemoryRead8 read8, MemoryDispatch.MemoryWrite8 write8) { Address = address; Size = size; Type = type; this.read8 = read8; this.write8 = write8; }
private void RefreshMemory(int RowIndex) { ThreadEventDispatcher.CurrentSelectedProcess = Processes.Text.Split('|')[0]; MemoryDispatch MemoryDispatch = new MemoryDispatch(); MemoryDispatch.Row = RowIndex; MemoryDispatch.TextAddress = (string)ValuesGrid[1, RowIndex].Value; MemoryDispatch.Type = DataTypeExactTool.GetValue((string)ValuesGrid[4, RowIndex].Value); ThreadEventDispatcher.RefreshValueAddresses.Enqueue(MemoryDispatch); }
/// <summary> /// Initializes a new instance of the <see cref="Multiboot"/> class. /// </summary> public static void Setup() { uint mem = 0x1000000; MemoryDispatch.Write32(0x200000, 0x2BADB002); MemoryDispatch.Write32(0x200004, mem); uint mem_upper = 0; foreach (MemoryHandler segment in MemoryDispatch.MemorySegments) { if (segment.Address + segment.Size > mem_upper) { mem_upper = segment.Address + segment.Size; } } mem_upper = mem_upper - (1024 * 1024); MemoryDispatch.Write32(mem + 0, 0x01 | 0x40); // flags MemoryDispatch.Write32(mem + 4, 640); // mem_lower - assuming at least 640k MemoryDispatch.Write32(mem + 8, mem_upper / 1024); // mem_upper MemoryDispatch.Write32(mem + 12, 0x0); // boot_device MemoryDispatch.Write32(mem + 16, 0x0); // cmdline MemoryDispatch.Write32(mem + 20, 0x0); // mods_count MemoryDispatch.Write32(mem + 24, 0x0); // mods_addr MemoryDispatch.Write32(mem + 28, 0x0); // syms MemoryDispatch.Write32(mem + 44, (uint)(MemoryDispatch.MemorySegments.Count * 24)); // mmap_length MemoryDispatch.Write32(mem + 48, 96); // mmap_addr MemoryDispatch.Write32(mem + 52, 0x0); // drives_length MemoryDispatch.Write32(mem + 56, 0x0); // drives_addr MemoryDispatch.Write32(mem + 60, 0x0); // config_table MemoryDispatch.Write32(mem + 64, 0x0); // boot_loader_name MemoryDispatch.Write32(mem + 68, 0x0); // apm_table MemoryDispatch.Write32(mem + 72, 0x0); // vbe_control_info MemoryDispatch.Write32(mem + 76, 0x0); // vbe_mode_info MemoryDispatch.Write32(mem + 80, 0x0); // vbe_mode MemoryDispatch.Write32(mem + 84, 0x0); // vbe_interface_seg MemoryDispatch.Write32(mem + 88, 0x0); // vbe_interface_off MemoryDispatch.Write32(mem + 92, 0x0); // vbe_interface_len mem = 96; foreach (MemoryHandler segment in MemoryDispatch.MemorySegments) { MemoryDispatch.Write32(mem + 0, 20); // Size MemoryDispatch.Write32(mem + 4, segment.Address); // base_addr_low MemoryDispatch.Write32(mem + 8, 0x00); // base_addr_high MemoryDispatch.Write32(mem + 12, segment.Size); // length_low MemoryDispatch.Write32(mem + 16, 0x00); // length_high MemoryDispatch.Write32(mem + 20, segment.Type); // type mem = mem + 24; } }
private void SetMemory(int RowIndex) { string TextAddress = (string)ValuesGrid[1, RowIndex].Value; MemoryDispatch MemoryDispatch = new MemoryDispatch(); MemoryDispatch.Row = RowIndex; MemoryDispatch.TextAddress = TextAddress; MemoryDispatch.Type = DataTypeExactTool.GetValue((string)ValuesGrid[3, RowIndex].Value); MemoryDispatch.Value = GetByteArrayForDataType(MemoryDispatch.Type, (string)ValuesGrid[2, RowIndex].Value); ThreadEventDispatcher.WriteAddress.Enqueue(MemoryDispatch); }
internal void SetMemory(string address, string value, DataTypeExact type, int RowIndex = -1) { MemoryDispatch MemoryDispatch = new MemoryDispatch(); MemoryDispatch.Row = RowIndex; MemoryDispatch.TextAddress = address; MemoryDispatch.Type = type; if (MemoryDispatch.Type == DataTypeExact.INVALID) { return; } //check value for type range bool inputInvalidOrOutOfRange; switch (MemoryDispatch.Type) { case DataTypeExact.Bytes1: try { byte.Parse(value); inputInvalidOrOutOfRange = false; } catch { inputInvalidOrOutOfRange = true; } break; case DataTypeExact.Bytes2: try { UInt16.Parse(value); inputInvalidOrOutOfRange = false; } catch { inputInvalidOrOutOfRange = true; } break; case DataTypeExact.Bytes4: try { UInt32.Parse(value); inputInvalidOrOutOfRange = false; } catch { inputInvalidOrOutOfRange = true; } break; case DataTypeExact.Bytes8: try { UInt64.Parse(value); inputInvalidOrOutOfRange = false; } catch { inputInvalidOrOutOfRange = true; } break; case DataTypeExact.Float: try { float.Parse(value); inputInvalidOrOutOfRange = false; } catch { inputInvalidOrOutOfRange = true; } break; case DataTypeExact.Double: try { double.Parse(value); inputInvalidOrOutOfRange = false; } catch { inputInvalidOrOutOfRange = true; } break; default: inputInvalidOrOutOfRange = false; break; } if (!inputInvalidOrOutOfRange) { MemoryDispatch.Value = GetByteArrayForDataType(MemoryDispatch.Type, value); ThreadEventDispatcher.WriteAddress.Enqueue(MemoryDispatch); if (RowIndex >= 0) { ValuesGrid[4, RowIndex].ErrorText = ""; ValuesGrid[4, RowIndex].Style.BackColor = System.Drawing.Color.Transparent; } } else { if (RowIndex >= 0) { ValuesGrid[4, RowIndex].ErrorText = "Value is out of range"; ValuesGrid[4, RowIndex].Style.BackColor = System.Drawing.Color.Red; } } }
/// <summary> /// Initializes a new instance of the <see cref="RAMChip"/> class. /// </summary> public RAMChip(uint addressBase, uint size) { this.addressBase = addressBase; memory = new byte[size]; MemoryDispatch.RegisterMemory(addressBase, size, 1, Read8, Write8); }
internal void ThreadEventDispatcher() { while (true) { if (DispatchConnect) { DispatchConnect = false; DoConnect(); } if (DispatchOpenProcess) { DispatchOpenProcess = false; DoOpenProcess(); } if (DispatchSearch) { DispatchSearch = false; DoSearch(); } if (DispatchConfig) { DispatchConfig = false; DoConfig(); } if (DispatchImport) { DispatchImport = false; DoImport(); } if (DispatchPointerSearch != null) { string TempAddress = DispatchPointerSearch; DispatchPointerSearch = null; DoPointerSearch(TempAddress); } while (RefreshValueAddresses.Count > 0) { MemoryDispatch Row = new MemoryDispatch(); RefreshValueAddresses.TryDequeue(out Row); uint Address; if (HexRegex.IsMatch(Row.TextAddress)) { Address = BitConverter.ToUInt32(Utilities.GetByteArrayFromByteString(Row.TextAddress).Reverse().ToArray(), 0);; } else { Match TopMatch = ParserRegex.Match(Row.TextAddress); if (!TopMatch.Success) { return; } Address = ResolvePointer(TopMatch); } if (Form.IsValidMemoryAddress(Address)) { Row.ResolvedAddress = Utilities.GetStringFromByteArray(BitConverter.GetBytes(Address).Reverse().ToArray()); Row.Value = GetMemoryAtAddress(CurrentSelectedProcess, Address, Row.Type); RefreshValueReturn.Enqueue(Row); } } while (WriteAddress.Count > 0) { MemoryDispatch Row = new MemoryDispatch(); WriteAddress.TryDequeue(out Row); uint Address; if (HexRegex.IsMatch(Row.TextAddress)) { Address = BitConverter.ToUInt32(Utilities.GetByteArrayFromByteString(Row.TextAddress).Reverse().ToArray(), 0);; } else { Match TopMatch = ParserRegex.Match(Row.TextAddress); if (!TopMatch.Success) { return; } Address = ResolvePointer(TopMatch); } if (Form.IsValidMemoryAddress(Address)) { Row.ResolvedAddress = Utilities.GetStringFromByteArray(BitConverter.GetBytes(Address).Reverse().ToArray()); uint ProcessID = BitConverter.ToUInt32(Utilities.GetByteArrayFromByteString(CurrentSelectedProcess.Split('|')[0]), 0); Form.NTRConnection.SendWriteMemoryPacket(ProcessID, Address, Row.Value); } } Thread.Sleep(100); } }