【发布时间】:2012-01-21 17:37:49
【问题描述】:
我正在尝试使用 Detours 3.0 来连接 FindWindowA 和 FindWindowW。这两个函数连接成功,我可以看到请求的类和窗口标题。但是当我尝试访问任何像
这样的词时if ( lpWindowName[0] == buf )
或类似的东西:
wcscpy(buf, lpWindowName);
memcpy(buf, lpWindowName, sizeof(lpWindowName));
我得到错误(钩子程序中的异常)。我无法访问此字符串,但我可以阅读它使用
MessageBox(NULL,lpWindowName,lpClassName,MB_OK);
http://s017.radikal.ru/i421/1201/73/54fa9046a46c.png我什么都不懂...有错误的错误代码。我使用此代码:
int filter(DWORD code, struct _EXCEPTION_POINTERS *ep) {
char buf[MAX_PATH] = {0};
sprintf(buf,"Exception code: %d", code);
MessageBox(NULL,buf,"Error",MB_OK);
return EXCEPTION_EXECUTE_HANDLER;
}
HWND __stdcall Mine_FindWindowW(LPCWSTR a0,
LPCWSTR a1)
{
__try
{
if (a1[0] == L'a')
return NULL;
}
__except(filter(GetExceptionCode(), GetExceptionInformation())){
}
HWND rv = 0;
__try {
rv = Real_FindWindowW(a0, a1);
} __finally {
};
return rv;
}
并且字符串没有损坏。一切正常...为什么我不能检查或直接访问这两个参数?
【问题讨论】:
-
那将是一个杀手锏。您必须发送 WM_SETTEXT 消息。