flat assembler
Message board for the users of flat assembler.
Index
> Main > cmp |
Author |
|
mike.dld 02 Aug 2004, 21:35
Try SendMessage
|
|||
02 Aug 2004, 21:35 |
|
mike.dld 02 Aug 2004, 21:41
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. |
|||
02 Aug 2004, 21:41 |
|
coconut 02 Aug 2004, 21:43
same problem
|
|||
02 Aug 2004, 21:43 |
|
coconut 02 Aug 2004, 21:53
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?
|
|||
02 Aug 2004, 21:53 |
|
mike.dld 02 Aug 2004, 21:57
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 |
|||
02 Aug 2004, 21:57 |
|
coconut 02 Aug 2004, 22:00
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 |
|||
02 Aug 2004, 22:00 |
|
mike.dld 02 Aug 2004, 22:14
Win32 Programmer's reference : SendMessage wrote: The return value specifies the result of the message processing and depends on the message sent. |
|||
02 Aug 2004, 22:14 |
|
coconut 02 Aug 2004, 22:17
ok, now i tried using ecx to return the -1 but it doesnt work either ?!
|
|||
02 Aug 2004, 22:17 |
|
mike.dld 02 Aug 2004, 22:20
My example works for you?
Return value MUST be in EAX, it's the only register which value wouldn't change for sure. |
|||
02 Aug 2004, 22:20 |
|
coconut 02 Aug 2004, 22:27
ah, i thought ecx wasnt used by windows? your example works fine, but my app still doesnt have eax equal to -1
|
|||
02 Aug 2004, 22:27 |
|
coconut 03 Aug 2004, 22:15
any way for an app to communicate to a dll, sending a message or such?
|
|||
03 Aug 2004, 22:15 |
|
madmatt 04 Aug 2004, 06:35
hey coconut, are you writing your own dll? do you have 'enter' right after the 'proc command,arg1,arg2...'
|
|||
04 Aug 2004, 06:35 |
|
decard 04 Aug 2004, 10:57
you don't need 'enter' when there are no locals.
|
|||
04 Aug 2004, 10:57 |
|
coconut 04 Aug 2004, 21:06
enter was the trick
|
|||
04 Aug 2004, 21:06 |
|
asmdemon 04 Aug 2004, 22:00
the simple way would be to:
push eax postmessage.... pop eax cmp eax, -1 ... ... |
|||
04 Aug 2004, 22:00 |
|
coconut 05 Aug 2004, 04:45
wouldnt work because of my previous pops in the app
|
|||
05 Aug 2004, 04:45 |
|
coconut 05 Aug 2004, 22:16
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?
|
|||
05 Aug 2004, 22:16 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.