The TWAIN Forum

www.twainforum.org
It is currently Thu Apr 24, 2014 9:43 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 24 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Wed Apr 22, 2009 8:57 am 
Offline

Joined: Thu Oct 05, 2006 1:24 pm
Posts: 17
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:




Code:
         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/A


Last edited by lcarrere on Fri Jun 12, 2009 9:59 am, edited 2 times in total.

Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 23, 2009 7:20 am 
Offline

Joined: Fri Nov 04, 2005 7:36 am
Posts: 74
Location: Saint John, New Brunswick, Canada
What 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", New

variable name: TWAINDSM_LOG
Variable value: %temp%\twain2.log

Ok | Ok | Ok

Run the sample TWAIN2 application to display the list of DS. Close.

View log file.
Start | run | %temp%\twain2.log | ok

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.
**************************************************


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 25, 2009 2:55 am 
Offline

Joined: Thu Oct 05, 2006 1:24 pm
Posts: 17
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 account

All 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:

Code:
[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:\Windows\twain_32\wiatwain.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:\Windows\twain_32\escndv\perv200.ds

[113006413 apps.cpp 1213     0 000015B8] Loaded library: C:\Windows\twain_32\HP559TW\HP559TW.DS

[113006417 apps.cpp 1213     0 000015B8] Loaded library: C:\Windows\twain_32\hpsj_0000\hpsj_0000.ds

[113006420 apps.cpp 1213     0 000015B8] Loaded library: C:\Windows\twain_32\hpsj_0003\hpsj_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_SUCCESS



Step2:

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/A


Last edited by lcarrere on Fri Jun 12, 2009 9:59 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 25, 2009 3:57 am 
Offline

Joined: Thu Oct 05, 2006 1:24 pm
Posts: 17
Hi 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 :D .

Kind regards,

Loïc


========================
GdPicture Imaging SDK
Imaging Toolkits for developers .NET & ActiveX
http://www.gdpicture.com
Image Processing, TWAIN scanning, OCR, PDF/A


Last edited by lcarrere on Fri Jun 12, 2009 9:59 am, edited 3 times in total.

Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 27, 2009 7:35 am 
Offline

Joined: Fri Nov 04, 2005 7:36 am
Posts: 74
Location: Saint John, New Brunswick, Canada
Thank 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.
**************************************************


Last edited by jimwatters on Mon Apr 27, 2009 8:04 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 27, 2009 7:44 am 
Offline

Joined: Thu Oct 05, 2006 1:24 pm
Posts: 17
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/A


Last edited by lcarrere on Fri Jun 12, 2009 10:00 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 27, 2009 8:07 am 
Offline

Joined: Fri Nov 04, 2005 7:36 am
Posts: 74
Location: Saint John, New Brunswick, Canada
Sorry. I updated my reply to be less positive. But you managed to read and reply before I could post the updated version.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 27, 2009 8:16 am 
Offline

Joined: Thu Oct 05, 2006 1:24 pm
Posts: 17
Ok Jim!

What I tried is to open any DS using the TWAIN_App_mfc32.exe from http://sourceforge.net/project/showfile ... _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/A


Last edited by lcarrere on Fri Jun 12, 2009 10:00 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 27, 2009 10:33 am 
Offline

Joined: Thu Oct 05, 2006 1:24 pm
Posts: 17
HI 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 6080

I 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/A


Last edited by lcarrere on Fri Jun 12, 2009 10:00 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 10, 2009 7:44 am 
Offline

Joined: Fri Nov 04, 2005 7:36 am
Posts: 74
Location: Saint John, New Brunswick, Canada
Loï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/showfil ... _id=212173


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.
**************************************************


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 10, 2009 7:46 am 
Offline

Joined: Thu Oct 05, 2006 1:24 pm
Posts: 17
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/A


Last edited by lcarrere on Fri Jun 12, 2009 10:00 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 10, 2009 8:28 am 
Offline

Joined: Thu Oct 05, 2006 1:24 pm
Posts: 17
Hi again.

Unfortunately the problem is exactly the same.


With Data Execution Prention (DEP) turned to:

1- for essential Windows programs and services only

:arrow: 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):

Quote:
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:\windows\system32\
- 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/A


Last edited by lcarrere on Fri Jun 12, 2009 10:00 am, edited 2 times in total.

Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 10, 2009 2:30 pm 
Offline

Joined: Fri Nov 04, 2005 7:36 am
Posts: 74
Location: Saint John, New Brunswick, Canada
I 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/showfil ... _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


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 10, 2009 11:46 pm 
Offline

Joined: Thu Oct 05, 2006 1:24 pm
Posts: 17
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 :wink:

Kind regards,

Loïc


========================
GdPicture Imaging SDK
Imaging Toolkits for developers .NET & ActiveX
http://www.gdpicture.com
Image Processing, TWAIN scanning, OCR, PDF/A


Last edited by lcarrere on Fri Jun 12, 2009 10:01 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 11, 2009 2:42 am 
Offline

Joined: Thu Oct 05, 2006 1:24 pm
Posts: 17
OK 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


Last edited by lcarrere on Fri Jun 12, 2009 10:01 am, edited 1 time in total.

Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 24 posts ]  Go to page 1, 2  Next

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group