Hi,

I was wondering how i could send data from a program to another program (a debug window).

i've tried the FindWindow, SendMessage method, but then you can only send dword's.

regards,
Slash0r
Posted on 2004-01-18 04:34:14 by Slash0r
For debug info:

you can use OutputDebugStringA function together with DbgView program from sysinternals.com
Posted on 2004-01-18 08:34:46 by BogdanOntanu
memory mapped files, pipes, sockets, mailslots, ... - look up IPC (inter-process communication) in MSDN.
Posted on 2004-01-18 10:02:48 by f0dder
WM_COPYDATA - works for me.
Posted on 2004-01-18 11:02:25 by gfalen
You can send text with a pointer. I tried this and it works fine...

[b][i]Debug window (using a dialog, ID 1002 is an edit control)[/i][/b]

.WMUSER
CMP EAX,WM_USER+200
JNE >.WMCLOSE
invoke GetDlgItem,[hwnd],1002
invoke SetWindowLong,[hwnd],DWL_MSGRESULT,eax
MOV EAX, TRUE
RET


[b][i]Sending App[/i][/b]

.data
WindowName DB "Debug",0
szText DB "Hello",0
.code
invoke FindWindow,NULL,OFFSET WindowName
invoke SendMessage,eax,WM_USER+200,0,0
invoke SendMessage,eax,WM_SETTEXT,0,OFFSET szText
Posted on 2004-01-18 11:29:11 by donkey
Hi :)

@donkey: AFAIK, you can't send pointers to other programs, unless:

1. You use WM_COPYDATA

or

2. The pointers are for data in the target process address space, or in a shared memory section in a DLL loaded by both programs.
Posted on 2004-01-19 16:02:11 by QvasiModo
well, if u use a Spy++ alike to get the prog's control IDs, using FindWindow to get the handle,
than u can send ur data such as text for example to be put at the edit-box.
Posted on 2004-01-19 16:15:26 by wizzra
@wizzra:
Well, the data I posted above was "theoretical" to me. I'll try your suggestion, to see what happens :)
Posted on 2004-01-19 16:19:14 by QvasiModo
Using an editbox (probably hidden) or similar to transfer data between two programs is silly.

First, there exists better methods (simple WM_COPYDATA seems like a simple solution, and there's multiple other IPC methods if that doesn't suit your needs).

Now, why is an approach like WM_SETTEXT silly? First of all, you can only pass ascii data (well, I wouldn't try anything else - though you could perhaps abuse the unicode variant). This means you'd have to do some conversion to/from ascii if you want to pass arbitrary data. Second, there's a little catch that could have pretty big ramifications: messages like WM_SETTEXT and WM_PASTE have been used for the so-called shatter attacks, and thus might be filtered interprocess in future windows versions.
Posted on 2004-01-19 16:28:19 by f0dder

Second, there's a little catch that could have pretty big ramifications: messages like WM_SETTEXT and WM_PASTE have been used for the so-called shatter attacks, and thus might be filtered interprocess in future windows versions.

Just curious, what's a shatter attack? (I'm guessing it's just sending those messages with bogus data in an endless loop to another process, to halt it. If so, it seems a bit dumb :sweat: but probably hard to avoid :notsure:
Posted on 2004-01-19 16:49:19 by QvasiModo
Even worse... shatter attacks are used to overwrite arbitrary memory locations, and can lead to remote code execution. The issue was blown totally out of proportion though, by the linux zealot foon (aka fool) who didn't *really* know what he was talking about. I have an article about it on my site, the WM_TIMER stuff.
Posted on 2004-01-19 16:53:27 by f0dder
Thanks :)

BTW, funny domain name... :grin:
F0dder has it!
Posted on 2004-01-19 17:26:19 by QvasiModo

Hi,

I was wondering how i could send data from a program to another program (a debug window).

i've tried the FindWindow, SendMessage method, but then you can only send dword's.

regards,
Slash0r


http://webster.cs.ucr.edu/Page_win32/WindowsAsmPgm/html/Ch06.html

In Chapter Six of "Windows Programming in Assembly" I cover this subject
and describe the creation of a "debug window" application to whom you
can send debug messages from some other application.
Cheers,
Randy Hyde
Posted on 2004-01-19 17:34:03 by rhyde
Hi,

Thanks for all the replies!

I've tried the WM_COPYDATA method and it work fine!

Thanks again.

Slash0r
Posted on 2004-01-20 01:35:32 by Slash0r