From dc75327decf38bccf699240192049c46cd5eccc7 Mon Sep 17 00:00:00 2001
From: Huoji's <1296564236@qq.com>
Date: Mon, 2 Oct 2023 17:31:02 +0800
Subject: [PATCH] =?UTF-8?q?=E7=BB=9F=E4=B8=80native=5Fsdk?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
csgo2/csgo2.vcxproj | 21 +-
csgo2/csgo2.vcxproj.filters | 75 +---
csgo2/dllmain.cpp | 2 +-
csgo2/events.cpp | 30 +-
csgo2/events.h | 7 +-
csgo2/global.h | 2 +-
csgo2/head.h | 62 ++++
csgo2/hooks.cpp | 20 +-
csgo2/hooks.h | 4 +-
csgo2/interface.cpp | 2 +-
csgo2/interface.h | 2 +-
csgo2/memory.h | 2 +-
csgo2/module.h | 2 +-
csgo2/{schema.cpp => native_sdk.cpp} | 58 ++-
csgo2/native_sdk.h | 334 ++++++++++++++++++
csgo2/native_sdk/cgameentitysystem.cpp | 6 -
csgo2/native_sdk/cgameentitysystem.h | 63 ----
csgo2/native_sdk/cgameresourceserviceserver.h | 12 -
csgo2/native_sdk/cschemasystem.cpp | 13 -
csgo2/native_sdk/cschemasystem.h | 77 ----
csgo2/native_sdk/entity/cbaseentity.cpp | 4 -
csgo2/native_sdk/entity/cbaseentity.h | 42 ---
.../native_sdk/entity/cbaseplayercontroller.h | 23 --
csgo2/native_sdk/entity/cbaseplayerpawn.h | 14 -
csgo2/native_sdk/entity/ccollisionproperty.h | 21 --
csgo2/native_sdk/entity/ccsplayercontroller.h | 12 -
csgo2/native_sdk/entity/ccsplayerpawn.h | 9 -
csgo2/native_sdk/entity/services.h | 18 -
csgo2/native_sdk/handle/handle.cpp | 11 -
csgo2/native_sdk/handle/handle.h | 24 --
csgo2/offset.h | 8 +-
csgo2/pch.cpp | 14 -
csgo2/pch.h | 32 --
csgo2/player.cpp | 6 -
csgo2/player.h | 35 --
csgo2/player_manager.cpp | 1 -
csgo2/player_manager.h | 3 +-
csgo2/schema.h | 60 ----
csgo2/sdk/interfaces/interfaces.h | 1 +
csgo2/sdk/sdk.h | 2 +-
csgo2/sdk_tools.cpp | 34 ++
csgo2/sdk_tools.h | 10 +
csgo2/vmt.cpp | 14 +
csgo2/vmt.h | 2 +-
csgo2/{VTHook.cpp => vmthook.cpp} | 2 -
csgo2/vmthook.h | 6 +-
46 files changed, 573 insertions(+), 629 deletions(-)
create mode 100644 csgo2/head.h
rename csgo2/{schema.cpp => native_sdk.cpp} (61%)
create mode 100644 csgo2/native_sdk.h
delete mode 100644 csgo2/native_sdk/cgameentitysystem.cpp
delete mode 100644 csgo2/native_sdk/cgameentitysystem.h
delete mode 100644 csgo2/native_sdk/cgameresourceserviceserver.h
delete mode 100644 csgo2/native_sdk/cschemasystem.cpp
delete mode 100644 csgo2/native_sdk/cschemasystem.h
delete mode 100644 csgo2/native_sdk/entity/cbaseentity.cpp
delete mode 100644 csgo2/native_sdk/entity/cbaseentity.h
delete mode 100644 csgo2/native_sdk/entity/cbaseplayercontroller.h
delete mode 100644 csgo2/native_sdk/entity/cbaseplayerpawn.h
delete mode 100644 csgo2/native_sdk/entity/ccollisionproperty.h
delete mode 100644 csgo2/native_sdk/entity/ccsplayercontroller.h
delete mode 100644 csgo2/native_sdk/entity/ccsplayerpawn.h
delete mode 100644 csgo2/native_sdk/entity/services.h
delete mode 100644 csgo2/native_sdk/handle/handle.cpp
delete mode 100644 csgo2/native_sdk/handle/handle.h
delete mode 100644 csgo2/player.cpp
delete mode 100644 csgo2/player.h
delete mode 100644 csgo2/schema.h
create mode 100644 csgo2/sdk_tools.cpp
create mode 100644 csgo2/sdk_tools.h
create mode 100644 csgo2/vmt.cpp
rename csgo2/{VTHook.cpp => vmthook.cpp} (92%)
diff --git a/csgo2/csgo2.vcxproj b/csgo2/csgo2.vcxproj
index 897f09f..98c197e 100644
--- a/csgo2/csgo2.vcxproj
+++ b/csgo2/csgo2.vcxproj
@@ -158,6 +158,7 @@
+
@@ -172,17 +173,10 @@
-
-
-
-
-
-
+
-
-
@@ -196,6 +190,7 @@
+
@@ -212,10 +207,7 @@
-
-
-
-
+
Create
@@ -223,12 +215,11 @@
Create
Create
-
-
-
+
+
diff --git a/csgo2/csgo2.vcxproj.filters b/csgo2/csgo2.vcxproj.filters
index 8544c47..a677b18 100644
--- a/csgo2/csgo2.vcxproj.filters
+++ b/csgo2/csgo2.vcxproj.filters
@@ -49,27 +49,9 @@
{c28f9f29-7571-4821-9cbd-11f27692566a}
-
- {e26bdf5e-ad8d-4ed2-965c-1fdb958a6098}
-
{c5938a38-9035-4f7a-952c-156a8549bb54}
-
- {ec02337e-1abc-42a9-b29c-355278bf4bf2}
-
-
- {6c9da4be-92c5-4504-8c46-ab0cc612bfe5}
-
-
- {f1101bd0-b17e-4c9e-87f1-e34d97979e77}
-
-
- {63beb427-0b96-4062-83e0-752efb2ed5f0}
-
-
- {68556c7c-97c0-4e1e-82f0-e4b45b9ad40d}
-
{befb97b4-a3ba-48a8-84a8-c36a74d2d48c}
@@ -168,33 +150,9 @@
头文件\sdk\interfaces
-
- 头文件\native_sdk\interfaces
-
-
- 头文件\native_sdk\interfaces
-
-
- 头文件\native_sdk\interfaces
-
-
- 头文件\native_sdk\entity
-
头文件\memory
-
- 头文件\native_sdk\entity
-
-
- 头文件\native_sdk\handle
-
-
- 头文件\native_sdk\entity
-
-
- 头文件\native_sdk\interfaces
-
头文件\sdk\convar
@@ -219,6 +177,15 @@
头文件\players
+
+ 头文件
+
+
+ 头文件\native_sdk
+
+
+ 头文件\native_sdk
+
@@ -260,24 +227,9 @@
源文件\events
-
- 源文件\native_sdk\interfaces
-
-
+
源文件\memory
-
- 源文件\native_sdk\interfaces
-
-
- 源文件\native_sdk\interfaces
-
-
- 源文件\native_sdk\entity
-
-
- 源文件\native_sdk\handle
-
头文件\sdk\convar
@@ -287,8 +239,11 @@
源文件\players
-
- 源文件\native_sdk\entity
+
+ 源文件\native_sdk
+
+
+ 源文件\native_sdk
diff --git a/csgo2/dllmain.cpp b/csgo2/dllmain.cpp
index 6751781..476bf36 100644
--- a/csgo2/dllmain.cpp
+++ b/csgo2/dllmain.cpp
@@ -1,5 +1,5 @@
// dllmain.cpp : 定义 DLL 应用程序的入口点。
-#include "pch.h"
+#include "head.h"
auto unload() -> void {
hooks::unload();
diff --git a/csgo2/events.cpp b/csgo2/events.cpp
index c1bef74..8b0a85e 100644
--- a/csgo2/events.cpp
+++ b/csgo2/events.cpp
@@ -1,7 +1,4 @@
#include "events.h"
-#include "native_sdk/entity/cbaseplayercontroller.h"
-#include "player.h"
-#include "player_manager.h"
namespace events {
auto OnPlayerDeathEvent(IGameEvent* event) -> void {
@@ -13,21 +10,18 @@ auto OnPlayerDeathEvent(IGameEvent* event) -> void {
const auto attacker = reinterpret_cast(
event->GetPlayerPawn(&attackerNameParams));
- CGameEntitySystem* pEntitySystem = CGameEntitySystem::GetInstance();
- if (!pEntitySystem) return;
-
- for (int i = 1; i <= 64; ++i) {
- CBaseEntity* pEntity = pEntitySystem->GetBaseEntity(i);
- if (!pEntity) continue;
- if (pEntity->IsBasePlayerController()) {
- const auto player = reinterpret_cast(pEntity);
- if (player->m_hPawn().Get() == victim) {
- printf("Found Pawn Player: %d %s \n", player->GetRefEHandle().GetEntryIndex(),&player->m_iszPlayerName());
- break;
- }
- }
- }
//printf("player[%p] %s kill[%p] %llu\n", attacker, &attacker->m_iszPlayerName(), victim, &victim->m_steamID());
}
-auto OnPlayerChat(IGameEvent* event) -> void {}
+auto OnPlayerChat(CCSPlayerController* player, std::string message) -> bool {
+ auto [procesChatSuccess, chatType, chatCtx] = SdkTools::ProcessChatString(message);
+ if (procesChatSuccess == false) {
+ return false;
+ }
+
+ LOG("player %s say[%d]: %s steamid: %llu\n", &player->m_iszPlayerName(), chatType ,chatCtx.c_str(), player->m_steamID());
+ if (chatCtx.at(0) == '/' || chatCtx.at(0) == '!') {
+ return true;
+ }
+ return false;
+}
} // namespace events
diff --git a/csgo2/events.h b/csgo2/events.h
index 50c2e13..56bcc37 100644
--- a/csgo2/events.h
+++ b/csgo2/events.h
@@ -1,8 +1,7 @@
#pragma once
-#include "pch.h"
-#include "sdk/gameevent/IGameEvent.h"
-
+#include "head.h"
+class CCSPlayerController;
namespace events {
auto OnPlayerDeathEvent(IGameEvent* event) -> void;
- auto OnPlayerChat(IGameEvent* event) -> void;
+ auto OnPlayerChat(CCSPlayerController* player, std::string message) -> bool;
}
diff --git a/csgo2/global.h b/csgo2/global.h
index a5cfaed..b6797cd 100644
--- a/csgo2/global.h
+++ b/csgo2/global.h
@@ -1,5 +1,5 @@
#pragma once
-#include "pch.h"
+#include "head.h"
namespace global {
extern bool Exit;
extern int MaxPlayers;
diff --git a/csgo2/head.h b/csgo2/head.h
new file mode 100644
index 0000000..4423a50
--- /dev/null
+++ b/csgo2/head.h
@@ -0,0 +1,62 @@
+#pragma once
+#include
+#include
+#include
+#include
+#include
+#include
+#include