Can a program be written to read/send messages to other Windows Applications?
Maybe if it was possible to detect exactly which mem address a program is using to store the MSG structure, and use asm to view it, what do you say?
That would be a great security hole wouldnt it?
Am i rediscovering the weel here?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2002-12-07
depends whether what you want to send is something the target app is designed to handle... ie, check out your win32 api reference for these:
---
EnumWindows()
should help you track down whether a desired target app is currently running, or to simply make a list of all running apps (in case you want to broadcast a given message - of course you can just use the HWND_BROADCAST flag with PostMessage() to send to all top-level windows)
---
PostMessage() and SendMessage()
sends the actual message to a specified app's message loop - note that if this is a message that the app isn't designed to look for, it may simply be ignored. note also that these functions can be used to talk directly to subwindows and controls (like buttons and such) as well, though determining their window handles is a little more tricky (requiring calls to EnumChildWindows() for each top-level window)
---
now if you designed your sending and receiving apps with these in mind, you can define custom message identifiers in each app source's header files like:
#define WMCUSTOM_MESSAGE WM_USER + 1
so that they're both essentially speaking the same language, then set up the receiving app's message procedure to look for WMCUSTOM_MESSAGE and respond accordingly, like:
// message loop callback function in receiving app
LRESULT CALLBACK MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message)
{
case WMCUSTOM_MESSAGE:
// read values from wParam and lParam,
// which are custom data members sent by the
// call to PostMessage() in the sending app
break;
...
}
...
}
// end code
note that this isn't really a security hack per se, since only messages which can be handled either by the target app's callback message handler or DefWindowProc() will be acknowledged and processed. if you really want to "pass a message" to an app without it's explicit consent ;) - sorta like the statistic/highscore trainers which are available these days for many games to modify data values in memory on the fly - well, that's a whole nother ball o code.
hope this helps
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Can a program be written to read/send messages to other Windows Applications?
Maybe if it was possible to detect exactly which mem address a program is using to store the MSG structure, and use asm to view it, what do you say?
That would be a great security hole wouldnt it?
Am i rediscovering the weel here?
depends whether what you want to send is something the target app is designed to handle... ie, check out your win32 api reference for these:
---
EnumWindows()
should help you track down whether a desired target app is currently running, or to simply make a list of all running apps (in case you want to broadcast a given message - of course you can just use the HWND_BROADCAST flag with PostMessage() to send to all top-level windows)
---
PostMessage() and SendMessage()
sends the actual message to a specified app's message loop - note that if this is a message that the app isn't designed to look for, it may simply be ignored. note also that these functions can be used to talk directly to subwindows and controls (like buttons and such) as well, though determining their window handles is a little more tricky (requiring calls to EnumChildWindows() for each top-level window)
---
now if you designed your sending and receiving apps with these in mind, you can define custom message identifiers in each app source's header files like:
#define WMCUSTOM_MESSAGE WM_USER + 1
so that they're both essentially speaking the same language, then set up the receiving app's message procedure to look for WMCUSTOM_MESSAGE and respond accordingly, like:
// message loop callback function in receiving app
LRESULT CALLBACK MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message)
{
case WMCUSTOM_MESSAGE:
// read values from wParam and lParam,
// which are custom data members sent by the
// call to PostMessage() in the sending app
break;
...
}
...
}
// end code
note that this isn't really a security hack per se, since only messages which can be handled either by the target app's callback message handler or DefWindowProc() will be acknowledged and processed. if you really want to "pass a message" to an app without it's explicit consent ;) - sorta like the statistic/highscore trainers which are available these days for many games to modify data values in memory on the fly - well, that's a whole nother ball o code.
hope this helps