Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Get the lparam of a SETTEXT hook message

Get the lparam of a SETTEXT hook message

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    ignacio rivera
    wrote on last edited by
    #1

    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

    A 1 Reply Last reply
    0
    • I ignacio rivera

      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

      A Offline
      A Offline
      AtomAnt
      wrote on last edited by
      #2

      Could it be possible that the WM_SETTEXT you get has been "POSTED" and the buffer lParam contains a pointer at has been destroyed by the time you get the hook-call?

      AtomAnt

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups