I cant seem to find any articles on such a simple thing,
not even the simple help's that come with MASM and RADASM helped at all.

So how can i get the strings that are passed as parameters to my applications

C:\TEST.EXE /S D:\*.*

Delphi uses ParamStr and ParamCount but i cant seem to get them with MASM\
Posted on 2003-01-21 16:15:02 by monkeyO_o
Since your pretty new to assembly & masm. I would recommend looking
at the helpfile MASMLIB ("\MASM32\HELP\MASMLIB.HLP") There youll find
alot of functions for all kinds of purposes.

For Command Line functions just look under "Command Line" and youll
find the following: ArgCL,ArgClC,GetCL and if you want to see what these
functions actually do then just open the <name of function>.asm file in
"\MASM32\M32LIB\". All the .asm files in that folder contains the source
of each function in the MASM32.LIB.

Read the MASM32.HLP & MASMLIB.HLP for more information about MASM :alright:
Posted on 2003-01-21 16:36:19 by natas
From Win32 help:

The GetCommandLine function returns a pointer to the command-line string for the current process.

LPTSTR GetCommandLine(VOID)

Posted on 2003-01-21 16:37:47 by LarryZ
I moved this thread to the MAIN so that you will get more chance of answers.

If I understand your question properly, strings are in fact NOT passed as parameters, the ADDRESS of the string is what is passed as a single DWORD parameter.

In the PROC that receives the parameters, you must have the capacity to receive and use the address.

In simple things like a MessageBox in a proc, you use the address directly in the parameters for the MessageBox.

Other procs depending on what they have to do will write the code to read from the address and do things like convert the string data at the address passed in the parameter.

I know it is a bit different if you are not used to this format but you MUST get used to thinking about string data in 32 bit assembler as the ADDRESS of where the data is in memory. High level languages in fact do it this way anyway, its just wrapped in a different way.


Posted on 2003-01-21 16:40:40 by hutch--

argc dd ?
argv dd 16 dup (?)
call ProcessCmdLine
; [argc] = number of parameters (including path to program)
; [argv+00h] = path to program
; [argv+04h] = parameter #1
; [argv+08h] = parameter #2

ProcessCmdLine proc uses ebx esi edi
call GetCommandLine
mov esi, eax
mov edi, OFFSET argv
xor ecx, ecx
xor ebx, ebx
xor edx, edx
@@cmss: mov eax, esi
mov dl, 20h
cmp byte ptr [esi], 22h
sete cl
lea edx, [edx+ecx*2]
add eax, ecx
@@cm00: inc esi
cmp byte ptr [esi], 0
je @@cm01
cmp byte ptr [esi], dl
jne @@cm00
mov byte ptr [esi], 0
add esi, ecx
inc esi
cmp byte ptr [esi], 0
je @@cm01
inc [argc]
jmp @@cmss
@@cm01: inc [argc]
ProcessCmdLine endp
Posted on 2003-01-21 19:27:50 by comrade