mirror of
https://github.com/reactos/reactos.git
synced 2025-04-22 13:10:39 +00:00
LdrGetExportByOrdinal was broken
LdrGetExportByName: fixed bug visible when number of exported functions > number of exported names + check for zero symbol name export table svn path=/trunk/; revision=4328
This commit is contained in:
parent
b41c5aa867
commit
04719148b0
1 changed files with 17 additions and 7 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: utils.c,v 1.59 2003/01/31 21:49:11 hbirr Exp $
|
/* $Id: utils.c,v 1.60 2003/03/17 23:05:07 gdalsnes Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -659,9 +659,9 @@ LdrGetExportByOrdinal (
|
||||||
DbgPrint(
|
DbgPrint(
|
||||||
"LdrGetExportByOrdinal(Ordinal %d) = %x\n",
|
"LdrGetExportByOrdinal(Ordinal %d) = %x\n",
|
||||||
Ordinal,
|
Ordinal,
|
||||||
ExFunctions[ExOrdinals[Ordinal - ExportDir->Base]]
|
RVA(BaseAddress, ExFunctions[Ordinal - ExportDir->Base] )
|
||||||
);
|
);
|
||||||
return(ExFunctions[ExOrdinals[Ordinal - ExportDir->Base]]);
|
return(RVA(BaseAddress, ExFunctions[Ordinal - ExportDir->Base] ));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -678,6 +678,8 @@ LdrGetExportByOrdinal (
|
||||||
* REVISIONS
|
* REVISIONS
|
||||||
*
|
*
|
||||||
* NOTE
|
* NOTE
|
||||||
|
* AddressOfNames and AddressOfNameOrdinals are paralell tables,
|
||||||
|
* both with NumberOfNames entries.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static PVOID
|
static PVOID
|
||||||
|
@ -709,6 +711,14 @@ LdrGetExportByName(PVOID BaseAddress,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//The symbol names may be missing entirely
|
||||||
|
if (ExportDir->AddressOfNames == 0)
|
||||||
|
{
|
||||||
|
DPRINT("LdrGetExportByName(): symbol names missing entirely\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get header pointers
|
* Get header pointers
|
||||||
*/
|
*/
|
||||||
|
@ -722,7 +732,7 @@ LdrGetExportByName(PVOID BaseAddress,
|
||||||
/*
|
/*
|
||||||
* Check the hint first
|
* Check the hint first
|
||||||
*/
|
*/
|
||||||
if (Hint < ExportDir->NumberOfFunctions)
|
if (Hint < ExportDir->NumberOfNames)
|
||||||
{
|
{
|
||||||
ExName = RVA(BaseAddress, ExNames[Hint]);
|
ExName = RVA(BaseAddress, ExNames[Hint]);
|
||||||
if (strcmp(ExName, SymbolName) == 0)
|
if (strcmp(ExName, SymbolName) == 0)
|
||||||
|
@ -744,7 +754,7 @@ LdrGetExportByName(PVOID BaseAddress,
|
||||||
* Try a binary search first
|
* Try a binary search first
|
||||||
*/
|
*/
|
||||||
minn = 0;
|
minn = 0;
|
||||||
maxn = ExportDir->NumberOfFunctions;
|
maxn = ExportDir->NumberOfNames;
|
||||||
while (minn <= maxn)
|
while (minn <= maxn)
|
||||||
{
|
{
|
||||||
ULONG mid;
|
ULONG mid;
|
||||||
|
@ -786,7 +796,7 @@ LdrGetExportByName(PVOID BaseAddress,
|
||||||
* Fall back on a linear search
|
* Fall back on a linear search
|
||||||
*/
|
*/
|
||||||
DPRINT("LdrGetExportByName(): Falling back on a linear search of export table\n");
|
DPRINT("LdrGetExportByName(): Falling back on a linear search of export table\n");
|
||||||
for (i = 0; i < ExportDir->NumberOfFunctions; i++)
|
for (i = 0; i < ExportDir->NumberOfNames; i++)
|
||||||
{
|
{
|
||||||
ExName = RVA(BaseAddress, ExNames[i]);
|
ExName = RVA(BaseAddress, ExNames[i]);
|
||||||
if (strcmp(ExName,SymbolName) == 0)
|
if (strcmp(ExName,SymbolName) == 0)
|
||||||
|
|
Loading…
Reference in a new issue