-3

I'm trying to make an application that reads memory and displays it. The source of the data is coming from a byte[] array and I've tried converting it into text, but did not work. I also tried to use BinaryReader, but it seems to be only for reading files which isn't what I'm trying to do. If there's a way to read memory other than files with Binaryreader that will help too. I found ICSharpCode.TextEditor.dll that may work, but I don't know how to use it. My main goal is to edit the memory with or without it displaying on the application. If anyone can help me I'd appreciate it!

List of questions that's related to this topic

  1. How to I display memory visually on the application? e.g. the picture below.
  2. What can I use to read memory without streaming a file?
  3. What .dll or c# function can I use to make a memory reader/editor that displays or not that reads a byte[].

This is how I want it to show on application.

Here are examples of what I'm trying to do

        byte[] Memory = { }; // Source code
        BinaryReader ReadMemory = new BinaryReader(Memory); // I need it to read byte[] , not a file
        ReadMemory.ReadBytes(10);

        //OR

        byte[] Memorysource = { }; // Source code
        richTextBox1.Text = Convert.ToString(Memorysource);
john Era
  • 7
  • 3
  • 2
    Unclear question. Post code. `but did not work` ??? What happened? – usr Nov 16 '15 at 00:18
  • 2
    Ah, you want a hexdump of the bytes. The simplest is `byte[]` and `printf("%02x ", byte)`. – Kenney Nov 16 '15 at 00:18
  • @Kenney Though a fine suggestion, OP's question is c# not c/c++. No such beastie as `printf()` in c# sadly –  Nov 16 '15 at 01:25
  • Try this : Byte[] data = null; MemoryStream stream = new MemoryStream(data); BinaryReader reader = new BinaryReader(stream, Encoding.UTF8); – jdweng Nov 16 '15 at 01:30

1 Answers1

0

You can use String.Format("{0,10:X}", bitValue)

You can also use the BitConverter:

BitConverter.ToString(byteArray);
CodingMadeEasy
  • 2,257
  • 4
  • 19
  • 31
  • `private static string ConvertByteToString(byte[] source) { return source != null ? System.Text.Encoding.UTF8.GetString(source) : null; } byte[] data = { 0xF2 ,32, 00,00,32, 0xF3, 00, 24, 0xA8, 00, 00, 00 }; // Example memoryStr.Text = ConvertByteToString(data); // memoryStr = richTextbox ` **How can I show the 00 (nulls) in as text? Example: byte 0 will come up as a dot.** – john Era Nov 16 '15 at 04:24