我正在测试这种注入(inject)技术(反射 dll 注入(inject)),发现代码上的任何 try/catch 都会引发未处理的 Windows 错误(KERNELBASE.dll,代码错误 e06d7363)并且主机进程终止。
我正在注入(inject)一个具有基本功能的测试 dll。 工作流程是: 打印“starting...”然后死掉。
我的 dll。
bool WINAPI DllMain(HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpReserved)
{
bool bReturnValue = TRUE;
switch (dwReason)
{
case DLL_PROCESS_ATTACH:
function();
break;
}
return bReturnValue;
}
void function()
{
cout << "starting..." << std::endl;
try
{
throw std::exception();
}
catch (...)
{
cout << " exception... " << std::endl;
}
}
任何技术解释?
最佳答案
这很可能是因为您在进行注入(inject)时未正确设置异常处理。参见 https://hackmag.com/uncategorized/exceptions-for-hardcore-users/ .
您使用什么库进行注入(inject)?支持SEH吗?或者,如果您自己做,您是否正确注册了处理程序?
但我怀疑这个问题更复杂,因为在我的标准测试用例中,使用支持 SEH 的库 (SimplePELoader) 加载标准内存 DLL 时遇到了类似的问题。
关于c++ - try catch 反射加载的 dll,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46180010/