读书人

拦截api失败找不到原因解决方法

发布时间: 2012-04-21 14:34:44 作者: rapoo

拦截api失败,找不到原因
我《在windows核心编程》代码例子的基础上,添加了hook函数GetFileAttributesW的代码,可是运行就出问题,一直没有找到原因。

hook其他的api就没有问题,hook这个GetFileAttributesW就不能成功。

在LastMsgBoxInfoLib.cpp里添加的代码:

C/C++ code
typedef DWORD (WINAPI *PENGetFileAttributesW)(            LPCWSTR lpFileName);//......extern CAPIHook g_GetFileAttributesW;//...... DWORD Hook_GetFileAttributesW(LPCWSTR lpFileName) {    DWORD nResult=0;    nResult = ((PENGetFileAttributesW)(PROC)g_GetFileAttributesW)(lpFileName);    return(nResult); }//......CAPIHook g_GetFileAttributesW("Kernel32.dll", "GetFileAttributesW", (PROC) Hook_GetFileAttributesW);


[解决办法]
DWORD WINAPI Hook_GetFileAttributesW(LPCWSTR lpFileName)

读书人网 >C++

热点推荐