flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
mike.dld
Try SendMessage
![]() |
|||
![]() |
|
mike.dld
Win32 Programmer's reference wrote: The PostMessage function places (posts) a message in the message queue associated with the thread that created the specified window and then returns without waiting for the thread to process the message. |
|||
![]() |
|
coconut
same problem
![]() |
|||
![]() |
|
coconut
in this case i dont care what the return value of sendmessage is. i dont see why the cmp eax,-1 doesnt work.. is it because i set eax to -1 but then post/sendmessage returns and changes it?
|
|||
![]() |
|
mike.dld
Hmm... maybe you forgot to create window first
EXE (TEMPLATE.ASM): Code: format PE GUI 4.0 entry start include '%fasminc%\win32a.inc' section '.data' data readable writeable _title db 'Win32 program template',0 _class db 'FASMWIN32',0 mainhwnd dd ? hinstance dd ? msg MSG wc WNDCLASS section '.code' code readable executable start: invoke GetModuleHandle,0 mov [hinstance],eax invoke LoadIcon,0,IDI_APPLICATION mov [wc.hIcon],eax invoke LoadCursor,0,IDC_ARROW mov [wc.hCursor],eax mov [wc.style],0 mov [wc.lpfnWndProc],WindowProc mov [wc.cbClsExtra],0 mov [wc.cbWndExtra],0 mov eax,[hinstance] mov [wc.hInstance],eax mov [wc.hbrBackground],COLOR_BTNFACE+1 mov [wc.lpszMenuName],0 mov [wc.lpszClassName],_class invoke RegisterClass,wc invoke CreateWindowEx,0,_class,_title,WS_VISIBLE+WS_DLGFRAME+WS_SYSMENU,128,128,192,192,NULL,NULL,[hinstance],NULL mov [mainhwnd],eax invoke ShowOK,eax msg_loop: invoke GetMessage,msg,NULL,0,0 or eax,eax jz end_loop invoke TranslateMessage,msg invoke DispatchMessage,msg jmp msg_loop end_loop: invoke ExitProcess,[msg.wParam] proc WindowProc, hwnd,wmsg,wparam,lparam push ebx esi edi cmp [wmsg],WM_DESTROY je wmdestroy cmp [wmsg],WM_USER je wmuser defwndproc: invoke DefWindowProc,[hwnd],[wmsg],[wparam],[lparam] jmp finish wmuser: or eax,-1 jmp finish wmdestroy: invoke PostQuitMessage,0 xor eax,eax finish: pop edi esi ebx return endp section '.idata' import data readable writeable library kernel,'KERNEL32.DLL',\ user,'USER32.DLL',\ errormsg,'ERRORMSG.DLL' import kernel,\ GetModuleHandle,'GetModuleHandleA',\ ExitProcess,'ExitProcess' import user,\ RegisterClass,'RegisterClassA',\ CreateWindowEx,'CreateWindowExA',\ DefWindowProc,'DefWindowProcA',\ GetMessage,'GetMessageA',\ TranslateMessage,'TranslateMessage',\ DispatchMessage,'DispatchMessageA',\ LoadCursor,'LoadCursorA',\ LoadIcon,'LoadIconA',\ PostQuitMessage,'PostQuitMessage' import errormsg,\ ShowOK,'ShowOK' DLL (ERRORMSG.ASM): Code: format PE GUI 4.0 DLL entry DllEntryPoint include '%fasminc%\win32a.inc' section '.code' code readable executable proc DllEntryPoint, hinstDLL,fdwReason,lpvReserved mov eax,TRUE return endp ok db 'ok!',0 proc ShowOK, hWnd invoke SendMessage,[hWnd],WM_USER,0,0 cmp eax,-1 jne @f invoke MessageBox,[hWnd],ok,0,0 @@: return endp section '.idata' import data readable writeable library user,'USER32.DLL' import user,\ MessageBox,'MessageBoxA',\ SendMessage,'SendMessageA' section '.edata' export data readable export 'ERRORMSG.DLL',\ ShowOK,'ShowOK' section '.reloc' fixups data discardable Last edited by mike.dld on 02 Aug 2004, 22:08; edited 1 time in total |
|||
![]() |
|
coconut
the window and dll run fine, just dont work as expected on the return value
the window i use is the win32 template example by privalov, the only lines i added were the wm_whatever ones. the dll i wrote is similar to yours im thinking eax is changed by the send/postmessage call sometime after i do the mov eax,-1 |
|||
![]() |
|
mike.dld
Win32 Programmer's reference : SendMessage wrote: The return value specifies the result of the message processing and depends on the message sent. |
|||
![]() |
|
coconut
ok, now i tried using ecx to return the -1 but it doesnt work either ?!
|
|||
![]() |
|
mike.dld
My example works for you?
Return value MUST be in EAX, it's the only register which value wouldn't change for sure. |
|||
![]() |
|
coconut
ah, i thought ecx wasnt used by windows? your example works fine, but my app still doesnt have eax equal to -1
|
|||
![]() |
|
coconut
any way for an app to communicate to a dll, sending a message or such?
|
|||
![]() |
|
madmatt
hey coconut, are you writing your own dll? do you have 'enter' right after the 'proc command,arg1,arg2...'
|
|||
![]() |
|
decard
you don't need 'enter' when there are no locals.
|
|||
![]() |
|
coconut
enter was the trick
![]() |
|||
![]() |
|
asmdemon
the simple way would be to:
push eax postmessage.... pop eax cmp eax, -1 ... ... |
|||
![]() |
|
coconut
wouldnt work because of my previous pops in the app
|
|||
![]() |
|
coconut
interesting, now im trying to use the carry flag to communicate between the app and dll, doesnt seem to be working. does windows 'seperate' the carry flag between two different processes?
|
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.