I've filled a MODULEENTRY32 struct from winapi including the modBaseAddr.  I need to convert it to a std::string while keeping its format.  I've tried copying the BYTE *modBaseAddr contents to a char buffer then making a std::string out of that.  This generated some cryptic characters, and other times gave a mem access violation: 0xC0000005: Access violation reading location 0x001013C0..  I understand why this happens, and after further research I'm stumped on any solutions.
Thanks,
Edit: To clarify my intent, I'm logging it solely for the memory address
You can use a std::ostringstream.  Any kind of pointer that is passed to operator<<, other than a char*, will print out the address it holds when.  char* is handled special as a null-terminated string instead.  Since BYTE* is really a char*, you just have to type-cast it to print its address:
std::ostringstream o;
o << (void*) modBaseAddr;
std::string str = o.str();
 Meme myself and a very creepy • edited Feb 21, 2019 by
 Meme myself and a very creepy • edited Feb 21, 2019 by User contributions licensed under CC BY-SA 3.0