My DLL
#include <windows.h>
#include <vector>
#include "Funkcje.h"
WNDPROC originalProc;
LRESULT CALLBACK myHookProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
BOOL WINAPI DllMain(
HINSTANCE hinstDLL,
DWORD fdwreason,
LPVOID lpReversed)
{
switch (fdwreason)
{
case DLL_PROCESS_ATTACH:
WNDPROC originalProc = SetWindowLongPtr(getToplevelWindows()[1], GWLP_WNDPROC, (LONG_PTR)myHookProc);
break;
}
return TRUE;
}
LRESULT CALLBACK myHookProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
LRESULT originalResult = originalProc(hWnd, uMsg, wParam, lParam); // call original first
if (uMsg == WM_PAINT)
{
PAINTSTRUCT ps;
HDC hdc = GetDC(hWnd);
TextOut(hdc, 150, 150, L"TEST", 4);
ReleaseDC(hWnd, hdc);
}
return originalResult;
}
Funkcje.h http://pastebin.com/dc5t5H8s
I got a problem with (LONG_PTR)myHookProc My compilers says that error C2440: 'initializing' : cannot convert from 'LONG' to 'WNDPROC' I dont have any idea what i can do now. Without (LONG_PTR) my compiler says that he can't convert from 'LRESULT' to 'LONG'
Change the signature to:
LRESULT APIENTRY myHookProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
And the call to:
WNDPROC originalProc = (WNDPROC)SetWindowLongPtr(getToplevelWindows()[1], GWLP_WNDPROC, (LONG_PTR)myHookProc);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.