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. Protection of Windows for SendMessage

Protection of Windows for SendMessage

Scheduled Pinned Locked Moved C / C++ / MFC
question
2 Posts 1 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.
  • K Offline
    K Offline
    Kreatief
    wrote on last edited by
    #1

    Hi, I know that it is possible to "protect" your application so that you can just see the top-level window of an app if you use Spy++ or similar. All child windows arent listed there (like Edit boxes, checkboxes etc). If I want to get the state of a checkbox, the normal Message BM_SETCHECK is not usable. What are the ways to protect the apps and is there a wor around to be able to send messages and get the state of a checkbox or read the text of an editbox? Thats what I used so far for nonprotected apps: #include "stdafx.h" using namespace std; #define TEXT_LENGTH 1024 char text[TEXT_LENGTH+1]; HWND hwndInfo = NULL; HWND hwndEdit = NULL; BOOL CALLBACK EnumChildWindowsProc(HWND hWnd, LPARAM lParam) { char pcControlClass[TEXT_LENGTH]; GetClassName(hWnd, pcControlClass, TEXT_LENGTH); if( ::strcmp(pcControlClass, "Edit") == 0 ) { TCHAR pcEditText[TEXT_LENGTH]; long len = SendMessage(hWnd, WM_GETTEXT, TEXT_LENGTH, (LPARAM)pcEditText); if( len != 0 ) { SendMessage(hWnd, WM_SETTEXT, TEXT_LENGTH, (LPARAM)"lala"); } return false; } return true; } BOOL CALLBACK EnumWindowsProc(HWND hWnd, LPARAM lParam) { char pcWinTitle[TEXT_LENGTH]; if( !::GetWindow(hWnd, GW_OWNER) ) { ::GetWindowText(hWnd, pcWinTitle, TEXT_LENGTH); if( ::strcmp(pcWinTitle, "HookTest123") == 0 ) { EnumChildWindows(hWnd, EnumChildWindowsProc, (LPARAM)0); return false; } } return true; } int _tmain(int argc, _TCHAR* argv[]) { EnumWindows( EnumWindowsProc, (LPARAM)0); return 0; }

    K 1 Reply Last reply
    0
    • K Kreatief

      Hi, I know that it is possible to "protect" your application so that you can just see the top-level window of an app if you use Spy++ or similar. All child windows arent listed there (like Edit boxes, checkboxes etc). If I want to get the state of a checkbox, the normal Message BM_SETCHECK is not usable. What are the ways to protect the apps and is there a wor around to be able to send messages and get the state of a checkbox or read the text of an editbox? Thats what I used so far for nonprotected apps: #include "stdafx.h" using namespace std; #define TEXT_LENGTH 1024 char text[TEXT_LENGTH+1]; HWND hwndInfo = NULL; HWND hwndEdit = NULL; BOOL CALLBACK EnumChildWindowsProc(HWND hWnd, LPARAM lParam) { char pcControlClass[TEXT_LENGTH]; GetClassName(hWnd, pcControlClass, TEXT_LENGTH); if( ::strcmp(pcControlClass, "Edit") == 0 ) { TCHAR pcEditText[TEXT_LENGTH]; long len = SendMessage(hWnd, WM_GETTEXT, TEXT_LENGTH, (LPARAM)pcEditText); if( len != 0 ) { SendMessage(hWnd, WM_SETTEXT, TEXT_LENGTH, (LPARAM)"lala"); } return false; } return true; } BOOL CALLBACK EnumWindowsProc(HWND hWnd, LPARAM lParam) { char pcWinTitle[TEXT_LENGTH]; if( !::GetWindow(hWnd, GW_OWNER) ) { ::GetWindowText(hWnd, pcWinTitle, TEXT_LENGTH); if( ::strcmp(pcWinTitle, "HookTest123") == 0 ) { EnumChildWindows(hWnd, EnumChildWindowsProc, (LPARAM)0); return false; } } return true; } int _tmain(int argc, _TCHAR* argv[]) { EnumWindows( EnumWindowsProc, (LPARAM)0); return 0; }

      K Offline
      K Offline
      Kreatief
      wrote on last edited by
      #2

      anyone?

      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