Results 1 to 4 of 4
  1. #1
    fiqhpratama's Avatar
    Join Date
    Jul 2015
    Gender
    male
    Location
    Bekasi, Jawa Barat
    Posts
    5
    Reputation
    10
    Thanks
    0
    My Mood
    Bitchy

    [DELPHI] Read/Write String Value

    Help me. im Noob

    how to write/Read string value on delphi using WriteProcessMemory

    im using Edit1.Text for writing value:


    please some help me.

  2. #2
    MikeRohsoft's Avatar
    Join Date
    May 2013
    Gender
    male
    Location
    Los Santos
    Posts
    797
    Reputation
    593
    Thanks
    26,314
    Quote Originally Posted by fiqhpratama View Post
    Help me. im Noob

    how to write/Read string value on delphi using WriteProcessMemory

    im using Edit1.Text for writing value:


    please some help me.
    i hate it there is no Delphi Section!
    The Windows API return LPRSTR which is a PChar in Delphi.
    A String in Delphi saves the Memory Position of the CharArray in Slot 0 of the Array, so the char array is beginning is at 1
    Code:
    var
      PlayerNameSlot1: string;
    begin
      SetLength(PlayerNameSlot1, 32);
      ReadProcessMemory(GameHandle, Pointer(GTA5.exe + $268A9F4 + $88),   @playernameSlot1[1], sizeof(PlayerNameSlot1), FByteBuffer); 
    end;
    Code:
    begin
     WriteProcessMemory(GameHandle, Pointer(Address), @edIT1.Text[1], sizeof(Edit1.Text), FByteBuffer);  
    end;
    Last edited by MikeRohsoft; 08-29-2016 at 04:21 PM.

  3. #3
    fiqhpratama's Avatar
    Join Date
    Jul 2015
    Gender
    male
    Location
    Bekasi, Jawa Barat
    Posts
    5
    Reputation
    10
    Thanks
    0
    My Mood
    Bitchy

    Unhappy

    Thanks for replay my post

    how about ansiString Writing?

    - - - Updated - - -

    i test writing with Edit1, but
    the output is a Unicode string,.
    how to write Ansi String?

    - - - Updated - - -

    Quote Originally Posted by MikeRohsoft View Post
    i hate it there is no Delphi Section!
    The Windows API return LPRSTR which is a PChar in Delphi.
    A String in Delphi saves the Memory Position of the CharArray in Slot 0 of the Array, so the char array is beginning is at 1
    Code:
    var
      PlayerNameSlot1: string;
    begin
      SetLength(PlayerNameSlot1, 32);
      ReadProcessMemory(GameHandle, Pointer(GTA5.exe + $268A9F4 + $88),   @playernameSlot1[1], sizeof(PlayerNameSlot1), FByteBuffer); 
    end;
    Code:
    begin
     WriteProcessMemory(GameHandle, Pointer(Address), @edIT1.Text[1], sizeof(Edit1.Text), FByteBuffer);  
    end;
    wow, its work, i just convert Unicode to AnsiString.
    Thanks for your Reply, your code is very helpfull...

  4. #4
    MikeRohsoft's Avatar
    Join Date
    May 2013
    Gender
    male
    Location
    Los Santos
    Posts
    797
    Reputation
    593
    Thanks
    26,314
    Quote Originally Posted by fiqhpratama View Post
    wow, its work, i just convert Unicode to AnsiString.
    Thanks for your Reply, your code is very helpfull...
    I'm writing a Wrapper Class at the Moment for the Memory Stuff, if you want to play arround with that you can contact me on Skype or by PM.
    If i penetrate it enough, i will make it public anyway.
    It can already handle to read and write nearly all basic types, AOB Pattern Scan and dll Injection.

    And i found out if you use my example you can only read 4 or 8 bytes depending on WOW or / and Plattform (64 Bit = 8 byte, 32 Bit = 4 byte) because the sizeof() return only the Size of the type, you should use Magic Function Length() for it.

    Anyway, if you read a String from Memory, but you don't know how big it will be, you read more then you have to.
    If you do that your String will maybe have "cryptic Characters" at the end, because a String in Delphi isn't NULL Terminated.
    You can Trim it after it by yourself or you use a workarround with PChar, because PChar is what "Char*" in C is (Pointer to array of Char) and this is NULL Terminated:
    Code:
    var
      BytesRead: SIZE_T;
      Str: string; // Here we want the Memory Read Output as clean String
      Buffer: array of char; // This we use to read the bytes, you could use 
      //Buffer: array of byte; // You can switch this line with the above, we don't care
      StrBuffer: PChar absolute Buffer; // this PChar points already to Buffer now
      len: integer; // How many we want to read
    begin
      len := 255;
      SetLength(Buffer, len); // set the char array length
      ReadProcessMemory(ProccessHandle, Pointer(addr), @ Buffer[0], len, BytesRead);
      Str := AnsiString(StrBuffer); // PChar to String 
      SetLength(Buffer, 0); // clean up, after we filled our String
    end;
    Last edited by MikeRohsoft; 09-01-2016 at 11:40 AM. Reason: forgotten to clean up

Similar Threads

  1. [Help] Reading/Writing Vector values
    By zurasaur in forum Visual Basic Programming
    Replies: 1
    Last Post: 04-23-2015, 01:46 PM
  2. [Help] How to write a string value in ReadWriteMemory.vb eg String(81)
    By 2000callum in forum Call of Duty Black Ops 2 Private Server Hacks
    Replies: 7
    Last Post: 08-17-2013, 06:20 PM
  3. [Help] How to write a string value in ReadWriteMemory.vb eg String(81)
    By 2000callum in forum Call of Duty Black Ops 2 Coding, Programming & Source Code
    Replies: 1
    Last Post: 06-27-2013, 01:48 AM
  4. [Source Help]Read/Write Text[Solved]
    By Samueldo in forum Visual Basic Programming
    Replies: 4
    Last Post: 04-05-2010, 10:17 AM
  5. ASM hacks like OPK,Invi.. in vb6? and VB write big value?
    By o0KoNsY0o in forum WarRock - International Hacks
    Replies: 21
    Last Post: 11-28-2007, 05:51 PM