上网老用手机上.贴一个这代码估计他这月该欠费了
替他贴一个(还是他写的)
DWORD myGetProcAddress(DWORD hModule,char *FuncName)
{
DWORD retAddr=0;
DWORD *namerav,*funrav;
DWORD cnt=0;
DWORD maxIndex,minIndex,temp,lasttemp;
WORD *nameOrdinal;
WORD nIndex=0;
int cmpresult=0;
char *ModuleBase=(char*)hModule;
PIMAGE_DOS_HEADER pDosHeader;
PIMAGE_FILE_HEADER pFileHeader;
PIMAGE_OPTIONAL_HEADER pOptHeader;
PIMAGE_EXPORT_DIRECTORY pExportDir;
if (hModule==0)
{
return 0;
}
pDosHeader=(PIMAGE_DOS_HEADER)ModuleBase;
pFileHeader=(PIMAGE_FILE_HEADER)(ModuleBase+pDosHeader->e_lfanew+4);
pOptHeader=(PIMAGE_OPTIONAL_HEADER)((char*)pFileHeader+sizeof(IMAGE_FILE_HEADER));
pExportDir=(PIMAGE_EXPORT_DIRECTORY)(ModuleBase+pOptHeader->DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress);
namerav=(DWORD*)(ModuleBase+pExportDir->AddressOfNames);
funrav=(DWORD*)(ModuleBase+pExportDir->AddressOfFunctions);
nameOrdinal=(WORD*)(ModuleBase+pExportDir->AddressOfNameOrdinals);
if ((DWORD)FuncName<0x0000FFFF)
{
retAddr=(DWORD)(ModuleBase+funrav[(WORD)FuncName]);
}
else
{
maxIndex=pExportDir->NumberOfFunctions;
minIndex=0;
lasttemp=0;
while (1)
{
temp=(maxIndex+minIndex)/2;
if (temp==lasttemp)
{
//Not Found!
retAddr=0;
break;
}
cmpresult=strcmp(FuncName,ModuleBase+namerav[temp]);
if (cmpresult<0)
{
maxIndex=lasttemp=temp;
}
else if (cmpresult>0)
{
minIndex=lasttemp=temp;
}
else
{
nIndex=nameOrdinal[temp];
retAddr=(DWORD)(ModuleBase+funrav[nIndex]);
break;
}
}
}
return retAddr;
}