none
Is there a way to correctly know the length of a string using ReadProcessMemory? RRS feed

  • Question

  • So I have a problem: I'm reading a string from a memory address that is different at different times. For example:

    Axe?ca Ocarina?tar??ing?ing????????????

    I only need Axe.

    Ball of Green Yarn??ing?ing????????????

    I only need Ball of Green Yarn.

    I'm reading 80 bytes of text (40 chars) because that's the most amount of characters the string should get to. But how can I know how long the string actually is?

    Saturday, February 2, 2019 10:29 PM

All replies

  • I'm reading a string from a memory address that is different at different times. For example:

    Axe?ca Ocarina?tar??ing?ing????????????

    I only need Axe.

    Ball of Green Yarn??ing?ing????????????

    I only need Ball of Green Yarn.

    I'm reading 80 bytes of text (40 chars) because that's the most amount of characters the string should get to. But how can I know how long the string actually is?

    What kind of "string" is it? Is it just a sequence of characters? Is it
    related in any way to strings as typically understood in programming such
    as the data in an object of a string class, a series of characters terminated
    by a sentinel or marker character such as a binary zero, a variable sequence
    of characters prefixed by a fixed-length character or word giving the length
    of the following variable-length string, etc.

    Objects of a string class often have a class member which holds the length
    of the data in that particular string object. Often all objects of a string
    class will be the same size, but they will have dynamically sized and
    allocated data areas. Each object will have a pointer to its string data 
    member in addition to a size/length member.

    Without some kind of formal format or defined rules it is impossible to tell
    where a completely arbitrary sequence of characters is intended to end.

    Also, from where are you getting this memory address? How did you determine
    that it was the address you want?

    - Wayne

    Sunday, February 3, 2019 9:57 AM
  • Hi OldGoldie,

    About using "ReadProcessMemory", maybe you can refer to ReadProcessMemory function.

    Regards,

    Kyle


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, February 4, 2019 3:25 AM