C# ReadMemoryProcess

10/08/2009 19:30 RiddiS#1
Ok, so i've written a class to read the memory address of a process and then convert it to a string so it's readable as a normal value.
It works fine, but for some reason if I read an address wich holds a value that has more then 3 numbers (for example 1000> ) it starts giving the wrong values.
Does anyone know why?


here's my piece of code(class not included becouse I'm sure everything is fine with that):
Code:
readmem.ReadProcess = myProcesses[0];

            readmem.OpenProcess();

            int bytesReaded;
            int Value;
            int Address = 0x00C33EDC;
            byte[] memory;

            memory = readmem.ReadProcessMemory((IntPtr)Address, 1, out bytesReaded);
            Value = memory[0];
            label1.Text = "Value: " + Value.ToString();
thank you ;)
10/09/2009 00:34 bloodx#2
maybe cuz of byte?
10/09/2009 00:37 link#3
Code:
            memory = readmem.ReadProcessMemory((IntPtr)Address, 1, out bytesReaded);
            Value = memory[0];
            label1.Text = "Value: " + Value.ToString();
Substitute the '1' with the size of an array (> 1).
Also this 'Value = memory[0]' does only take the first byte of 'memory', so either try 'memory.ToString()' or take its values repetitive.
10/09/2009 15:32 saweet#4
Do you know the size allocated to the memory address you're reading? Is it null (\0) terminated?
10/09/2009 20:33 RiddiS#5
Quote:
Originally Posted by link View Post
Code:
            memory = readmem.ReadProcessMemory((IntPtr)Address, 1, out bytesReaded);
            Value = memory[0];
            label1.Text = "Value: " + Value.ToString();
Substitute the '1' with the size of an array (> 1).
Also this 'Value = memory[0]' does only take the first byte of 'memory', so either try 'memory.ToString()' or take its values repetitive.
memory.ToString(); would just give me "Value: System.Byte[], also replacing the 1 with the size of the array doesn't make a difference.

Quote:
Originally Posted by saweet View Post
Do you know the size allocated to the memory address you're reading? Is it null (\0) terminated?
No, I don't :\]

thank you for helping :)
10/09/2009 22:13 Shadowz75#6
Quote:
Originally Posted by RiddiS View Post
memory.ToString(); would just give me "Value: System.Byte[], also replacing the 1 with the size of the array doesn't make a difference.



No, I don't :\]

thank you for helping :)
Code:
label1.Text = "Value: " + Encoding.ASCII.GetString(memory);
pseudocode