能力值:
( LV2,RANK:10 )
|
-
-
2 楼
exe通过导入表知道依赖哪些dll,dll也可以有导入表啊,这就是一个递归的过程,直到该exe所需的所以dll都加载为止。
|
能力值:
( LV2,RANK:10 )
|
-
-
3 楼
嗯,我再研究下,谢谢……
|
能力值:
( LV2,RANK:10 )
|
-
-
4 楼
// 循环扫描每个将要导入的dll
for (; pIID->Name != NULL; pIID++)
{
//IMAGE_THUNK_DATA* pITD = (IMAGE_THUNK_DATA*)(lpDynPEBuf + pIID->FirstThunk);
PIMAGE_THUNK_DATA pRealIAT = (PIMAGE_THUNK_DATA)((unsigned long)lpDynPEBuf + pIID->FirstThunk);
PIMAGE_THUNK_DATA pOriginalIAT = (PIMAGE_THUNK_DATA)((unsigned long)lpDynPEBuf + pIID->OriginalFirstThunk);
HINSTANCE hInstance = LoadLibraryA((LPCSTR)lpDynPEBuf + pIID->Name); assert(hInstance);
//循环扫描dll内每个被导入函数
for(; pOriginalIAT->u1.Ordinal != 0; pOriginalIAT++)
{
FARPROC fpFun = NULL;
if(pOriginalIAT->u1.Ordinal & IMAGE_ORDINAL_FLAG32)
{
//函数是以序号的方式导入的
fpFun = GetProcAddress(hInstance, (LPCSTR)(pOriginalIAT->u1.Ordinal & 0x0000ffff));
}
else
{
//函数是以名称方式导入的
IMAGE_IMPORT_BY_NAME* pIIBN = (IMAGE_IMPORT_BY_NAME *)((DWORD)lpDynPEBuf + (DWORD)pOriginalIAT->u1.Ordinal);
fpFun = GetProcAddress(hInstance, (char *)pIIBN->Name);
}
pRealIAT->u1.Ordinal = (long)fpFun;
}
FreeLibrary(hInstance);
hInstance = NULL;
} // end for
|
|
|