• Advertisement
Sign in to follow this  

Need help with strings!

This topic is 4910 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How do you find a string in memory? using the ReadMemoryProcess() of course. after you use the ReadMemoryProcess what do you do to find the string.

Share this post


Link to post
Share on other sites
Advertisement
So, you have a chunk of memory in a buffer, and you want to find a string? Its not really very difficult...

byte byBuffer[4096]; // Buffer from ReadProcessMemory()
char szSearch = "Hello World"; // String to search for
const int nSearchLen = strlen(szSearch)-1;
for(int i=0; i<4095; ++i)
{
if((byBuffer == *szSearch) && (strncmp(byBuffer+i+1,szSearch+1,nSearchLen) == 0))
{
// Found string at byBuffer+i
}
}


Thats probably about the fastest way to do it. Bear in mind that if a string straddles to buffers (e.g. on a 4k boundary), it won't be found this way.

Share this post


Link to post
Share on other sites
Quote:
Original post by Oluseyi
Why not just use strstr?

Because the buffer filled by ReadProcessMemory() will probably contain '\0' characters before the string, so strstr() will probably return NULL all the time. strstr() is only for strings, it won't work on a buffer.

Share this post


Link to post
Share on other sites
would this work?

bool compare(int start,char *s1, char *s2)
{
int len = strlen(s2);
for(int i = 0; i < len && s1[i+start] == s2; i++);
if(i == len)
return true;
else
return false;
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement