Skip to content

Commit 4ce0fe0

Browse files
committed
实现HSI对于死亡消息的网络上传
1 parent 063aff2 commit 4ce0fe0

11 files changed

Lines changed: 1507 additions & 759 deletions

File tree

0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

bin/MulNX/CS2OBTool/CS2OBTool.dll

9.5 KB
Binary file not shown.

bin/MulNX/CS2OBTool/UISystem/Config/MulNXUIConfig.ini

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ Collapsed=0
219219
DockId=0x00000009,0
220220

221221
[Window][音视频]
222-
Pos=1526,189
222+
Pos=1544,282
223223
Size=406,434
224224
Collapsed=0
225225

@@ -273,7 +273,7 @@ DockId=0x0000000C,0
273273

274274
[Window][时间轴]
275275
Pos=0,0
276-
Size=1920,57
276+
Size=1920,39
277277
Collapsed=0
278278
DockId=0x00000001,0
279279

@@ -293,6 +293,6 @@ DockNode ID=0x0000000A Pos=820,750 Size=685,394 Split=X
293293
DockNode ID=0x0000000C Parent=0x0000000A SizeRef=606,407 Selected=0x4DB1B67D
294294
DockNode ID=0x0000000D Pos=1276,584 Size=451,292 Selected=0x8BE9650D
295295
DockSpace ID=0x633F05CB Window=0xFB32D03B Pos=0,0 Size=1920,1080 Split=Y Selected=0xC52A91C6
296-
DockNode ID=0x00000001 Parent=0x633F05CB SizeRef=1920,57 Selected=0x38DB91B6
297-
DockNode ID=0x00000002 Parent=0x633F05CB SizeRef=1920,1021 CentralNode=1
296+
DockNode ID=0x00000001 Parent=0x633F05CB SizeRef=1920,39 Selected=0x38DB91B6
297+
DockNode ID=0x00000002 Parent=0x633F05CB SizeRef=1920,1039 CentralNode=1
298298

bin/MulNX/Log/Log_CS2Injector.txt

Lines changed: 100 additions & 100 deletions
Large diffs are not rendered by default.

bin/MulNX/Log/Log_CS2OBTool.txt

Lines changed: 1283 additions & 650 deletions
Large diffs are not rendered by default.

source/MulNXExtensions/CS2/Buildup/CS2Hash/CS2Hash.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#include "CS2Hash.hpp"
22

3+
uint32_t CS2Hash::WrapHash(const std::string& str) {
4+
return this->CSHashString(str.c_str(), str.length(), str.length() ^ 0x31415926);
5+
}
6+
37
bool CS2Hash::Init() {
48
this->SubscribeSync("Hook/LoadLibraryExW/client.dll", [this](MulNX::Message& msg) {
59
auto pattern = MulNX::CS2::Signatures::Utils::CSHashString;
@@ -16,6 +20,15 @@ bool CS2Hash::Init() {
1620
// hitgroup 实际使用子串 "roup",长度 4,种子 0x1717BDDE
1721
this->hitgroup = this->CSHashString("roup", 4, 0x1717BDDE);
1822

23+
this->assistedflash = this->WrapHash("assistedflash");
24+
this->weapon = this->WrapHash("weapon");
25+
this->headshot = this->WrapHash("headshot");
26+
this->penetrated = this->WrapHash("penetrated");
27+
this->noscope = this->WrapHash("noscope");
28+
this->thrusmoke = this->WrapHash("thrusmoke");
29+
this->attackerblind = this->WrapHash("attackerblind");
30+
this->attackerinair = this->WrapHash("attackerinair");
31+
1932
this->LogSucc("找到CS2哈希函数并计算哈希值");
2033
});
2134

source/MulNXExtensions/CS2/Buildup/CS2Hash/CS2Hash.hpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,22 @@
22
#include <Intro/CSModuleBase.hpp>
33

44
class CS2Hash final :public CSModuleBase {
5-
using HashFunc_t = uint32_t(__fastcall*)(const char* str, size_t len, uint32_t seed);
5+
using HashFunc_t = uint32_t(__fastcall*)(const char* str, uint32_t len, uint32_t seed);
66
HashFunc_t CSHashString{ nullptr };
7-
7+
uint32_t WrapHash(const std::string& str);
88
bool Init()override;
99
public:
1010
uint32_t attacker = 0;
1111
uint32_t userid = 0;
1212
uint32_t assister = 0;
1313
uint32_t hitgroup = 0;
14+
15+
uint32_t assistedflash = 0;
16+
uint32_t weapon = 0;
17+
uint32_t headshot = 0;
18+
uint32_t penetrated = 0;
19+
uint32_t noscope = 0;
20+
uint32_t thrusmoke = 0;
21+
uint32_t attackerblind = 0;
22+
uint32_t attackerinair = 0;
1423
};
Lines changed: 75 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,85 @@
11
#include "HSI.hpp"
22
#include <Intro/HookGameEvents/HookGameEvents.hpp>
3+
#include <Buildup/CS2Hash/CS2Hash.hpp>
4+
#include <nlohmann/json.hpp>
35

46
bool HSI::Init() {
57
this->SubscribeSync("Hook/FireEventClientSide/player_death", [this](MulNX::Message& msg) {
68
auto&& [pEvent] = msg.Access<CS2::CGameEvent*>();
7-
std::string test("游戏事件");
8-
this->WebPost(test);
9+
this->OnDeathEvent(pEvent);
10+
});
11+
12+
this->SendTask("Main", "CSControl", [this]() {
13+
this->Main();
14+
return true;
915
});
1016

1117
return true;
18+
}
19+
20+
void HSI::OnDeathEvent(CS2::CGameEvent* event) {
21+
static CS2::CKV3MemberName attacker{ this->CS2Hashs->attacker, -1, nullptr };
22+
static CS2::CKV3MemberName userid{ this->CS2Hashs->userid, -1, nullptr };
23+
static CS2::CKV3MemberName assister{ this->CS2Hashs->assister, -1, nullptr };
24+
25+
static CS2::CKV3MemberName assistedflash{ CS2Hashs->assistedflash, -1, nullptr };
26+
static CS2::CKV3MemberName weapon{ CS2Hashs->weapon, -1, nullptr };
27+
static CS2::CKV3MemberName headshot{ CS2Hashs->headshot, -1, nullptr };
28+
static CS2::CKV3MemberName penetrated{ CS2Hashs->penetrated, -1, nullptr };
29+
static CS2::CKV3MemberName noscope{ CS2Hashs->noscope, -1, nullptr };
30+
static CS2::CKV3MemberName thrusmoke{ CS2Hashs->thrusmoke, -1, nullptr };
31+
static CS2::CKV3MemberName attackerblind{ CS2Hashs->attackerblind, -1, nullptr };
32+
static CS2::CKV3MemberName attackerinair{ CS2Hashs->attackerinair, -1, nullptr };
33+
34+
// 读取并填充结构体
35+
KillEvent kEvent;
36+
kEvent.assistedflash = event->GetInt(assistedflash);
37+
kEvent.headshot = event->GetInt(headshot);
38+
kEvent.penetrated = event->GetInt(penetrated);
39+
kEvent.noscope = event->GetInt(noscope);
40+
kEvent.thrusmoke = event->GetInt(thrusmoke);
41+
kEvent.attackerblind = event->GetInt(attackerblind);
42+
kEvent.attackerinair = event->GetInt(attackerinair);
43+
const char* weaponStr = event->GetString(weapon);
44+
kEvent.weapon = weaponStr ? weaponStr : "";
45+
46+
try {
47+
auto pAttacker = event->GetPlayerController(attacker);
48+
auto pVictim = event->GetPlayerController(userid);
49+
auto pAssister = event->GetPlayerController(assister);
50+
51+
kEvent.attacker = MulNX::MRead(pAttacker->m_steamID());
52+
kEvent.victim = MulNX::MRead(pVictim->m_steamID());
53+
if (pAssister)kEvent.assister = MulNX::MRead(pAssister->m_steamID());
54+
else kEvent.assister = 0;
55+
}
56+
catch (MulNX::Exception& e) {
57+
this->LogError(e);
58+
this->LogError("丢失了一个击杀事件");
59+
return;
60+
}
61+
62+
this->buffer.enqueue(std::move(kEvent));
63+
}
64+
65+
void HSI::Main() {
66+
KillEvent kEvent;
67+
if (!this->buffer.try_dequeue(kEvent))return;
68+
69+
nlohmann::json j;
70+
j["assistedflash"] = kEvent.assistedflash;
71+
j["weapon"] = kEvent.weapon;
72+
j["headshot"] = kEvent.headshot;
73+
j["penetrated"] = kEvent.penetrated;
74+
j["noscope"] = kEvent.noscope;
75+
j["thrusmoke"] = kEvent.thrusmoke;
76+
j["attackerblind"] = kEvent.attackerblind;
77+
j["attackerinair"] = kEvent.attackerinair;
78+
79+
// SteamID 转为字符串,与原始 JSON 格式一致
80+
j["attackerSteamId"] = std::to_string(kEvent.attacker);
81+
j["victimSteamId"] = std::to_string(kEvent.victim);
82+
j["assistSteamId"] = std::to_string(kEvent.assister);
83+
84+
this->WebPost(j.dump());
1285
}

source/MulNXExtensions/CS2/Outro/HSI/HSI.hpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,26 @@
22
#include <Intro/CSModuleBase.hpp>
33
#include <MulNXExtensions/WebSocketManager/WebSocketMixin.hpp>
44

5+
namespace CS2 {
6+
class CGameEvent;
7+
}
58
class HSI final :public CSModuleBase, public WebSocketMixin<HSI> {
9+
struct KillEvent {
10+
Steam64UID attacker;
11+
Steam64UID victim;
12+
Steam64UID assister;
13+
14+
int assistedflash;
15+
int headshot;
16+
int penetrated;
17+
int noscope;
18+
int thrusmoke;
19+
int attackerblind;
20+
int attackerinair;
21+
std::string weapon; // weapon 是字符串,单独处理
22+
};
23+
moodycamel::ConcurrentQueue<KillEvent>buffer{};
624
bool Init()override;
25+
void OnDeathEvent(CS2::CGameEvent*);
26+
void Main();
727
};

0 commit comments

Comments
 (0)