mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 23:26:34 +00:00
Use import hint if present
svn path=/trunk/; revision=1608
This commit is contained in:
parent
ae14d5ffc6
commit
c93d52a405
2 changed files with 29 additions and 25 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: utils.c,v 1.37 2001/02/06 02:03:35 dwelch Exp $
|
/* $Id: utils.c,v 1.38 2001/02/06 05:50:50 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -638,8 +638,7 @@ LdrGetExportByOrdinal (
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static PVOID
|
static PVOID
|
||||||
LdrGetExportByName (PVOID BaseAddress,
|
LdrGetExportByName (PVOID BaseAddress, PUCHAR SymbolName, WORD Hint)
|
||||||
PUCHAR SymbolName)
|
|
||||||
{
|
{
|
||||||
PIMAGE_EXPORT_DIRECTORY ExportDir;
|
PIMAGE_EXPORT_DIRECTORY ExportDir;
|
||||||
PDWORD * ExFunctions;
|
PDWORD * ExFunctions;
|
||||||
|
@ -666,6 +665,19 @@ LdrGetExportByName (PVOID BaseAddress,
|
||||||
ExFunctions = (PDWORD *)RVA(BaseAddress,
|
ExFunctions = (PDWORD *)RVA(BaseAddress,
|
||||||
ExportDir->AddressOfFunctions);
|
ExportDir->AddressOfFunctions);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check the hint first
|
||||||
|
*/
|
||||||
|
if (Hint < ExportDir->NumberOfFunctions)
|
||||||
|
{
|
||||||
|
ExName = RVA(BaseAddress, ExNames[Hint]);
|
||||||
|
if (strcmp(ExName, SymbolName) == 0)
|
||||||
|
{
|
||||||
|
Ordinal = ExOrdinals[Hint];
|
||||||
|
return(RVA(BaseAddress, ExFunctions[Ordinal]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Try a binary search first
|
* Try a binary search first
|
||||||
*/
|
*/
|
||||||
|
@ -867,7 +879,7 @@ static NTSTATUS LdrFixupImports(PIMAGE_NT_HEADERS NTHeaders,
|
||||||
PULONG FunctionNameList;
|
PULONG FunctionNameList;
|
||||||
UNICODE_STRING DllName;
|
UNICODE_STRING DllName;
|
||||||
DWORD pName;
|
DWORD pName;
|
||||||
PWORD pHint;
|
WORD pHint;
|
||||||
|
|
||||||
DPRINT("ImportModule->Directory->dwRVAModuleName %s\n",
|
DPRINT("ImportModule->Directory->dwRVAModuleName %s\n",
|
||||||
(PCHAR)(ImageBase + ImportModuleDirectory->dwRVAModuleName));
|
(PCHAR)(ImageBase + ImportModuleDirectory->dwRVAModuleName));
|
||||||
|
@ -911,10 +923,9 @@ static NTSTATUS LdrFixupImports(PIMAGE_NT_HEADERS NTHeaders,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FunctionNameList = (PULONG) (
|
FunctionNameList =
|
||||||
ImageBase
|
(PULONG)(ImageBase
|
||||||
+ ImportModuleDirectory->dwRVAFunctionAddressList
|
+ ImportModuleDirectory->dwRVAFunctionAddressList);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Walk through function list and fixup addresses.
|
* Walk through function list and fixup addresses.
|
||||||
|
@ -930,17 +941,11 @@ static NTSTATUS LdrFixupImports(PIMAGE_NT_HEADERS NTHeaders,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pName = (DWORD) (
|
pName = (DWORD) (ImageBase + *FunctionNameList + 2);
|
||||||
ImageBase
|
pHint = *(PWORD)(ImageBase + *FunctionNameList);
|
||||||
+ *FunctionNameList
|
|
||||||
+ 2);
|
|
||||||
pHint = (PWORD) (
|
|
||||||
ImageBase
|
|
||||||
+ *FunctionNameList);
|
|
||||||
|
|
||||||
*ImportAddressList =
|
*ImportAddressList =
|
||||||
LdrGetExportByName(BaseAddress,
|
LdrGetExportByName(BaseAddress, (PUCHAR)pName, pHint);
|
||||||
(PUCHAR) pName);
|
|
||||||
if ((*ImportAddressList) == NULL)
|
if ((*ImportAddressList) == NULL)
|
||||||
{
|
{
|
||||||
DbgPrint("Failed to import %s\n", pName);
|
DbgPrint("Failed to import %s\n", pName);
|
||||||
|
|
|
@ -216,13 +216,12 @@ exception_handler(struct trap_frame* tf)
|
||||||
|
|
||||||
DbgPrint("stack<%p>: ", stack);
|
DbgPrint("stack<%p>: ", stack);
|
||||||
|
|
||||||
for (i = 0; i < 16; i = i + 4)
|
for (i = 0; i < 18; i = i + 6)
|
||||||
{
|
{
|
||||||
DbgPrint("%.8x %.8x %.8x %.8x\n",
|
DbgPrint("%.8x %.8x %.8x %.8x\n",
|
||||||
stack[i],
|
stack[i], stack[i+1],
|
||||||
stack[i+1],
|
stack[i+2], stack[i+3],
|
||||||
stack[i+2],
|
stack[i+4], stack[i+5]);
|
||||||
stack[i+3]);
|
|
||||||
}
|
}
|
||||||
DbgPrint("Frames:\n");
|
DbgPrint("Frames:\n");
|
||||||
for (i = 0; i < 32; i++)
|
for (i = 0; i < 32; i++)
|
||||||
|
@ -249,7 +248,7 @@ exception_handler(struct trap_frame* tf)
|
||||||
if (MmIsPagePresent(NULL,&stack[i]))
|
if (MmIsPagePresent(NULL,&stack[i]))
|
||||||
{
|
{
|
||||||
DbgPrint("%.8x ",stack[i]);
|
DbgPrint("%.8x ",stack[i]);
|
||||||
if (((i+1)%4) == 0)
|
if (((i+1)%8) == 0)
|
||||||
{
|
{
|
||||||
DbgPrint("\n");
|
DbgPrint("\n");
|
||||||
}
|
}
|
||||||
|
@ -258,7 +257,7 @@ exception_handler(struct trap_frame* tf)
|
||||||
|
|
||||||
if (MmIsPagePresent(NULL, (PVOID)tf->eip))
|
if (MmIsPagePresent(NULL, (PVOID)tf->eip))
|
||||||
{
|
{
|
||||||
char instrs[512];
|
unsigned char instrs[512];
|
||||||
|
|
||||||
memcpy(instrs, (PVOID)tf->eip, 512);
|
memcpy(instrs, (PVOID)tf->eip, 512);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue