Dll 调用 LoadLibrary成功,GetProcAddress失败 127 找不到过程

曹建峰-17年老猿 2006-01-11 04:39:32
dll:

BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{

//return FALSE;
printf("dll call");
return TRUE;
}
extern "C" __declspec(dllexport)
int if2_2_amr(BYTE *srcBuf, BYTE *dscBuf, int len){
int dsclen=-1;
printf("dll call");
return dsclen;
}

exe:
HMODULE If22Amr;
If22Amr= LoadLibrary("amr_if2.dll");
if( NULL == If22Amr )
{
DWORD r=GetLastError();
printf( "Load DLL failure" );
return -1;
}
else
{
printf( "Load DLL OK");
convertFunc* if22amr;
if22amr=(convertFunc*)::GetProcAddress(If22Amr,"if2_2_amr");
if(if22amr==NULL)
{
DWORD r=GetLastError();
printf( "Load DLL methode failure:%d",r );
return -2;
}
else
if22amr(NULL,NULL,0);
return 0;
}

output:Load DLL OKLoad DLL methode failure:127test result -2
为什么我的GetProcAddress会失败>
...全文
1584 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
CBitmap::CreateCompatibleBitmap
CDC::CreateCompatibleDC
  • 打赏
  • 举报
回复
问题解决了,是我debug版本的dll 函数名有问题“?if2_2_amr@@YAHPAE0H@Z”
to wangk(倒之) 这就是你说的被修饰了吧
有没有这方面的文章给个连接
lixiaosan 2006-01-11
  • 打赏
  • 举报
回复
typedef int (__stdcall *convertFunc)(BYTE *srcBuf, BYTE *dscBuf, int len);]

convertFunc if22amr;

if22amr = (convertFunc) GetProcAddress(If22Amr, "if2_2_amr");
  • 打赏
  • 举报
回复
老大我刚用depends看了一下
e ordinnal hint function entri point
c 0x0001 0x000 if2_2_amr 0x0001118
wangk 2006-01-11
  • 打赏
  • 举报
回复
你用VC自带的工具Depends看看amr_if2.dll导出的函数名是否if2_2_amr有没有被加修饰了。
有时后extern "C"也不能让if2_2_amr不被修饰。
  • 打赏
  • 举报
回复
typedef int convertFunc (BYTE *,BYTE *,int);
和声明类型有关系吗?

15,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 进程/线程/DLL
社区管理员
  • 进程/线程/DLL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧