Files
csgo2_tiny_server_plugin_sy…/csgo2/dllmain.cpp

77 lines
2.3 KiB
C++
Raw Normal View History

2023-10-01 02:28:13 +08:00
// dllmain.cpp : 定义 DLL 应用程序的入口点。
2023-10-02 17:31:02 +08:00
#include "head.h"
2023-10-01 02:28:13 +08:00
auto unload() -> void {
hooks::unload();
LOG("unload \n");
}
auto WatchExitThread(void *ctx) -> void {
while (true) {
if (GetAsyncKeyState(VK_END) & 1) {
break;
}
Sleep(100);
}
global::Exit = true;
unload();
}
auto init(void* ctx) -> bool {
2023-10-04 22:49:16 +08:00
2023-10-01 02:28:13 +08:00
AllocConsole();
SetConsoleTitleA("huoji debug console");
freopen_s(reinterpret_cast<FILE**> stdout, "CONOUT$", "w", stdout);
CreateThread(NULL, 0,
reinterpret_cast<LPTHREAD_START_ROUTINE>(WatchExitThread),
NULL, 0, NULL);
2023-10-04 22:49:16 +08:00
uint64_t serverHandle{};
uint64_t localizeHandle{};
2023-10-01 02:28:13 +08:00
2023-10-04 22:49:16 +08:00
while (Offset::Module_tier0 == 0 || serverHandle == 0 || localizeHandle == 0)
2023-10-01 02:28:13 +08:00
{
if (global::Exit) {
return false;
}
Offset::Module_tier0 = reinterpret_cast<uint64_t>(GetModuleHandleA("tier0"));
2023-10-04 22:49:16 +08:00
serverHandle = reinterpret_cast<uint64_t>(GetModuleHandleA("server.dll"));
localizeHandle = reinterpret_cast<uint64_t>(GetModuleHandleA("localize.dll"));
2023-10-20 20:19:22 +08:00
Sleep(100);
2023-10-01 02:28:13 +08:00
}
2023-10-20 20:19:22 +08:00
global::IsMetaModInit = (GetModuleHandleA("metamod.2.cs2.dll") != nullptr);
2023-10-01 02:28:13 +08:00
if (Offset::Init() == false) {
LOG("Offset::Init() == false !\n");
return false;
}
LOG("hacked by huoji 2023.9.14 \n");
bool isSuccess = false;
isSuccess = hooks::init();
if (isSuccess) {
LOG("plugin install success !\n");
2023-10-04 22:49:16 +08:00
while (Offset::InitOffsetSuccess == false)
{
Sleep(200);
}
2023-10-02 18:04:54 +08:00
ScriptEngine::Init();
2023-10-01 02:28:13 +08:00
}
return isSuccess;
}
2023-10-08 01:56:49 +08:00
extern BOOL APIENTRY VersionHijack_DllMain(HMODULE hModule, DWORD dwReason, PVOID pvReserved);
2023-10-01 02:28:13 +08:00
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call,
LPVOID lpReserved) {
bool result = true;
switch (ul_reason_for_call) {
case DLL_PROCESS_ATTACH:
2023-10-08 01:56:49 +08:00
// 有vac
//VersionHijack_DllMain(hModule, ul_reason_for_call, lpReserved);
2023-10-01 02:28:13 +08:00
CreateThread(NULL, 0,
reinterpret_cast<LPTHREAD_START_ROUTINE>(init),
NULL, 0, NULL);
break;
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return result;
}