Hello,
for 64-Bit, the code in dlls/twain_32 should be compiled into a library installed as twaindsm.dll instead of twain_32.dll, since Windows applications do expect a 64-Bit Data Source Manager to be named twaindsm.dll.
How could that be done?
Background:
wine includes an interface from the TWAIN interface common in Windows to the SANE interface common on Linux. This is dlls/sane.ds, which is in TWAIN speak a "Data Source". This allows to use most scanners supported by SANE from WINE, without caring about any special drivers. Which is a pretty cool thing.
64 Bit TWAIN is somewhat exotic, since Microsoft is pushing towards their WIA interface and does not include a 64-Bit Data Source Manager with Windows. The 32-Bit Data Source Manager shipped with Windows is TWAIN_32.DLL.
This DLL is under control of Microsoft and the TWAIN organization cannot update it, so they choose to name their update DSM "twaindsm.dll". I found some more information on that here:
https://github.com/twain/twain-dsm/blob/master/TWAIN_DSM/src/readme.doc%5D(h...)
This twaindsm.dll is available in 32-Bit and 64-Bit. And so the only 64-Bit DSM that application programs expect is twaindsm.dll. There are hardly any 64-Bit TWAIN drivers available on Windows.
Irfanview 64-Bit uses twaindsm.dll if installed and spawns a 32-Bit EXE if not.
Older versions of 64-Bit Libreoffice for Windows used twaindsm.dll. New Versions start a 32-Bit process to use 32-Bit TWAIN.
The code in the dlls/sane.ds searches for "twain_32", and I know two ways to solve this.
What I don't know is how to change wine so that it compiles dlls/twain_32 to twaindsm.dll for 64-Bit Builds only and deploy that dll to the wine prefix.
Any suggestion of how to do that?
Yours
Bernd Herd
:-)
We can't just disable in configure based on host arch, because in the case of new wow64 we'll be building for i386 and x86_64 in the same tree.
I think we want to do two things:
Use the PARENTSRC feature to create two dlls, twain_32 and twaindsm, that share the same source files.
Disable one or the other dll by default, based on architecture. In theory, this can be done in configure. One can, if I'm reading this right, use a configure switch like --enable-twain_32=i386 --enable-twaindsm=x86_64,arm64ec,arm,aarch64. Although, it seems like twaindsm.dll exists in 32-bit as well, so it should probably be built for all architectures.
As for how to actually do that, I think we want to set enable_twain_32 in configure.ac, only when it hasn't been already set by the user. See enable_dpnsvr for an example of this.
On 2025-11-08 12:42, Bernd Herd wrote:
Hello,
for 64-Bit, the code in dlls/twain_32 should be compiled into a library installed as twaindsm.dll instead of twain_32.dll, since Windows applications do expect a 64-Bit Data Source Manager to be named twaindsm.dll.
How could that be done?
Background:
wine includes an interface from the TWAIN interface common in Windows to the SANE interface common on Linux. This is dlls/sane.ds, which is in TWAIN speak a "Data Source". This allows to use most scanners supported by SANE from WINE, without caring about any special drivers. Which is a pretty cool thing.
64 Bit TWAIN is somewhat exotic, since Microsoft is pushing towards their WIA interface and does not include a 64-Bit Data Source Manager with Windows. The 32-Bit Data Source Manager shipped with Windows is TWAIN_32.DLL.
This DLL is under control of Microsoft and the TWAIN organization cannot update it, so they choose to name their update DSM "twaindsm.dll". I found some more information on that here:
https://github.com/twain/twain-dsm/blob/master/TWAIN_DSM/src/readme.doc%5D(h...)
This twaindsm.dll is available in 32-Bit and 64-Bit. And so the only 64-Bit DSM that application programs expect is twaindsm.dll. There are hardly any 64-Bit TWAIN drivers available on Windows.
Irfanview 64-Bit uses twaindsm.dll if installed and spawns a 32-Bit EXE if not.
Older versions of 64-Bit Libreoffice for Windows used twaindsm.dll. New Versions start a 32-Bit process to use 32-Bit TWAIN.
The code in the dlls/sane.ds searches for "twain_32", and I know two ways to solve this.
What I don't know is how to change wine so that it compiles dlls/twain_32 to twaindsm.dll for 64-Bit Builds only and deploy that dll to the wine prefix.
Any suggestion of how to do that?
Yours
Bernd Herd
:-)
On Monday, 10 November 2025 09:23:37 CST Esme Povirk wrote:
We can't just disable in configure based on host arch, because in the case of new wow64 we'll be building for i386 and x86_64 in the same tree.
I think we want to do two things:
Use the PARENTSRC feature to create two dlls, twain_32 and twaindsm, that share the same source files.
Disable one or the other dll by default, based on architecture. In theory, this can be done in configure. One can, if I'm reading this right, use a configure switch like --enable-twain_32=i386 --enable-twaindsm=x86_64,arm64ec,arm,aarch64. Although, it seems like twaindsm.dll exists in 32-bit as well, so it should probably be built for all architectures.
As for how to actually do that, I think we want to set enable_twain_32 in configure.ac, only when it hasn't been already set by the user. See enable_dpnsvr for an example of this.
If I'm not mistaken, we can do much simpler, and just rename it from wine.inf. As of ad9dfe8bcc we look for the builtin by its export name, which will still be twain_32 in that case. That was meant for comctl32, but I think it works in the reverse direction as well.
Whether we should actually do this seems a bit questionable to me, if Windows doesn't actually ship twaindsm.dll, and if twaindsm.dll is presumably a different piece of software that is even LGPL 2.1 licensed.