0

I need to intercept SendMessage API to prevent someone getting text from a particular window by sending WM_GETTEXT . so please suggest me how to do this

  • 2
    Do you own the said window? It would probably be easier to come up with a sensical solution if you told us why you need to prevent that, too. – chris Nov 02 '12 at 06:29
  • yeah ...actually we r working on file protection means we r taking care of data in the file so if someone try to copy the data by sending GET_TEXT message via SendMessage API we r not able to protect right now so we need protect data leak from SendMessage Method also .. – user1746087 Nov 02 '12 at 06:36
  • Run the application in a different user session. – CB Bailey Nov 02 '12 at 06:56
  • would you please elaborate your answer .. – user1746087 Nov 02 '12 at 07:07
  • Why are you putting sensitive file data in a place where a WM_GETTEXT message can get to it in the first place? – Remy Lebeau Nov 02 '12 at 07:11

1 Answers1

4

The easiest solution would be to simply subclass the window procedure of the target HWND and discard any WM_GETTEXT messages that you do not invoke yourself.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
  • 2
    Or simply return a null string for all `WM_GETTEXT` queries, and have your internal text management use a private mechanism. A lot of controls do this already. (For example, sending a `WM_GETTEXT` to a treeview control does not return anything interesting.) – Raymond Chen Nov 02 '12 at 07:52