I am filling a char array using ReadProcessMemory and I am curious to know what is the ‘correct/standard/best’ way to determine if the returned char array contains a valid string. I’m not worried about the string, it can contain the a-zA-Z0-9 plus spaces and characters such as ‘./_’ and a few other things but really all I want to know if it is valid and just not full of junk.
int char_read_length = 255;
char data[255];
memset(data, 0, char_read_length);
ReadProcessMemory( hProcess, (void *)start, data, char_read_length, &lpRead);
Thanks.
It can be treated as a string if it contains a NUL character to terminate the string. If there is no NUL, treating it as a string will run off the end of the buffer and cause very bad things to happen. Thus: