QList<Notifications::Type> Notifications::notifiers() { QList<Type> result = QList<Type>(); for (int i = 0; i < moduleList()->size(); ++i) result << moduleList()->at(i)->type(); return result; }
NotificationModule* Notifications::module(Type t) { for(int i = 0; i < moduleList()->size(); ++i) { NotificationModule* current = moduleList()->at(i); if(current->type() == t) return current; } return 0; }
QString Notifications::name(Type t) { for(int i = 0; i < moduleList()->size(); ++i) { NotificationModule* current = moduleList()->at(i); if(current->type() == t) return current->name(); } return ""; }
Memory::Memory(const std::string& processName) { // First, get the handle of the process PROCESSENTRY32 entry; entry.dwSize = sizeof(entry); HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); while (Process32Next(snapshot, &entry)) { if (processName == entry.szExeFile) { _handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, entry.th32ProcessID); if (!_handle) { std::cerr << "Couldn't find " << processName.c_str() << ". Is it open?" << std::endl; exit(EXIT_FAILURE); } break; } } // Next, get the process base address DWORD numModules; std::vector<HMODULE> moduleList(1024); EnumProcessModulesEx(_handle, &moduleList[0], static_cast<DWORD>(moduleList.size()), &numModules, 3); std::string name(64, 0); for (DWORD i = 0; i < numModules / sizeof(HMODULE); i++) { GetModuleBaseNameA(_handle, moduleList[i], &name[0], sizeof(name)); // TODO: Filling with 0s still yeilds name.size() == 64... if (strcmp(processName.c_str(), name.c_str()) == 0) { _baseAddress = (uintptr_t)moduleList[i]; break; } } if (_baseAddress == 0) { std::cerr << "Couldn't find base address!" << std::endl; exit(EXIT_FAILURE); } }
std::list<std::wstring> ConfigVariable::getModuleList() { std::list<std::wstring> moduleList(m_ModuleList); return moduleList; }