mor*_*nlf 5 c++ com dll regsvr32 visual-leak-detector
我正在开发一个包含多个C++ COM Dll的遗留项目.每次在调试配置上构建解决方案时,构建过程都会为每个COM项目提供错误:
Error 10 error MSB3073: The command "
regsvr32 /s /c "D:\*****removed intentionally****_d.dll"
echo regsvr32 exec. time > ".\Debug\regsvr32.trg"
echo Server registration done!
:VCEnd
" exited with code -1073741819.
Run Code Online (Sandbox Code Playgroud)
我最近加入了这个项目,所以当我询问它时,我被告知每个人都会忽略这些错误,因为解决方案在第二个版本上成功构建.
我决定深入挖掘,似乎COM注册本身成功(这解释了为什么第二个版本没有重新尝试注册),但是对regsvr32的调用会返回错误代码(0xC0000005).这就是构建失败的原因.
我还试图从自定义构建步骤中删除注册,而是选择从链接器属性表"注册输出=是"注册,并得到相同的错误.
我尝试用其中一个dll调试regsvr32并找到以下内容:
我最初无法在DllRegisterServer中放置断点,然后我尝试调试regsvr32的X86版本(来自Windows\SysWOW64),然后才能在DllRegisterServer上中断.有人可以解释一下吗?
DllRegisterServer成功并返回S_OK.
DllRegisterServer返回后,抛出异常,并出现以下异常和堆栈跟踪:
regsvr32.exe中0x759849c1处的第一次机会异常:0xC0000005:访问冲突读取位置0x005bf028.
oleaut32.dll!_MemFree@4() + 0x25 bytes
oleaut32.dll!OLE_TYPEMGR::Release() + 0x1b138 bytes
oleaut32.dll!ReleaseAppData() + 0x317 bytes
oleaut32.dll!_OACleanup@0() + 0x5 bytes
ole32.dll!wCoUninitialize(COleTls & Tls, int fHostThread) Line 2830 C++
ole32.dll!CoUninitialize() Line 2620 C++
regsvr32.exe!_wWinMain@16() + 0xa77 bytes
regsvr32.exe!__initterm_e() + 0x1b1 bytes
kernel32.dll!@BaseThreadInitThunk@12() + 0x12 bytes
ntdll.dll!___RtlUserThreadStart@8() + 0x27 bytes
ntdll.dll!__RtlUserThreadStart@8() + 0x1b bytes
Run Code Online (Sandbox Code Playgroud)
那么你对此有何看法?我是否应该像团队的其他成员一样忽略它(产品在开发和生产中运行良好)?
您是否知道为什么即使注册成功我也会收到访问冲突?COM dll注册后是否还有其他进程/逻辑?任何其他方向?
这是处理注册的类的代码:
CComModule _Module;
BEGIN_OBJECT_MAP(ObjectMap)
OBJECT_ENTRY(CLSID_C3DT2D, CC3DT2D)
END_OBJECT_MAP()
class CMy3DT2DApp : public CWinApp
{
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMy3DT2DApp)
public:
virtual BOOL InitInstance();
virtual int ExitInstance();
//}}AFX_VIRTUAL
//{{AFX_MSG(CMy3DT2DApp)
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
BEGIN_MESSAGE_MAP(CMy3DT2DApp, CWinApp)
//{{AFX_MSG_MAP(CMy3DT2DApp)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
CMy3DT2DApp theApp;
BOOL CMy3DT2DApp::InitInstance()
{
_Module.Init(ObjectMap, m_hInstance, &LIBID_MY3DT2DLib);
return CWinApp::InitInstance();
}
int CMy3DT2DApp::ExitInstance()
{
_Module.Term();
return CWinApp::ExitInstance();
}
/////////////////////////////////////////////////////////////////////////////
// Used to determine whether the DLL can be unloaded by OLE
STDAPI DllCanUnloadNow(void)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
return (AfxDllCanUnloadNow()==S_OK && _Module.GetLockCount()==0) ? S_OK : S_FALSE;
}
/////////////////////////////////////////////////////////////////////////////
// Returns a class factory to create an object of the requested type
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
{
return _Module.GetClassObject(rclsid, riid, ppv);
}
/////////////////////////////////////////////////////////////////////////////
// DllRegisterServer - Adds entries to the system registry
STDAPI DllRegisterServer(void)
{
// registers object, typelib and all interfaces in typelib
return _Module.RegisterServer(TRUE);
}
/////////////////////////////////////////////////////////////////////////////
// DllUnregisterServer - Removes entries from the system registry
STDAPI DllUnregisterServer(void)
{
return _Module.UnregisterServer(TRUE);
}
Run Code Online (Sandbox Code Playgroud)
显然,罪魁祸首是一个名为Visual Leak Detector 的工具,它在包含到源文件中时会附加自身。
我们从一个新的 ATL 项目(如 manuell 建议的那样)开始发现了它,并一步一步地添加了功能。当我们添加一些链接到另一个包含 vld.h 的 dll 的代码时,就会返回注册错误。
因此,我们删除了对 VLD 的所有引用,现在我们很高兴注册,即使使用原始发布的代码也是如此。
我们甚至发现了这个小美人......
感谢大家的帮助!
| 归档时间: |
|
| 查看次数: |
1905 次 |
| 最近记录: |