资源描述:
《分享简单的降低网络游戏cpu占用率的方法(Share simple ways to reduce CPU usage in online games)》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、分享简单的降低网络游戏cpu占用率的方法(SharesimplewaystoreduceCPUusageinonlinegames)Infact,verysimple.MainlyfortheD3Dgame.Themainidea:HookIDirect3DDevice9::Present,inwhichtoaddthesleepfunction.LetthesystemgetmoreCPUtimesliceTestthegame:JianWangthree(asD3D9)Learnallkindsofplug-inpro
2、ductiontechnology,immediatelytoBaidusearch"devilworkshop",clickonthefirststoptogotheretolearn.Concreteimplementationsteps:Direct3DCreate9togetthe1.HOOKinterfacepointertypeLPDIRECT3D9Direct3Dobject,ithasamemberfunctionIDirect3D9::CreateDevice,so,aslongastheDirect3D
3、objectDirect3Dobjectinterfacepointertofindvirtualfunctiontable,thenaccordingtothevirtualfunctiontableIDirect3D9::CreateDevicememoryaddress,youcanhookthisfunction,soastoobtainthetypeLPDIRECT3DDEVICE9deviceobjectpointer,andthenaccordingtothedeviceobjectdeviceobjectp
4、ointertothevirtualfunctiontable,accordingtothevirtualfunctiontabletofindIDirect3DDevice9:Presentaddressinmemory,theHOOK,withsleepfunction.----------------------------------------------------------------------------------------------------//Runjinreferencecode#incl
5、ude#include#pragmacomment(LIB,"D3D9.lib")#pragmacomment(LIB,"D3Dx9.lib")Void,GameD3D_HOOK();IDirect3D9*_stdcallNew_Direct3DCreate9(UINTSDKVersion);HRESULT,_stdcall,New_CreateDeviceLPDIRECT3D9pDx9,UINTAdapter,D3DDEVTYPEDeviceType,HWNDhFocusWind
6、ow,DWORDBehaviorFlags,D3DPRESENT_PARAMETERS*pPresentsentationParameters,IDirect3DDevice9**pPresentturnedDeviceInterface);HRESULT,_stdcall,New_PresentLPDIRECT3DDEVICE9pDxdevice,CONSTRECT*pSourceRect,CONSTRECT*pDestRect,HWNDhDestWindowOverride,CONSTRGNDATA*pDirtyReg
7、ion);LPDIRECT3D9m_pD3D=NULL;theinterfacepointerofthe//Direct3Dobjectvoid*pdirect3dcreate9=null;//direct3dcreate9函数地址指针void*pcreatedevice=null;/::函数地址指针CreateDevice函数void*ppresent=null;//IDirect3DDevice9::目前函数地址指针在睡眠时间=50;//延时时间字节direct3dcreate_begin[5];//用于保存direc
8、t3dcreate9入口的5字节字节createdevice_begin[5];//用于保存CreateDevice函数::入口的字节字节present_begin[5];//用于保存IDirect3DDevice9::目前入口的5字节无效gamed3d_hook(){//钩direct3dcreate