Commit 1dd462b6 authored by Alexandre Julliard's avatar Alexandre Julliard

twain_32: Fix loading of TWAIN source modules.

parent 8f70855f
...@@ -40,7 +40,7 @@ static HWND DSM_parent; ...@@ -40,7 +40,7 @@ static HWND DSM_parent;
static UINT event_message; static UINT event_message;
struct all_devices { struct all_devices {
char *modname; WCHAR *modname;
TW_IDENTITY identity; TW_IDENTITY identity;
}; };
...@@ -48,21 +48,23 @@ static int nrdevices = 0; ...@@ -48,21 +48,23 @@ static int nrdevices = 0;
static struct all_devices *devices = NULL; static struct all_devices *devices = NULL;
static void static void
twain_add_onedriver(const char *dsname) { twain_add_onedriver(const WCHAR *dsname) {
HMODULE hmod; HMODULE hmod;
DSENTRYPROC dsEntry; DSENTRYPROC dsEntry;
TW_IDENTITY fakeOrigin; TW_IDENTITY fakeOrigin;
TW_IDENTITY sourceId; TW_IDENTITY sourceId;
TW_UINT16 ret; TW_UINT16 ret;
WCHAR path[MAX_PATH];
hmod = LoadLibraryA(dsname); swprintf( path, MAX_PATH, L"c:\\windows\\twain_%u\\%s", sizeof(void *) * 8, dsname );
hmod = LoadLibraryW(path);
if (!hmod) { if (!hmod) {
ERR("Failed to load TWAIN Source %s\n", debugstr_a(dsname)); ERR("Failed to load TWAIN Source %s\n", debugstr_w(path));
return; return;
} }
dsEntry = (DSENTRYPROC)GetProcAddress(hmod, "DS_Entry"); dsEntry = (DSENTRYPROC)GetProcAddress(hmod, "DS_Entry");
if (!dsEntry) { if (!dsEntry) {
ERR("Failed to find DS_Entry() in TWAIN DS %s\n", debugstr_a(dsname)); ERR("Failed to find DS_Entry() in TWAIN DS %s\n", debugstr_w(path));
return; return;
} }
/* Loop to do multiple detects, mostly for sane.ds and gphoto2.ds */ /* Loop to do multiple detects, mostly for sane.ds and gphoto2.ds */
...@@ -87,12 +89,8 @@ twain_add_onedriver(const char *dsname) { ...@@ -87,12 +89,8 @@ twain_add_onedriver(const char *dsname) {
} }
if (i < nrdevices) if (i < nrdevices)
break; break;
if (nrdevices) devices = realloc( devices, sizeof(devices[0])*(nrdevices+1) );
devices = HeapReAlloc(GetProcessHeap(), 0, devices, sizeof(devices[0])*(nrdevices+1)); devices[nrdevices].modname = wcsdup( path );
else
devices = HeapAlloc(GetProcessHeap(), 0, sizeof(devices[0]));
if ((devices[nrdevices].modname = HeapAlloc(GetProcessHeap(), 0, strlen(dsname) + 1)))
lstrcpyA(devices[nrdevices].modname, dsname);
devices[nrdevices].identity = sourceId; devices[nrdevices].identity = sourceId;
nrdevices++; nrdevices++;
DSM_sourceId++; DSM_sourceId++;
...@@ -107,12 +105,12 @@ twain_autodetect(void) { ...@@ -107,12 +105,12 @@ twain_autodetect(void) {
if (detectionrun) return; if (detectionrun) return;
detectionrun = TRUE; detectionrun = TRUE;
twain_add_onedriver("sane.ds"); twain_add_onedriver(L"sane.ds");
twain_add_onedriver("gphoto2.ds"); twain_add_onedriver(L"gphoto2.ds");
#if 0 #if 0
twain_add_onedriver("c:\\windows\\Twain_32\\Largan\\sp503a.ds"); twain_add_onedriver(L"Largan\\sp503a.ds");
twain_add_onedriver("c:\\windows\\Twain_32\\vivicam10\\vivicam10.ds"); twain_add_onedriver(L"vivicam10\\vivicam10.ds");
twain_add_onedriver("c:\\windows\\Twain_32\\ws30slim\\sp500a.ds"); twain_add_onedriver(L"ws30slim\\sp500a.ds");
#endif #endif
} }
...@@ -282,7 +280,6 @@ TW_UINT16 TWAIN_OpenDS (pTW_IDENTITY pOrigin, TW_MEMREF pData) ...@@ -282,7 +280,6 @@ TW_UINT16 TWAIN_OpenDS (pTW_IDENTITY pOrigin, TW_MEMREF pData)
TW_UINT16 i = 0; TW_UINT16 i = 0;
pTW_IDENTITY pIdentity = (pTW_IDENTITY) pData; pTW_IDENTITY pIdentity = (pTW_IDENTITY) pData;
activeDS *newSource; activeDS *newSource;
const char *modname = NULL;
HMODULE hmod; HMODULE hmod;
TRACE("DG_CONTROL/DAT_IDENTITY/MSG_OPENDS\n"); TRACE("DG_CONTROL/DAT_IDENTITY/MSG_OPENDS\n");
...@@ -315,9 +312,9 @@ TW_UINT16 TWAIN_OpenDS (pTW_IDENTITY pOrigin, TW_MEMREF pData) ...@@ -315,9 +312,9 @@ TW_UINT16 TWAIN_OpenDS (pTW_IDENTITY pOrigin, TW_MEMREF pData)
FIXME("Out of memory.\n"); FIXME("Out of memory.\n");
return TWRC_FAILURE; return TWRC_FAILURE;
} }
hmod = LoadLibraryA(devices[i].modname); hmod = LoadLibraryW(devices[i].modname);
if (!hmod) { if (!hmod) {
ERR("Failed to load TWAIN Source %s\n", debugstr_a(modname)); ERR("Failed to load TWAIN Source %s\n", debugstr_w(devices[i].modname));
DSM_twCC = TWCC_OPERATIONERROR; DSM_twCC = TWCC_OPERATIONERROR;
HeapFree(GetProcessHeap(), 0, newSource); HeapFree(GetProcessHeap(), 0, newSource);
return TWRC_FAILURE; return TWRC_FAILURE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment