資源描述:
《分享簡單的降低網(wǎng)絡游戲cpu占用率的方法(Share simple ways to reduce CPU usage in online games)》由會員上傳分享,免費在線閱讀,更多相關內容在學術論文-天天文庫。
1、分享簡單的降低網(wǎng)絡游戲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函數(shù)地址指針void*pcreatedevice=null;/::函數(shù)地址指針CreateDevice函數(shù)void*ppresent=null;//IDirect3DDevice9::目前函數(shù)地址指針在睡眠時間=50;//延時時間字節(jié)direct3dcreate_begin[5];//用于保存direc
8、t3dcreate9入口的5字節(jié)字節(jié)createdevice_begin[5];//用于保存CreateDevice函數(shù)::入口的字節(jié)字節(jié)present_begin[5];//用于保存IDirect3DDevice9::目前入口的5字節(jié)無效gamed3d_hook(){//鉤direct3dcreate