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