Home › Forums › TWAIN Classic › [Urgent] Critical issue with TWAIN DSM 2.0 and Windows Vista
- This topic has 23 replies, 3 voices, and was last updated 14 years, 2 months ago by jimwatters.
- AuthorPosts
Hi all !
I encountered a big problem calling the new TWAIN DSM (twaindsm.dll) under Windows Vista, especially sending a MSG_OPENDS to the DSM. There is no problem on Windows XP.
Here a fast way to reproduce the problem:
– Open the Twain Toolkit project under Visual C++ 2008
– Modify CDA_GLUE.C & TWACK_32.RC to use twaindsm.dll instead twain_32.dll:IN CDA_GLUE.C
Before:
lstrcat (WinDir, DSMName);Add:
lstrcat (WinDir, “System32\”);IN TWACK_32.RC
Replace:
IDS_DSMNAME “TWAIN_32.DLL”By:
IDS_DSMNAME “TWAINDSM.DLL”– Now start the project and open the default source -> The program crashes !
Here the line which cause the error in DCA_GLUE.C:
twRC = CallDSMEntry(&appID,
NULL,
DG_CONTROL,
DAT_IDENTITY,
MSG_OPENDS,
&dsID);I suppose the problem come for the twaindsm.dll library
I’ve been able to reproduce this problem on my development computer & customer computers using Windows Vista.Anybody have an idea ?
PS: I’ve uploaded the modified project here: http://www.gdpicture.com/twainorg/TWAIN_Toolkit.zip
Kind regards,
Loïc Carrère
========================
GdPicture Imaging SDK
Imaging Toolkits for developers .NET & ActiveX
http://www.gdpicture.com
Image Processing, TWAIN scanning, OCR, PDF/AWhat version of the DSM are you using? 2.0.5?
I don’t currently have access to a Vista machine to test. Can you post a log file. By setting an environment variable you can create a log file from the DSM that may help narrow down the issue.right click “My Computer” | Properties | Advanced | Environment Variables
in “User variables for yourname”, Newvariable name: TWAINDSM_LOG
Variable value: %temp%twain2.logOk | Ok | Ok
Run the sample TWAIN2 application to display the list of DS. Close.
View log file.
Start | run | %temp%twain2.log | okRegards,
Jim Watters**************************************************
JFL Peripheral Solutions Inc.
http://www.jflinc.com/
Your Expert Source of Custom Software and Services
for TWAIN Applications, Data Sources,
Peripheral Drivers and Support Software.
**************************************************Hi Jim,
First, thank you for your assistance.
I’ve made what you suggested, however the generated log become empty each time I try to open a Data Source. If I just open your demo application which open the Data Source Manager, the created log reports some operations (but I don’t think this can help you).
I’ve made test on my development computer (Vista Premium 32bit) with difference configurations:
– With / without antivirus
– With / without UAC
– Always with TWAINDSM.DLL 2.0.5
– Always using Administrator accountAll my tests fail using the TWAIN_App_mfc32.exe after trying to open a source.
See these 2 screen captures.
Step1:
I start the TWAIN_App_mfc32.exe application. The TWAIN DS are succefully listed. At this step, if I close the application a log are generated.– The capture screen: http://www.gdpicture.com/twainorg/step1.png
– The content of the log:[113006408 dsm.cpp 398 183 000015B8] TWAIN Working Group
[113006408 dsm.cpp 399 183 000015B8] TWAIN 32 Source Manager (Image Acquisition Interface)
[113006408 dsm.cpp 400 183 000015B8] version: 2.0
[113006408 dsm.cpp 2028 183 000015B8]
[113006408 dsm.cpp 2029 183 000015B8] DG_CONTROL/DAT_PARENT/MSG_OPENDSM
[113006408 apps.cpp 215 183 000015B8] Application: "App's Manufacturer"
[113006408 apps.cpp 216 183 000015B8] "App's Product Family"
[113006408 apps.cpp 217 183 000015B8] "Specific App Product Name" version: 1.0
[113006408 apps.cpp 218 183 000015B8] TWAIN 2.0
[113006409 apps.cpp 1200 127 000015B8] Could not find DS_Entry function in DS: C:Windowstwain_32wiatwain.ds
[113006409 apps.cpp 528 127 000015B8] Condition Code: DS or DSM reported error, application shouldn't
[113006410 apps.cpp 1213 0 000015B8] Loaded library: C:Windowstwain_32escndvperv200.ds
[113006413 apps.cpp 1213 0 000015B8] Loaded library: C:Windowstwain_32HP559TWHP559TW.DS
[113006417 apps.cpp 1213 0 000015B8] Loaded library: C:Windowstwain_32hpsj_0000hpsj_0000.ds
[113006420 apps.cpp 1213 0 000015B8] Loaded library: C:Windowstwain_32hpsj_0003hpsj_0003.ds
[113006421 dsm.cpp 596 18 000015B8] TWRC_SUCCESS
[113006421 dsm.cpp 2028 18 000015B8]
[113006421 dsm.cpp 2029 18 000015B8] DG_CONTROL/DAT_NULL/MSG_GET
[113006421 dsm.cpp 596 18 000015B8] TWRC_SUCCESS
[113006421 dsm.cpp 2028 18 000015B8]
[113006421 dsm.cpp 2029 18 000015B8] DG_CONTROL/DAT_IDENTITY/MSG_GETFIRST
[113006421 dsm.cpp 596 18 000015B8] TWRC_SUCCESS
[113006421 dsm.cpp 2028 18 000015B8]
[113006421 dsm.cpp 2029 18 000015B8] DG_CONTROL/DAT_IDENTITY/MSG_GETNEXT
[113006421 dsm.cpp 596 18 000015B8] TWRC_SUCCESS
[113006421 dsm.cpp 2028 18 000015B8]
[113006421 dsm.cpp 2029 18 000015B8] DG_CONTROL/DAT_IDENTITY/MSG_GETNEXT
[113006421 dsm.cpp 596 18 000015B8] TWRC_SUCCESS
[113006421 dsm.cpp 2028 18 000015B8]
[113006421 dsm.cpp 2029 18 000015B8] DG_CONTROL/DAT_IDENTITY/MSG_GETNEXT
[113006421 dsm.cpp 596 18 000015B8] TWRC_SUCCESS
[113006421 dsm.cpp 2028 18 000015B8]
[113006421 dsm.cpp 2029 18 000015B8] DG_CONTROL/DAT_IDENTITY/MSG_GETNEXT
[113006421 dsm.cpp 596 18 000015B8] TWRC_ENDOFLIST
[113006421 dsm.cpp 2028 18 000015B8]
[113006421 dsm.cpp 2029 18 000015B8] DG_CONTROL/DAT_IDENTITY/MSG_GETDEFAULT
[113006421 dsm.cpp 596 18 000015B8] TWRC_SUCCESS
[113006421 dsm.cpp 2028 0 000015B8]
[113006421 dsm.cpp 2029 0 000015B8] DG_CONTROL/DAT_PARENT/MSG_CLOSEDSM
[113006421 dsm.cpp 596 0 000015B8] TWRC_SUCCESSStep2:
If I try to open a TWAIN DS (I’ve tested with all) the application simply crashes and the generated log is empty.
See the screenshot: http://www.gdpicture.com/twainorg/step2.png
I’ve made other tests:
– Using my own TWAIN dll based on the twain toolkit: fail when sending MSG_OPENDS If link to twaindsm.dll, success if I link the twain_32.dll.– Using the twack_32 exe: fail when sending MSG_OPENDS If link to twaindsm.dll, success if I link the twain_32.dll.
One strange behaviour: If I call my own twain dll (based on TWAIN toolkit) from a vb.net / c# application, the crash occurs. If I call the dll from a vb6 application: no problem ! Maybe this detail can help…
I hope I was clear enough. If you need more details or deeper test I will be happy to assist.
I’ve past many hours on this issue and my conclusion is that there is a problem with the last DSM & Vista (but maybe I’am wrong ). 🙂Kind regards,
Loïc Carrère
PS: Full success under Windows XP
========================
GdPicture Imaging SDK
Imaging Toolkits for developers .NET & ActiveX
http://www.gdpicture.com
Image Processing, TWAIN scanning, OCR, PDF/AHi again Jim.
Finally I found the reason !
On Vista, when computer is set to apply DEP to all programs and services the TWAINDSM.DLL crash the calling application on a MSG_OPENDS request.
I was able to reproduce the problem on all my Vista computers.
A solution is to switch the DEP for Windows programs & services only (the default configuration I think):
# Click Start, click Run, type sysdm.cpl, and then click OK.
# Click the Advanced tab, click Performance, and then click Settings.
# In Performance Options, click the Data Execution Prevention tab, and select the first option, then apply.I think it is a critical issue for the twaindsm.dll which should be resolved 😀 .
Kind regards,
Loïc
========================
GdPicture Imaging SDK
Imaging Toolkits for developers .NET & ActiveX
http://www.gdpicture.com
Image Processing, TWAIN scanning, OCR, PDF/AThank you.
I thought I found the issue but not sure.
After some searching I discovered that there is a know issue with version 7.1 of ATL causing DEP. But the DSM is not using ATL. It maybe the DS or one of the libraries that the DS loads is using this.Do you have issues if you open other DS?
Regards,
Jim Watters**************************************************
JFL Peripheral Solutions Inc.
http://www.jflinc.com/
Your Expert Source of Custom Software and Services
for TWAIN Applications, Data Sources,
Peripheral Drivers and Support Software.
**************************************************Great new for everybody !
Thank you Jim.
Regards,
Loïc
========================
GdPicture Imaging SDK
Imaging Toolkits for developers .NET & ActiveX
http://www.gdpicture.com
Image Processing, TWAIN scanning, OCR, PDF/ASorry. I updated my reply to be less positive. But you managed to read and reply before I could post the updated version.
Ok Jim!
What I tried is to open any DS using the TWAIN_App_mfc32.exe from http://sourceforge.net/project/showfiles.php?group_id=212173
I tried on 3 different Vista computers with 6 different Twain drivers. All my tests crash when I try to open a source.
Also, my personal twain library generating the same crash doesn’t use ATL.
I will make other test this afternoon using the TWAIN_App_mfc32.exe & the TWAIN 2.0 Sample Data Source.
Kind regards,
Loïc
========================
GdPicture Imaging SDK
Imaging Toolkits for developers .NET & ActiveX
http://www.gdpicture.com
Image Processing, TWAIN scanning, OCR, PDF/AHI Jim,
Me again…
I’ve tested the TWAIN2 datasource which uses FreeImage -> Full success on all my Vista computers in all configuration.
However, I have 6 TWAIN drivers and all crash on the DSOPEN.
Here the 6 TWAIN drivers I tested:
– EPSON Perfect V200
– HP Commercial Scanjet 5590 (from ECM)
– HP psc 2200
– HP Scanjet 5590
– Canon DR 9080C
– Canon DR 6080I don’t know if the problem can be fixed into the twaindsm.dll library but it is hard to tell to my customers that the problem come from the drivers because all is working fine if I use the twain_32.dll DSM
Kind regards,
Loïc Carrère
========================
GdPicture Imaging SDK
Imaging Toolkits for developers .NET & ActiveX
http://www.gdpicture.com
Image Processing, TWAIN scanning, OCR, PDF/ALoïc,
A new version of the Data Source Manager has been released that may help with this issue. If the crash still happens can you post an new log file.
You can install the latest DSM by installing the sample Application.
https://sourceforge.net/project/showfiles.php?group_id=212173Regards,
Jim Watters**************************************************
JFL Peripheral Solutions Inc.
http://www.jflinc.com/
Your Expert Source of Custom Software and Services
for TWAIN Applications, Data Sources,
Peripheral Drivers and Support Software.
**************************************************OK Jim. Let’s go !
Loïc
========================
GdPicture Imaging SDK
Imaging Toolkits for developers .NET & ActiveX
http://www.gdpicture.com
Image Processing, TWAIN scanning, OCR, PDF/AHi again.
Unfortunately the problem is exactly the same.
With Data Execution Prention (DEP) turned to:
1- for essential Windows programs and services only
➡ No problem !2 – for all programs and services.
When I click on the “”Connect to Data Source” button, the app is closed by Windows and this message are displayed (by Windows):
Sample TWAIN Application was closed
To help protect your computer, Data Execution
Prevention has closed Sample TWAIN Application.A log file is created, but empty.
The problem appears with all my other DS but NOT with the “TWAIN2 FreeImage Software Scanner”.
It should be great if one the the TWAIN DSM developers could be able to reproduce the issue to bring a deeper investigation.
Here a simple way to reproduce the problem:
– Install Windows Vista (any 32 bit editions French or US tested from my side including home edition, ultimate & pro.)
– Switch the DEP for all programs: Control Pannel / System / Advanced System Settings / Advances tab / Settings… / Data Execution Prevention tab / Select Turn on Dep for all programs and services excepted those I select.
– Download & install canon dr9080c DS from http://software.canon-europe.com/software/0025504.asp (don’t need the scanner)
– Copy TWAINDSM.DLL into c:windowssystem32
– Install TWAIN 2.0 Sample Application 2.0.6
– Run TWAIN2 Sample App
– Select Canon DR-9080C TWAIN
– Click on “Connect to Data Source”
– Crash…Again, thank you for the time you spent on this issue. If there is anything I can do I will be happy to help.
Kind regards,
Loïc
========================
GdPicture Imaging SDK
Imaging Toolkits for developers .NET & ActiveX
http://www.gdpicture.com
Image Processing, TWAIN scanning, OCR, PDF/AI installed the Canon DS to try and run in simulation mode.
OpenDS does not cause any crash for me, but I do get a dialog to Configure Device Settings. Selected Device: No Devices Found.
If I click OK or Cancel, “Can’t locate device; check cable and power. (-4536)”
The DS then returns TWRC_FAILURE
Is something else required to run in simulation mode?The source code for the TWAINDSM.dll is available. you could try building it and stepping through the code to see what is happening.
https://sourceforge.net/project/showfiles.php?group_id=180588&package_id=265942
line 1127 of dsm.cpp is where the DS is sent the MSG_OPENDS message.Maybe these DS can not handle Application identity structure with DF_DSM2 flag. Or one of the TW_STR32 of the identity structure that are not NULL terminated and the DS does a strcpy without limiting the number of characters copied.
Jim Watters
Hi Jim,
I will go through the twaindsm.dll source code to see if I can can do something.
Thank you for your test, but did you turned the DEP for all programs ?
Control Pannel / System / Advanced System Settings / Advances tab / Settings… / Data Execution Prevention tab / Select Turn on Dep for all programs and services excepted those I select.
Like I said before, with this DEP configuration the lib crashes, with the other one this is running perfectly.
Hey, I guess there is a unallocated memory access issue by the twaindsm lib 😉
Kind regards,
Loïc
========================
GdPicture Imaging SDK
Imaging Toolkits for developers .NET & ActiveX
http://www.gdpicture.com
Image Processing, TWAIN scanning, OCR, PDF/AOK I found it. A hook problem.
In apps.cpp:
pDSInfo->pHandle = LOADLIBRARY(_pPath,hook,_DsId);
When hook is not null, the lib crashes.
If I add before:
hook = 0;
All is running fine (and this solve another issue I had using an unmanaged dll from a managed app).
Someone can investigate ?
I can give any help (distant access, tests on any windows edition…)
Kind regards,
Loïc
========================
GdPicture Imaging SDK
Imaging Toolkits for developers .NET & ActiveX
http://www.gdpicture.com
Image Processing, TWAIN scanning, OCR, PDF/A- AuthorPosts