关于远程线程插入的有关问题CreateRemoteThread和重定位

关于远程线程插入的问题CreateRemoteThread和重定位
我用CreateRemoteThread函数来向目标进程中插入本地的线程函数,目的是显示出一个MessageBox函数,但是往往把目标进程搞坏掉,。。。。。
在网上找了点资料,说是没有重定位的问题,后来修改了一下,但是还是不能在远程进程中执行。代码如下:


希望有人指点一下,主要是对于重定位的问题还是不太明白。谢过。。。。。

#pragma comment(lib,"Psapi.Lib")
#include "Windows.h"
#include "psapi.h"
#include "Shlwapi.h"
#include "Winbase.h"
#include <tlhelp32.h>
typedef int (WINAPI *MESSAGEBOXA)(HWND, LPCSTR, LPCSTR, UINT);
typedef struct _REMOTE_PARAMETER  
 { CHAR m_msgContent[MAX_PATH];  
  CHAR m_msgTitle[MAX_PATH];  
  MESSAGEBOXA m_dwMessageBoxAddr;  
}RemotePara, * PRemotePara;

/********************************************************************************
初始化数据
/********************************************************************/
void InitInjeData(PRemotePara pInjeData)
{
strcpy(pInjeData->m_msgContent,"hello deng");//第一个参数
strcpy(pInjeData->m_msgTitle,"title\0");//第二个参数
  HMODULE hUser32=LoadLibrary("User32.dll");
if(hUser32==NULL)
{
MessageBox(0,"模块失败","模块",MB_OK);
}
pInjeData->m_dwMessageBoxAddr=(MESSAGEBOXA)GetProcAddress(hUser32,"MessageBoxA");
FreeLibrary(hUser32);
}
//得到目标进程************************************************************************/
DWORD GetTargetProcess()
{
HANDLE hSnapshot=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,NULL); 
PROCESSENTRY32 lppe;

lppe.dwSize=sizeof(PROCESSENTRY32);
Process32First(hSnapshot,&lppe);
  do
{

if(0==StrCmp(lppe.szExeFile,"text.exe"))
{

  MessageBox(0,lppe.szExeFile,"ProcessName",MB_OK);

return lppe.th32ProcessID;
}
//else MessageBox(0,"FAIL","得到想要的进程",MB_OK);

}while(Process32Next(hSnapshot,&lppe));
return 0;
}
/************************************************提升进程权限********************************/
bool AdjustPrivilege()
{
HANDLE hToken;
OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES,&hToken);
if(hToken==NULL)
MessageBox(0,"fail","fail",0);
TOKEN_PRIVILEGES pt;
LookupPrivilegeValue( NULL, SE_DEBUG_NAME, &pt.Privileges[0].Luid);
pt.PrivilegeCount=1;
pt.Privileges[0].Attributes= SE_PRIVILEGE_ENABLED;
if(!AdjustTokenPrivileges(hToken,FALSE,&pt,sizeof(pt),NULL,NULL))


return 0;
}

return 1;
}
//-------------------------------------------
//远程线程
//-----------------------------------------
DWORD WINAPI RemoteThreadProc(PRemotePara pRemotePara)
{

//PRemotePara pRemotePara=(PRemotePara )lParam;
//MESSAGEBOXA MessageBoxAa;
//MessageBoxAa = (MESSAGEBOXA )pRemotePara->m_dwMessageBoxAddr;
pRemotePara->m_dwMessageBoxAddr(NULL, pRemotePara->m_msgContent, pRemotePara->m_msgTitle, MB_OK);
return 1;
}



int WINAPI WinMain(
  HINSTANCE hInstance, // handle to current instance
  HINSTANCE hPrevInstance, // handle to previous instance
  LPSTR lpCmdLine, // command line
  int nCmdShow // show state
)
{
//调整进程权限
if(0==AdjustPrivilege())
{
MessageBox(0,"调整权限失败!","adjust",0);
return 0;
}

//得到目标进程
DWORD tarProcessID=GetTargetProcess();
if(tarProcessID==NULL)
{
  MessageBox(0,"得到进程失败!","目标",0);
return 0;
}
//初始化数据
  RemotePara pData;
strcpy(pData.m_msgContent,"hello deng");//第一个参数