/*以上都在构建目标程序的环境设置,下面调用createprocess来启动目标程序,注意将倒数第3个参数要填为目标程序的路径,第6个参数为create_suspended是为了将程序加载到内存中之后可以进行一些修改,以更好的配合外挂程序的运行*/
if(createprocess(appname,null,null,null,false,create_suspended,null,extractfiledir(appname).c_str(),&si,&pi)==0)
{
//启动目标程序失败
showmessage("error open exe file");
return;
}
gamehandle=pi.hprocess;
/*在本节中要执行程序的话,最好将这个条件注释掉,我将在以后的教程中进行讲解,这里大概说一下功能,第一个write是为了跳过update,第二个是为了退出的时候不打开网页,我的电脑要是退出大话的时候打开网页的话,中间的时间可以抽上几根烟了,所以将程序改了*/
if(writeprocessmemory(gamehandle,(void*)0x0042bc13,no_update,1,null)==false
||writeprocessmemory(gamehandle,(void*)0x
)
return;
threadhand=pi.hthread;
gamethreadid=pi.dwthreadid;
//恢复程序,让程序执行
resumethread(pi.hthread);
/*下面的代码也是本节中不需要的,我将物品的有关信息存到了当前目录(外挂启动程序目录)中的item.ini文件中,但目标程序中并不知道外挂启动程序的路径,因此我在目标程序文件夹中建立了一个名字叫path.ini文件,里面包含了item.ini的路径*/
string inipath= "path="+extractfiledir(application->exename)+"\\item.ini";
writeprivateprofilesection("item",inipath.c_str(),(extractfiledir(openfile->filename)+"\\path.ini").c_str());