0

I have dll injected into executable with a few function hooks installed. Executable has global std::map variable, declared as

std::map<int, int> g_lenMap;

I know it's address from the disassembly. I need to insert key/value pair into this map (or somehow hook ::find() function, which looks much more different for me).

However, the most obvious way doesnt work:

std::map<int,int>* g_lenMap;
g_lenMap = (std::map<int,int> *) 0x4D7480;
int result = (*g_lenMap)[100];

It throws "map/set iterators incompatible" assert. I can easily read and change other global variables/structures, but not std::map. What am I doing wrong?

splattru
  • 608
  • 1
  • 9
  • 19
  • 1
    Are you sure you are compiling your DLL with *exactly* the same compiler/linker and STL as was used for the EXE? If not, you may be invoking an `operator[]` that expects a different data format that what was constructed by the EXE. You may be able to work around this by finding the `std::map`'s `operator[]` function dynamically in the EXE at run time and calling it. – nobody Oct 17 '14 at 18:06
  • Both are compiled with MS visual studio, but I am not sure about version. Thank you for your answer, I will try calling operator[]. – splattru Oct 17 '14 at 18:45

0 Answers0