Results 1 to 7 of 7

Thread: [2.0] a few read/writeprocessmemory questions

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2007
    Posts
    26

    [2.0] a few read/writeprocessmemory questions

    thanks to all who help...
    1)How do i read a 2 byte, 4 byte, or 8 byte value? I know how to read a one byte, but that only goes up to 255...

    2)If any of you are familiar assembly, i need know now how to change (write) to an addresses hex dump, also known as Array of Byte (in most memory editing engines).

    3) Reading/writing to a pointer I.E (0x1009624, offset: 0xb14), or any other pointer...
    thanks in advanced, and positive rating to all who help!

  2. #2
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: [2.0] a few read/writeprocessmemory questions

    1)How do i read a 2 byte, 4 byte, or 8 byte value? I know how to read a one byte, but that only goes up to 255...
    Read 2 bytes and concatenate them in a Short
    2)If any of you are familiar assembly, i need know now how to change (write) to an addresses hex dump, also known as Array of Byte (in most memory editing engines).
    We have a forum for Assembly
    Reading/writing to a pointer I.E (0x1009624, offset: 0xb14), or any other pointer...
    Unless you're working in assembly you'll keep getting AddressViolationException If that memory location is reserved for the system or another app
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jun 2007
    Posts
    26

    Re: [2.0] a few read/writeprocessmemory questions

    Thanks, for trying...but I may have mis-communicated, let me clarify:

    1)
    Code:
                ProcessMemoryReaderLib.ProcessMemoryReader memedit 
                = new ProcessMemoryReaderLib.ProcessMemoryReader();
                memedit.ReadProcess = myprocess[0];
                memedit.OpenProcess();
    
                int bytesread; //needed
                int byteswritten; //needed
                int address = 0x1009624; //address
                int value; //value of address
                short value2=444; //for writing 2 byte, 444 for the value
                byte[] memory; //for reading byte
    
                reading
                memory = memedit.ReadProcessMemory((IntPtr)address, 1, out bytesread);
                //starts out as a byte array...i'm wondering how to get around this...
                value = memory[0];
                MessageBox.Show(value.ToString());
    
                //writing
                memory = BitConverter.GetBytes(value2);
                memedit.WriteProcessMemory((IntPtr)address, memory, out byteswritten);
    Code:
    Resolution:
                byteone = BitConverter.GetBytes(intone);
                inttwo = BitConverter.ToInt32(byteone, 0);
                MessageBox.Show(inttwo.ToString());
    As you can see, when you read an address...the value is assigned to a byte array, how do I get around this? Like if I want to read a 4-byte value.

    2)
    Code:
    I understand that you have an assembly forum, I need this to be done in c#...should just 
    be another variation of writing 2 byte, 4 byte, 8 byte, ect...
    should be easy...

    3)
    Code:
    Don't say this can only be done in assembly...I've seen it done in C++, and in Delphi...
    and I'm pretty sure it can be done in C#...
    again...should be easy
    Last edited by gamesguru; Jul 6th, 2007 at 09:48 AM.

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Jun 2007
    Posts
    26

    Re: [2.0] a few read/writeprocessmemory questions

    Step 1 and 2 have been resolved! Only 3 remains!
    Last edited by gamesguru; Jul 7th, 2007 at 09:36 AM.

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Jun 2007
    Posts
    26

    Re: [2.0] a few read/writeprocessmemory questions

    Can anyone tell me how to read the value of pointers?! Let me give a better explanation of what I want...

    Pointers are 4 byte values that hold the the address of a memorylocation instead of a normal value.

    That address is used by the game to find out where to store and look for it's data. E.g: 10 bytes after the pointer to the start of the player data is health, 14 bytes after the start of the player data is armor, 18 bytes after the player is ammo etc....

    Here's a picture...I hope someone understands, and knows what to do!

  6. #6
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: [2.0] a few read/writeprocessmemory questions

    Read up on the following C# topics:

    - unsafe code
    - fixed()
    - pointers

    You can use pointers in C# just as you can in C/C++. To read the value at a pointer's address just dereference the pointer...

    int fred = 0;
    fred = *myPointer;

    to set the value at the pointers address...

    *myPointer = 12345;
    I don't live here any more.

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Jun 2007
    Posts
    26

    Re: [2.0] a few read/writeprocessmemory questions

    Sorry for the mis-communication, but I need to read/write from and to a process's memory (pointers that is), not my application's memory. I've seen it done in Delphi and C++ but never in C#...and I'd like to know how.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width