0

I am currently reverse engineering a software sample in which the original author has pre-defined a series of unicode data types/variables into the .data portion of the sample upon compilation. Thus, since they seem to be compiled into the executable itself, I cannot find where the code where they are written (obviously).

THUS, my question... how did the original author, using C/C++, compile these variables into the .data portion of the executable? Through an #include statement? What would the C/C++ psydo-code look like? Or is it a "variable.c" that was converted into an "variable.o" and added into the GCC compiler as an arguement?

Any ideas/suggestions/theories are appreciated.

enter image description here

Stryker2k2
  • 108
  • 9

1 Answers1

1

I am pretty sure that is what (typically) happens to string literals:

int main() {
    std::string s = u"Services";
    return 0;
}

See this.

Dean Johnson
  • 1,682
  • 7
  • 12
  • Ahhh, okay, I think you just thawed out my brain freeze. So, anything like a "std::string" or "const char[64]" would be compiled into the executable before hand; unlike the variables that can be dynamically changed. – Stryker2k2 Feb 24 '21 at 18:15
  • The character data is compiled into the exe, yes. Because `std::string` is mutable, it probably ends up making a copy and storing that data on the heap but the data for the string literals themselves that are assign to `std::string` will typically be stored in the data segment. – Dean Johnson Feb 24 '21 at 18:17
  • @DeanJohnson: `std::string` internally allocates storage to store any string it is given. It doesn't *ever* point to a string literal. – Nicol Bolas Feb 24 '21 at 18:19
  • @NicolBolas Thanks, reworded my comment to address that. The literal is still stored in the data segment, but `std::string` will have to have it's own storage as well. – Dean Johnson Feb 24 '21 at 18:21