Externes Fenster bearbeiten
-
Ich möchte mittels FindWindow und SetClassLongPtr versuchen, die WndProc-Funktion eines externen Anwendungsfensters zu bearbeiten. Mein Ansatz sieht folgendermaßen aus, jedoch funktioniert es nicht.
`
[cpp]#include <windows.h>
LRESULT CALLBACK NotepadWndProc(HWND hWnd, UINT uMsg, WPARAM wParam,
LPARAM lParam) { switch(uMsg) { case WM_CREATE: { MessageBox(hWnd, "Hallo", "Hallo", 0); return 0; } case WM_DESTROY: { PostQuitMessage(0); return 0; } } return DefWindowProc(hWnd, uMsg, wParam, lParam);}
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPTSTR lpCmdLine, int nCmdShow) { WinExec("notepad.exe", 1); LPTSTR ClassName = "Notepad"; HWND hWnd; hWnd = FindWindow(ClassName, 0); SetClassLongPtr(hWnd, GWL_WNDPROC, (long)NotepadWndProc); MSG Msg; while (GetMessage(&Msg, 0, 0, 0) > 0) { TranslateMessage(&Msg); DispatchMessage(&Msg); } return Msg.wParam;}[/cpp]`
-
das geht nur durch DLL/code injektion (->google) in den Zielprozess!