Files
csgo2_tiny_server_plugin_sy…/csgo2/offset.cpp

167 lines
7.4 KiB
C++
Raw Normal View History

2023-10-01 02:28:13 +08:00
#include "offset.h"
namespace Offset {
uint64_t GameResourceServicePtr;
uint64_t FireEventServerSidePtr;
uint64_t CGameEventManagerPtr;
2023-10-04 06:01:28 +08:00
uint64_t CCSGameRulesInterFacePtr;
2023-10-01 02:28:13 +08:00
uint64_t Host_SayPtr;
uint64_t Module_tier0;
2023-10-02 05:03:37 +08:00
uint64_t MaxPlayerNumsPtr;
2023-10-03 00:25:23 +08:00
HashFunction_t FnServerHashFunction;
2023-10-03 04:07:50 +08:00
StateChanged_t FnStateChanged;
NetworkStateChanged_t FnNetworkStateChanged;
2023-10-09 02:33:33 +08:00
RespawnPlayerInDeathMatch_t FnRespawnPlayerInDeathMatch;
2023-10-05 03:24:31 +08:00
GiveNamedItem_t FnGiveNamedItem;
EntityRemove_t FnEntityRemove;
2023-10-06 05:08:40 +08:00
UTIL_SayTextFilter_t FnUTIL_SayTextFilter;
UTIL_ClientPrintAll_t FnUTIL_ClientPrintAll;
ClientPrint_t FnClientPrint;
2023-10-08 02:29:04 +08:00
CCSWeaponBase_Spawn_t FnCCSWeaponBase_Spawn;
2023-10-06 05:08:40 +08:00
// CreateGameRuleInterFace_t FnCreateCCSGameRulesInterFace;
2023-10-04 22:49:16 +08:00
bool InitOffsetSuccess = false;
2023-10-01 02:28:13 +08:00
namespace InterFaces {
CSchemaSystem* SchemaSystem;
IGameEventManager2* GameEventManager;
CGameEventManager* CGameEventManger;
CGameResourceService* GameResourceServiceServer;
IServerGameClients* IServerGameClient;
IVEngineServer2* IVEngineServer;
2023-10-03 00:25:23 +08:00
ISource2Server* ISource2ServerInterFace;
2023-10-03 04:07:50 +08:00
CLocalize* ILocalize;
INetworkServerService* INetworkServerServiceInteFace;
2023-10-04 06:01:28 +08:00
CCSGameRules* CCSGameRulesInterFace;
2023-10-08 01:56:49 +08:00
ICvar* IVEngineCvar;
}; // namespace InterFaces
2023-10-04 22:49:16 +08:00
auto SafeDelayInit(void* ctx) -> void {
// <20><>Ҫ<EFBFBD><D2AA>Ϸ<EFBFBD><CFB7><EFBFBD>ú<EFBFBD><C3BA><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>
2023-10-06 05:08:40 +08:00
InterFaces::CCSGameRulesInterFace = reinterpret_cast<CCSGameRules*>(
Memory::read<CCSGameRules*>(CCSGameRulesInterFacePtr));
2023-10-04 22:49:16 +08:00
2023-10-06 05:08:40 +08:00
while (InterFaces::CCSGameRulesInterFace == 0) {
InterFaces::CCSGameRulesInterFace = reinterpret_cast<CCSGameRules*>(
Memory::read<CCSGameRules*>(CCSGameRulesInterFacePtr));
2023-10-04 22:49:16 +08:00
Sleep(100);
}
InitOffsetSuccess = true;
2023-10-06 05:08:40 +08:00
LOG("[huoji]InterFaces::CCSGameRulesInterFace : %llx \n",
InterFaces::CCSGameRulesInterFace);
LOG("m_bForceTeamChangeSilent: %d \n",
InterFaces::CCSGameRulesInterFace->m_bForceTeamChangeSilent());
2023-10-04 22:49:16 +08:00
}
2023-10-10 03:00:15 +08:00
2023-10-01 02:28:13 +08:00
auto Init() -> bool {
CModule server("server.dll");
CModule schemasystem("schemasystem.dll");
CModule engine("engine2.dll");
2023-10-03 04:07:50 +08:00
CModule localize("localize.dll");
2023-10-09 20:31:59 +08:00
CModule tier0("tier0.dll");
2023-10-10 16:49:15 +08:00
Memory::PathVscript();
2023-10-03 04:07:50 +08:00
2023-10-02 05:03:37 +08:00
// engine.dll
2023-10-04 06:01:28 +08:00
engine.FindPattern(pattern_MaxPlayerNumsPtr)
.ToAbsolute(3, 0)
.Get(MaxPlayerNumsPtr);
2023-10-01 02:28:13 +08:00
// server.dll
server.FindPattern(pattern_FireEventServerSide).Get(FireEventServerSidePtr);
2023-10-03 04:07:50 +08:00
server.FindPattern(pattern_NetworkStateChanged).Get(FnNetworkStateChanged);
server.FindPattern(pattern_FnStateChangedPtr).Get(FnStateChanged);
server.FindPattern(pattern_CGameEventManager)
.ToAbsolute(3, 0)
.Get(CGameEventManagerPtr);
2023-10-04 06:01:28 +08:00
server.FindPattern(pattern_CreateCCSGameRulesInterFacePtr)
2023-10-04 22:49:16 +08:00
.ToAbsolute(3, 0)
2023-10-04 06:01:28 +08:00
.Get(CCSGameRulesInterFacePtr);
2023-10-09 02:33:33 +08:00
server.FindPattern(pattern_FnRespawnPlayerInDeathMatch).Get(FnRespawnPlayerInDeathMatch);
2023-10-06 05:08:40 +08:00
server.FindPattern(pattern_FnEntityRemove).Get(FnEntityRemove);
server.FindPattern(pattern_FnGiveNamedItemPtr).Get(FnGiveNamedItem);
2023-10-01 02:28:13 +08:00
server.FindPattern(pattern_fnHost_SayPtr).Get(Host_SayPtr);
//server.FindPattern(pattern_ServerHashFunctionPtr).Get(FnServerHashFunction);
2023-10-06 05:08:40 +08:00
server.FindPattern(pattern_UTIL_ClientPrintAll).Get(FnUTIL_ClientPrintAll);
server.FindPattern(pattern_FnClientPrint).Get(FnClientPrint);
server.FindPattern(pattern_FnUTIL_SayTextFilter).Get(FnUTIL_SayTextFilter);
2023-10-08 02:29:04 +08:00
server.FindPattern(pattern_CCSWeaponBase_Spawn).Get(FnCCSWeaponBase_Spawn);
InterFaces::SchemaSystem = reinterpret_cast<CSchemaSystem*>(
schemasystem.FindInterface("SchemaSystem_001").Get());
2023-10-04 06:01:28 +08:00
// InterFaces::GameEventManager = reinterpret_cast<IGameEventManager2*>(
// engine.FindInterface("GameEventSystemServerV001").Get());
InterFaces::ILocalize = reinterpret_cast<CLocalize*>(
localize.FindInterface("Localize_001").Get());
2023-10-08 01:56:49 +08:00
InterFaces::IVEngineCvar = reinterpret_cast<ICvar*>(
2023-10-09 20:31:59 +08:00
tier0.FindInterface("VEngineCvar007").Get());
2023-10-08 01:56:49 +08:00
InterFaces::GameResourceServiceServer =
reinterpret_cast<CGameResourceService*>(
engine.FindInterface("GameResourceServiceServerV001").Get());
InterFaces::IVEngineServer = reinterpret_cast<IVEngineServer2*>(
engine.FindInterface("Source2EngineToServer001").Get());
2023-10-04 06:01:28 +08:00
InterFaces::INetworkServerServiceInteFace =
reinterpret_cast<INetworkServerService*>(
engine.FindInterface("NetworkServerService_001").Get());
InterFaces::IServerGameClient = reinterpret_cast<IServerGameClients*>(
server.FindInterface("Source2GameClients001").Get());
2023-10-03 00:25:23 +08:00
InterFaces::ISource2ServerInterFace = reinterpret_cast<ISource2Server*>(
server.FindInterface("Source2Server001").Get());
2023-10-08 01:56:49 +08:00
2023-10-03 00:25:23 +08:00
if (InterFaces::ISource2ServerInterFace) {
2023-10-04 06:01:28 +08:00
InterFaces::GameEventManager =
(IGameEventManager2*)(CALL_VIRTUAL(
uintptr_t, 91,
InterFaces::ISource2ServerInterFace) -
8);
2023-10-03 00:25:23 +08:00
}
InterFaces::CGameEventManger =
reinterpret_cast<CGameEventManager*>(CGameEventManagerPtr);
2023-10-04 22:49:16 +08:00
2023-10-04 06:01:28 +08:00
// global::MaxPlayers = *(int*)((char*)MaxPlayerNumsPtr + 2);
// client.FindPattern(pattern_FireEventServerSide).Get(FireEventServerSidePtr);
2023-10-03 00:25:23 +08:00
global::MaxPlayers = 64;
2023-10-01 02:28:13 +08:00
LOG("[huoji]FireEventServerSidePtr : %llx \n", FireEventServerSidePtr);
LOG("[huoji]Host_SayPtr : %llx \n", Host_SayPtr);
2023-10-03 04:07:50 +08:00
LOG("[huoji]FnNetworkStateChanged : %llx \n", FnNetworkStateChanged);
//LOG("[huoji]FnServerHashFunction : %llx \n", FnServerHashFunction);
2023-10-03 04:07:50 +08:00
LOG("[huoji]FnStateChanged : %llx \n", FnStateChanged);
2023-10-09 02:33:33 +08:00
LOG("[huoji]FnRespawnPlayerInDeathMatch : %llx \n", FnRespawnPlayerInDeathMatch);
2023-10-05 03:24:31 +08:00
LOG("[huoji]FnGiveNamedItem : %llx \n", FnGiveNamedItem);
2023-10-06 05:08:40 +08:00
LOG("[huoji]FnClientPrint : %llx \n", FnClientPrint);
LOG("[huoji]FnUTIL_ClientPrintAll : %llx \n", FnUTIL_ClientPrintAll);
2023-10-08 02:29:04 +08:00
LOG("[huoji]FnCCSWeaponBase_Spawn : %llx \n", FnCCSWeaponBase_Spawn);
2023-10-05 03:24:31 +08:00
2023-10-02 05:03:37 +08:00
LOG("[huoji]MaxGlobals : %d \n", global::MaxPlayers);
2023-10-01 02:28:13 +08:00
LOG("[huoji]InterFaces::SchemaSystem : %llx \n", InterFaces::SchemaSystem);
LOG("[huoji]InterFaces::GameEventManager : %llx \n",
InterFaces::GameEventManager);
LOG("[huoji]InterFaces::CGameEventManger : %llx \n",
InterFaces::CGameEventManger);
LOG("[huoji]InterFaces::GameResourceServiceServer : %llx \n",
InterFaces::GameResourceServiceServer);
LOG("[huoji]InterFaces::IServerGameClient : %llx \n",
InterFaces::IServerGameClient);
LOG("[huoji]InterFaces::IVEngineServer : %llx \n",
InterFaces::IVEngineServer);
2023-10-03 00:25:23 +08:00
LOG("[huoji]InterFaces::ISource2ServerInterFace : %llx \n",
InterFaces::ISource2ServerInterFace);
2023-10-08 01:56:49 +08:00
LOG("[huoji]InterFaces::IVEngineCvar : %llx \n",
InterFaces::IVEngineCvar);
2023-10-05 03:24:31 +08:00
LOG("[huoji] CGameEntitySystem::GetInstance : %llx \n",
CGameEntitySystem::GetInstance());
2023-10-01 02:28:13 +08:00
LOG("init offset success !\n");
2023-10-04 22:49:16 +08:00
CreateThread(NULL, 0,
2023-10-06 05:08:40 +08:00
reinterpret_cast<LPTHREAD_START_ROUTINE>(SafeDelayInit), NULL,
0, NULL);
2023-10-04 06:01:28 +08:00
// LOG("FnServerHashFunction: %llx \n", FnServerHashFunction("here",
// sizeof("here") - 1, 0x31415926));
return FnCCSWeaponBase_Spawn && FnEntityRemove && FnRespawnPlayerInDeathMatch && FnGiveNamedItem && Host_SayPtr && InterFaces::IVEngineServer &&
InterFaces::GameResourceServiceServer &&
InterFaces::IServerGameClient && InterFaces::GameEventManager &&
2023-10-06 05:08:40 +08:00
InterFaces::SchemaSystem && FireEventServerSidePtr &&
FnNetworkStateChanged;
2023-10-01 02:28:13 +08:00
}
} // namespace Offset