mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
Fixed crash if exported function does not exist
svn path=/trunk/; revision=1783
This commit is contained in:
parent
3a788d44ee
commit
6a0be77508
1 changed files with 20 additions and 9 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: utils.c,v 1.42 2001/03/26 16:33:10 dwelch Exp $
|
/* $Id: utils.c,v 1.43 2001/04/10 19:14:27 ekohl Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -623,6 +623,11 @@ LdrGetExportByName(PVOID BaseAddress,
|
||||||
TRUE,
|
TRUE,
|
||||||
IMAGE_DIRECTORY_ENTRY_EXPORT,
|
IMAGE_DIRECTORY_ENTRY_EXPORT,
|
||||||
&ExportDirSize);
|
&ExportDirSize);
|
||||||
|
if (ExportDir == NULL)
|
||||||
|
{
|
||||||
|
DbgPrint("LdrGetExportByName(): no export directory!\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get header pointers
|
* Get header pointers
|
||||||
|
@ -658,7 +663,8 @@ LdrGetExportByName(PVOID BaseAddress,
|
||||||
/*
|
/*
|
||||||
* Try a binary search first
|
* Try a binary search first
|
||||||
*/
|
*/
|
||||||
minn = 0, maxn = ExportDir->NumberOfFunctions;
|
minn = 0;
|
||||||
|
maxn = ExportDir->NumberOfFunctions;
|
||||||
while (minn <= maxn)
|
while (minn <= maxn)
|
||||||
{
|
{
|
||||||
ULONG mid;
|
ULONG mid;
|
||||||
|
@ -681,6 +687,11 @@ LdrGetExportByName(PVOID BaseAddress,
|
||||||
if (Function != NULL)
|
if (Function != NULL)
|
||||||
return Function;
|
return Function;
|
||||||
}
|
}
|
||||||
|
else if (minn == maxn)
|
||||||
|
{
|
||||||
|
DPRINT("LdrGetExportByName(): binary search failed\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
else if (res > 0)
|
else if (res > 0)
|
||||||
{
|
{
|
||||||
maxn = mid - 1;
|
maxn = mid - 1;
|
||||||
|
@ -690,11 +701,11 @@ LdrGetExportByName(PVOID BaseAddress,
|
||||||
minn = mid + 1;
|
minn = mid + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Fall back on a linear search
|
* Fall back on a linear search
|
||||||
*/
|
*/
|
||||||
|
DPRINT("LdrGetExportByName(): Falling back on a linear search of export table\n");
|
||||||
DbgPrint("LDR: Falling back on a linear search of export table\n");
|
|
||||||
for (i = 0; i < ExportDir->NumberOfFunctions; i++)
|
for (i = 0; i < ExportDir->NumberOfFunctions; i++)
|
||||||
{
|
{
|
||||||
ExName = RVA(BaseAddress, ExNames[i]);
|
ExName = RVA(BaseAddress, ExNames[i]);
|
||||||
|
@ -712,7 +723,7 @@ LdrGetExportByName(PVOID BaseAddress,
|
||||||
return Function;
|
return Function;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DbgPrint("LdrGetExportByName() = failed to find %s\n",SymbolName);
|
DbgPrint("LdrGetExportByName(): failed to find %s\n",SymbolName);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue