-/* $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
* PROJECT: ReactOS kernel
PVOID Function;
ULONG minn, maxn;
ULONG ExportDirSize;
-
+
DPRINT("LdrGetExportByName %x %s %hu\n", BaseAddress, SymbolName, Hint);
-
+
ExportDir = (PIMAGE_EXPORT_DIRECTORY)
RtlImageDirectoryEntryToData(BaseAddress,
TRUE,
IMAGE_DIRECTORY_ENTRY_EXPORT,
&ExportDirSize);
-
+ if (ExportDir == NULL)
+ {
+ DbgPrint("LdrGetExportByName(): no export directory!\n");
+ return NULL;
+ }
+
/*
* Get header pointers
*/
return Function;
}
}
-
+
/*
* Try a binary search first
*/
- minn = 0, maxn = ExportDir->NumberOfFunctions;
+ minn = 0;
+ maxn = ExportDir->NumberOfFunctions;
while (minn <= maxn)
{
ULONG mid;
if (Function != NULL)
return Function;
}
+ else if (minn == maxn)
+ {
+ DPRINT("LdrGetExportByName(): binary search failed\n");
+ break;
+ }
else if (res > 0)
{
maxn = mid - 1;
minn = mid + 1;
}
}
+
/*
* Fall back on a linear search
*/
-
- DbgPrint("LDR: 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++)
{
ExName = RVA(BaseAddress, ExNames[i]);
return Function;
}
}
- DbgPrint("LdrGetExportByName() = failed to find %s\n",SymbolName);
+ DbgPrint("LdrGetExportByName(): failed to find %s\n",SymbolName);
return NULL;
}