#define CMDHELPER_CHECK 0x172C8
HANDLE CmdEdit::CheckCMDHelperHANDLE() {
static const char* checkStr = "{FFA0661D}[blast.hk] {FFFFFF}CMD helper by {FFA0661D}MISTER_GONWIK";
HANDLE hProcess;
HMODULE hMods[1024];
DWORD cbNeeded;
hProcess = GetCurrentProcess();
if (NULL == hProcess)
return NULL;
HMODULE ret = NULL;
if (K32EnumProcessModules(hProcess, hMods, sizeof(hMods), &cbNeeded) != NULL) {
DWORD dwProt;
MODULEINFO module_info;
MEMORY_BASIC_INFORMATION mem_info;
TCHAR szModName[MAX_PATH];
DWORD base;
for (int i = 0; i < (cbNeeded / sizeof(HMODULE)) && ret == NULL; i++) {
memset(&module_info, 0, sizeof(module_info));
memset(&mem_info, 0, sizeof(mem_info));
if (K32GetModuleFileNameExA(hProcess, hMods[i], szModName,
sizeof(szModName) / sizeof(TCHAR)) == NULL) continue;
if (K32GetModuleInformation(hProcess, hMods[i], &module_info, sizeof(module_info)) == NULL)
continue;
base = (DWORD)module_info.lpBaseOfDll;
if (module_info.SizeOfImage > CMDHELPER_CHECK + strlen(checkStr)+1) {
if (VirtualQuery((void*)(base + CMDHELPER_CHECK), &mem_info, sizeof(mem_info)) != NULL) {
if (mem_info.Protect == PAGE_READONLY &&
(DWORD)mem_info.AllocationBase + mem_info.RegionSize > base + CMDHELPER_CHECK + strlen(checkStr) + 1) {
if (!strcmp((const char*)(hMods[i] + CMDHELPER_CHECK), checkStr))
ret = hMods[i];
else SF->getSAMP()->getChat()->AddChatMessage(-1, "INC STR %s", szModName);
}
}
else SF->getSAMP()->getChat()->AddChatMessage(-1, "ERR %s (0x%08X) %u", szModName, hMods[i], GetLastError());
}
}
}
CloseHandle(hProcess);
return ret;
}