📄 hookqueue.cpp
字号:
//
// Online Game Cheats Client.dll hook
// Copyright (c) system 2001-2002
// Copyright (c) bunny771 2001-2002
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
// NOTE:
// GNU license doesn't cover Engine directory.
// Content of Engine directory is copyrighted (c) 1999, 2000, by Valve LLC
// and it is licensed under Valve's proprietary license (see original HL SDK).
//
#include "stdafx.h"
#include "hookqueue.h"
#include "engine/wrect.h"
#include "engine/cl_dll.h"
#include "engine/cdll_int.h"
#include "engine/r_efx.h"
#include "client.h"
#include <gl/gl.h>
#include <assert.h>
#pragma warning (disable:4731)
#include <fstream>
using namespace std;
MapStringInt myintmap;
DWORD engcodestart,engcodesize;
int pInitialize (cl_enginefunc_t *pEnginefuncs, int iVersion);
int pHUD_AddEntity (int type, struct cl_entity_s *ent, const char *modelname);
int pHUD_Init (void);
int pHUD_Redraw (float x, int y);
void pHUD_PlayerMove (struct playermove_s *a, int b); // 02899
void pV_CalcRefdef (struct ref_params_s *pparams);
void pCL_CreateMove (float frametime, struct usercmd_s *cmd, int active);
void pHUD_TempEntUpdate (double,double,double,TEMPENTITY**,TEMPENTITY**,int(*)(cl_entity_t *),void(*)(TEMPENTITY*,float) );
int pHUD_GetStudioModelInterface( int version, struct r_studio_interface_s **ppinterface, struct engine_studio_api_s *pstudio );
hookinfo Initialize_Info (&pInitialize,2,0x24E0);
hookinfo HUD_AddEntity_Info (&pHUD_AddEntity,3,0x26D1);
//hookinfo HUD_Init_Info (&pHUD_Init,0,0x294D);
hookinfo HUD_Redraw_Info (&pHUD_Redraw,2,0x2979);
hookinfo HUD_PlayerMove_Info (&pHUD_PlayerMove,2,0x02899);
hookinfo V_CalcRefdef_Info (&pV_CalcRefdef,1,0x27B2);
hookinfo CL_CreateMove_Info (&pCL_CreateMove,3,0x281A);
hookinfo HUD_TempEntUpdate_Info (&pHUD_TempEntUpdate,10,0x2541);
//hookinfo HUD_GetStudioModelInterface_Info (&pHUD_GetStudioModelInterface,3);
void APIENTRY pglBlendFunc(GLenum sfactor, GLenum dfactor);
void APIENTRY pglVertex3f( float x, float y, float z);
void APIENTRY pglBegin(unsigned int mode);
// only oldfunc infos:
hookinfo glBlendFuncInfo (&pglBlendFunc,2,-1);
hookinfo glBeginInfo (&pglBegin ,1,-1);
hookinfo glVertex3fInfo (&pglVertex3f ,3,-1);
hookinfo glDisableInfo (NULL ,1,-1);
hookinfo glEnableInfo (NULL ,1,-1);
hookinfo glColor3fInfo (NULL ,3,-1);
hookinfo glTexEnviInfo (NULL ,3,-1);
hookinfo glPolygonModeInfo (NULL ,2,-1);
hookinfo glClearColorInfo (NULL ,4,-1);
hookinfo glClearInfo (NULL ,1,-1);
hookinfo glGetFloatvInfo (NULL ,1,-1);
hookinfo glViewportInfo (NULL ,4,-1);
hookinfo glColor4fInfo (NULL ,4,-1);
hookinfo glLineWidthInfo (NULL ,1,-1);
hookinfo glRectiInfo (NULL ,4,-1);
////ofstream logfile("c:\\tmpaxx\\log.txt");
//void opengl_reroute(hookinfo* info,DWORD* callcode)
//{
// if(! ( *(BYTE*)callcode == 0xA3 ) ) return; // mov ??,eax
//
// info->oldfunc = (PVOID)*(DWORD*)(((BYTE*)callcode)+1);
// void* oldfunc2 = (PVOID)*(DWORD*)(((BYTE*)callcode)+13);
// BYTE *pos;
// BYTE* codestart=(BYTE*)engcodestart;
// DWORD length=engcodesize;
//
// if(info->newfunc==NULL) return;
//
// //if(dolog)logfile<<"scanning for ff15+"<<hex<<(DWORD)info->oldfunc<<endl;
// while (ScanPattern_FF15calladr(codestart,(DWORD)info->oldfunc,length,&pos))
// {
// //if(dolog)logfile<<"found at "<<(DWORD)pos<<endl;
// length-=pos+6-codestart;
// codestart=pos+6;
// Protect(pos+2,sizeof(DWORD));
// DWORD* blub0r=(DWORD*)(pos+2);
// *blub0r = (DWORD)&info->newfunc;
// Protect(pos+2);
// info->return_trampoline=NULL;
// }
//
// codestart=(BYTE*)engcodestart;
// length=engcodesize;
// //if(dolog)logfile<<"scanning for ff15+"<<hex<<(DWORD)oldfunc2<<endl;
// while (ScanPattern_FF15calladr(codestart,(DWORD)oldfunc2,length,&pos))
// {
// //if(dolog)logfile<<"found at "<<(DWORD)pos<<endl;
// length-=pos+6-codestart;
// codestart=pos+6;
// Protect(pos+2,sizeof(DWORD));
// DWORD* blub0r=(DWORD*)(pos+2);
// *blub0r = (DWORD)&info->newfunc;
// Protect(pos+2);
// info->return_trampoline=NULL;
// }
//}
FARPROC check_hook_queue(char* procname, FARPROC original)
{
MapStringInt::iterator pos = myintmap.find(procname);
if(pos != myintmap.end() )
{
hookinfo* info = (hookinfo*)pos->second;
assert(info);
info->oldfunc = original;
if(info->newfunc) return (FARPROC)info->newfunc;
else return original;
}
return original;
}
//=======================================================================================
void init_hook_queue()
{
// client.dll reroute info
typedef MapStringInt::value_type Entry;
//myintmap.insert(Entry("Initialize",&Initialize_Info));
//myintmap.insert(Entry("HUD_AddEntity",&HUD_AddEntity_Info));
////myintmap.insert(Entry("HUD_Init",&HUD_Init_Info));
//myintmap.insert(Entry("HUD_Redraw",&HUD_Redraw_Info));
//myintmap.insert(Entry("HUD_PlayerMove",&HUD_PlayerMove_Info));
//myintmap.insert(Entry("V_CalcRefdef",&V_CalcRefdef_Info));
//myintmap.insert(Entry("CL_CreateMove",&CL_CreateMove_Info));
//myintmap.insert(Entry("HUD_TempEntUpdate",&HUD_TempEntUpdate_Info));
////////////myintmap.insert(Entry("HUD_GetStudioModelInterface",&HUD_GetStudioModelInterface_Info));
////////////myintmap.insert(Entry("HUD_VidInit",&HUD_VidInit_Info));
#define INSERT_INFO(a) myintmap.insert(Entry(#a,&a##Info));
INSERT_INFO(glBlendFunc )
INSERT_INFO(glBegin )
INSERT_INFO(glVertex3f )
INSERT_INFO(glDisable )
INSERT_INFO(glEnable )
INSERT_INFO(glColor3f )
INSERT_INFO(glTexEnvi )
INSERT_INFO(glPolygonMode )
INSERT_INFO(glClearColor )
INSERT_INFO(glClear )
INSERT_INFO(glGetFloatv )
INSERT_INFO(glViewport )
INSERT_INFO(glColor4f )
INSERT_INFO(glLineWidth )
INSERT_INFO(glRecti )
}
extern struct dllfuncs_t gClientExports;
extern struct cl_enginefuncs_s gEngfuncs;
//int pInitialize (cl_enginefunc_t *pEnginefuncs, int iVersion)
//{
// LOG(initialize_start)
//
// static bool firstcall = true;
// if(firstcall)
// {
// // save engine funcs
// memcpy (&gEngfuncs, pEnginefuncs, sizeof(cl_enginefunc_t));
// gEngfuncs.pfnConsolePrint("// ==== OGC-INITIALIZE ====\n");
// MessageBox(0,"initialize",0,0);
// firstcall = false;
// }
// else
// {
// gEngfuncs.pfnConsolePrint("// ==== OGC-INITIALIZE 2 ====\n");
// }
//
// int nResult = gClientExports.Initialize(pEnginefuncs,iVersion);
// LOG(initialize_end)
// return nResult;
//}
//
//int pHUD_Redraw (float x, int y)
//{
// LOG(hudredraw_start)
// int nResult = gClientExports.HUD_Redraw(x,y);
// LOG(hudredraw_end)
// return nResult;
//}
//
//int pHUD_AddEntity (int type, struct cl_entity_s *ent, const char *modelname)
//{
// //__asm int 03;
// LOG(addentity_start)
// if(ent->player)
// {
// ent->curstate.renderamt = 1;
// ent->curstate.rendercolor.r = 255;
// ent->curstate.rendercolor.b = 0;
// ent->curstate.rendercolor.g = 100;
// ent->curstate.renderfx = kRenderFxGlowShell;
// }
// int nResult = gClientExports.HUD_AddEntity(type,ent,modelname);
// LOG(addentity_end)
// if ((strstr(modelname, "black_smoke")||strstr(modelname, "fast_wallpuff"))) return 0;
// return nResult;
//}
//
//void pHUD_PlayerMove (struct playermove_s *a, int b)
//{
// LOG(playermove_start)
// gClientExports.HUD_PlayerMove(a,b);
// LOG(playermove_end)
//}
//
//void pV_CalcRefdef (struct ref_params_s *pparams)
//{
// LOG(calcrefdef_start)
// gClientExports.V_CalcRefdef(pparams);
// LOG(calcrefdef_end)
//}
//
//void pCL_CreateMove (float frametime, struct usercmd_s *cmd, int active)
//{
// LOG(createmove_start)
// gClientExports.CL_CreateMove(frametime,cmd,active);
// LOG(createmove_end)
//}
//
//void pHUD_TempEntUpdate (
// double frametime, // Simulation time
// double client_time, // Absolute time on client
// double cl_gravity, // True gravity on client
// TEMPENTITY **ppTempEntFree, // List of freed temporary ents
// TEMPENTITY **ppTempEntActive, // List
// int ( *Callback_AddVisibleEntity )( cl_entity_t *pEntity ),
// void ( *Callback_TempEntPlaySound )( TEMPENTITY *pTemp, float damp ) )
//{
// LOG(Tempent_start)
// typedef void (*HUD_TempEntUpdateFunc)(double,double,double,TEMPENTITY**,TEMPENTITY**, int(*)(cl_entity_t*),void(*)(TEMPENTITY*,float));
// (*(HUD_TempEntUpdateFunc)(gClientExports.HUD_TempEntUpdate))
// (
// frametime,
// client_time,
// cl_gravity,
// ppTempEntFree,
// ppTempEntActive,
// Callback_AddVisibleEntity,
// Callback_TempEntPlaySound
// );
// LOG(Tempent_end)
//}
//
//int pHUD_GetStudioModelInterface( int version, struct r_studio_interface_s **ppinterface, struct engine_studio_api_s *pstudio )
//{
// LOG(studiomodel_start)
// int nResult = gClientExports.HUD_GetStudioModelInterface(version,ppinterface,pstudio);
// LOG(studiomodel_end)
// return nResult;
//}
//
////=====================================================================
//void ClientApiHook(dllfuncs_t* df)
//{
// static bool firstcall = true;
// if(firstcall)
// {
// memcpy((char*)&gClientExports, (char*)df, sizeof(*df) );
// //__asm int 03
// df->Initialize = pInitialize;
// df->HUD_Redraw = pHUD_Redraw;
// df->HUD_AddEntity = pHUD_AddEntity;
// df->HUD_PlayerMove = pHUD_PlayerMove;
// df->V_CalcRefdef = pV_CalcRefdef;
// df->CL_CreateMove = pCL_CreateMove;
// df->HUD_TempEntUpdate = pHUD_TempEntUpdate;
// df->HUD_GetStudioModelInterface = pHUD_GetStudioModelInterface;
// firstcall = false;
// }
//}
//
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -