i’m wondering what does this do:
std::basic_string<char, std::char_traits<char>, std::allocator<char>>::
basic_string<char, std::char_traits<char>, std::allocator<char>>
(&myText, "hello world");
my first guess is that it’s allocating “hello world” to a myText variable
if that’s true then what does it do in this case :
if ( v106 == v67 ||
std::basic_string<char, std::char_traits<char>, std::allocator<char>>::
basic_string<char, std::char_traits<char>, std::allocator<char>>
(&v109,"program"), v137 = 1)
{
BYTE3(v95) = 0;
}
it’s not really a condition…
I guess this is output from Hex-Ray’s decompiler plugin for IDA, am I right? This is the way it displays the call of the constructor of the
std::stringclass.v109is the memory allocated on the stack to hold thestd::stringinstance, while the second parameter,"hello world", is the string to initialize it with.In cases where multiple conditions lead to the same resulting code, compilers often choose to reuse the (equivalent) code fragment from a previous condition to minimize the size of the generated bytecode. Hex-Ray’s decompiler plugin often displays them using the Comma-operator up to version 1.5 – newer versions of the decompiler have a better understanding of such situations.
This is more likely to look like the actual source. Replacing the huge
std::basic_string<...>construct with a simplestd::stringdeclaration makes it even more readable.