能力值:
(RANK:1060 )
|
-
-
2 楼
EP之前remote thread load的dll不能加载user32
|
能力值:
( LV2,RANK:10 )
|
-
-
3 楼
是不是没有做好清场工作?下面是我写的,你看一下对你有没有帮助
CXdit::m_bInject (bool型) 和 CXdit::m_hInjectDllMod (HMODULE)你可以替换成两个全局变量
//! 创建远程线程
/*!
\param[in] hTarget 目标进程的主窗口句柄
\param[in] pcInjectDllName 注入的dll路径
\param[in] bInject 注入/取消注入
*/
BOOL CXdit::MyCreateRemoteThread(HWND hTarget, LPCSTR pcInjectDllName, BOOL bInject)
{
BOOL bRet = FALSE;
CXdit::m_bInject = FALSE;
char pcDllName[MAX_PATH] = { 0 };
strcpy(pcDllName, pcInjectDllName);
// 根据主窗口句柄得到目标线程Id
DWORD dwProcessId;
::GetWindowThreadProcessId(hTarget, &dwProcessId);
// 打开目标进程
HANDLE hTargetProcess = ::OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwProcessId);
if (hTargetProcess == NULL)
return FALSE;
HMODULE hMod = ::GetModuleHandle( _T("Kernel32") );
PTHREAD_START_ROUTINE pThreadStartAddr = NULL;
HANDLE hRemoteThread = NULL;
if (bInject) // 注入
{
// 在目标进程内分配内存空间,用来存放注入的DLL文件的路径名称
int nLen = lstrlen(pcInjectDllName) + 1;
void* pRemoteThread = VirtualAllocEx(hTargetProcess, NULL, nLen, MEM_COMMIT, PAGE_READWRITE);
// 在分配的内存空间中写入dll文件路径
DWORD dwWrite;
if ( !::WriteProcessMemory(hTargetProcess, pRemoteThread, pcDllName, nLen, &dwWrite) )
{
MessageBox(NULL, "Write data to target process failed !", "Notice", MB_ICONINFORMATION | MB_OK);
return FALSE;
}
pThreadStartAddr = (PTHREAD_START_ROUTINE)::GetProcAddress(hMod, _T("LoadLibraryA"));
hRemoteThread = ::CreateRemoteThread(hTargetProcess, NULL, 0, pThreadStartAddr, pRemoteThread, 0, NULL);
if (!hRemoteThread)
{
MessageBox(NULL, "Create remote thread failed !", "Notice", MB_ICONSTOP);
return FALSE;
}
// 等待远程线程退出
::WaitForSingleObject(hRemoteThread, INFINITE);
// 得到注入的Dll在目标进程的基地址
DWORD dwInjectDllMod;
if (::GetExitCodeThread(hRemoteThread, &dwInjectDllMod))
{
CXdit::m_hInjectDllMod = (HMODULE)dwInjectDllMod;
}
// 清场处理
if (pRemoteThread != NULL)
::VirtualFreeEx(hTargetProcess, pRemoteThread, 0, MEM_RELEASE);
}
else // 取消注入
{
pThreadStartAddr = (PTHREAD_START_ROUTINE)::GetProcAddress(hMod, _T("FreeLibrary"));
hRemoteThread = ::CreateRemoteThread(hTargetProcess, NULL, 0, pThreadStartAddr, CXdit::m_hInjectDllMod, 0, NULL);
if (!hRemoteThread)
{
MessageBox(NULL, "Create remote thread failed !", "Notice", MB_ICONSTOP);
return FALSE;
}
// 等待远程线程退出
::WaitForSingleObject(hRemoteThread, INFINITE);
}
// 清场处理
if (hRemoteThread)
::CloseHandle(hRemoteThread);
if (hTargetProcess)
::CloseHandle(hTargetProcess);
CXdit::m_bInject = bInject;
bRet = TRUE;
return bRet;
}
|
能力值:
( LV9,RANK:160 )
|
-
-
4 楼
谢谢forgot和楼上的支持。
我怀疑是由于CALL 到自己的空间里回去直接把EAX赋值为1而没有去恢复API然后调用的缘故……
呵呵
|