Seregon/Hermes

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

C/3.8 KB/No license
DyForge/include/DyForge.h
Hermes / DyForge / include / DyForge.h
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 
12namespace DyForge {
13 
14// Forward declarations
15class ProcessManager;
16class InjectionManager;
17class AnalysisManager;
18class ReportingManager;
19class UIManager;
20 
21// Main application class
22class DyForge {
23public:
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
61private:
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
82class ProcessManager {
83public:
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
95private:
96 DWORD m_processId;
97 HANDLE m_processHandle;
98 DyHexInjectProcessInfo m_processInfo;
99};
100 
101// Injection management class
102class InjectionManager {
103public:
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
120private:
121 ProcessManager& m_processManager;
122 bool m_dllInjected;
123 HANDLE m_communicationHandle;
124 DyHexInjectCommunication m_communication;
125};
126 
127// Analysis management class
128class AnalysisManager {
129public:
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
140private:
141 InjectionManager& m_injectionManager;
142 bool m_analysisRunning;
143};
144 
145// Reporting management class
146class ReportingManager {
147public:
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
154private:
155 AnalysisManager& m_analysisManager;
156};
157 
158// UI management class
159class UIManager {
160public:
161 UIManager(DyForge& dyForge);
162 ~UIManager();
163
164 bool ShowMainWindow();
165 bool HideMainWindow();
166 bool IsMainWindowVisible() const;
167
168private:
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