Skip to content

Commit 6e562bc

Browse files
committed
Log the hell out of the injector, this thing will work !
1 parent c7aff85 commit 6e562bc

File tree

1 file changed

+38
-2
lines changed

1 file changed

+38
-2
lines changed

injector/injector.c

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include <stdio.h>
44
#include <string.h>
5+
#include <time.h>
56

67
void Log(const char* fmt, ...) {
78
va_list va;
@@ -12,11 +13,25 @@ void Log(const char* fmt, ...) {
1213
f = stderr;
1314
}
1415

16+
char buffer[4096];
17+
time_t now = time(NULL);
18+
struct tm* tm = localtime(&now);
19+
strftime(buffer, 4095, "%Y-%m-%d %H:%M:%S", tm);
20+
fprintf(f, "[%s] ", buffer);
1521
vfprintf(f, fmt, va);
1622
va_end(va);
1723
}
1824

1925
int main() {
26+
{
27+
FILE* f = fopen("injector.log", "w");
28+
if (f) {
29+
fclose(f);
30+
}
31+
}
32+
33+
Log("Starting injector\n");
34+
2035
STARTUPINFOA startupInfo;
2136
memset(&startupInfo, 0, sizeof(startupInfo));
2237

@@ -28,19 +43,28 @@ int main() {
2843
Log("Failed to create process: %d\n", GetLastError());
2944
return -1;
3045
}
46+
else {
47+
Log("Started isaac-ng.exe in suspended state, processID = %d\n", processInfo.dwProcessId);
48+
}
3149

3250
HANDLE process = OpenProcess(PROCESS_CREATE_THREAD | PROCESS_QUERY_INFORMATION | PROCESS_VM_OPERATION | PROCESS_VM_WRITE | PROCESS_VM_READ,
3351
FALSE, processInfo.dwProcessId);
3452
if (!process) {
3553
Log("Failed to open process: %d\n", GetLastError());
3654
return -1;
3755
}
56+
else {
57+
Log("Acquired handle to isaac-ng.exe, process ID = %d\n", processInfo.dwProcessId);
58+
}
3859

3960
void* remotePage = VirtualAllocEx(process, NULL, 4096, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
4061
if (!remotePage) {
4162
Log("Failed to allocate memory in isaac-ng.exe to load the dsound DLL: %d\n", GetLastError());
4263
return -1;
4364
}
65+
else {
66+
Log("Allocated memory for remote thread at %p\n", remotePage);
67+
}
4468

4569
size_t bytesWritten = 0;
4670
char zeroBuffer[4096];
@@ -52,6 +76,9 @@ int main() {
5276
Log("Unable to find kernel32.dll, WTF\n");
5377
return -1;
5478
}
79+
else {
80+
Log("Acquired kernel32.dll at %p\n", kernel32);
81+
}
5582

5683
FARPROC getProcAddress = GetProcAddress(kernel32, "GetProcAddress");
5784
FARPROC loadLibraryA = GetProcAddress(kernel32, "LoadLibraryA");
@@ -66,6 +93,8 @@ int main() {
6693
return -1;
6794
}
6895

96+
Log("Acquired GetProcAddress at %p, LoadLibraryA at %p\n", getProcAddress, loadLibraryA);
97+
6998
const char* dllName = "launcher.dll";
7099
const char* functionName = "LaunchZHL";
71100
size_t offset = 0;
@@ -124,7 +153,11 @@ int main() {
124153
Log("Error while creating remote thread: %d\n", GetLastError());
125154
return -1;
126155
}
156+
else {
157+
Log("Created remote thread in isaac-ng.exe\n");
158+
}
127159

160+
Log("Waiting for remote thread to complete\n");
128161
result = WaitForSingleObject(remoteThread, 60 * 1000);
129162
switch (result) {
130163
case WAIT_OBJECT_0:
@@ -136,7 +169,7 @@ int main() {
136169
break;
137170

138171
case WAIT_TIMEOUT:
139-
Log("RemoteThread timeout\n");
172+
Log("RemoteThread timed out\n");
140173
break;
141174

142175
case WAIT_FAILED:
@@ -150,10 +183,13 @@ int main() {
150183
return -1;
151184
}
152185
else {
153-
Log("ResumeThread: %d\n", result);
186+
Log("Resumed main thread of isaac-ng.exe, previous supend count was %d\n", result);
154187
}
155188

189+
Log("Waiting for isaac-ng.exe main thread to return\n");
156190
WaitForSingleObject(processInfo.hProcess, INFINITE);
191+
Log("isaac-ng.exe completed, shutting down injector\n");
192+
157193
CloseHandle(processInfo.hProcess);
158194
CloseHandle(processInfo.hThread);
159195

0 commit comments

Comments
 (0)