Usage limitations during the DllMain Attach and Detach process(DllMain 附加和分离过程中的使用限制)
问题描述
我的一位同事在 DllMain Detach 过程中遇到了麻烦.他的错误似乎并非在所有情况下都会出现,但相当频繁.
One colleague of mine has troubles during the DllMain Detach process. His bug seems not to appear in all cases, but fairly often.
在尝试帮助他的过程中,我想起了一些在 DllMain 附加和分离过程中的使用限制,但我不确定我是否记得清楚,因为这是 2 年前的技术讨论并且不是我在处理那些终止问题.
While trying to help him, I kind of remembered of some usage limitations during the DllMain Attach and Detach process, but I am not sure I remember well since it was 2 year old technical discussions and it was not me working on thoses termination issues.
也就是说,我记得我们应该:
Namely I kind of remember that we should:
- 避免使用 new 和 delete 运算符,更喜欢 HGLOBAL 内存分配
- 避免在此处处理线程终止.
如果我错了,你能不能纠正我,解释一下,或者指出一篇可以解决这些问题的技术文章.
Could you correct me if I am wrong, explain me if ever, or point to a technical article that would deal with these issues.
推荐答案
避免调用 LoadLibrary 和相关 API.
Avoid calling LoadLibrary and related APIs.
除了 Steve 的链接之外,这里还有一些来自 Raymond Chen 的The Old New Thing:
In addition to Steve's link, here are some good relevant posts from Raymond Chen's The Old New Thing:
- https://devblogs.microsoft.com/oldnewthing/20040127-00/?p=40873
- https://devblogs.microsoft.com/oldnewthing/20040128-00/?p=40853
- https://devblogs.microsoft.com/oldnewthing/20070904-00/?p=25283
- https://devblogs.microsoft.com/oldnewthing/20100115-00/?p=15253
这篇关于DllMain 附加和分离过程中的使用限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:DllMain 附加和分离过程中的使用限制
基础教程推荐
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- 初始化列表*参数*评估顺序 2021-01-01
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
- CString 到 char* 2021-01-01
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
