Home › Forums › TWAIN Classic › Data Source DLL not being unloaded
- This topic has 2 replies, 2 voices, and was last updated 14 years, 5 months ago by jimwatters.
- AuthorPosts
I’m debugging a rather nasty problem in a TWAIN application and thought I’d post a description here in case it sounds familiar and anyone has a suggestion. My next step is likely to try to build and use a debug version of the DSM so that I can see exactly what’s happening.
Basically, the DLL of the Source that I’m using — the test Source from TWAIN 1.0 — is not being unloaded when it’s closed. The program I’m working on has extensive tracing in place. Here are some selected fragments from the Debug output:
09:38:45 (TWAIN): DSM_Entry 1 => DSM (DG_CONTROL / DAT_IDENTITY / MSG_OPENDS) pData: 0x0274EC50
‘mstsc.exe’: Loaded ‘C:WINDOWStwain_32sample_datasourcetwsrc_32.ds’
‘mstsc.exe’: Unloaded ‘C:WINDOWStwain_32sample_datasourcetwsrc_32.ds’
‘mstsc.exe’: Loaded ‘C:WINDOWStwain_32.dll’
‘mstsc.exe’: Loaded ‘C:WINDOWStwain_32sample_datasourcetwsrc_32.ds’
InitializeCaps: initialized 41 capabilities.
09:38:45 (TWAIN): DSM_Entry 1 <= DSM (DG_CONTROL / DAT_IDENTITY / MSG_OPENDS) TWRC_SUCCESS pData: 0x0274EC50 … and then later, after enabling the Source UI, “scanning”, and disabling it, all without error … 09:38:57 (TWAIN): DSM_Entry 1 => 2 (DG_CONTROL / DAT_IDENTITY / MSG_CLOSEDS) pData: 0x02666270
FreeCaps: finished cleanup.
09:38:57 (TWAIN): DSM_Entry 1 <= 2 (DG_CONTROL / DAT_IDENTITY / MSG_CLOSEDS) TWRC_SUCCESS pData: 0x02666270 Notice the lack of an “Unloaded” message. The application is 32-bit, but I’m running on a 64-bit machine. The 32-bit TWAIN 2.0.9 DSM is being used: ‘mstsc.exe’: Loaded ‘C:WINDOWSSysWOW64TWAINDSM.dll’ Everything works OK until the application is shut down During termination of some thread, the application crashes in CRT code during thread cleanup. I’m not 100% certain that it is caused by this DLL, but the crash always occurs just after TWAINDSM is unloaded. TWSRC_32 is apparently never unloaded. When I change the point at which I unload TWAINDSM, the crash moves to a different thread. Any thoughts or ideas would be most welcome.I figured it out. Having the DSM source code available helped immensely.
I had a programming error that caused the MSG_CLOSEDS to be directed at the DS rather than the DSM. The DSM happily passes this on to the DS, producing a successful result, but doesn’t do its post-processing — including unloading the DS’s DLL.
After groping through all the code that works around the TWAIN_32.DLL compatibility issues, I understand why the symptoms were so bizarre.
Was this an application that you updated from using the older DSM?
I am wondering if TWAIN_32.DLL handled the MSG_CLOSEDS in the same way.Jim Watters
- AuthorPosts