Soyez le premier à donner votre avis sur cette source.
Vue 11 795 fois - Téléchargée 501 fois
; Win32ASM command-line arguments ; By Dean (based on a code of comrade) call GetCommandLine ; get the command-line string mov esi, eax ; store the pointer in esi lea edi, argv ; mov in edi the address of argv xor ecx, ecx ; reset ecx cl_skipspace: cmp byte ptr [esi], 0 ; if we are at the end je cl_end ; exit cmp byte ptr [esi], 32 ; else if the character is not a space jne cl_findarg ; find the argument inc esi ; move of one character in the command-line jmp cl_skipspace ; skip the spaces cl_findarg: mov eax, esi ; store the pointer on the rest of the command-line in eax mov edx, 32 ; edx = 32 ([space] character) cmp byte ptr [esi], 34 ; the first character of the argument is a quote ? sete cl ; in this case, cl = 1 (else cl = 0) lea edx, [edx + ecx * 2] ; edx = [space] or [quote] add eax, ecx ; if the first character is a quote, we move of one character cl_parsearg: inc esi ; go on the next character cmp byte ptr [esi], 0 ; we are at the end ? je cl_storelastarg ; ok, store the last argument in the argv array cmp byte ptr [esi], dl ; the character is a [space] or a [quote] ? jne cl_parsearg ; no, continue to parse the argument mov byte ptr [esi], 0 ; else put a [null] character at the end of the argument stosd ; store the pointer in argv inc argc ; increment the counter inc esi ; get the next character jmp cl_skipspace ; skip the spaces until the new argument cl_storelastarg: stosd ; store the pointer in argv inc argc ; increment the counter cl_end:
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.