diff --git a/csgo2/csgo2.vcxproj b/csgo2/csgo2.vcxproj
index 717aa79..96b205a 100644
--- a/csgo2/csgo2.vcxproj
+++ b/csgo2/csgo2.vcxproj
@@ -154,6 +154,7 @@
pch.h
stdcpplatest
MultiThreaded
+ Disabled
Windows
diff --git a/csgo2/dllmain.cpp b/csgo2/dllmain.cpp
index 2b9b716..186337d 100644
--- a/csgo2/dllmain.cpp
+++ b/csgo2/dllmain.cpp
@@ -37,6 +37,7 @@ auto init(void* ctx) -> bool {
Sleep(200);
}
+ 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 1c49f54..9f8ded0 100644
--- a/csgo2/global.cpp
+++ b/csgo2/global.cpp
@@ -7,4 +7,5 @@ namespace global {
CGlobalVars* GlobalVars;
float m_flUniversalTime;
float m_flLastTickedTime;
+ bool isMetaModInit;
}
\ No newline at end of file
diff --git a/csgo2/global.h b/csgo2/global.h
index 41ccf18..802a32a 100644
--- a/csgo2/global.h
+++ b/csgo2/global.h
@@ -10,4 +10,5 @@ namespace global {
extern CGlobalVars* GlobalVars;
extern float m_flUniversalTime;
extern float m_flLastTickedTime;
+ extern bool isMetaModInit;
}
\ No newline at end of file
diff --git a/csgo2/memory.cpp b/csgo2/memory.cpp
index e69de29..dc2c67e 100644
--- a/csgo2/memory.cpp
+++ b/csgo2/memory.cpp
@@ -0,0 +1,23 @@
+#include "memory.h"
+namespace Memory {
+ auto PathVscript() -> void {
+ CModule vscript_old("vscript_old.dll");
+ CModule vscript("vscript.dll");
+
+ uint64_t vscriptPathAddr = 0;
+ if (vscript_old.IsLoaded() == true) {
+ vscript_old.FindPattern(Offset::pattern_VscriptPath).Get(vscriptPathAddr);
+ }
+ else {
+ vscript.FindPattern(Offset::pattern_VscriptPath).Get(vscriptPathAddr);
+ }
+ if (vscriptPathAddr != 0) {
+ const static char PatchVScriptEnable[] = { 0xBE, 0x02 };
+ DWORD oldProtect;
+ VirtualProtect(reinterpret_cast(vscriptPathAddr), sizeof(PatchVScriptEnable), PAGE_EXECUTE_READWRITE, &oldProtect);
+ memcpy(reinterpret_cast(vscriptPathAddr), PatchVScriptEnable, sizeof(PatchVScriptEnable));
+ VirtualProtect(reinterpret_cast(vscriptPathAddr), sizeof(PatchVScriptEnable), oldProtect, &oldProtect);
+ LOG("success patch vscript at %llx \n", vscriptPathAddr);
+ }
+ }
+};
\ No newline at end of file
diff --git a/csgo2/memory.h b/csgo2/memory.h
index 27968b8..a0926f5 100644
--- a/csgo2/memory.h
+++ b/csgo2/memory.h
@@ -14,5 +14,5 @@ namespace Memory {
ReadProcessMemory(GetCurrentProcess(), (void*)address, &buffer, sizeof(T), 0);
return buffer;
}
-
+ auto PathVscript() -> void;
};
\ No newline at end of file
diff --git a/csgo2/module.h b/csgo2/module.h
index b8c0dbf..874ed91 100644
--- a/csgo2/module.h
+++ b/csgo2/module.h
@@ -2,6 +2,10 @@
#include "head.h"
#define IS_WINDOWS 1
class InterfaceReg;
+//cancer fix me plz
+namespace global {
+ extern bool isMetaModInit;
+};
// Pointer arithmetic utility class.
struct UTILPtr {
public:
@@ -65,10 +69,8 @@ class CModule {
UTILPtr GetProcAddress(const char* procName) const {
UTILPtr rv = 0;
if (this->IsLoaded()) {
-#ifdef IS_WINDOWS
rv = ::GetProcAddress(static_cast(this->m_handle),
procName);
-#endif
}
return rv;
}
@@ -77,11 +79,7 @@ class CModule {
if (this->IsLoaded()) {
UTILPtr pCreateInterface = this->GetProcAddress("CreateInterface");
if (!pCreateInterface.IsValid()) return rv;
-
- InterfaceReg* s_pInterfaceRegs = pCreateInterface.ToAbsolute(3, 0)
- .Dereference(1)
- .Get();
-
+ auto s_pInterfaceRegs = pCreateInterface.ToAbsolute(3, 0).Dereference(1).Get();
for (; s_pInterfaceRegs;
s_pInterfaceRegs = s_pInterfaceRegs->m_pNext) {
if (strcmp(version, s_pInterfaceRegs->m_pName) == 0) {
@@ -121,9 +119,36 @@ class CModule {
private:
void InitializeHandle() {
-#ifdef IS_WINDOWS
- this->m_handle = static_cast(GetModuleHandleA(this->GetName()));
-#endif
+ if (global::isMetaModInit == false) {
+ this->m_handle = static_cast(GetModuleHandleA(this->GetName()));
+ return;
+ }
+
+ HANDLE hProcess = GetCurrentProcess();
+ DWORD cbNeeded;
+
+ // Call EnumProcessModules with a null hMods parameter to get the needed size.
+ EnumProcessModules(hProcess, nullptr, 0, &cbNeeded);
+ int moduleCount = cbNeeded / sizeof(HMODULE);
+ std::vector hMods(moduleCount);
+
+ if (EnumProcessModules(hProcess, hMods.data(), cbNeeded, &cbNeeded))
+ {
+ for (const auto& hMod : hMods)
+ {
+ char szModName[MAX_PATH];
+
+ if (GetModuleFileNameExA(hProcess, hMod, szModName, sizeof(szModName) / sizeof(char)))
+ {
+ const auto fullModulePath = std::string(szModName);
+ if (fullModulePath.find("metamod") == std::string::npos && fullModulePath.ends_with(this->GetName()) == true) {
+ this->m_handle = static_cast(hMod);
+ break;
+ }
+ }
+ }
+ }
+ CloseHandle(hProcess);
}
void InitializeBounds() {
if (!this->IsLoaded()) return;
diff --git a/csgo2/offset.cpp b/csgo2/offset.cpp
index 3c46d2a..73ee570 100644
--- a/csgo2/offset.cpp
+++ b/csgo2/offset.cpp
@@ -49,33 +49,14 @@ auto SafeDelayInit(void* ctx) -> void {
LOG("m_bForceTeamChangeSilent: %d \n",
InterFaces::CCSGameRulesInterFace->m_bForceTeamChangeSilent());
}
-auto PathVscript() -> void {
- CModule vscript_old("vscript_old.dll");
- CModule vscript("vscript.dll");
- uint64_t vscriptPathAddr = 0;
- if (vscript_old.IsLoaded() == true) {
- vscript_old.FindPattern(pattern_VscriptPath).Get(vscriptPathAddr);
- }
- else {
- vscript.FindPattern(pattern_VscriptPath).Get(vscriptPathAddr);
- }
- if (vscriptPathAddr != 0) {
- const static char PatchVScriptEnable[] = {0xBE, 0x02};
- DWORD oldProtect;
- VirtualProtect(reinterpret_cast(vscriptPathAddr), sizeof(PatchVScriptEnable), PAGE_EXECUTE_READWRITE, &oldProtect);
- memcpy(reinterpret_cast(vscriptPathAddr), PatchVScriptEnable, sizeof(PatchVScriptEnable));
- VirtualProtect(reinterpret_cast(vscriptPathAddr), sizeof(PatchVScriptEnable), oldProtect, &oldProtect);
- LOG("success patch vscript at %llx \n", vscriptPathAddr);
- }
-}
auto Init() -> bool {
CModule server("server.dll");
CModule schemasystem("schemasystem.dll");
CModule engine("engine2.dll");
CModule localize("localize.dll");
CModule tier0("tier0.dll");
- PathVscript();
+ Memory::PathVscript();
// engine.dll
engine.FindPattern(pattern_MaxPlayerNumsPtr)