读书人

神奇的有关问题啊GetProcAddress一个不

发布时间: 2012-01-31 21:28:41 作者: rapoo

神奇的问题啊,GetProcAddress一个不存在的API时,返回非空值,且指向另一个API

C/C++ code
        typedef UINT (WINAPI *pfnGetSystemWow64DirectoryA)(LPSTR,UINT uSize);        pfnGetSystemWow64DirectoryA fnGetSystemWow64DirectoryA=NULL;        fnGetSystemWow64DirectoryA=(pfnGetSystemWow64DirectoryA)::GetProcAddress(::GetModuleHandleA("kernel32"),"GetSystemWow64DirectoryA");        if (fnGetSystemWow64DirectoryA)        {            CString str;            str.Format("%08X",fnGetSystemWow64DirectoryA);            OutputDebugStringA(str);            OutputDebugStringA("存在 Syswow64");            fnGetSystemWow64DirectoryA(s_szSystem32,sizeof(s_szSystem32));        }else{            OutputDebugStringA("不存在 Syswow64");            ::GetSystemDirectoryA(s_szSystem32,sizeof(s_szSystem32));        }

在32位XP下,kernel32是没有导出GetSystemWow64DirectoryA的
fnGetSystemWow64DirectoryA指向的居然是SetHandleContext
胃什么啊..

[解决办法]
没遇到过这样的问题,偶只能对此表示鸭梨很大。。。
[解决办法]
你是用什么编译的?什么系统下编译的?

[解决办法]
只能问 微软了
[解决办法]
后面换成GetSystemWow64DirectoryW,照样指向SetHandleContext

这样的话微软的GetProcAddressBug可不小
最好和 GetProcAddressBug(..."SetHandleContext")地址对比下,是否真如楼主所言

读书人网 >VC/MFC

热点推荐