| 10 | |
| 11 | |
| 12 | class ProcessResolver { |
| 13 | public: |
| 14 | ProcessResolver(); |
| 15 | ~ProcessResolver(); |
| 16 | |
| 17 | void addObject(DWORD id, const Process& obj); |
| 18 | BOOL containsObject(DWORD pid); |
| 19 | Process* getObject(DWORD id); |
| 20 | void removeObject(DWORD id); |
| 21 | |
| 22 | void ResetData(); |
| 23 | BOOL PopulateAllProcesses(); |
| 24 | void LogCacheStatistics(); |
| 25 | //void RefreshCache(); |
| 26 | void RefreshTargetMatching(); |
| 27 | |
| 28 | void SetTargetNames(const std::vector<std::string>& names); |
| 29 | size_t GetCacheCount(); |
| 30 | |
| 31 | // Cleanup thread management |
| 32 | void StartCleanupThread(std::chrono::minutes interval); |
| 33 | void StopCleanupThread(); |
| 34 | |
| 35 | private: |
| 36 | std::vector<std::string> targetProcessNames = {}; |
| 37 | std::unordered_map<DWORD, Process> cache; |
| 38 | |
| 39 | // Cleanup thread members |
| 40 | std::atomic<bool> cleanupThreadRunning{false}; |
| 41 | std::thread cleanupThread; |
| 42 | std::chrono::minutes cleanupInterval{1}; |
| 43 | |
| 44 | // Cleanup Helper methods |
| 45 | void CleanupWorker(); |
| 46 | void CleanupStaleProcesses(); |
| 47 | bool IsProcessAlive(DWORD pid); |
| 48 | }; |
| 49 | |
| 50 | // Declare a global instance |
| 51 | extern ProcessResolver g_ProcessResolver; |
nothing calls this directly
no outgoing calls
no test coverage detected