Get the lparam of a SETTEXT hook message
-
The next question is about catching all the SETTEXT message that are sent to a specific window: I'm trying to hook all the settext messages that are sent to a specific window. The hook works almost perfectly, it intercepts all the settext messages and gets de windows handle stored in the pwp structure. pwp is a CWPRETSTRUCT type structure that contains the information of the SETTEXT hooked message. The problem is that I can't get the text(caption) send to the window stored in the LPARAM of the settext hooked message (pwp->lParam. I only get garbage). The idea is to get the text send to the window and save it to a file. Im using a CallWndRetProc hook. Here is my code. LRESULT CALLBACK CallWndRetProc(int nCode, WPARAM wParam, LPARAM lParam) { TCHAR *a; FILE *f1; if(nCode < 0) { return CallNextHookEx(hook, nCode, wParam, lParam); } if (nCode == HC_ACTION) { CWPRETSTRUCT* pwp = (CWPRETSTRUCT*)lParam; UINT message = pwp->message; if (message == WM_SETTEXT) { unsigned int whandle = (unsigned int) pwp->hwnd; // globalvar contains the // (unsigned int)window's handle I want to catch. if (whandle == globalvar) { LPARAM l = pwp->lParam; // The problem is on the next line. // Var a only gets garbage. a = (TCHAR *) l f1=fopen("c:\\hook.txt","a+"); fprintf(f1,"%d %s\n", whandle, a); fclose(f1); } } } return CallNextHookEx(hook, nCode, wParam, lParam); } Ignacio Rivera Mexico
-
The next question is about catching all the SETTEXT message that are sent to a specific window: I'm trying to hook all the settext messages that are sent to a specific window. The hook works almost perfectly, it intercepts all the settext messages and gets de windows handle stored in the pwp structure. pwp is a CWPRETSTRUCT type structure that contains the information of the SETTEXT hooked message. The problem is that I can't get the text(caption) send to the window stored in the LPARAM of the settext hooked message (pwp->lParam. I only get garbage). The idea is to get the text send to the window and save it to a file. Im using a CallWndRetProc hook. Here is my code. LRESULT CALLBACK CallWndRetProc(int nCode, WPARAM wParam, LPARAM lParam) { TCHAR *a; FILE *f1; if(nCode < 0) { return CallNextHookEx(hook, nCode, wParam, lParam); } if (nCode == HC_ACTION) { CWPRETSTRUCT* pwp = (CWPRETSTRUCT*)lParam; UINT message = pwp->message; if (message == WM_SETTEXT) { unsigned int whandle = (unsigned int) pwp->hwnd; // globalvar contains the // (unsigned int)window's handle I want to catch. if (whandle == globalvar) { LPARAM l = pwp->lParam; // The problem is on the next line. // Var a only gets garbage. a = (TCHAR *) l f1=fopen("c:\\hook.txt","a+"); fprintf(f1,"%d %s\n", whandle, a); fclose(f1); } } } return CallNextHookEx(hook, nCode, wParam, lParam); } Ignacio Rivera Mexico