Hermes/Dyforge is a program written in c++ allows you to inject a dll that can analyze all processes in a program, can be used for mod and reverse engeneering
| 1 | #pragma once |
| 2 | |
| 3 | #include <string> |
| 4 | #include <memory> |
| 5 | #include <vector> |
| 6 | #include <functional> |
| 7 | #include <windows.h> |
| 8 | #include <commctrl.h> |
| 9 | #include <shlwapi.h> |
| 10 | #include "../DyHexInject/DyHexInject.h" |
| 11 | |
| 12 | namespace DyForge { |
| 13 | |
| 14 | // Forward declarations |
| 15 | class ProcessManager; |
| 16 | class InjectionManager; |
| 17 | class AnalysisManager; |
| 18 | class ReportingManager; |
| 19 | class UIManager; |
| 20 | |
| 21 | // Main application class |
| 22 | class DyForge { |
| 23 | public: |
| 24 | static DyForge& GetInstance(); |
| 25 | |
| 26 | // Core functionality |
| 27 | bool Initialize(); |
| 28 | void Cleanup(); |
| 29 | bool IsInitialized() const; |
| 30 | |
| 31 | // Process management |
| 32 | bool OpenProcess(DWORD processId); |
| 33 | bool CloseProcess(); |
| 34 | bool IsProcessOpen() const; |
| 35 | DWORD GetCurrentProcessId() const; |
| 36 | |
| 37 | // Injection management |
| 38 | bool InjectDll(const std::wstring& dllPath); |
| 39 | bool UnloadDll(); |
| 40 | bool IsDllInjected() const; |
| 41 | |
| 42 | // Analysis management |
| 43 | bool StartAnalysis(); |
| 44 | bool StopAnalysis(); |
| 45 | bool IsAnalysisRunning() const; |
| 46 | |
| 47 | // Reporting |
| 48 | bool GenerateReport(const std::wstring& outputPath); |
| 49 | bool ExportData(const std::wstring& format, const std::wstring& outputPath); |
| 50 | |
| 51 | // Event handling |
| 52 | using EventCallback = std::function<void(const std::string&)>; |
| 53 | void RegisterEventCallback(const std::string& eventName, EventCallback callback); |
| 54 | void UnregisterEventCallback(const std::string& eventName); |
| 55 | |
| 56 | // UI management |
| 57 | bool ShowMainWindow(); |
| 58 | bool HideMainWindow(); |
| 59 | bool IsMainWindowVisible() const; |
| 60 | |
| 61 | private: |
| 62 | DyForge(); |
| 63 | ~DyForge(); |
| 64 | |
| 65 | // Prevent copying |
| 66 | DyForge(const DyForge&) = delete; |
| 67 | DyForge& operator=(const DyForge&) = delete; |
| 68 | |
| 69 | // Internal state |
| 70 | bool m_initialized; |
| 71 | std::unique_ptr<ProcessManager> m_processManager; |
| 72 | std::unique_ptr<InjectionManager> m_injectionManager; |
| 73 | std::unique_ptr<AnalysisManager> m_analysisManager; |
| 74 | std::unique_ptr<ReportingManager> m_reportingManager; |
| 75 | std::unique_ptr<UIManager> m_uiManager; |
| 76 | |
| 77 | // Event handling |
| 78 | std::unordered_map<std::string, std::vector<EventCallback>> m_eventCallbacks; |
| 79 | }; |
| 80 | |
| 81 | // Process management class |
| 82 | class ProcessManager { |
| 83 | public: |
| 84 | ProcessManager(); |
| 85 | ~ProcessManager(); |
| 86 | |
| 87 | bool OpenProcess(DWORD processId); |
| 88 | void CloseProcess(); |
| 89 | bool IsProcessOpen() const; |
| 90 | DWORD GetCurrentProcessId() const; |
| 91 | |
| 92 | // Access to process info for other managers |
| 93 | const DyHexInjectProcessInfo& GetProcessInfo() const { return m_processInfo; } |
| 94 | |
| 95 | private: |
| 96 | DWORD m_processId; |
| 97 | HANDLE m_processHandle; |
| 98 | DyHexInjectProcessInfo m_processInfo; |
| 99 | }; |
| 100 | |
| 101 | // Injection management class |
| 102 | class InjectionManager { |
| 103 | public: |
| 104 | InjectionManager(ProcessManager& processManager); |
| 105 | ~InjectionManager(); |
| 106 | |
| 107 | bool InjectDll(const std::wstring& dllPath); |
| 108 | bool UnloadDll(); |
| 109 | bool IsDllInjected() const; |
| 110 | |
| 111 | // Access to communication handle for other managers |
| 112 | HANDLE GetCommunicationHandle() const { return m_communicationHandle; } |
| 113 | |
| 114 | // Access to communication structure for other managers |
| 115 | DyHexInjectCommunication* GetCommunication() { return &m_communication; } |
| 116 | |
| 117 | // Access to process manager for other managers |
| 118 | ProcessManager& GetProcessManager() { return m_processManager; } |
| 119 | |
| 120 | private: |
| 121 | ProcessManager& m_processManager; |
| 122 | bool m_dllInjected; |
| 123 | HANDLE m_communicationHandle; |
| 124 | DyHexInjectCommunication m_communication; |
| 125 | }; |
| 126 | |
| 127 | // Analysis management class |
| 128 | class AnalysisManager { |
| 129 | public: |
| 130 | AnalysisManager(InjectionManager& injectionManager); |
| 131 | ~AnalysisManager(); |
| 132 | |
| 133 | bool StartAnalysis(); |
| 134 | bool StopAnalysis(); |
| 135 | bool IsAnalysisRunning() const; |
| 136 | |
| 137 | // Access to injection manager for other managers |
| 138 | InjectionManager& GetInjectionManager() { return m_injectionManager; } |
| 139 | |
| 140 | private: |
| 141 | InjectionManager& m_injectionManager; |
| 142 | bool m_analysisRunning; |
| 143 | }; |
| 144 | |
| 145 | // Reporting management class |
| 146 | class ReportingManager { |
| 147 | public: |
| 148 | ReportingManager(AnalysisManager& analysisManager); |
| 149 | ~ReportingManager(); |
| 150 | |
| 151 | bool GenerateReport(const std::wstring& outputPath); |
| 152 | bool ExportData(const std::wstring& format, const std::wstring& outputPath); |
| 153 | |
| 154 | private: |
| 155 | AnalysisManager& m_analysisManager; |
| 156 | }; |
| 157 | |
| 158 | // UI management class |
| 159 | class UIManager { |
| 160 | public: |
| 161 | UIManager(DyForge& dyForge); |
| 162 | ~UIManager(); |
| 163 | |
| 164 | bool ShowMainWindow(); |
| 165 | bool HideMainWindow(); |
| 166 | bool IsMainWindowVisible() const; |
| 167 | |
| 168 | private: |
| 169 | // Window procedure and message handling |
| 170 | static LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); |
| 171 | LRESULT HandleMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); |
| 172 | LRESULT HandleCommand(int id); |
| 173 | LRESULT HandleNotify(LPNMHDR pnmh); |
| 174 | LRESULT HandleSize(int width, int height); |
| 175 | |
| 176 | // Control creation and management |
| 177 | void CreateControls(); |
| 178 | void UpdateProcessList(); |
| 179 | void UpdateButtonStates(); |
| 180 | void ShowError(const std::wstring& message); |
| 181 | void ShowStatus(const std::wstring& message); |
| 182 | |
| 183 | // File dialogs |
| 184 | std::wstring ShowOpenDllDialog(); |
| 185 | std::wstring ShowSaveReportDialog(); |
| 186 | std::wstring ShowSaveExportDialog(); |
| 187 | |
| 188 | // Event handlers |
| 189 | void OnProcessSelected(); |
| 190 | void OnInjectDll(); |
| 191 | void OnStartAnalysis(); |
| 192 | void OnStopAnalysis(); |
| 193 | void OnGenerateReport(); |
| 194 | void OnExportData(); |
| 195 | |
| 196 | // Member variables |
| 197 | DyForge& m_dyForge; |
| 198 | bool m_windowVisible; |
| 199 | HWND m_hwnd; |
| 200 | HWND m_hwndProcessList; |
| 201 | HWND m_hwndInjectButton; |
| 202 | HWND m_hwndStartAnalysisButton; |
| 203 | HWND m_hwndStopAnalysisButton; |
| 204 | HWND m_hwndGenerateReportButton; |
| 205 | HWND m_hwndExportDataButton; |
| 206 | HWND m_hwndStatusBar; |
| 207 | |
| 208 | // Constants |
| 209 | static const wchar_t* WINDOW_CLASS_NAME; |
| 210 | static const int WINDOW_WIDTH; |
| 211 | static const int WINDOW_HEIGHT; |
| 212 | |
| 213 | // Control IDs |
| 214 | enum { |
| 215 | IDC_PROCESS_LIST = 1001, |
| 216 | IDC_INJECT_BUTTON = 1002, |
| 217 | IDC_START_ANALYSIS_BUTTON = 1003, |
| 218 | IDC_STOP_ANALYSIS_BUTTON = 1004, |
| 219 | IDC_GENERATE_REPORT_BUTTON = 1005, |
| 220 | IDC_EXPORT_DATA_BUTTON = 1006, |
| 221 | IDC_STATUS_BAR = 1007 |
| 222 | }; |
| 223 | }; |
| 224 | |
| 225 | } // namespace DyForge |