Fix twain device handle corruption
Francois Gouget
fgouget at codeweavers.com
Thu Sep 9 06:07:02 CDT 2004
Calling TWAIN_CapabilityGet() was corrupting the SANE device handle. The
reason is that it calls TWAIN_SaneCapability() which is implemented in
capability.c which does not include config.h. This means the activeDS
had a different layout because HAVE_SANE was not defined. So when
TWAIN_SaneCapability() was setting capXferMech it was in fact
overwriting part of deviceHandle.
So what I have done is move all the 'optional' SANE fields to the end of
the structure. This way it does not matter if files that don't need SANE
don't include config.h.
There are other ways to deal with this:
* one would be to include config.h in twain_i.h but IMO this one is no
good because we should always include config.h first or not at all and
we have no garantee twain_i.h will be included first.
* or we could check that config.h has been included first using
something like:
#ifndef __WINE_CONFIG_H
# error You must include config.h first
#endif
Let me know if one of these other approaches would be better.
Changelog:
* dlls/twain/twain_i.h
Francois Gouget <fgouget at codeweavers.com>
Move the SANE fields to the end of activeDS so they don't get
corrupted if a C file does not include config.h.
--
Francois Gouget
fgouget at codeweavers.com
-------------- next part --------------
Index: dlls/twain/twain_i.h
===================================================================
RCS file: /var/cvs/wine/dlls/twain/twain_i.h,v
retrieving revision 1.4
diff -u -r1.4 twain_i.h
--- dlls/twain/twain_i.h 5 Sep 2003 23:08:30 -0000 1.4
+++ dlls/twain/twain_i.h 9 Sep 2004 10:54:20 -0000
@@ -38,13 +38,17 @@
application */
TW_UINT16 twCC; /* condition code */
HWND hwndOwner; /* window handle of the app */
+ /* Capabiblities */
+ TW_UINT16 capXferMech; /* ICAP_XFERMECH */
+
#ifdef HAVE_SANE
+ /* Make sure these are last so it's not such a big deal
+ * if we don't include config.h in some C file.
+ */
SANE_Handle deviceHandle; /* device handle */
SANE_Parameters sane_param; /* parameters about the image
- transfered */
+ transferred */
#endif
- /* Capabiblities */
- TW_UINT16 capXferMech; /* ICAP_XFERMECH */
} activeDS;
TW_UINT16 DSM_initialized; /* whether Source Manager is initialized */
More information about the wine-patches
mailing list