Hello
I am stuck. I want to send a message from app1.exe to .... notepad orso.
; find window (unchecked syntax) ;-)
push eax
push 0
call findwindow
mov var,eax
push 0
push 0
push wm_quit
push offset var
call sendmessage
BTW the classname of notepad is ... "Notepad"
from here i get really strange behaviour like the calling app.exe that QUITS instead of Notepad.exe thats loaded also.
I wonder how i can quit notepad from caller.exe.
Any ideas?
Hi marco1974,
Here is an autotyping example where the notepad application receives WM_CHAR messages.
.386
.model flat,stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
.data
msg db 'Hello my friend!',13,10
db 'This is an autotyping example. :)',0
app db 'notepad.exe',0
wndclass db 'Notepad',0
childclass db 'Edit',0
.data?
handle dd ?
.code
start:
invoke WinExec,ADDR app,SW_SHOW
invoke FindWindow,ADDR wndclass,0
invoke FindWindowEx,eax,0,ADDR childclass,0
mov handle,eax
mov edx,OFFSET msg
@@:
xor eax,eax
mov al,byte PTR [edx]
or al,al
jz @f
push edx
invoke SendMessage,handle,WM_CHAR,eax,0
invoke Sleep,200
pop edx
inc edx
jmp @b
@@:
invoke ExitProcess,0
END start
Welcome marco1974 :U
Glad to have you here! :green
You will find some the best people in the world, come here to get answers, as well as give them.
If you like getting and giving help in Assembler, this is the place for you!! :clap:
Look forward to you participating with us. :thumbu
Look up how to use EnumWindows for this. It gives you a Windows Handle right away to test for your search conditions, then send it the message you want.
PS: Both of you assume that you will find the window, and have no code in place if you don't.
Regards, P1 :8)
Hello everybody!
It has been a few days .. stupid windows os! I was infected!
The code is saved! phey what a mess.
Thankx Vortex, this really works!
What if i want to check if the aplication is LOADED without starting it from the Caliing aplication?
And then use functionality from that aplication.
Is that possible just by calling findwindow and sendmessage?
another question: Who owns the process and can i search for a hex value and write to the
memory area of for example notepad.exe?
Hi Marco,
To check if the application is already loaded, you can use the FindWindows & FindWindowEx functions but the situation is more complicated if there are multiple instances of the same application.
It worked.
invoke FindWindow,ADDR wndclass,0
gets the handle in eax and then i can spy the messages and send a buffer
with text to notepad. some interesting code :
invoke SendMessage,handle,WM_CLOSE,eax,0
;closes the document.
if i try WM_QUIT It wont work.
Dont know why i cant close it. Is it garded against external control??