Пользователь
-
Автор темы
- #1
Okay, here is full spoonfeed with includes, cuz some people will not understand even how to define and hook classes
1. IClientNetworkable.hpp
C++:
#pragma once
class IClientUnknown;
class ClientClass;
class bf_read;
class IClientNetworkable
{
public:
virtual IClientUnknown* GetIClientUnknown() = 0;
virtual void Release() = 0;
virtual ClientClass* GetClientClass() = 0;
virtual void NotifyShouldTransmit(int state) = 0;
virtual void OnPreDataChanged(int updateType) = 0;
virtual void OnDataChanged(int updateType) = 0;
virtual void PreDataUpdate(int updateType) = 0;
virtual void PostDataUpdate(int updateType) = 0;
virtual void __unkn(void) = 0;
virtual bool IsDormant(void) = 0;
virtual int EntIndex(void) const = 0;
virtual void ReceiveMessage(int classID, bf_read& msg) = 0;
virtual void* GetDataTableBasePtr() = 0;
virtual void SetDestroyedOnRecreateEntities(void) = 0;
};
// classes, definitions
#include <cstddef>
namespace VirtualMethod
{
template <typename T, std::size_t Idx, typename ...Args>
constexpr auto call(void* classBase, Args... args) noexcept
{
return ((*reinterpret_cast<T(__thiscall***)(void*, Args...)>(classBase))[Idx])(classBase, args...);
}
}
#define VIRTUAL_METHOD(returnType, name, idx, args, argsRaw) \
constexpr auto name args noexcept \
{ \
return VirtualMethod::call<returnType, idx>argsRaw; \
}
class NetworkStringTable {
public:
VIRTUAL_METHOD(int, addString, 8, (bool isServer, const char* value, int length = -1, const void* userdata = nullptr), (this, isServer, value, length, userdata))
};
class NetworkStringTableContainer {
public:
VIRTUAL_METHOD(NetworkStringTable*, findTable, 3, (const char* name), (this, name))
};
2. csgo.hpp
C++:
#pragma once
#include "..\sdk\interfaces\IVEngineClient.hpp"
#include "..\sdk\interfaces\IInputSystem.hpp"
#include "..\sdk\interfaces\IBaseClientDll.hpp"
#include "..\sdk\interfaces\IClientEntityList.hpp"
#include "..\sdk\interfaces\IClientMode.hpp"
#include "..\sdk\interfaces\ICvar.hpp"
#include "..\sdk\interfaces\IEngineTrace.hpp"
#include "..\sdk\interfaces\IEngineSound.hpp"
#include "..\sdk\interfaces\IRenderView.hpp"
#include "..\sdk\interfaces\IVModelRender.hpp"
#include "..\sdk\interfaces\IMaterialSystem.hpp"
#include "..\sdk\interfaces\IPanel.hpp"
#include "..\sdk\interfaces\IVModelInfoClient.hpp"
#include "..\sdk\interfaces\IMDLCache.hpp"
#include "..\sdk\interfaces\memalloc.h"
#include "..\sdk\interfaces\CClientState.hpp"
#include "..\sdk\interfaces\IPrediction.hpp"
#include "..\sdk\interfaces\IMoveHelper.hpp"
#include "..\sdk\interfaces\CInput.hpp"
#include "..\sdk\interfaces\ISurface.hpp"
#include "..\sdk\interfaces\IVDebugOverlay.hpp"
#include "..\sdk\interfaces\IViewRenderBeams.hpp"
#include "..\sdk\interfaces\IPhysics.hpp"
#include "..\sdk\interfaces\ILocalize.hpp"
#include "..\sdk\interfaces\ISoundServices.hpp"
#include "..\sdk\misc\GlobalVars.hpp"
#include "..\sdk\misc\glow_outline_effect.hpp"
#include "..\sdk\interfaces\IGameEventManager.hpp"
#include "..\sdk\misc\C_CSPlayerResource.h"
#include <d3dx9.h>
#include <d3d9.h>
class InterfaceReg
{
private:
using InstantiateInterfaceFn = void*(*)();
public:
InstantiateInterfaceFn m_CreateFn;
const char *m_pName;
InterfaceReg *m_pNext;
};
class C_CSGO
{
public:
IDirect3DDevice9 * m_device();
IVEngineClient * m_engine();
IInputSystem * m_inputsys();
IBaseClientDLL * m_client();
IClientEntityList * m_entitylist();
ICvar * m_cvar();
IEngineTrace * m_trace();
IEngineSound * m_enginesound();
DWORD * m_inputinternal();
IVRenderView * m_renderview();
IMDLCache * m_modelcache();
IVModelRender * m_modelrender();
IMaterialSystem * m_materialsystem();
IPanel * m_panel();
IVModelInfoClient * m_modelinfo();
IPrediction * m_prediction();
IGameMovement * m_gamemovement();
ISurface * m_surface();
IVDebugOverlay * m_debugoverlay();
IPhysicsSurfaceProps * m_physsurface();
IGameEventManager2 * m_eventmanager();
IViewRenderBeams * m_viewrenderbeams();
IMemAlloc * m_memalloc();
IClientMode * m_clientmode();
CGlobalVarsBase * m_globals();
CGlowObjectManager * m_glow();
CClientState * m_clientstate();
IMoveHelper * m_movehelper();
CInput * m_input();
C_CSPlayerResource * m_playerresource();
CSGameRulesProxy * m_gamerules();
ILocalize * m_localize();
IBaseFileSystem* m_basefilesys();
NetworkStringTableContainer* m_networkStringTableContainer();
DWORD m_postprocessing();
DWORD m_ccsplayerrenderablevftable();
private:
IDirect3DDevice9 * p_device = nullptr;
IVEngineClient * p_engine = nullptr;
IInputSystem * p_inputsys = nullptr;
IBaseClientDLL * p_client = nullptr;
IClientEntityList * p_entitylist = nullptr;
IEngineTrace * p_trace = nullptr;
IEngineSound * p_enginesound = nullptr;
ICvar * p_cvar = nullptr;
DWORD * p_inputinternal = nullptr;
IVRenderView * p_renderview = nullptr;
IMDLCache* p_modelcache = nullptr;
IVModelRender * p_modelrender = nullptr;
IMaterialSystem * p_materialsystem = nullptr;
IPanel * p_panel = nullptr;
IVModelInfoClient * p_modelinfo = nullptr;
IPrediction * p_prediciton = nullptr;
IGameMovement * p_gamemovement = nullptr;
ISurface * p_surface = nullptr;
IVDebugOverlay * p_debugoverlay = nullptr;
IPhysicsSurfaceProps * p_physsurface = nullptr;
IGameEventManager2 * p_eventmanager = nullptr;
IViewRenderBeams * p_viewrenderbeams = nullptr;
IMemAlloc * p_memalloc = nullptr;
IClientMode * p_clientmode = nullptr;
CGlobalVarsBase * p_globals = nullptr;
CGlowObjectManager * p_glow = nullptr;
CClientState * p_clientstate = nullptr;
IMoveHelper * p_movehelper = nullptr;
CInput * p_input = nullptr;
C_CSPlayerResource * p_playerresource = nullptr;
CSGameRulesProxy * p_gamerules = nullptr;
ILocalize * p_localize = nullptr;
IBaseFileSystem* p_basefilesys = nullptr;
NetworkStringTableContainer* p_networkStringTableContainer = nullptr;
DWORD p_postprocessing = 0;
DWORD p_ccsplayerrenderablevftable = 0;
};
extern C_CSGO g_csgo;
3. csgo.cpp
C++:
// This is an independent project of an individual developer. Dear PVS-Studio, please check it.
// PVS-Studio Static Code Analyzer for C, C++, C#, and Java: http://www.viva64.com
#include "csgo.hpp"
#include "..\includes.hpp"
C_CSGO g_csgo;
#undef m_client
#undef m_clientmode
#undef m_clientstate
#undef m_cvar
#undef m_debugoverlay
#undef m_device
#undef m_engine
#undef m_enginesound
#undef m_entitylist
#undef m_eventmanager
#undef m_gamemovement
#undef m_gamerules
#undef m_globals
#undef m_glow
#undef m_input
#undef m_inputinternal
#undef m_inputsys
#undef m_localize
#undef m_materialsystem
#undef m_memalloc
#undef m_modelcache
#undef m_modelinfo
#undef m_modelrender
#undef m_movehelper
#undef m_panel
#undef m_physsurface
#undef m_playerresource
#undef m_postprocessing
#undef m_prediction
#undef m_renderview
#undef m_surface
#undef m_trace
#undef m_viewrenderbeams
#undef m_soundservices
#undef m_basefilesys
#undef m_networkStringTableContainer
template<typename T>
static T *get_interface(const char *mod_name, const char *interface_name, bool exact = false) {
T *iface = nullptr;
InterfaceReg *register_list;
int part_match_len = strlen(interface_name); //-V103
DWORD interface_fn = reinterpret_cast<DWORD>(GetProcAddress(GetModuleHandleA(mod_name), crypt_str("CreateInterface")));
if (!interface_fn) {
return nullptr;
}
unsigned int jump_start = (unsigned int)(interface_fn)+4;
unsigned int jump_target = jump_start + *(unsigned int*)(jump_start + 1) + 5;
register_list = **reinterpret_cast<InterfaceReg***>(jump_target + 6);
for (InterfaceReg *cur = register_list; cur; cur = cur->m_pNext) {
if (exact == true) {
if (strcmp(cur->m_pName, interface_name) == 0)
iface = reinterpret_cast<T*>(cur->m_CreateFn());
}
else {
if (!strncmp(cur->m_pName, interface_name, part_match_len) && std::atoi(cur->m_pName + part_match_len) > 0) //-V106
iface = reinterpret_cast<T*>(cur->m_CreateFn());
}
}
return iface;
}
IDirect3DDevice9 * C_CSGO::m_device() {
if (!p_device)
p_device = **reinterpret_cast<IDirect3DDevice9***>(util::FindSignature(crypt_str("shaderapidx9.dll"), g_ctx.signatures.at(0).c_str()) + 0x1);
return p_device;
}
IVEngineClient * C_CSGO::m_engine() {
if (!p_engine)
p_engine = get_interface<IVEngineClient>(crypt_str("engine.dll"), crypt_str("VEngineClient"));
return p_engine;
}
IInputSystem * C_CSGO::m_inputsys() {
if (!p_inputsys)
p_inputsys = get_interface<IInputSystem>(crypt_str("inputsystem.dll"), crypt_str("InputSystemVersion"));
return p_inputsys;
}
IBaseClientDLL * C_CSGO::m_client() {
if (!p_client)
p_client = get_interface<IBaseClientDLL>(crypt_str("client.dll"), crypt_str("VClient0"));
return p_client;
}
IClientEntityList * C_CSGO::m_entitylist() {
if (!p_entitylist)
p_entitylist = get_interface<IClientEntityList>(crypt_str("client.dll"), crypt_str("VClientEntityList"));
return p_entitylist;
}
ICvar * C_CSGO::m_cvar() {
if (!p_cvar)
p_cvar = get_interface<ICvar>(crypt_str("vstdlib.dll"), crypt_str("VEngineCvar"));
return p_cvar;
}
IEngineTrace * C_CSGO::m_trace() {
if (!p_trace)
p_trace = get_interface<IEngineTrace>(crypt_str("engine.dll"), crypt_str("EngineTraceClient"));
return p_trace;
}
IEngineSound* C_CSGO::m_enginesound() {
if (!p_enginesound)
p_enginesound = get_interface<IEngineSound>(crypt_str("engine.dll"), crypt_str("IEngineSoundClient"));
return p_enginesound;
}
DWORD* C_CSGO::m_inputinternal() {
if (!p_inputinternal)
p_inputinternal = get_interface<DWORD>(crypt_str("vgui2.dll"), crypt_str("VGUI_InputInternal"));
return p_inputinternal;
}
IVRenderView * C_CSGO::m_renderview() {
if (!p_renderview)
p_renderview = get_interface<IVRenderView>(crypt_str("engine.dll"), crypt_str("VEngineRenderView"));
return p_renderview;
}
IMDLCache * C_CSGO::m_modelcache() {
if (!p_modelcache)
p_modelcache = get_interface<IMDLCache>(crypt_str("datacache.dll"), crypt_str("MDLCache"));
return p_modelcache;
}
IVModelRender * C_CSGO::m_modelrender() {
if (!p_modelrender)
p_modelrender = get_interface<IVModelRender>(crypt_str("engine.dll"), crypt_str("VEngineModel"));
return p_modelrender;
}
IMaterialSystem * C_CSGO::m_materialsystem() {
if (!p_materialsystem)
p_materialsystem = get_interface<IMaterialSystem>(crypt_str("materialsystem.dll"), crypt_str("VMaterialSystem"));
return p_materialsystem;
}
IPanel * C_CSGO::m_panel() {
if (!p_panel)
p_panel = get_interface<IPanel>(crypt_str("vgui2.dll"), crypt_str("VGUI_Panel"));
return p_panel;
}
IVModelInfoClient * C_CSGO::m_modelinfo() {
if (!p_modelinfo)
p_modelinfo = get_interface<IVModelInfoClient>(crypt_str("engine.dll"), crypt_str("VModelInfoClient"));
return p_modelinfo;
}
IPrediction * C_CSGO::m_prediction() {
if (!p_prediciton)
p_prediciton = get_interface<IPrediction>(crypt_str("client.dll"), crypt_str("VClientPrediction"));
return p_prediciton;
}
IGameMovement * C_CSGO::m_gamemovement() {
if (!p_gamemovement)
p_gamemovement = get_interface<IGameMovement>(crypt_str("client.dll"), crypt_str("GameMovement"));
return p_gamemovement;
}
ISurface * C_CSGO::m_surface() {
if (!p_surface)
p_surface = get_interface<ISurface>(crypt_str("vguimatsurface.dll"), crypt_str("VGUI_Surface"));
return p_surface;
}
IVDebugOverlay * C_CSGO::m_debugoverlay() {
if (!p_debugoverlay)
p_debugoverlay = get_interface<IVDebugOverlay>(crypt_str("engine.dll"), crypt_str("VDebugOverlay"));
return p_debugoverlay;
}
IPhysicsSurfaceProps * C_CSGO::m_physsurface() {
if (!p_physsurface)
p_physsurface = get_interface< IPhysicsSurfaceProps >(crypt_str("vphysics.dll"), crypt_str("VPhysicsSurfaceProps"));
return p_physsurface;
}
IGameEventManager2 * C_CSGO::m_eventmanager() {
if (!p_eventmanager)
p_eventmanager = get_interface<IGameEventManager2>(crypt_str("engine.dll"), crypt_str("GAMEEVENTSMANAGER002"), true);
return p_eventmanager;
}
IViewRenderBeams * C_CSGO::m_viewrenderbeams() {
if (!p_viewrenderbeams)
p_viewrenderbeams = *reinterpret_cast<IViewRenderBeams **>(util::FindSignature(crypt_str("client.dll"), g_ctx.signatures.at(1).c_str()) + 0x1);
return p_viewrenderbeams;
}
IMemAlloc * C_CSGO::m_memalloc() {
if (!p_memalloc)
p_memalloc = *reinterpret_cast<IMemAlloc**>(GetProcAddress(GetModuleHandle(crypt_str("tier0.dll")), crypt_str("g_pMemAlloc")));
return p_memalloc;
}
IClientMode * C_CSGO::m_clientmode() {
if (!p_clientmode)
p_clientmode = **reinterpret_cast<IClientMode***>((*(DWORD**)(m_client()))[10] + 0x5);
return p_clientmode;
}
CGlobalVarsBase * C_CSGO::m_globals() {
if (!p_globals)
p_globals = **reinterpret_cast<CGlobalVarsBase***>((*(DWORD**)(m_client()))[0] + 0x1F);
return p_globals;
}
CGlowObjectManager * C_CSGO::m_glow() {
if (!p_glow)
p_glow = *reinterpret_cast<CGlowObjectManager**>(util::FindSignature(crypt_str("client.dll"), g_ctx.signatures.at(2).c_str()) + 0x3);
return p_glow;
}
CClientState * C_CSGO::m_clientstate() {
if (!p_clientstate)
p_clientstate = **reinterpret_cast<CClientState***> ((*reinterpret_cast<uintptr_t**> (m_engine()))[12] + 0x10);
return p_clientstate;
}
IMoveHelper * C_CSGO::m_movehelper() {
if (!p_movehelper)
p_movehelper = **reinterpret_cast<IMoveHelper***>(util::FindSignature(crypt_str("client.dll"), g_ctx.signatures.at(3).c_str()) + 0x2);
return p_movehelper;
}
CInput * C_CSGO::m_input() {
if (!p_input)
p_input = *reinterpret_cast<CInput**>(util::FindSignature(crypt_str("client.dll"), g_ctx.signatures.at(4).c_str()) + 0x1);
return p_input;
}
C_CSPlayerResource * C_CSGO::m_playerresource() {
if (!p_playerresource)
p_playerresource = **reinterpret_cast<C_CSPlayerResource ***>(util::FindSignature(crypt_str("client.dll"), g_ctx.signatures.at(5).c_str()) + 0x2);
else if (g_ctx.globals.should_update_playerresource)
{
g_ctx.globals.should_update_playerresource = false;
p_playerresource = **reinterpret_cast<C_CSPlayerResource ***>(util::FindSignature(crypt_str("client.dll"), g_ctx.signatures.at(5).c_str()) + 0x2);
}
return p_playerresource;
}
CSGameRulesProxy * C_CSGO::m_gamerules() {
if (!p_gamerules)
p_gamerules = **reinterpret_cast<CSGameRulesProxy ***>(util::FindSignature(crypt_str("client.dll"), g_ctx.signatures.at(6).c_str()) + 0x1);
else if (g_ctx.globals.should_update_gamerules)
{
g_ctx.globals.should_update_gamerules = false;
p_gamerules = **reinterpret_cast<CSGameRulesProxy ***>(util::FindSignature(crypt_str("client.dll"), g_ctx.signatures.at(6).c_str()) + 0x1);
}
return p_gamerules;
}
IBaseFileSystem* C_CSGO::m_basefilesys() {
if (!p_basefilesys)
p_basefilesys = get_interface<IBaseFileSystem>("filesystem_stdio.dll", "VBaseFileSystem");
return p_basefilesys;
}
ILocalize * C_CSGO::m_localize()
{
if (!p_localize)
p_localize = get_interface< ILocalize >(crypt_str("localize.dll"), crypt_str("Localize_"));
return p_localize;
}
NetworkStringTableContainer* C_CSGO::m_networkStringTableContainer() {
if (!p_networkStringTableContainer)
p_networkStringTableContainer = get_interface< NetworkStringTableContainer >(crypt_str("engine.dll"), crypt_str("VEngineClientStringTable"));
return p_networkStringTableContainer;
}
DWORD C_CSGO::m_postprocessing() {
if (!p_postprocessing)
p_postprocessing = *(DWORD*)(util::FindSignature(crypt_str("client.dll"), g_ctx.signatures.at(7).c_str()) + 0x2);
return p_postprocessing;
}
DWORD C_CSGO::m_ccsplayerrenderablevftable() {
if (!p_ccsplayerrenderablevftable)
p_ccsplayerrenderablevftable = *(DWORD *)(util::FindSignature(crypt_str("client.dll"), g_ctx.signatures.at(8).c_str()) + 0x4E);
return p_ccsplayerrenderablevftable;
}
4. includes.hpp
Just add here at the end
C++:
#define m_networkStringTableContainer g_csgo.m_networkStringTableContainer
// will use bool this later
extern bool LoadPlayerMdlOnce;
Add this code at the beginning of source
C++:
bool LoadPlayerMdlOnce = false;
// Load custom model
bool LoadModel(const char* thisModelName)
{
const auto CustomModel = m_networkStringTableContainer()->findTable("modelprecache");
if (CustomModel)
{
m_modelinfo()->GetModelIndex(thisModelName);
int MdlNum = CustomModel->addString(false, thisModelName);
if (MdlNum == NULL)
return false;
}
return true;
}
// one by one
void InitCustomModels()
{
// only once, no need to spam this every frame...
// cache will be reloaded each new map
if (!LoadPlayerMdlOnce)
{
LoadModel("models/player/custom_player/kuristaja/cso2/mila/mila.mdl");
LoadPlayerMdlOnce = true;
}
}
6. Add your model now to the player list - SkinChanger.cpp
C++:
// todo - separation for various team models.
static const char* player_model_index_t[] =
{
"models/player/custom_player/legacy/tm_phoenix_variantf.mdl",
"models/player/custom_player/legacy/tm_phoenix_varianth.mdl",
"models/player/custom_player/legacy/tm_leet_variantg.mdl",
"models/player/custom_player/legacy/tm_balkan_varianti.mdl",
"models/player/custom_player/legacy/tm_leet_varianth.mdl",
"models/player/custom_player/legacy/tm_phoenix_variantg.mdl",
"models/player/custom_player/legacy/tm_balkan_variantf.mdl",
"models/player/custom_player/legacy/tm_balkan_variantj.mdl",
"models/player/custom_player/legacy/tm_leet_varianti.mdl",
"models/player/custom_player/legacy/tm_balkan_variantg.mdl",
"models/player/custom_player/legacy/tm_balkan_varianth.mdl",
"models/player/custom_player/legacy/tm_leet_variantf.mdl",
"models/player/custom_player/kuristaja/cso2/mila/mila.mdl"
};
static const char* player_model_index_ct[] =
{
"models/player/custom_player/legacy/ctm_st6_variante.mdl",
"models/player/custom_player/legacy/ctm_st6_variantk.mdl",
"models/player/custom_player/legacy/ctm_fbi_variantf.mdl",
"models/player/custom_player/legacy/ctm_sas_variantf.mdl",
"models/player/custom_player/legacy/ctm_fbi_variantg.mdl",
"models/player/custom_player/legacy/ctm_st6_variantg.mdl",
"models/player/custom_player/legacy/ctm_st6_variantm.mdl",
"models/player/custom_player/legacy/ctm_st6_varianti.mdl",
"models/player/custom_player/legacy/ctm_fbi_variantb.mdl",
"models/player/custom_player/kuristaja/cso2/mila/mila.mdl"
};
7. Goto SkinChanger.cpp function run and add precache
C++:
void SkinChanger::run(ClientFrameStage_t stage) noexcept
{
if (stage != FRAME_NET_UPDATE_POSTDATAUPDATE_START)
return;
if (!g_ctx.local())
return;
// load custom models
InitCustomModels();
8. Add now to menu list >_< constchars.h
C++:
const char* player_model_t[] =
{
"None",
"Enforcer",
"Soldier",
"Ground Rebel",
"Maximus",
"Osiris",
"Slingshot",
"Dragomir",
"Blackwolf",
"Prof. Shahmat",
"Rezan The Ready",
"Doctor Romanov",
"Mr. Muhlik",
"CS Online 2: Mila"
};
const char* player_model_ct[] =
{
"None",
"Seal Team 6",
"3rd Commando",
"Operator FBI",
"Squadron Officer",
"Markus Delrow",
"Buckshot",
"McCoy",
"Commander Ricksaw",
"Agent Ava",
"CS Online 2: Mila"
};
9. Now we need to set our bool to false again, if we are disconnected or map is changing
Do it doesn't matter where... I prefer function HUD_REDRAW, so goto hooked_painttraverse.cpp
C++:
void __fastcall hooks::hooked_painttraverse(void* ecx, void* edx, vgui::VPANEL panel, bool force_repaint, bool allow_force)
{
static auto original_fn = panel_hook->get_func_address <PaintTraverse_t> (41);
g_ctx.local((player_t*)m_entitylist()->GetClientEntity(m_engine()->GetLocalPlayer()), true); //-V807
// reset if not ingame, or is not connected
if (!m_engine()->IsInGame() || !m_engine()->IsConnected())
LoadPlayerMdlOnce = false;
Remember! Model path are defined into it's source, so if you want to create your own model path - you need to decompile .mdl file and set your own.
I'm using Crowbar for example.
Ok, you've done everything, you are cool cucumber now
If you have a questions, just ask, gonna release this now for supremacy
Последнее редактирование: