本文介绍了崩溃使用变量声明__declspec(线程)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用静态线程本地存储( __ declspec(thread))的DLL(用C编写),我想从Visual Basic图形中使用这个DLL接口。



不幸的是,当在Windows XP上运行该接口时,使用静态线程本地存储的DLL在尝试访问其线程变量时会崩溃。



如何解决这个问题?



感谢
感谢



GB



PS
我不想修改DLL。

解决方案

这是一个 TLS。尽管您没有明确地调用 LoadLibrary(),但VB运行时也是这样做的。



请注意这个限制已经从Vista解除了。我所知道的最全面的参考是Ken Johnson的。



如果您可以将DLL包含在生成的.exe的导入表中,那么可能会遇到问题,这可能涉及一些PE黑客攻击,我远远不能确定它是一个可行的策略。否则你需要更改DLL。


I have a DLL (written in C) that uses static thread local storage (__declspec(thread)), and I want to use this DLL from a Visual Basic graphic interface.

Unfortunately, when running the interface on Windows XP that DLL which use static thread local storage crashes when it try to acess its thread variables.

How can I solve this problem?

Thanks,Regards

G.B.

PSI would like to not modify the DLL.

解决方案

This is a known limitation of static TLS. Although you aren't explicitly calling LoadLibrary(), the VB runtime does so on your behalf.

Note that this limitation has been lifted from Vista. The most comprehensive reference that I know of is on Ken Johnson's blog.

You may be able to get around the problem if you could get the DLL included in the imports table of the generated .exe, which would likely involve some PE hacking and I'm far from certain it's a viable strategy. Otherwise you'll need to change the DLL.

这篇关于崩溃使用变量声明__declspec(线程)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 15:33