1999-04-18 14:09:21 +02:00
|
|
|
/*
|
|
|
|
* Module/Library loadorder
|
|
|
|
*
|
|
|
|
* Copyright 1999 Bertho Stultiens
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <assert.h>
|
|
|
|
|
1999-04-22 11:13:38 +02:00
|
|
|
#include "config.h"
|
1999-04-18 14:09:21 +02:00
|
|
|
#include "windef.h"
|
|
|
|
#include "options.h"
|
|
|
|
#include "loadorder.h"
|
|
|
|
#include "heap.h"
|
2000-12-03 04:14:29 +01:00
|
|
|
#include "file.h"
|
1999-04-22 11:13:38 +02:00
|
|
|
#include "module.h"
|
1999-06-12 17:45:58 +02:00
|
|
|
#include "debugtools.h"
|
1999-04-18 14:09:21 +02:00
|
|
|
|
2000-11-28 00:54:25 +01:00
|
|
|
DEFAULT_DEBUG_CHANNEL(module);
|
1999-04-19 16:56:29 +02:00
|
|
|
|
1999-04-18 14:09:21 +02:00
|
|
|
|
|
|
|
/* #define DEBUG_LOADORDER */
|
|
|
|
|
|
|
|
#define LOADORDER_ALLOC_CLUSTER 32 /* Allocate with 32 entries at a time */
|
|
|
|
|
|
|
|
static module_loadorder_t default_loadorder;
|
|
|
|
static module_loadorder_t *module_loadorder = NULL;
|
|
|
|
static int nmodule_loadorder = 0;
|
|
|
|
static int nmodule_loadorder_alloc = 0;
|
|
|
|
|
2000-10-02 05:33:51 +02:00
|
|
|
/* DLL order is irrelevant ! Gets sorted later. */
|
1999-04-25 11:15:25 +02:00
|
|
|
static struct tagDllOverride {
|
|
|
|
char *key,*value;
|
|
|
|
} DefaultDllOverrides[] = {
|
2000-10-02 05:33:51 +02:00
|
|
|
/* "system" DLLs */
|
1999-04-25 11:15:25 +02:00
|
|
|
{"kernel32,gdi32,user32", "builtin"},
|
1999-10-13 18:02:40 +02:00
|
|
|
{"krnl386,gdi,user", "builtin"},
|
1999-04-25 11:15:25 +02:00
|
|
|
{"toolhelp", "builtin"},
|
2000-10-13 22:26:52 +02:00
|
|
|
{"windebug", "native,builtin"},
|
2000-10-02 05:33:51 +02:00
|
|
|
{"system,display", "builtin"},
|
|
|
|
{"w32skrnl,wow32", "builtin"},
|
|
|
|
{"advapi32,crtdll,ntdll", "builtin,native"},
|
|
|
|
{"lz32,lzexpand", "builtin,native"},
|
2000-11-30 02:15:30 +01:00
|
|
|
{"version,ver", "builtin,native"},
|
2001-01-11 00:59:25 +01:00
|
|
|
{"msvcrt", "native,builtin"},
|
2000-10-02 05:33:51 +02:00
|
|
|
/* "new" interface */
|
2000-11-30 02:15:30 +01:00
|
|
|
{"comdlg32,commdlg", "builtin,native"},
|
1999-04-25 11:15:25 +02:00
|
|
|
{"shell32,shell", "builtin,native"},
|
1999-08-15 19:03:37 +02:00
|
|
|
{"shlwapi", "native,builtin"},
|
2000-10-02 05:33:51 +02:00
|
|
|
{"shfolder", "builtin,native"},
|
|
|
|
{"comctl32,commctrl", "builtin,native"},
|
|
|
|
/* network */
|
2000-10-13 22:26:52 +02:00
|
|
|
{"wsock32,ws2_32,winsock", "builtin"},
|
1999-11-07 22:22:17 +01:00
|
|
|
{"icmp", "builtin"},
|
2000-10-02 05:33:51 +02:00
|
|
|
/* multimedia */
|
|
|
|
{"ddraw,dinput,dsound", "builtin,native"},
|
|
|
|
{"winmm,mmsystem", "builtin"},
|
|
|
|
{"msvfw32,msvideo", "builtin,native"},
|
|
|
|
{"mcicda.drv,mciseq.drv", "builtin,native"},
|
|
|
|
{"mciwave.drv", "builtin,native"},
|
|
|
|
{"mciavi.drv,mcianim.drv", "native,builtin"},
|
|
|
|
{"msacm.drv,midimap.drv", "builtin,native"},
|
2001-01-06 02:23:11 +01:00
|
|
|
{"msacm,msacm32", "builtin,native"},
|
2000-10-02 05:33:51 +02:00
|
|
|
{"opengl32", "builtin,native"},
|
2000-10-13 22:26:52 +02:00
|
|
|
/* we have to use libglideXx.so instead of glideXx.dll ... */
|
|
|
|
{"glide2x,glide3x", "so,native"},
|
2000-10-02 05:33:51 +02:00
|
|
|
/* other stuff */
|
|
|
|
{"mpr,winspool.drv", "builtin,native"},
|
|
|
|
{"wnaspi32,winaspi", "builtin"},
|
1999-12-12 00:56:46 +01:00
|
|
|
{"odbc32", "builtin"},
|
2000-07-15 21:53:50 +02:00
|
|
|
{"rpcrt4", "native,builtin"},
|
2000-10-02 05:33:51 +02:00
|
|
|
/* non-windows DLLs */
|
|
|
|
{"wineps,wprocs,x11drv", "builtin"},
|
1999-04-25 11:15:25 +02:00
|
|
|
{NULL,NULL},
|
|
|
|
};
|
|
|
|
|
2000-02-19 21:51:01 +01:00
|
|
|
static const struct tagDllPair {
|
|
|
|
const char *dll1, *dll2;
|
|
|
|
} DllPairs[] = {
|
|
|
|
{ "krnl386", "kernel32" },
|
|
|
|
{ "gdi", "gdi32" },
|
|
|
|
{ "user", "user32" },
|
|
|
|
{ "commdlg", "comdlg32" },
|
|
|
|
{ "commctrl", "comctl32" },
|
|
|
|
{ "ver", "version" },
|
|
|
|
{ "shell", "shell32" },
|
|
|
|
{ "lzexpand", "lz32" },
|
|
|
|
{ "mmsystem", "winmm" },
|
|
|
|
{ "msvideo", "msvfw32" },
|
2001-01-06 02:23:11 +01:00
|
|
|
{ "msacm", "msacm32" },
|
2000-02-19 21:51:01 +01:00
|
|
|
{ "winsock", "wsock32" },
|
|
|
|
{ NULL, NULL }
|
|
|
|
};
|
|
|
|
|
1999-04-18 14:09:21 +02:00
|
|
|
/***************************************************************************
|
|
|
|
* cmp_sort_func (internal, static)
|
|
|
|
*
|
|
|
|
* Sorting and comparing function used in sort and search of loadorder
|
|
|
|
* entries.
|
|
|
|
*/
|
|
|
|
static int cmp_sort_func(const void *s1, const void *s2)
|
|
|
|
{
|
2000-12-03 04:14:29 +01:00
|
|
|
return FILE_strcasecmp(((module_loadorder_t *)s1)->modulename,
|
|
|
|
((module_loadorder_t *)s2)->modulename);
|
1999-04-18 14:09:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
* get_tok (internal, static)
|
|
|
|
*
|
|
|
|
* strtok wrapper for non-destructive buffer writing.
|
|
|
|
* NOTE: strtok is not reentrant and therefore this code is neither.
|
|
|
|
*/
|
|
|
|
static char *get_tok(const char *str, const char *delim)
|
|
|
|
{
|
|
|
|
static char *buf = NULL;
|
|
|
|
char *cptr;
|
|
|
|
|
1999-04-19 18:44:22 +02:00
|
|
|
if(!str && !buf)
|
1999-04-18 14:09:21 +02:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if(str && buf)
|
|
|
|
{
|
2000-02-16 23:47:24 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, buf);
|
1999-04-18 14:09:21 +02:00
|
|
|
buf = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(str && !buf)
|
|
|
|
{
|
2000-02-16 23:47:24 +01:00
|
|
|
buf = HEAP_strdupA(GetProcessHeap(), 0, str);
|
1999-04-18 14:09:21 +02:00
|
|
|
cptr = strtok(buf, delim);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cptr = strtok(NULL, delim);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!cptr)
|
|
|
|
{
|
2000-02-16 23:47:24 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, buf);
|
1999-04-18 14:09:21 +02:00
|
|
|
buf = NULL;
|
|
|
|
}
|
|
|
|
return cptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
* ParseLoadOrder (internal, static)
|
|
|
|
*
|
|
|
|
* Parses the loadorder options from the configuration and puts it into
|
|
|
|
* a structure.
|
|
|
|
*/
|
|
|
|
static BOOL ParseLoadOrder(char *order, module_loadorder_t *mlo)
|
|
|
|
{
|
2000-11-30 02:15:30 +01:00
|
|
|
static int warn;
|
1999-04-18 14:09:21 +02:00
|
|
|
char *cptr;
|
|
|
|
int n = 0;
|
|
|
|
|
|
|
|
memset(mlo->loadorder, 0, sizeof(mlo->loadorder));
|
|
|
|
|
|
|
|
cptr = get_tok(order, ", \t");
|
|
|
|
while(cptr)
|
|
|
|
{
|
|
|
|
char type = MODULE_LOADORDER_INVALID;
|
|
|
|
|
|
|
|
if(n >= MODULE_LOADORDER_NTYPES)
|
|
|
|
{
|
1999-06-12 17:45:58 +02:00
|
|
|
ERR("More than existing %d module-types specified, rest ignored", MODULE_LOADORDER_NTYPES);
|
1999-04-18 14:09:21 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch(*cptr)
|
|
|
|
{
|
|
|
|
case 'N': /* Native */
|
|
|
|
case 'n': type = MODULE_LOADORDER_DLL; break;
|
|
|
|
|
|
|
|
case 'E': /* Elfdll */
|
2000-11-30 02:15:30 +01:00
|
|
|
case 'e':
|
2000-12-09 04:25:34 +01:00
|
|
|
if (!warn++) MESSAGE("Load order 'elfdll' no longer supported, ignored\n");
|
2000-11-30 02:15:30 +01:00
|
|
|
break;
|
1999-04-18 14:09:21 +02:00
|
|
|
case 'S': /* So */
|
|
|
|
case 's': type = MODULE_LOADORDER_SO; break;
|
|
|
|
|
|
|
|
case 'B': /* Builtin */
|
|
|
|
case 'b': type = MODULE_LOADORDER_BI; break;
|
|
|
|
|
|
|
|
default:
|
1999-06-12 17:45:58 +02:00
|
|
|
ERR("Invalid load order module-type '%s', ignored\n", cptr);
|
1999-04-18 14:09:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(type != MODULE_LOADORDER_INVALID)
|
|
|
|
{
|
|
|
|
mlo->loadorder[n++] = type;
|
|
|
|
}
|
|
|
|
cptr = get_tok(NULL, ", \t");
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
* AddLoadOrder (internal, static)
|
|
|
|
*
|
2000-01-29 22:12:58 +01:00
|
|
|
* Adds an entry in the list of overrides. If the entry exists, then the
|
|
|
|
* override parameter determines whether it will be overwritten.
|
1999-04-18 14:09:21 +02:00
|
|
|
*/
|
|
|
|
static BOOL AddLoadOrder(module_loadorder_t *plo, BOOL override)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* TRACE(module, "'%s' -> %08lx\n", plo->modulename, *(DWORD *)(plo->loadorder)); */
|
|
|
|
|
|
|
|
for(i = 0; i < nmodule_loadorder; i++)
|
|
|
|
{
|
|
|
|
if(!cmp_sort_func(plo, &module_loadorder[i]))
|
|
|
|
{
|
|
|
|
if(!override)
|
1999-06-12 17:45:58 +02:00
|
|
|
ERR("Module '%s' is already in the list of overrides, using first definition\n", plo->modulename);
|
1999-04-18 14:09:21 +02:00
|
|
|
else
|
|
|
|
memcpy(module_loadorder[i].loadorder, plo->loadorder, sizeof(plo->loadorder));
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(nmodule_loadorder >= nmodule_loadorder_alloc)
|
|
|
|
{
|
|
|
|
/* No space in current array, make it larger */
|
|
|
|
nmodule_loadorder_alloc += LOADORDER_ALLOC_CLUSTER;
|
2000-02-16 23:47:24 +01:00
|
|
|
module_loadorder = (module_loadorder_t *)HeapReAlloc(GetProcessHeap(),
|
1999-04-18 14:09:21 +02:00
|
|
|
0,
|
|
|
|
module_loadorder,
|
|
|
|
nmodule_loadorder_alloc * sizeof(module_loadorder_t));
|
|
|
|
if(!module_loadorder)
|
|
|
|
{
|
1999-06-12 17:45:58 +02:00
|
|
|
MESSAGE("Virtual memory exhausted\n");
|
1999-04-18 14:09:21 +02:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
memcpy(module_loadorder[nmodule_loadorder].loadorder, plo->loadorder, sizeof(plo->loadorder));
|
2000-02-16 23:47:24 +01:00
|
|
|
module_loadorder[nmodule_loadorder].modulename = HEAP_strdupA(GetProcessHeap(), 0, plo->modulename);
|
1999-04-18 14:09:21 +02:00
|
|
|
nmodule_loadorder++;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
* AddLoadOrderSet (internal, static)
|
|
|
|
*
|
2000-01-29 22:12:58 +01:00
|
|
|
* Adds a set of entries in the list of overrides from the key parameter.
|
|
|
|
* If the entry exists, then the override parameter determines whether it
|
|
|
|
* will be overwritten.
|
1999-04-18 14:09:21 +02:00
|
|
|
*/
|
|
|
|
static BOOL AddLoadOrderSet(char *key, char *order, BOOL override)
|
|
|
|
{
|
|
|
|
module_loadorder_t ldo;
|
|
|
|
char *cptr;
|
|
|
|
|
|
|
|
/* Parse the loadorder before the rest because strtok is not reentrant */
|
|
|
|
if(!ParseLoadOrder(order, &ldo))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
cptr = get_tok(key, ", \t");
|
|
|
|
while(cptr)
|
|
|
|
{
|
1999-04-26 16:55:24 +02:00
|
|
|
char *ext = strrchr(cptr, '.');
|
|
|
|
if(ext)
|
|
|
|
{
|
2000-12-03 04:14:29 +01:00
|
|
|
if(strlen(ext) == 4 &&
|
|
|
|
(!FILE_strcasecmp(ext, ".dll") || !FILE_strcasecmp(ext, ".exe")))
|
1999-06-12 17:45:58 +02:00
|
|
|
MESSAGE("Warning: Loadorder override '%s' contains an extension and might not be found during lookup\n", cptr);
|
1999-04-26 16:55:24 +02:00
|
|
|
}
|
1999-04-18 14:09:21 +02:00
|
|
|
|
|
|
|
ldo.modulename = cptr;
|
|
|
|
if(!AddLoadOrder(&ldo, override))
|
|
|
|
return FALSE;
|
|
|
|
cptr = get_tok(NULL, ", \t");
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
* ParseCommandlineOverrides (internal, static)
|
|
|
|
*
|
|
|
|
* The commandline is in the form:
|
2000-08-28 23:33:28 +02:00
|
|
|
* name[,name,...]=native[,b,...][+...]
|
1999-04-18 14:09:21 +02:00
|
|
|
*/
|
|
|
|
static BOOL ParseCommandlineOverrides(void)
|
|
|
|
{
|
|
|
|
char *cpy;
|
|
|
|
char *key;
|
|
|
|
char *next;
|
|
|
|
char *value;
|
|
|
|
BOOL retval = TRUE;
|
|
|
|
|
|
|
|
if(!Options.dllFlags)
|
|
|
|
return TRUE;
|
|
|
|
|
2000-02-16 23:47:24 +01:00
|
|
|
cpy = HEAP_strdupA(GetProcessHeap(), 0, Options.dllFlags);
|
1999-04-18 14:09:21 +02:00
|
|
|
key = cpy;
|
|
|
|
next = key;
|
|
|
|
for(; next; key = next)
|
|
|
|
{
|
2000-08-28 23:33:28 +02:00
|
|
|
next = strchr(key, '+');
|
1999-04-18 14:09:21 +02:00
|
|
|
if(next)
|
|
|
|
{
|
|
|
|
*next = '\0';
|
|
|
|
next++;
|
|
|
|
}
|
|
|
|
value = strchr(key, '=');
|
|
|
|
if(!value)
|
|
|
|
{
|
|
|
|
retval = FALSE;
|
|
|
|
goto endit;
|
|
|
|
}
|
|
|
|
*value = '\0';
|
|
|
|
value++;
|
|
|
|
|
1999-06-12 17:45:58 +02:00
|
|
|
TRACE("Commandline override '%s' = '%s'\n", key, value);
|
1999-04-18 14:09:21 +02:00
|
|
|
|
|
|
|
if(!AddLoadOrderSet(key, value, TRUE))
|
|
|
|
{
|
|
|
|
retval = FALSE;
|
|
|
|
goto endit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
endit:
|
2000-02-16 23:47:24 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, cpy);
|
1999-04-18 14:09:21 +02:00
|
|
|
return retval;;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
* MODULE_InitLoadOrder (internal)
|
|
|
|
*
|
|
|
|
* Initialize the load order from the wine.conf file.
|
2000-01-29 22:12:58 +01:00
|
|
|
* The section has the following format:
|
1999-04-18 14:09:21 +02:00
|
|
|
* Section:
|
|
|
|
* [DllDefaults]
|
|
|
|
*
|
|
|
|
* Keys:
|
2000-11-30 02:15:30 +01:00
|
|
|
* DefaultLoadOrder=native,so,builtin
|
2000-01-29 22:12:58 +01:00
|
|
|
* A comma separated list of module types to try to load in that specific
|
1999-04-18 14:09:21 +02:00
|
|
|
* order. The DefaultLoadOrder key is used as a fallback when a module is
|
2000-01-29 22:12:58 +01:00
|
|
|
* not specified explicitly. If the DefaultLoadOrder key is not found,
|
2000-11-30 02:15:30 +01:00
|
|
|
* then the order "dll,so,bi" is used
|
2000-01-29 22:12:58 +01:00
|
|
|
* The possible module types are:
|
1999-04-18 14:09:21 +02:00
|
|
|
* - native Native windows dll files
|
|
|
|
* - so Native .so libraries mapped to dlls
|
|
|
|
* - builtin Built-in modules
|
|
|
|
*
|
|
|
|
* Case is not important and only the first letter of each type is enough to
|
2000-11-30 02:15:30 +01:00
|
|
|
* identify the type n[ative], s[o], b[uiltin]. Also whitespace is
|
1999-04-18 14:09:21 +02:00
|
|
|
* ignored.
|
|
|
|
* E.g.:
|
2000-11-30 02:15:30 +01:00
|
|
|
* n,s , b
|
1999-04-18 14:09:21 +02:00
|
|
|
* is equal to:
|
2000-11-30 02:15:30 +01:00
|
|
|
* native,so,builtin
|
1999-04-18 14:09:21 +02:00
|
|
|
*
|
|
|
|
* Section:
|
|
|
|
* [DllOverrides]
|
|
|
|
*
|
|
|
|
* Keys:
|
|
|
|
* There are no explicit keys defined other than module/library names. A comma
|
|
|
|
* separated list of modules is followed by an assignment of the load-order
|
|
|
|
* for these specific modules. See above for possible types. You should not
|
|
|
|
* specify an extension.
|
|
|
|
* Examples:
|
|
|
|
* kernel32, gdi32, user32 = builtin
|
|
|
|
* kernel, gdi, user = builtin
|
2000-11-30 02:15:30 +01:00
|
|
|
* comdlg32 = native, builtin
|
1999-04-18 14:09:21 +02:00
|
|
|
* commdlg = native, builtin
|
2000-11-30 02:15:30 +01:00
|
|
|
* version, ver = native, builtin
|
1999-04-18 14:09:21 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define BUFFERSIZE 1024
|
|
|
|
|
|
|
|
BOOL MODULE_InitLoadOrder(void)
|
|
|
|
{
|
|
|
|
char buffer[BUFFERSIZE];
|
2000-02-19 21:51:01 +01:00
|
|
|
char key[256];
|
1999-04-18 14:09:21 +02:00
|
|
|
int nbuffer;
|
2000-02-19 21:51:01 +01:00
|
|
|
int idx;
|
|
|
|
const struct tagDllPair *dllpair;
|
1999-04-18 14:09:21 +02:00
|
|
|
|
|
|
|
/* Get the default load order */
|
2000-11-30 02:15:30 +01:00
|
|
|
nbuffer = PROFILE_GetWineIniString("DllDefaults", "DefaultLoadOrder", "n,b,s", buffer, sizeof(buffer));
|
1999-04-18 14:09:21 +02:00
|
|
|
if(!nbuffer)
|
|
|
|
{
|
2000-01-29 22:12:58 +01:00
|
|
|
MESSAGE("MODULE_InitLoadOrder: mysteriously read nothing from default loadorder\n");
|
1999-04-18 14:09:21 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
1999-06-12 17:45:58 +02:00
|
|
|
TRACE("Setting default loadorder=%s\n", buffer);
|
1999-04-18 14:09:21 +02:00
|
|
|
|
|
|
|
if(!ParseLoadOrder(buffer, &default_loadorder))
|
|
|
|
return FALSE;
|
|
|
|
default_loadorder.modulename = "<none>";
|
|
|
|
|
1999-04-25 11:15:25 +02:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i=0;DefaultDllOverrides[i].key;i++)
|
|
|
|
AddLoadOrderSet(
|
|
|
|
DefaultDllOverrides[i].key,
|
|
|
|
DefaultDllOverrides[i].value,
|
|
|
|
FALSE
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
1999-04-18 14:09:21 +02:00
|
|
|
/* Read the explicitely defined orders for specific modules as an entire section */
|
2000-02-19 21:51:01 +01:00
|
|
|
idx = 0;
|
|
|
|
while (PROFILE_EnumWineIniString( "DllOverrides", idx++, key, sizeof(key),
|
|
|
|
buffer, sizeof(buffer)))
|
|
|
|
{
|
|
|
|
TRACE("Key '%s' uses override '%s'\n", key, buffer);
|
|
|
|
if(!AddLoadOrderSet(key, buffer, TRUE))
|
|
|
|
return FALSE;
|
|
|
|
}
|
1999-04-18 14:09:21 +02:00
|
|
|
|
|
|
|
/* Add the commandline overrides to the pool */
|
|
|
|
if(!ParseCommandlineOverrides())
|
|
|
|
{
|
2000-11-30 02:15:30 +01:00
|
|
|
MESSAGE( "Syntax: -dll name[,name[,...]]={native|so|builtin}[,{n|s|b}[,...]][+...]\n"
|
1999-04-18 14:09:21 +02:00
|
|
|
" - 'name' is the name of any dll without extension\n"
|
2000-11-30 02:15:30 +01:00
|
|
|
" - the order of loading (native, so and builtin) can be abbreviated\n"
|
1999-04-18 14:09:21 +02:00
|
|
|
" with the first letter\n"
|
|
|
|
" - different loadorders for different dlls can be specified by seperating the\n"
|
2000-08-28 23:33:28 +02:00
|
|
|
" commandline entries with a '+'\n"
|
1999-04-18 14:09:21 +02:00
|
|
|
" Example:\n"
|
2000-08-28 23:33:28 +02:00
|
|
|
" -dll comdlg32,commdlg=n+shell,shell32=b\n"
|
1999-04-18 14:09:21 +02:00
|
|
|
);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Sort the array for quick lookup */
|
|
|
|
qsort(module_loadorder, nmodule_loadorder, sizeof(module_loadorder[0]), cmp_sort_func);
|
|
|
|
|
|
|
|
/* Check the pairs of dlls */
|
2000-02-19 21:51:01 +01:00
|
|
|
dllpair = DllPairs;
|
|
|
|
while (dllpair->dll1)
|
|
|
|
{
|
|
|
|
module_loadorder_t *plo1, *plo2;
|
2000-08-28 23:33:28 +02:00
|
|
|
plo1 = MODULE_GetLoadOrder(dllpair->dll1, FALSE);
|
|
|
|
plo2 = MODULE_GetLoadOrder(dllpair->dll2, FALSE);
|
2000-02-19 21:51:01 +01:00
|
|
|
assert(plo1 && plo2);
|
|
|
|
if(memcmp(plo1->loadorder, plo2->loadorder, sizeof(plo1->loadorder)))
|
|
|
|
MESSAGE("Warning: Modules '%s' and '%s' have different loadorder which may cause trouble\n", dllpair->dll1, dllpair->dll2);
|
|
|
|
dllpair++;
|
|
|
|
}
|
1999-04-18 14:09:21 +02:00
|
|
|
|
|
|
|
if(TRACE_ON(module))
|
|
|
|
{
|
|
|
|
int i, j;
|
2000-11-30 02:15:30 +01:00
|
|
|
static char types[] = "-NSB";
|
1999-04-18 14:09:21 +02:00
|
|
|
|
|
|
|
for(i = 0; i < nmodule_loadorder; i++)
|
|
|
|
{
|
|
|
|
DPRINTF("%3d: %-12s:", i, module_loadorder[i].modulename);
|
|
|
|
for(j = 0; j < MODULE_LOADORDER_NTYPES; j++)
|
|
|
|
DPRINTF(" %c", types[module_loadorder[i].loadorder[j] % (MODULE_LOADORDER_NTYPES+1)]);
|
|
|
|
DPRINTF("\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
* MODULE_GetLoadOrder (internal)
|
|
|
|
*
|
|
|
|
* Locate the loadorder of a module.
|
|
|
|
* Any path is stripped from the path-argument and so are the extension
|
1999-09-03 14:36:20 +02:00
|
|
|
* '.dll' and '.exe'. A lookup in the table can yield an override for
|
1999-07-30 20:06:35 +02:00
|
|
|
* the specific dll. Otherwise the default load order is returned.
|
1999-04-18 14:09:21 +02:00
|
|
|
*/
|
2000-08-28 23:33:28 +02:00
|
|
|
module_loadorder_t *MODULE_GetLoadOrder(const char *path, BOOL win32 )
|
1999-04-18 14:09:21 +02:00
|
|
|
{
|
|
|
|
module_loadorder_t lo, *tmp;
|
|
|
|
char fname[256];
|
2000-08-28 23:33:28 +02:00
|
|
|
char sysdir[MAX_PATH+1];
|
1999-04-18 14:09:21 +02:00
|
|
|
char *cptr;
|
|
|
|
char *name;
|
|
|
|
int len;
|
|
|
|
|
2000-05-12 22:18:14 +02:00
|
|
|
TRACE("looking for %s\n", path);
|
|
|
|
|
1999-04-18 14:09:21 +02:00
|
|
|
assert(path != NULL);
|
|
|
|
|
2000-08-28 23:33:28 +02:00
|
|
|
if ( ! GetSystemDirectoryA ( sysdir, MAX_PATH ) )
|
|
|
|
return &default_loadorder; /* Hmmm ... */
|
1999-04-18 14:09:21 +02:00
|
|
|
|
2000-08-28 23:33:28 +02:00
|
|
|
/* Strip path information for 16 bit modules or if the module
|
|
|
|
resides in the system directory */
|
2000-12-03 04:14:29 +01:00
|
|
|
if ( !win32 || !FILE_strncasecmp ( sysdir, path, strlen (sysdir) ) )
|
2000-08-28 23:33:28 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
cptr = strrchr(path, '\\');
|
|
|
|
if(!cptr)
|
|
|
|
name = strrchr(path, '/');
|
|
|
|
else
|
|
|
|
name = strrchr(cptr, '/');
|
|
|
|
|
|
|
|
if(!name)
|
|
|
|
name = cptr ? cptr+1 : (char *)path;
|
|
|
|
else
|
|
|
|
name++;
|
|
|
|
|
|
|
|
if((cptr = strchr(name, ':')) != NULL) /* Also strip drive if in format 'C:MODULE.DLL' */
|
|
|
|
name = cptr+1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
name = (char *)path;
|
|
|
|
|
1999-04-18 14:09:21 +02:00
|
|
|
len = strlen(name);
|
|
|
|
if(len >= sizeof(fname) || len <= 0)
|
|
|
|
{
|
2000-08-28 23:33:28 +02:00
|
|
|
ERR("Path '%s' -> '%s' reduces to zilch or just too large...\n", path, name);
|
|
|
|
return &default_loadorder;
|
1999-04-18 14:09:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
strcpy(fname, name);
|
2000-12-03 04:14:29 +01:00
|
|
|
if(len >= 4 && (!FILE_strcasecmp(fname+len-4, ".dll") || !FILE_strcasecmp(fname+len-4, ".exe")))
|
1999-04-18 14:09:21 +02:00
|
|
|
fname[len-4] = '\0';
|
|
|
|
|
|
|
|
lo.modulename = fname;
|
|
|
|
tmp = bsearch(&lo, module_loadorder, nmodule_loadorder, sizeof(module_loadorder[0]), cmp_sort_func);
|
|
|
|
|
1999-06-12 17:45:58 +02:00
|
|
|
TRACE("Looking for '%s' (%s), found '%s'\n", path, fname, tmp ? tmp->modulename : "<nothing>");
|
1999-04-18 14:09:21 +02:00
|
|
|
|
|
|
|
if(!tmp)
|
|
|
|
return &default_loadorder;
|
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
|