flat assembler
Message board for the users of flat assembler.
![]() Goto page 1, 2, 3 Next |
Author |
|
baldr 24 Oct 2010, 14:10
Overflowz,
You may import CommandLineToArgvW() from Shell32.DLL and use its result in familiar C style (I suppose). Code: format PE include "Win32WX.Inc" include "Win32X+.Inc" .code invoke shell32::CommandLineToArgvW, <invoke GetCommandLine>, argc mov esi, eax cinvoke MSVCRT::wprintf, _argc, [argc] cinvoke _putws, _banner .repeat cinvoke MSVCRT::_putws, dword[esi] add esi, 4 dec [argc] .until ZERO? ret .data _argc TCHAR "argc: %u", 10, 0 _banner TCHAR "argv[]:", 0 align 4 argc rd 1 .end |
|||
![]() |
|
vid 24 Oct 2010, 15:03
baldr: (nitpick) why do you use "TCHAR" for what is widechar buffer (nonportable to ANSI)?
|
|||
![]() |
|
Picnic 24 Oct 2010, 15:43
Vortex old example should do for your simple needs. Search board Overflowz.
Code: invoke LocalAlloc, LMEM_ZEROINIT, MAX_PATH mov ebx, eax mov esi, eax invoke GetCommandLine lea edx, [eax-1] xor eax, eax lea edi, [ebx+32] mov ch, 32 .CL0: inc edx mov cl, [edx] test cl, cl jz .CL4 cmp cl, 32 jz .CL0 inc eax mov [ebx], edi add ebx, 4 .CL1: mov cl, [edx] test cl, cl jz .CL4 cmp cl, ch jz .CL3 cmp cl, 34 jnz @F xor ch, 32 jmp .CL2 @@: mov [edi], cl inc edi .CL2: inc edx jmp .CL1 .CL3: mov byte [edi], 0 inc edi jmp .CL0 .CL4: cmp eax, 3 ;parameters should be 2 only jz @F ;error parameters @@: ;dword [esi+4] = Parameter 1 ;dword [esi+8] = Parameter 2 |
|||
![]() |
|
baldr 24 Oct 2010, 15:55
vid,
Reference to wcstombs() probably will confuse respondent. That's kinda elements of a good style, to use tools provided. ![]() |
|||
![]() |
|
Overflowz 24 Oct 2010, 16:04
baldr, thanks I'll try to learn that.
Picnic, searched but didn't found any "good example for me" thats hard for me and long ![]() |
|||
![]() |
|
vid 24 Oct 2010, 16:22
Quote: Reference to wcstombs() probably will confuse respondent. That's kinda elements of a good style, to use tools provided. I meant to make it simpler, not more complicated: keeping it widechar-only, and using "du" instead of TCHAR. That ANSI/Unicode portability doesn't work in Asm anyway without writing lot of extra code, and I still don't understand who was the genius that introduced TCHAR to Asm. |
|||
![]() |
|
baldr 24 Oct 2010, 16:30
Picnic,
Paraphrasing what my mother said once, "never use 32 or 0x20 instead of ' ' when you do mean latter exactly, unless you're going to confuse reader or you don't have the choice". ![]() |
|||
![]() |
|
Overflowz 24 Oct 2010, 18:38
I'll write code and someone fix my code please. Just for me to learn cause those sources is difficult for me.. here's mine:
Code: format PE console include 'WIN32AX.INC' entry main section '.data' data readable writeable argv dd ? argc dd ? env dd ? buffer rb 10 section '.text' code readable executable proc main invoke GetCommandLine invoke CommandLineToArgvW,eax,argc invoke printf,argv invoke ExitProcess,0 endp section '.idata' import data readable library user32,'user32.dll',kernel32,'kernel32.dll',shell32,'shell32.dll',msvcrt,'msvcrt.dll' include 'API\USER32.INC' include 'API\KERNEL32.INC' include 'API\SHELL32.INC' import msvcrt,printf,'printf' and I have some questions. #1 how to compare how many arguments are passed ? #2 how to print 1st, 2nd, 3nd.. etc arguments ? P.S this code doesn't work.. |
|||
![]() |
|
baldr 24 Oct 2010, 19:06
Overflowz,
How do you expect argv to be filled? |
|||
![]() |
|
Overflowz 24 Oct 2010, 19:26
I dont know nothing about this just some working example.. I'm just guessing what I'm doing.. but this code is easy to understand for me but I dont need msvcrt support and putws and TCHAR things. I dont know em..
|
|||
![]() |
|
Tyler 24 Oct 2010, 19:50
Command Line Parameters example on the examples page.
|
|||
![]() |
|
Overflowz 24 Oct 2010, 20:09
Right.. can you just CUT main code of using command line things ? cause I dont understand alooot of there.. for example:
where the code checks how much arguments there.. how argv1 argv2 ... moves into messagebox and alot of things.. just type main and little example please ? ![]() |
|||
![]() |
|
Tyler 24 Oct 2010, 21:01
Code: int argc; char **argv; argv = CommandLineToArgvA(GetCommandLineA(), &argc); It's that easy. |
|||
![]() |
|
vid 24 Oct 2010, 21:25
Tyler: No, it's not. Next time please test your code first
![]() |
|||
![]() |
|
Overflowz 24 Oct 2010, 21:39
dude, please read first post what I'm trying to do.
Quote: example like this structure: just LITTLE example.. |
|||
![]() |
|
vid 24 Oct 2010, 21:44
baldr gave you example, just instead of using MessageBox he displayed all parameters in loop to console.
|
|||
![]() |
|
Tyler 24 Oct 2010, 21:49
Overflowz wrote: dude, please read first post what I'm trying to do. What exactly can't you do? After you've got the args in argc/v form, everything else is, or at least should be, trivial. vid: What's wrong with the code I posted? I didn't intend to give a full solution, if that's what you mean. Last edited by Tyler on 24 Oct 2010, 21:55; edited 1 time in total |
|||
![]() |
|
Overflowz 24 Oct 2010, 21:49
Yes but I don't understand where it compares how many arguments there and without using C library..
|
|||
![]() |
|
Tyler 24 Oct 2010, 22:01
Overflowz wrote: Yes but I don't understand where it compares how many arguments there and without using C library.. Me wrote:
Um... it's passed by reference into the argc... which was passed by reference. Why else would it require a reference to an int, which I named argc to emphasise it's purpose? |
|||
![]() |
|
Goto page 1, 2, 3 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.