views:

48

answers:

1

When loading external DLLs (not under our control) via LoadLibrary, we're hitting a problem where the statically linked CRT in those DLLs are failing to allocate fiber-local storage. This is similar to mskb 193462, except that this is FLS and there's only 128 of them.

Are there any useful ways to work around the problem? The CRT is using GetProcAddress to find FlsAlloc anyway (since that apparently never existed in XP), so does it even really need it?

(This is on Vista, where FlsAlloc actually exists; the DLLs appear to be using MSVC8)

A: 

There is frankly no solution here, short of loading less dlls.

You could hook the dll's import address table - but that will happen too late as you can only install an IAT hook when LoadLibrary returns, and the CRT initialization code probably executes in response to DllProcessAttach which will already have been processed.

You could I guess find the kernel32.dll module in memory, and patch the export address for GetProcAddress or perhaps FlsAlloc to point to your implementation. But that approach is getting seriously hackish.

Chris Becke
Went with the temporary solution of cutting out things and hoping we won't need too much more :( Trying to patch FlsAlloc is just too scary, though since most of those DLLs are loaded at runtime (via LoadLibrary) it's probably technically possible.
Mook