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
DyHexInject/example.c
Hermes / DyHexInject / example.c
1#include "DyHexInject.h"
2#include <stdio.h>
3 
4int main(int argc, char* argv[]) {
5 if (argc != 3) {
6 printf("Usage: %s <process_id> <dll_path>\n", argv[0]);
7 return 1;
8 }
9
10 // Parse arguments
11 DWORD processId = (DWORD)atoi(argv[1]);
12 wchar_t dllPath[MAX_PATH];
13 MultiByteToWideChar(CP_UTF8, 0, argv[2], -1, dllPath, MAX_PATH);
14
15 // Initialize DyHexInject
16 DyHexInjectError error = DyHexInject_Initialize();
17 if (error != DYHEXINJECT_SUCCESS) {
18 printf("Failed to initialize DyHexInject: %s\n", DyHexInject_GetErrorString(error));
19 return 1;
20 }
21
22 // Enable debug logging
23 DyHexInject_EnableDebugLogging(true);
24
25 // Open target process
26 DyHexInjectProcessInfo processInfo;
27 error = DyHexInject_OpenProcess(processId, &processInfo);
28 if (error != DYHEXINJECT_SUCCESS) {
29 printf("Failed to open process: %s\n", DyHexInject_GetErrorString(error));
30 DyHexInject_Cleanup();
31 return 1;
32 }
33
34 // Configure injection
35 DyHexInjectConfig config = {
36 .waitForInjection = true,
37 .hideInjection = true,
38 .enableDebugLogging = true
39 };
40 wcscpy_s(config.dllPath, MAX_PATH, dllPath);
41
42 // Inject DLL
43 error = DyHexInject_InjectDll(&processInfo, &config);
44 if (error != DYHEXINJECT_SUCCESS) {
45 printf("Failed to inject DLL: %s\n", DyHexInject_GetErrorString(error));
46 DyHexInject_CloseProcess(&processInfo);
47 DyHexInject_Cleanup();
48 return 1;
49 }
50
51 printf("DLL injected successfully!\n");
52
53 // Start communication with injected DLL
54 HANDLE communicationHandle;
55 error = DyHexInject_StartCommunication(&processInfo, &communicationHandle);
56 if (error != DYHEXINJECT_SUCCESS) {
57 printf("Failed to start communication: %s\n", DyHexInject_GetErrorString(error));
58 DyHexInject_CloseProcess(&processInfo);
59 DyHexInject_Cleanup();
60 return 1;
61 }
62
63 // Example: Send a command to the injected DLL
64 const char* command = "START_ANALYSIS";
65 error = DyHexInject_SendCommand(communicationHandle, command, strlen(command));
66 if (error != DYHEXINJECT_SUCCESS) {
67 printf("Failed to send command: %s\n", DyHexInject_GetErrorString(error));
68 DyHexInject_CloseProcess(&processInfo);
69 DyHexInject_Cleanup();
70 return 1;
71 }
72
73 // Example: Receive response from the injected DLL
74 char responseBuffer[1024];
75 size_t bytesReceived;
76 error = DyHexInject_ReceiveResponse(communicationHandle, responseBuffer, sizeof(responseBuffer), &bytesReceived);
77 if (error != DYHEXINJECT_SUCCESS) {
78 printf("Failed to receive response: %s\n", DyHexInject_GetErrorString(error));
79 DyHexInject_CloseProcess(&processInfo);
80 DyHexInject_Cleanup();
81 return 1;
82 }
83
84 printf("Received response: %.*s\n", (int)bytesReceived, responseBuffer);
85
86 // Cleanup
87 DyHexInject_CloseProcess(&processInfo);
88 DyHexInject_Cleanup();
89
90 return 0;
91}