线程问题. “挂钩" [英] Thread Problem. "Hook"
问题描述
你好,
再一次,我有问题.
我创建了一个DLL,它在目标应用程序中设置了一些钩子.但是我有一个功能的问题.我们称之为ParseData.
我迷上了这个函数,所有传入的数据都显示在ListCtrl中.
我有3个实际上调用此函数的类.
第一个主类将ParseData的地址传递给其余2个类.
喜欢:
Hello,
Once again, I have problem.
I created an DLL that sets few hooks into target application. But I have problem with one function. Let''s call it ParseData.
I hooked this function and any data coming through are displayed in ListCtrl.
I have 3 classes that actually calls this function.
The first master class passes address of the ParseData to 2 remaining classes.
Like:
...
*(DWORD*)&ParseData = m_pParseDataAddress; // Set the function call for MasterClass
m_SomeDlg->SetParseDataFunction(m_pParseDataAddress); // Pass the addr to class 2
m_Para.SetParseDataFunction(m_pParseDataAddress); // Pass the addr to class 3
...
当m_SomeDlg调用ParseData时,它将经过钩子,并且数据显示在ListCtrl中.
但是m_Para通过以下命令在某个时刻创建新线程:
When m_SomeDlg calls ParseData, it goes though hook and data are displayed in ListCtrl.
m_Para however creates new thread at some point via command:
...
// IN COMMAND HANDLER
if( strcmp(chCommand, "Load") == 0)
{
Init();
m_bActivated = true;
_beginthread((void (__cdecl *)(void *))&ProcThreadAddr, 0, (void*)this);
}
...
void __cdecl CPara::ProcThreadAddr(CPara * ParaPtr)
{
ParaPtr->MainThread();
_endthread();
}
在MainThread中有一个while循环,用于检查m_bActivated = true.
但是,从此线程对ParseData的任何调用都不会显示在钩子中(但是会解析数据)
当我从任何地方调用ParseData时,数据都显示在钩子中,但是当我从MainThread调用它时,它不显示任何内容.
这对我来说真的很奇怪.
谢谢您的帮助.
In MainThread there is a while loop which checks if m_bActivated = true.
However any calls to ParseData from this thread aren''t displayed in hook (Data is parsed however)
When I call ParseData from any place, data is displayed in hook, but when I call it from MainThread it doesn''t display anything.
That''s actually pretty strange for me.
Thank you for your help.
推荐答案
Agghhh,我想我现在知道问题了.我失去的所有宝贵时间...该死.
无论如何-让我解释一下其他可能存在相同问题的其他编码器的解决方案/问题:
我没有使用常规断点或弯路/jmp.我正在使用硬件断点.但是,这些断点设置在线程上下文中.并且由于新线程是在设置挂钩之后创建的,因此它不包含硬件断点.
我怎么发现错了?我只是将钩子的地址传递给了m_Para类.
m_Para.SetParseDataFunction(&ParseDataHook);
Agghhh, I guess I know the problem now. All the precious time I lost... Damn it.
Anyways - Let me explain the solution/problem for any other coders that might have same issue:
I''m not using regular breakpoints or detour/jmp. I''m using Hardware breakpoints. However those breakpoints are set into thread context. And because the new thread is created after setting up hooks, it doesn''t contain hardware breakpoints.
How I found what''s wrong? I simply passed address of hook to m_Para class.
m_Para.SetParseDataFunction(&ParseDataHook);
这篇关于线程问题. “挂钩"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!