mirror of
https://github.com/reactos/reactos.git
synced 2025-01-04 21:38:43 +00:00
simplified dynamic loading of dlls
svn path=/trunk/; revision=10086
This commit is contained in:
parent
6535d130b7
commit
ad9cdc4edc
3 changed files with 23 additions and 19 deletions
|
@ -1,4 +1,4 @@
|
|||
/* $Id: desktop.c,v 1.7 2004/07/11 22:35:07 weiden Exp $
|
||||
/* $Id: desktop.c,v 1.8 2004/07/12 10:33:04 weiden Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
|
@ -218,7 +218,11 @@ AddDesktopItemW (BOOL bCommonDesktop,
|
|||
DPRINT ("szArguments: '%S'\n", szArguments);
|
||||
|
||||
/* dynamically load ole32.dll */
|
||||
LoadDynamicImports(&DynOle32, &Ole32);
|
||||
if(!LoadDynamicImports(&DynOle32, &Ole32))
|
||||
{
|
||||
DPRINT1("USERENV: Unable to load OLE32.DLL\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Ole32.fn.CoInitialize(NULL);
|
||||
|
||||
|
@ -508,7 +512,11 @@ AddItemW (LPCWSTR lpGroupName,
|
|||
DPRINT ("szArguments: '%S'\n", szArguments);
|
||||
|
||||
/* dynamically load ole32.dll */
|
||||
LoadDynamicImports(&DynOle32, &Ole32);
|
||||
if(!LoadDynamicImports(&DynOle32, &Ole32))
|
||||
{
|
||||
DPRINT1("USERENV: Unable to load OLE32.DLL\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Ole32.fn.CoInitialize(NULL);
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: internal.h,v 1.7 2004/07/11 22:35:07 weiden Exp $
|
||||
/* $Id: internal.h,v 1.8 2004/07/12 10:33:04 weiden Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
|
@ -55,8 +55,7 @@ typedef struct _DYN_FUNCS
|
|||
typedef struct _DYN_MODULE
|
||||
{
|
||||
LPWSTR Library; /* dll file name */
|
||||
int nFunctions; /* number of functions in the Functions array */
|
||||
LPSTR *Functions; /* function names */
|
||||
LPSTR Functions[]; /* function names */
|
||||
} DYN_MODULE, *PDYN_MODULE;
|
||||
|
||||
extern DYN_MODULE DynOle32;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: misc.c,v 1.4 2004/07/11 23:08:31 weiden Exp $
|
||||
/* $Id: misc.c,v 1.5 2004/07/12 10:33:04 weiden Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
|
@ -94,18 +94,15 @@ GetUserSidFromToken (HANDLE hToken,
|
|||
/* Dynamic DLL loading interface **********************************************/
|
||||
|
||||
/* OLE32.DLL import table */
|
||||
LPSTR Ole32Imports[] =
|
||||
{
|
||||
"CoInitialize",
|
||||
"CoCreateInstance",
|
||||
"CoUninitialize",
|
||||
};
|
||||
|
||||
DYN_MODULE DynOle32 =
|
||||
{
|
||||
L"ole32.dll",
|
||||
sizeof(Ole32Imports) / sizeof(LPSTR),
|
||||
Ole32Imports
|
||||
{
|
||||
"CoInitialize",
|
||||
"CoCreateInstance",
|
||||
"CoUninitialize",
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -118,7 +115,7 @@ DYN_MODULE DynOle32 =
|
|||
BOOL
|
||||
LoadDynamicImports(PDYN_MODULE Module, PDYN_FUNCS DynFuncs)
|
||||
{
|
||||
int i;
|
||||
LPSTR *fname;
|
||||
PVOID *fn;
|
||||
|
||||
ZeroMemory(DynFuncs, sizeof(DYN_FUNCS));
|
||||
|
@ -132,9 +129,9 @@ LoadDynamicImports(PDYN_MODULE Module, PDYN_FUNCS DynFuncs)
|
|||
fn = &DynFuncs->fn.foo;
|
||||
|
||||
/* load the imports */
|
||||
for(i = 0; i < Module->nFunctions; i++)
|
||||
for(fname = Module->Functions; *fname != NULL; fname++)
|
||||
{
|
||||
*fn = GetProcAddress(DynFuncs->hModule, Module->Functions[i]);
|
||||
*fn = GetProcAddress(DynFuncs->hModule, *fname);
|
||||
if(*fn == NULL)
|
||||
{
|
||||
FreeLibrary(DynFuncs->hModule);
|
||||
|
|
Loading…
Reference in a new issue