diff --git a/csgo2/csgo2.vcxproj b/csgo2/csgo2.vcxproj
index 33fcf4c..52e434f 100644
--- a/csgo2/csgo2.vcxproj
+++ b/csgo2/csgo2.vcxproj
@@ -230,6 +230,7 @@
+
diff --git a/csgo2/csgo2.vcxproj.filters b/csgo2/csgo2.vcxproj.filters
index fb83021..16c4ebf 100644
--- a/csgo2/csgo2.vcxproj.filters
+++ b/csgo2/csgo2.vcxproj.filters
@@ -369,6 +369,9 @@
源文件\script_engine\lua_cjson
+
+ 头文件\sdk\public
+
diff --git a/csgo2/dllmain.cpp b/csgo2/dllmain.cpp
index 186337d..a6714d7 100644
--- a/csgo2/dllmain.cpp
+++ b/csgo2/dllmain.cpp
@@ -35,9 +35,9 @@ auto init(void* ctx) -> bool {
serverHandle = reinterpret_cast(GetModuleHandleA("server.dll"));
localizeHandle = reinterpret_cast(GetModuleHandleA("localize.dll"));
- Sleep(200);
+ Sleep(100);
}
- global::isMetaModInit = (GetModuleHandleA("metamod.2.cs2.dll") != nullptr);
+ global::IsMetaModInit = (GetModuleHandleA("metamod.2.cs2.dll") != nullptr);
if (Offset::Init() == false) {
LOG("Offset::Init() == false !\n");
return false;
diff --git a/csgo2/global.cpp b/csgo2/global.cpp
index 9f8ded0..bb961d4 100644
--- a/csgo2/global.cpp
+++ b/csgo2/global.cpp
@@ -7,5 +7,6 @@ namespace global {
CGlobalVars* GlobalVars;
float m_flUniversalTime;
float m_flLastTickedTime;
- bool isMetaModInit;
+ bool IsMetaModInit;
+ bool IsDisableBlood;
}
\ No newline at end of file
diff --git a/csgo2/global.h b/csgo2/global.h
index 802a32a..9f2c56f 100644
--- a/csgo2/global.h
+++ b/csgo2/global.h
@@ -10,5 +10,6 @@ namespace global {
extern CGlobalVars* GlobalVars;
extern float m_flUniversalTime;
extern float m_flLastTickedTime;
- extern bool isMetaModInit;
+ extern bool IsMetaModInit;
+ extern bool IsDisableBlood;
}
\ No newline at end of file
diff --git a/csgo2/hooks.cpp b/csgo2/hooks.cpp
index 69e9cfd..c18ba9a 100644
--- a/csgo2/hooks.cpp
+++ b/csgo2/hooks.cpp
@@ -6,6 +6,8 @@ namespace hooks {
VMTHook* VMT_IServerGameClient;
VMTHook* VMT_INetworkServerServiceInteFace;
VMTHook* VMT_ISource2ServerInterFace;
+VMTHook* VMT_GameEventSystem;
+
FireEventServerSide_t original_FireEventServerSide = NULL;
OnClientConnect_t original_OnClientConnected = NULL;
OnClientDisconnect_t original_OnClientDisconnect = NULL;
@@ -14,23 +16,45 @@ StartupServer_t origin_StartServer = NULL;
GameFrame_t origin_GameFrame = NULL;
CCSWeaponBase_Spawn_t origin_CCSWeaponBase_Spawn = NULL;
UTIL_SayText2Filter_t origin_UTIL_SayText2Filter = NULL;
+PostEventAbstract_t origin_PostEventAbstract = NULL;
+void __fastcall hook_PostEventAbstract(
+ void* rcx,
+ CSplitScreenSlot nSlot,
+ bool bLocalOnly,
+ int nClientCount,
+ const uint64* clients,
+ INetworkSerializable* pEvent,
+ const void* pData,
+ unsigned long nSize,
+ NetChannelBufType_t bufType)
+{
+ /*
+ if (global::IsDisableBlood == true) {
+ NetMessageInfo_t* info = pEvent->GetNetMessageInfo();
+ if (info) {
+ if (info->m_MessageId == TE_WorldDecalId)
+ {
+ LOG("delete the blood in here \n");
+ //*(uint64_t*)clients &= ~((uint64)1 << nSlot.Get());
+ }
+ }
+ }
+
+ */
+ if (pEvent) {
+ NetMessageInfo_t* info = pEvent->GetNetMessageInfo();
+ if (info && info->m_MessageId != 0) {
+ LOG("1111:%d \n", info->m_MessageId);
+ }
+ }
+ return origin_PostEventAbstract(rcx, nSlot, bLocalOnly, nClientCount, clients, pEvent, pData, nSize, bufType);
+}
void __fastcall hook_UTIL_SayText2Filter(
IRecipientFilter& filter, CCSPlayerController* pEntity,
uint64_t eMessageType, const char* messeageName, const char* param1,
const char* param2, const char* param3, const char* param4) {
const auto entIndex =
PlayerSlot_to_EntityIndex(filter.GetRecipientIndex(0).Get());
- /*
-LOG("UTIL_SayText2Filter: %s\n", messeageName);
-LOG("entIndex: %d\n", entIndex);
-
-LOG("param1: %s\n", param1);
-LOG("param2: %s\n", param2);
-
-LOG("param3: %s\n", param3);
-LOG("param4: %s\n", param4);
-LOG("eMessageType: %d\n", eMessageType);
-*/
const auto isHandle = ScriptCallBacks::luCall_onSayText2Filter(
entIndex, eMessageType, messeageName, param1, param2, param3, param4);
if (isHandle == false) {
@@ -110,6 +134,9 @@ void __fastcall hook_GameFrame(void* rcx, bool simulating, bool bFirstTick,
if (global::EntitySystem == nullptr) {
global::EntitySystem = CGameEntitySystem::GetInstance();
}
+ if (global::GlobalVars == nullptr) {
+ global::GlobalVars = GetGameGlobals();
+ }
return origin_GameFrame(rcx, simulating, bFirstTick, bLastTick);
}
void __fastcall hook_StartServer(void* rcx,
@@ -300,7 +327,12 @@ auto initVmtHook() -> bool {
VMT_ISource2ServerInterFace =
new VMTHook(Memory::read(reinterpret_cast(
Offset::InterFaces::ISource2ServerInterFace)));
+ VMT_GameEventSystem =
+ new VMTHook(Memory::read(reinterpret_cast(
+ Offset::InterFaces::GameEventSystem)));
+ origin_PostEventAbstract = reinterpret_cast(
+ VMT_GameEventSystem->Hook(16, hook_PostEventAbstract));
original_OnClientConnected = reinterpret_cast(
VMT_IServerGameClient->Hook(11, hook_OnClientConnected));
original_OnClientDisconnect = reinterpret_cast(
@@ -323,8 +355,14 @@ auto init() -> bool {
}
auto unload() -> void {
VMT_IServerGameClient->ClearHooks();
+ VMT_INetworkServerServiceInteFace->ClearHooks();
+ VMT_ISource2ServerInterFace->ClearHooks();
+ VMT_GameEventSystem->ClearHooks();
delete VMT_IServerGameClient;
+ delete VMT_INetworkServerServiceInteFace;
+ delete VMT_ISource2ServerInterFace;
+ delete VMT_GameEventSystem;
MH_DisableHook(MH_ALL_HOOKS);
MH_RemoveHook(MH_ALL_HOOKS);
diff --git a/csgo2/hooks.h b/csgo2/hooks.h
index 278a580..a5ef475 100644
--- a/csgo2/hooks.h
+++ b/csgo2/hooks.h
@@ -19,7 +19,7 @@ typedef void(__fastcall* UTIL_SayText2Filter_t)(IRecipientFilter&,
const char*, const char*,
const char*, const char*,
const char*);
-
+typedef void(__fastcall* PostEventAbstract_t)(void*, CSplitScreenSlot, bool, int, const uint64_t*, INetworkSerializable*, const void*, unsigned long, NetChannelBufType_t);
namespace hooks {
extern Host_Say_t original_Host_Say;
auto init() -> bool;
diff --git a/csgo2/module.h b/csgo2/module.h
index 874ed91..d37d078 100644
--- a/csgo2/module.h
+++ b/csgo2/module.h
@@ -4,7 +4,7 @@
class InterfaceReg;
//cancer fix me plz
namespace global {
- extern bool isMetaModInit;
+ extern bool IsMetaModInit;
};
// Pointer arithmetic utility class.
struct UTILPtr {
@@ -119,7 +119,7 @@ class CModule {
private:
void InitializeHandle() {
- if (global::isMetaModInit == false) {
+ if (global::IsMetaModInit == false) {
this->m_handle = static_cast(GetModuleHandleA(this->GetName()));
return;
}
diff --git a/csgo2/offset.cpp b/csgo2/offset.cpp
index 31bee9b..d3e9933 100644
--- a/csgo2/offset.cpp
+++ b/csgo2/offset.cpp
@@ -34,6 +34,7 @@ CLocalize* ILocalize;
INetworkServerService* INetworkServerServiceInteFace;
CCSGameRules* CCSGameRulesInterFace;
ICvar* IVEngineCvar;
+IGameEventSystem* GameEventSystem;
}; // namespace InterFaces
auto SafeDelayInit(void* ctx) -> void {
// ҪϷúʼ
@@ -108,10 +109,13 @@ auto Init() -> bool {
InterFaces::INetworkServerServiceInteFace =
reinterpret_cast(
engine.FindInterface("NetworkServerService_001").Get());
+ InterFaces::GameEventSystem = reinterpret_cast(
+ engine.FindInterface("GameEventSystemServerV001").Get());
InterFaces::IServerGameClient = reinterpret_cast(
server.FindInterface("Source2GameClients001").Get());
InterFaces::ISource2ServerInterFace = reinterpret_cast(
server.FindInterface("Source2Server001").Get());
+
if (InterFaces::ISource2ServerInterFace) {
InterFaces::GameEventManager =
(IGameEventManager2*)(CALL_VIRTUAL(
@@ -156,6 +160,8 @@ auto Init() -> bool {
LOG("[huoji]InterFaces::ISource2ServerInterFace : %llx \n",
InterFaces::ISource2ServerInterFace);
LOG("[huoji]InterFaces::IVEngineCvar : %llx \n", InterFaces::IVEngineCvar);
+ LOG("[huoji]InterFaces::GameEventSystem : %llx \n", InterFaces::GameEventSystem);
+
LOG("[huoji] CGameEntitySystem::GetInstance : %llx \n",
CGameEntitySystem::GetInstance());
LOG("init offset success !\n");
@@ -166,6 +172,7 @@ auto Init() -> bool {
// sizeof("here") - 1, 0x31415926));
return FnPlayerChangeName && FnCCSWeaponBase_Spawn && FnEntityRemove &&
FnRespawnPlayerInDeathMatch && FnGiveNamedItem && Host_SayPtr &&
+ InterFaces::GameEventSystem &&
InterFaces::IVEngineServer &&
InterFaces::GameResourceServiceServer &&
InterFaces::IServerGameClient && InterFaces::GameEventManager &&
diff --git a/csgo2/offset.h b/csgo2/offset.h
index fa94f36..4bb92ee 100644
--- a/csgo2/offset.h
+++ b/csgo2/offset.h
@@ -6,6 +6,11 @@ class CCSPlayerPawn;
class CGameEntitySystem;
class CCSPlayerController;
class CBaseEntity;
+class IGameEventSystem;
+class CSchemaSystem;
+class CGameResourceService;
+class CLocalize;
+class CCSGameRules;
typedef uint64_t(__fastcall* HashFunction_t)(const char*, unsigned int,
unsigned int);
typedef void(__fastcall* StateChanged_t)(void* networkTransmitComponent,
@@ -32,10 +37,7 @@ typedef void(__fastcall* ClientPrint_t)(CCSPlayerController* player,
const char* param3, const char* param4);
typedef void(__fastcall* CCSWeaponBase_Spawn_t)(CBaseEntity*, void*);
typedef void(__fastcall* PlayerChangeName_t)(CBaseEntity*, char*);
-class CSchemaSystem;
-class CGameResourceService;
-class CLocalize;
-class CCSGameRules;
+
namespace Offset {
namespace InterFaces {
extern CSchemaSystem* SchemaSystem;
@@ -49,6 +51,7 @@ extern INetworkServerService* INetworkServerServiceInteFace;
extern ISource2Server* ISource2ServerInterFace;
extern CCSGameRules* CCSGameRulesInterFace;
extern ICvar* IVEngineCvar;
+extern IGameEventSystem* GameEventSystem;
}; // namespace InterFaces
static const auto pattern_FnUTIL_SayText2FilterPtr = THE_GAME_SIG(
"48 89 5C 24 ?? 55 56 57 48 8D 6C 24 ?? 48 81 EC ?? ?? ?? ?? 41 0F B6 F8");
diff --git a/csgo2/script_apis.cpp b/csgo2/script_apis.cpp
index 139c271..db9d639 100644
--- a/csgo2/script_apis.cpp
+++ b/csgo2/script_apis.cpp
@@ -968,8 +968,17 @@ auto luaApi_GetConVarObject(lua_State* luaVm) -> int {
const auto name = lua_tostring(luaVm, 1);
lua_pushnumber(luaVm,
Offset::InterFaces::IVEngineCvar->FindConVar(name).Get());
+ lua_pop(luaVm, 1);
+
return 1;
}
+
+auto luaApi_SetServerBloodStatus(lua_State* luaVm) -> int {
+ // param: isEnableBoold:bool
+ global::IsDisableBlood = !lua_toboolean(luaVm, 1);
+ lua_pop(luaVm, 1);
+ return 0;
+}
auto initFunciton(lua_State* luaVm) -> void {
lua_register(luaVm, "ListenToGameEvent", luaApi_ListenToGameEvent);
lua_register(luaVm, "luaApi_SetPlayerCurrentWeaponAmmo",
@@ -1029,6 +1038,7 @@ auto initFunciton(lua_State* luaVm) -> void {
lua_register(luaVm, "luaApi_GetPlayerName", luaApi_GetPlayerName);
lua_register(luaVm, "luaApi_SetPlayerNameSlient",
luaApi_SetPlayerNameSlient);
+ lua_register(luaVm, "luaApi_SetServerBloodStatus", luaApi_SetServerBloodStatus);
// lua_register(luaVm, "luaApi_TeleportPlayer", luaApi_TeleportPlayer);
diff --git a/csgo2/sdk/public/eiface.h b/csgo2/sdk/public/eiface.h
index dbabd48..e116d5b 100644
--- a/csgo2/sdk/public/eiface.h
+++ b/csgo2/sdk/public/eiface.h
@@ -161,6 +161,7 @@ class EconControlPointInfo_t;
struct EconItemInfo_t {
};
+class bf_read;
class bf_write;
typedef uint32_t SpawnGroupHandle_t;
typedef uint32_t SwapChainHandle_t;
diff --git a/csgo2/sdk/public/igameeventsystem.h b/csgo2/sdk/public/igameeventsystem.h
new file mode 100644
index 0000000..644b089
--- /dev/null
+++ b/csgo2/sdk/public/igameeventsystem.h
@@ -0,0 +1,147 @@
+#include "../sdk.h"
+class IAppSystem;
+class CUtlSlot;
+class CUtlAbstractDelegate;
+class CBaseHandle;
+typedef uint16 NetworkMessageId;
+typedef uint8 NetworkGroupId;
+typedef uint NetworkCategoryId;
+
+enum NetChannelBufType_t
+{
+ kFuckOffAss
+};
+
+enum NetworkValidationMode_t
+{
+ kFuckOffAss_NetworkValidationMode
+};
+class IProtobufBinding
+{
+public:
+ virtual const char* GetName() = 0;
+ virtual int GetSize() = 0;
+
+ virtual const char* ToString(const void* pData, CUtlString& sResult) = 0;
+
+ virtual const char* GetGroup() = 0;
+ virtual Color GetGroupColor() = 0;
+ virtual NetChannelBufType_t GetBufType() = 0;
+
+ virtual bool ReadFromBuffer(void* pData, bf_read& pBuf) = 0;
+ virtual bool WriteToBuffer(const void* pData, bf_write& pBuf) = 0;
+
+ virtual void* AllocateMessage() = 0;
+ virtual void DeallocateMessage(void* pMsg) = 0;
+ virtual void* AllocateAndCopyConstructNetMessage(const void* pOther) = 0;
+
+ virtual bool OkToRedispatch() = 0;
+ virtual void Copy(const void* pFrom, void* pTo) = 0;
+ virtual bool unk001() = 0;
+};
+
+struct NetMessageInfo_t
+{
+ int m_nCategories;
+ IProtobufBinding* m_pBinding;
+ CUtlString m_szGroup;
+ NetworkMessageId m_MessageId;
+ NetworkGroupId m_GroupId;
+
+ // (1 << 0) - FLAG_RELIABLE
+ // (1 << 6) - FLAG_AUTOASSIGNEDID
+ // (1 << 7) - FLAG_UNK001
+ uint8 m_nFlags;
+
+ int m_unk001;
+ int m_unk002;
+ bool m_bOkayToRedispatch;
+};
+enum NetworkSerializationMode_t
+{
+ NET_SERIALIZATION_MODE_0 = 0x0,
+ NET_SERIALIZATION_MODE_1 = 0x1,
+ NET_SERIALIZATION_MODE_COUNT = 0x2,
+ NET_SERIALIZATION_MODE_DEFAULT = 0x0,
+ NET_SERIALIZATION_MODE_SERVER = 0x0,
+ NET_SERIALIZATION_MODE_CLIENT = 0x1,
+};
+enum ETEProtobufIds_t {
+ TE_EffectDispatchId = 400,
+ TE_ArmorRicochetId = 401,
+ TE_BeamEntPointId = 402,
+ TE_BeamEntsId = 403,
+ TE_BeamPointsId = 404,
+ TE_BeamRingId = 405,
+ TE_BSPDecalId = 407,
+ TE_BubblesId = 408,
+ TE_BubbleTrailId = 409,
+ TE_DecalId = 410,
+ TE_WorldDecalId = 411,
+ TE_EnergySplashId = 412,
+ TE_FizzId = 413,
+ TE_ShatterSurfaceId = 414,
+ TE_GlowSpriteId = 415,
+ TE_ImpactId = 416,
+ TE_MuzzleFlashId = 417,
+ TE_BloodStreamId = 418,
+ TE_ExplosionId = 419,
+ TE_DustId = 420,
+ TE_LargeFunnelId = 421,
+ TE_SparksId = 422,
+ TE_PhysicsPropId = 423,
+ TE_PlayerDecalId = 424,
+ TE_ProjectedDecalId = 425,
+ TE_SmokeId = 426
+};
+class INetworkSerializable
+{
+public:
+ virtual ~INetworkSerializable() = 0;
+
+ virtual const char* GetUnscopedName() = 0;
+ virtual NetMessageInfo_t* GetNetMessageInfo() = 0;
+
+ virtual void SetMessageId(unsigned short nMessageId) = 0;
+
+ virtual void AddCategoryMask(int nMask, bool) = 0;
+
+ virtual void SwitchMode(NetworkValidationMode_t nMode) = 0;
+
+ virtual void* AllocateMessage() = 0;
+ virtual void DeallocateMessage(void* pMsg) = 0;
+ virtual void* AllocateAndCopyConstructNetMessage(void const* pOther) = 0;
+
+ virtual bool Serialize(bf_write& pBuf, void const* pData, NetworkSerializationMode_t unused) = 0;
+ virtual bool Unserialize(bf_read& pBuf, void* pData, NetworkSerializationMode_t unused) = 0;
+};
+
+class IGameEventSystem : public IAppSystem
+{
+public:
+ //vmt index 11
+ virtual void RegisterGameEvent(INetworkSerializable * pEvent) = 0;
+
+ virtual void RegisterGameEventHandlerAbstract(CUtlSlot* nSlot, const CUtlAbstractDelegate& delegate, INetworkSerializable* pEvent) = 0;
+ virtual void UnregisterGameEventHandlerAbstract(CUtlSlot* nSlot, const CUtlAbstractDelegate& delegate, INetworkSerializable* pEvent) = 0;
+
+ // Providing nSize has no effect and is unused.
+ virtual void PostEventAbstract_Local(CSplitScreenSlot nSlot, INetworkSerializable* pEvent, const void* pData, unsigned long nSize) = 0;
+
+ // Providing nSlot as -1 would select 0nth slot.
+ // clients pointer is a masked uint64 value where (client index - 1) is mapped to each bit.
+ // Providing nClientCount as -1 and clients pointer as NULL would post event to all available clients.
+ // Providing nSize has no effect and is unused.
+ virtual void PostEventAbstract(CSplitScreenSlot nSlot, bool bLocalOnly, int nClientCount, const uint64* clients,
+ INetworkSerializable* pEvent, const void* pData, unsigned long nSize, NetChannelBufType_t bufType) = 0;
+ virtual void PostEventAbstract(CSplitScreenSlot nSlot, bool bLocalOnly, IRecipientFilter* pFilter,
+ INetworkSerializable* pEvent, const void* pData, unsigned long nSize) = 0;
+
+ // Posts the event to all clients, even tho the function name tells otherwise
+ // Providing nSize has no effect and is unused.
+ virtual void PostEntityEventAbstract(const CBaseHandle& hndl, INetworkSerializable* pEvent, const void* pData, unsigned long nSize, NetChannelBufType_t bufType) = 0;
+
+ virtual void ProcessQueuedEvents() = 0;
+ virtual int GetEventSource() const = 0;
+ virtual void PurgeQueuedEvents() = 0;
+};
\ No newline at end of file
diff --git a/csgo2/sdk/sdk.h b/csgo2/sdk/sdk.h
index 1b2f594..dc5ee15 100644
--- a/csgo2/sdk/sdk.h
+++ b/csgo2/sdk/sdk.h
@@ -112,3 +112,4 @@ inline T AlignValue(T val, uintptr_t alignment) {
#include "gameevent/IGameEvent.h"
#include "tier1/bufferstring.h"
#include "public/eiface.h"
+#include "public/igameeventsystem.h"