The application that I inject the DLL into is the one that unloads it, not the DLL itself.
The actual test wouldn't work otherwise:
Code:
if ( ExitWindowsEx(0xFF/*EWX_LOGOFF*/, 0) )
{
AbortSystemShutdown(NULL);
MessageBox(_T("System log out successfully initiated and aborted!"), _T("Success"), MB_ICONINFORMATION);
}
else
MessageBox(_T("Failed to log out!"), _T("Error"), MB_ICONERROR);
And if the SpyThread.dll is injected properly:
Code:
BOOL WINAPI MyExitWindowsEx(UINT uFlags, DWORD dwReason)
{
MessageBox(NULL, "System shutdown... DENIED!", "", 0);
return FALSE;
}
I get feedback.
I put it as buttons on a dialog to test if it worked.
Now it unloads fine, but I seem to have run into another problem. It never injects the code at all - CreateRemoteThread fails for some reason. Currently investigating why.