拦截api失败,找不到原因解决方法
拦截api失败,找不到原因
我《在windows核心编程》代码例子的基础上,添加了hook函数GetFileAttributesW的代码,可是运行就出问题,一直没有找到原因。
hook其他的api就没有问题,hook这个GetFileAttributesW就不能成功。
在LastMsgBoxInfoLib.cpp里添加的代码:
------解决方案--------------------
DWORD WINAPI Hook_GetFileAttributesW(LPCWSTR lpFileName)
我《在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)