Basically i need some sort of trigger to make my injected dll do what it needs to do, at first i used createremotethread but it soon became apparent to me that its not a viable option as the target program likes to move its memory around alot and constantly renewing the function handle would be very tedious. So i figured id go for something more high level and decided to try and hook windows messages. Heres whats inside the injected dll:
When i inject the thing everything seems ok, the unhook seems to work but when i try to send a message with WM_USER+101 the target program crashes, hard(like 3 crash messages!)
any ideas?
EDIT: ok appears the crashing was a secondary problem caused by something totally unrelated, now that it doesent crash tho it just does nothing at all, i tried changing message to 0 (WM_NULL) to see if it even gets anything but it doesent :/
Code:
LRESULT CALLBACK MyWndProc(UINT Msg, WPARAM wParam, LPARAM lParam)
{
if (Msg == WM_USER+100)
{
UnHook;
} else if (Msg == WM_USER+101) {
SendMessage(HWND_BROADCAST, 0, 0x1337, 0x1337);
}
return CallNextHookEx(MsgHook, Msg, wParam, lParam);
}
MsgHook = SetWindowsHookEx(WH_CALLWNDPROC, (HOOKPROC)MyWndProc, (HINSTANCE)hInst, GetCurrentThreadId());
any ideas?
EDIT: ok appears the crashing was a secondary problem caused by something totally unrelated, now that it doesent crash tho it just does nothing at all, i tried changing message to 0 (WM_NULL) to see if it even gets anything but it doesent :/