init
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
#include "CGameEntitySystem.h"
|
||||
#include "..\..\hooks\hooks.h"
|
||||
|
||||
void* CGameEntitySystem::GetEntityByIndex(int nIndex) {
|
||||
return H::ogGetBaseEntity(this, nIndex);
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include "../../../cs2/entity/handle.h"
|
||||
#include "../../../templeware/utils/memory/memorycommon.h"
|
||||
#include "../../../templeware/utils/math/vector/vector.h"
|
||||
#include "..\..\..\..\source\templeware\utils\schema\schema.h"
|
||||
#include "..\..\..\..\source\templeware\utils\memory\vfunc\vfunc.h"
|
||||
|
||||
#include "..\..\..\cs2\entity\C_BaseEntity\C_BaseEntity.h"
|
||||
#include "..\..\..\cs2\entity\C_CSPlayerPawn\C_CSPlayerPawn.h"
|
||||
#include "..\..\..\cs2\entity\CCSPlayerController\CCSPlayerController.h"
|
||||
|
||||
class CGameEntitySystem
|
||||
{
|
||||
public:
|
||||
template <typename T = C_BaseEntity>
|
||||
T* Get(int nIndex)
|
||||
{
|
||||
return reinterpret_cast<T*>(this->GetEntityByIndex(nIndex));
|
||||
}
|
||||
|
||||
/// GetClientEntityFromHandle
|
||||
template <typename T = C_BaseEntity>
|
||||
T* Get(const CBaseHandle hHandle)
|
||||
{
|
||||
if (!hHandle.valid())
|
||||
return nullptr;
|
||||
|
||||
return reinterpret_cast<T*>(this->GetEntityByIndex(hHandle.index()));
|
||||
}
|
||||
|
||||
int GetHighestEntityIndex()
|
||||
{
|
||||
return *reinterpret_cast<int*>(reinterpret_cast<std::uintptr_t>(this) + 0x20F0);
|
||||
}
|
||||
|
||||
|
||||
C_CSPlayerPawn* get_entity(int index)
|
||||
{
|
||||
__int64 v2; // rcx
|
||||
__int64 v3; // r8
|
||||
__int64 result{}; // rax
|
||||
|
||||
if ((unsigned int)index <= 0x7FFE
|
||||
&& (unsigned int)(index >> 9) <= 0x3F
|
||||
&& (v2 = *(std::uintptr_t*)(std::uintptr_t(this) + 8 * (index >> 9) + 16)) != 0
|
||||
&& (v3 = 120 * (index & 0x1FF), v3 + v2)
|
||||
&& (*(std::uintptr_t*)(v3 + v2 + 16) & 0x7FFF) == index)
|
||||
{
|
||||
result = *(std::uintptr_t*)(v3 + v2);
|
||||
}
|
||||
return reinterpret_cast<C_CSPlayerPawn*>(result);
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
void* GetEntityByIndex(int nIndex);
|
||||
|
||||
};
|
||||
|
||||
class IGameResourceService
|
||||
{
|
||||
public:
|
||||
MEM_PAD(0x58);
|
||||
CGameEntitySystem* Instance;
|
||||
};
|
||||
@@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
|
||||
// used: callvfunc
|
||||
#include "..\..\utils\memory\vfunc\vfunc.h"
|
||||
#include <type_traits>
|
||||
class IEngineClient
|
||||
{
|
||||
public:
|
||||
int maxClients()
|
||||
{
|
||||
return M::vfunc<int, 34U>(this);
|
||||
}
|
||||
|
||||
bool in_game()
|
||||
{
|
||||
return M::vfunc<bool, 35U>(this);
|
||||
}
|
||||
|
||||
bool connected()
|
||||
{
|
||||
return M::vfunc<bool, 36U>(this);
|
||||
}
|
||||
|
||||
int get_local_player() {
|
||||
int nIndex = -1;
|
||||
M::vfunc<void, 49U>(this, std::ref(nIndex), 0);
|
||||
return nIndex + 1;
|
||||
}
|
||||
public:
|
||||
inline bool valid() {
|
||||
return connected() && in_game();
|
||||
}
|
||||
|
||||
};
|
||||
36
TempleWare-CS2/source/templeware/interfaces/interfaces.cpp
Normal file
36
TempleWare-CS2/source/templeware/interfaces/interfaces.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
#include "interfaces.h"
|
||||
#include "CGameEntitySystem/CGameEntitySystem.h"
|
||||
|
||||
// @used: I::Get<template>
|
||||
#include "..\..\templeware\utils\memory\Interface\Interface.h"
|
||||
bool I::Interfaces::init()
|
||||
{
|
||||
const HMODULE tier0_base = GetModuleHandleA("tier0.dll");
|
||||
if (!tier0_base)
|
||||
return false;
|
||||
|
||||
bool success = true;
|
||||
|
||||
// interfaces
|
||||
EngineClient = I::Get<IEngineClient>(("engine2.dll"), "Source2EngineToClient00");
|
||||
success &= (EngineClient != nullptr);
|
||||
|
||||
GameEntity = I::Get<IGameResourceService>(("engine2.dll"), "GameResourceServiceClientV00");
|
||||
success &= (GameEntity != nullptr);
|
||||
|
||||
// exports
|
||||
ConstructUtlBuffer = reinterpret_cast<decltype(ConstructUtlBuffer)>(GetProcAddress(tier0_base, "??0CUtlBuffer@@QEAA@HHH@Z"));
|
||||
EnsureCapacityBuffer = reinterpret_cast<decltype(EnsureCapacityBuffer)>(GetProcAddress(tier0_base, "?EnsureCapacity@CUtlBuffer@@QEAAXH@Z"));
|
||||
PutUtlString = reinterpret_cast<decltype(PutUtlString)>(GetProcAddress(tier0_base, "?PutString@CUtlBuffer@@QEAAXPEBD@Z"));
|
||||
CreateMaterial = reinterpret_cast<decltype(CreateMaterial)>(M::FindPattern("materialsystem2.dll", "48 89 5C 24 ? 48 89 6C 24 ? 56 57 41 56 48 81 EC ? ? ? ? 48 8B 05"));
|
||||
LoadKeyValues = reinterpret_cast<decltype(LoadKeyValues)>(GetProcAddress(tier0_base, "?LoadKV3@@YA_NPEAVKeyValues3@@PEAVCUtlString@@PEBDAEBUKV3ID_t@@2@Z"));
|
||||
ConMsg = reinterpret_cast<decltype(ConMsg)>(GetProcAddress(tier0_base, "?ConMsg@@YAXPEBDZZ"));
|
||||
ConColorMsg = reinterpret_cast<decltype(ConColorMsg)>(GetProcAddress(tier0_base, "?ConColorMsg@@YAXAEBVColor@@PEBDZZ"));
|
||||
|
||||
printf("Source2EngineToClient00: 0x%p\n", reinterpret_cast<void*>(EngineClient));
|
||||
printf("GameResourceServiceClientV00: 0x%p\n", reinterpret_cast<void*>(GameEntity));
|
||||
printf("CreateMaterial: 0x%p\n", reinterpret_cast<void*>(CreateMaterial));
|
||||
|
||||
// return status
|
||||
return success;
|
||||
}
|
||||
27
TempleWare-CS2/source/templeware/interfaces/interfaces.h
Normal file
27
TempleWare-CS2/source/templeware/interfaces/interfaces.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
#include "IEngineClient/IEngineClient.h"
|
||||
#include "CGameEntitySystem/CGameEntitySystem.h"
|
||||
#include "..\..\cs2\entity\C_CSPlayerPawn\C_CSPlayerPawn.h"
|
||||
#include "..\..\cs2\datatypes\cutlbuffer\cutlbuffer.h"
|
||||
#include "..\..\cs2\datatypes\keyvalues\keyvalues.h"
|
||||
#include "..\..\cs2\entity\C_Material\C_Material.h"
|
||||
|
||||
namespace I
|
||||
{
|
||||
inline void(__fastcall* EnsureCapacityBuffer)(CUtlBuffer*, int) = nullptr;
|
||||
inline CUtlBuffer* (__fastcall* ConstructUtlBuffer)(CUtlBuffer*, int, int, int) = nullptr;
|
||||
inline void(__fastcall* PutUtlString)(CUtlBuffer*, const char*);
|
||||
inline std::int64_t(__fastcall* CreateMaterial)(void*, void*, const char*, void*, unsigned int, unsigned int);
|
||||
inline bool(__fastcall* LoadKeyValues)(CKeyValues3*, void*, const char*, const KV3ID_t*, const char*);
|
||||
|
||||
// Logging functions
|
||||
inline void(__fastcall* ConMsg)(const char*, ...);
|
||||
inline void(__fastcall* ConColorMsg)(const Color&, const char*, ...);
|
||||
|
||||
inline IEngineClient* EngineClient = nullptr;
|
||||
inline IGameResourceService* GameEntity = nullptr;
|
||||
class Interfaces {
|
||||
public:
|
||||
bool init();
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user