News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Passing strings to procedures

Started by Lightman, February 09, 2016, 09:50:24 PM

Previous topic - Next topic

Lightman

Hello Everybody,

How do I pass a string to a procedure? For example, I could pass a dword....


MyProc   PROTO  :DWORD



MyProc   PROC   foo:DWORD
   mov   eax, foo
   ...
   ret
MyProc ENDP



invoke   MyProc, 100h


But with a string? Do I just pass the address? But then how, would I reference that in the procedure itself...


MyProc   PROC   msg:DB 1024 DUP('1')
   invoke   MessageBox, hWnd, addr msg, addr AppName, MB_OK
   ...
   ret
MyProc   ENDP




MyProc   PROC  msg:DWORD
   invoke   MessageBox, hWnd, msg, addr AppName, MB_OK
   ...
   ret
MyProc   ENDP


I'm a but confused by this one.

Regards,

Lightman

dedndave

don't pass the string
pass the address of the string (pointer)

MyProc   PROC   lpszFoo:LPSTR
   mov   eax, foo
   ...
   ret
MyProc ENDP


    INVOKE  MyProc,offset szString