
Roland wrote:
BTW.: I think there is a typo in your post:
reinterpret_cast<PDWORD> ( &tls_index ), reinterpret_cast<PIMAGE_TLS_CALLBACK *> ( &callback_array ),
shouldn't they read: reinterpret_cast<DWORD> ( &tls_index ), reinterpret_cast<DWOD> ( &callback_array ),
instead?
It's just a question of which winnt.h (indirectly through windows.h) you are using. I'm using MSVC6 with original includes, possibly you have newer Platform SDK. This whole structure could be just replaced by "extern "C" DWORD _tls_used[6]; DWORD _tls_used[6] = ..." in order to avoid conflicts in the future.
However the callback never gets called for me. I tried to link with Multithreaded debug version of CRT.
I think that's because this structure is not placed in .tls section. On my computer it's executed, possibly because I have different OS (Windows Server 2003). We need to find a way to put callback address in .tls section using older compilers. B.