Skip to content

Commit b578ed3

Browse files
committed
Allow detecting injection success
At least this will hint to issues that can be discovered by looking at the log.
1 parent 6ca7e08 commit b578ed3

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

src/Bootstrap/Injector.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ static HHOOK _messageHookHandle;
1616
//-----------------------------------------------------------------------------
1717
//Spying Process functions follow
1818
//-----------------------------------------------------------------------------
19-
void Injector::Launch(System::IntPtr windowHandle, System::String^ assemblyFile, System::String^ typeFullName, System::String^ methodName)
19+
bool Injector::Launch(System::IntPtr windowHandle, System::String^ assemblyFile, System::String^ typeFullName, System::String^ methodName)
2020
{
2121
System::String^ assemblyClassAndMethod = assemblyFile + "$" + typeFullName + "$" + methodName;
2222
pin_ptr<const wchar_t> acmLocal = PtrToStringChars(assemblyClassAndMethod);
@@ -52,6 +52,7 @@ void Injector::Launch(System::IntPtr windowHandle, System::String^ assemblyFile,
5252
LogMessage("SetWindowsHookEx successful", true);
5353
::SendMessage((HWND)windowHandle.ToPointer(), WM_GOBABYGO, (WPARAM)acmRemote, 0);
5454
::UnhookWindowsHookEx(_messageHookHandle);
55+
return true;
5556
}
5657

5758
::VirtualFreeEx(hProcess, acmRemote, 0, MEM_RELEASE);
@@ -69,6 +70,8 @@ void Injector::Launch(System::IntPtr windowHandle, System::String^ assemblyFile,
6970
}
7071
::FreeLibrary(hinstDLL);
7172
}
73+
74+
return false;
7275
}
7376

7477
void Injector::LogMessage(String^ message, bool append)

src/Bootstrap/Injector.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace Devlooped
1616
{
1717
public:
1818

19-
static void Launch(System::IntPtr windowHandle, System::String^ assemblyFile, System::String^ typeFullName, System::String^ methodName);
19+
static bool Launch(System::IntPtr windowHandle, System::String^ assemblyFile, System::String^ typeFullName, System::String^ methodName);
2020

2121
static void LogMessage(System::String^ message, bool append);
2222
};

src/Injector/Program.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@ static int Main(string[] args)
3131
var typeName = args[2].Trim('"');
3232
var methodName = args[3].Trim('"');
3333

34-
Injector.Launch(mainWindow, assemblyFile, typeName, methodName);
35-
return 0;
34+
if (Injector.Launch(mainWindow, assemblyFile, typeName, methodName))
35+
return 0;
36+
else
37+
return -1;
3638
}
3739
}
3840
}

0 commit comments

Comments
 (0)