include '%include%\win32a.inc'

format PE GUI 4.0
section 'dane' data
napis db 'ala ma kota',0
addr equ



section 'kod' code readable executable
start:
invoke MeBo,NULL,addr napis,addr napis,MB_OK
invoke quit,0


section 'libki' import data readable writeable executable

library kern,'KERNEL32.DLL',\
user,'USER32.DLL'
import kern,\
quit,'ExitProcess'

import user,\
MeBo,'MessageBox'
Posted on 2003-09-22 04:24:57 by etn
You forgot to define the entry point. Add entry start somewhere in your code.
Also you should add at least the "readable" flag for your data section.
And there's no "MessageBox" export in the USER32 library, only "MessageBoxA" (this one you should use) and "MessageBoxW".

BTW: you can use "win32ax.inc" include to get the extended ADDR syntax (which uses LEA for pointers relative to registers, like variables on stack). When you include this header, you should remove "format" line from your source, as the header does it itself.
Posted on 2003-09-22 04:42:21 by Tomasz Grysztar
about what inform entry start ?What it exactly means to system.
I thought that it means start address for PE header but a lot of programmers insert entry start before data section...


Privalov thanks a lot for correction my homework above!
Posted on 2003-09-22 14:02:52 by etn
It says that the start address is at the "start" label, which you have in your code section. And the "entry" directive can be put anywhere.
Posted on 2003-09-22 15:09:31 by Tomasz Grysztar
so for what it is ,i mean entry...
is an other directive like no entry ?

I puted it somewhere at the end of my code and it does not work.
It looks like the two directives :1 entry and 2 start must be in pairs...
What do you think about it? If you think I can't catch your idea please write in Polish on my PM.
Posted on 2003-09-23 01:28:33 by etn
Hi, etn.

You miss something:

The directive is: "entry" - it defines entry point in the exe file. This is address where OS will start the code.
"start" is simply label somewhere in your code. It's not definately "start" it can be any label you want: "begin", "entrypoint", even "end" or "sdiufgskdf". Only you need this label to exists somewhere in your code. The reason everyone put "entry" directive at the begin of source is that this is more readable way to understand where the code begins.
Posted on 2003-09-23 02:10:03 by JohnFound
oh my doG! it is one of the stupidest question I asked in this Assembly.

I have been written the sentence "entry start" without any understanding what is going on,so no wonder I sometimes forgot it...
what a shame :(



Posted on 2003-09-23 02:39:08 by etn
I want to know how can I call by "nvoke"a function which addres I got through GetProcAddress.
I do something wrong and I'v no idea what it is?


include '%include%/win32a.inc'
format PE GUI 4.0
entry Warsaw
section 'data' data readable writeable
uch dd ?
h dd ?
dll_imp db 'user32.dll'
func_imp db 'MessagBoxA'
addr equ
section 'code' code readable writeable executable
Warsaw :
invoke LoadLibrary,addr dll_imp
mov [uch],eax
invoke GetProcAddress,uch, addr func_imp
mov [h],eax


;------------------------------------------
;how can i invoke h,"message","title",MB_OK
;------------------------------------------


invoke ExitProcess,0

section 'idata' data import readable writeable executable
library kernel,'kernel32.dll'
import kernel,\
ExitProcess, 'ExitProcess',\
LoadLibrary, 'LoadLibraryA',\
GetProcAddress,'GetProcAddress'

Posted on 2003-09-24 14:26:13 by etn
Just:
invoke h,[hwnd],message,title,MB_OK

as it is evaluated to:
stdcall [h],[hwnd],message,title,MB_OK

and this is further evaluated to:
push MB_OK

push title
push message
push [hwnd]
call dword [h]
Posted on 2003-09-24 15:41:24 by Tomasz Grysztar
error: value out of range

pushd 'title'


jj.ASM[19]
stdcall.inc[46]
stdcall.inc[39]

stdcall ,NULL,"message","title",MB_OK
invoke h,NULL,"message","title",MB_OK


:(
maybe I am blind and that's why MBox does not appear...
Posted on 2003-09-25 01:37:42 by etn
You can't push string, you can push only address of the string:




; somewhere in data section.
strTitle db 'title',0
strMessage db 'message', 0

; somewhere in the code. I use your convention.
[Wrong]: invoke h, "title", "message","title",MB_OK[/Wrong]

[right] invoke h, strTitle, strMessage, MB_OK ; Use this. [/right]

regards.

Posted on 2003-09-25 01:49:41 by JohnFound
Thank to You I have no errors but not MBox too
I do somthings wrong and I can't find out any mistake, please be so nice and check my code:

include '%include%/win32a.inc'

format PE GUI 4.0
entry Warsaw
section 'data' data readable writeable
uch dd ?
h dd ?
message db 'message',0
title db 'title',0
dll_imp db 'user32.dll'
func_imp db 'MessagBoxA'
addr equ
section 'code' code readable writeable executable
Warsaw :
invoke LoadLibrary,addr dll_imp
mov [uch],eax
invoke GetProcAddress,uch, addr func_imp
mov [h],eax


;------------------------------------------
stdcall [h],NULL,message,title,MB_OK
;------------------------------------------


invoke ExitProcess,0

section 'idata' data readable writeable executable
library kernel,'kernel32.dll'
import kernel,\
ExitProcess, 'ExitProcess',\
LoadLibrary, 'LoadLibraryA',\
GetProcAddress,'GetProcAddress'
Posted on 2003-09-25 01:57:51 by etn
Hi.

Here is fixed version. Better compare line by line to understand where was the problem.

BTW: When posting code, don't forget to enclose it in /code/ tags. Replace "/" symbol with "[" and "]".



include '%include%/win32a.inc'

format PE GUI 4.0
entry Warsaw


section 'data' data readable writeable

uch dd ?
h dd ?
message db 'message',0
title db 'title',0
dll_imp db 'user32.dll',0
func_imp db 'MessageBoxA',0


section 'code' code readable executable

Warsaw:
invoke LoadLibrary, dll_imp
mov [uch],eax
invoke GetProcAddress, [uch], func_imp
mov [h],eax

stdcall [h], NULL, message, title, MB_OK
invoke ExitProcess,0

section 'idata' import readable writeable

library kernel,'kernel32.dll'

import kernel, \
ExitProcess, 'ExitProcess', \
LoadLibrary, 'LoadLibraryA', \
GetProcAddress, 'GetProcAddress'
Posted on 2003-09-25 02:50:19 by JohnFound

Thank to You I have no errors but not MBox too
I do somthings wrong and I can't find out any mistake, please be so nice and check my code:



(...)
dll_imp db 'user32.dll'
func_imp db [u]'MessagBoxA'[/u]
(...)
invoke GetProcAddress,uch, addr func_imp
mov [h],eax

;------------------------------------------
stdcall [h],NULL,message,title,MB_OK
;------------------------------------------



You say "no errors", huh? I wonder why you get no errors while executing a NULL address (GetProcAddress returns NULL in this case, or am I wrong?). Check the function name you're trying to get address of.
Posted on 2003-09-25 03:22:35 by Morris
Big THX for You both Wizards of Asm-Code

I need to introduce some order in my sourcecodes because when I had read and compared my code with the fixed one made by Johny I got perception that my programm it is like a terrible mess.

see you soon;)
Posted on 2003-09-25 06:21:39 by etn