We have a dll (developed by our company, we have the source) which is hosted and loaded by another application (we don't have the source code), lately we have a lot of access violation exception because of std string:

76FAE228:000196 [76FAE3BE] RtlInitializeGenericTable (ntdll.dll)
76FADFA5:00007E [76FAE023] RtlGetCompressionWorkSpaceSize (ntdll.dll)
749714C9:000014 [749714DD] HeapLock (kernel32.dll)
730B3B4E:0000CD [730B3C1B] free (msvcr90.dll)
736A5DFB:000035 [736A5E30] ?_Tidy@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@IAEX_NI@Z (msvcp90.dll) 
736A5EBB:000009 [736A5EC4] ??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ (msvcp90.dll)

As you can see we are using Multi threaded DLL (/MD) as the runtime library and using Platform toolset v90...

We suspect that the hosting application changed the Platform toolset to newer version and what is causing the issue, the problem is that I cannot find out the Platform toolset of the hosting application (they are using Multi-threaded (/MT) as Runtime library) Process Walker didn't help as well...

How can I find the Platform toolset of the hosted application if they are using /MT?

Thanks...

有帮助吗?

解决方案

multiple solutions (worst to better order) : 1) if your dll comes with a header file, add a global inline init function that checks if _MT and _DLL are defined (see http://msdn.microsoft.com/en-us/library/vstudio/abx4dbyh.aspx)

2) you could walk the dlls loaded in the program using EnumProcessModules (http://msdn.microsoft.com/en-us/library/ms682631%28VS.85%29.aspx) and check if msvcrtxxx.dll is loaded. Be carefull though, by the time you do the ccheck, msvcrtxxx.dll might not be loaded.

3) design you dll exported method to be crt free eg do not pass classes (std::string) instances by value, crt objects (file ..etc); pointers to classes are ok if you provide a way to allocate / destroy instances;

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top