Working around fls limitations with too many statically linked CRTs?

微笑、不失礼 提交于 2019-12-07 06:34:58

问题


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)


回答1:


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.



来源:https://stackoverflow.com/questions/1437422/working-around-fls-limitations-with-too-many-statically-linked-crts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!