hi im overlooking something i just know it. ive looked over my procedure for a few hours now and i cant figure out why my variable loc2 isnt being filled properly. after being parsed right the variable loc2 should contain "owner". here is my code:
.586

.model flat, stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\kernel32.lib
include \masm32\include\user32.inc
includelib \masm32\lib\user32.lib

.data
data db "dr-xr-xr-x 1 owner group 0 May 21 2001 deskapps",0
flag db 0

.data?
loc1 dd 512 dup (?)
loc2 dd 512 dup (?)
loc3 dd 512 dup (?)
loc4 dd 512 dup (?)
loc5 dd 512 dup (?)
loc6 dd 512 dup (?)

.code
start:
mov esi,offset data
lea edi,loc1
xor ecx,ecx
dec ecx
@L1:
inc ecx ;start at zero and inc one
mov al,byte ptr[esi + ecx] ;mov one byte at a time into al
mov byte ptr[edi + ecx],al ;then mov that byte into esi
cmp al,0 ;check the byte to see if there is any info to process
je @over ;if no info to process jmp over everything
cmp al,"d" ;else cmp first byte for the letter d
jne @L2 ;if not a directory then we know its a file so jmp to L2
inc flag ;SET FLAG TO INDICATE A DIRECTORY
@L2:
inc ecx ;inc one
mov al,byte ptr[esi + ecx] ;mov one byte at a time into al
mov byte ptr[edi + ecx],al ;then mov that byte into esi
cmp al,20h ;check for a space
jne @L2 ;if no space jmp back and try another
mov byte ptr[edi + ecx],0 ;space found, put a 0 there to terminate it
@L3:
inc ecx ;inc one
mov al,byte ptr[esi + ecx] ;mov one byte at a time into al
cmp al,20h ;check for a space
je @L3 ;if a space is found jmp back
inc ecx ;ok the 1 is found so inc to move into space
lea edi,loc2 ;new storage location
@L4:
inc ecx ;inc one
mov al,byte ptr[esi + ecx] ;mov one byte at a time into al
mov byte ptr[edi + ecx],al ;then mov that byte into esi which is buffer
cmp al,20h ;check for a space
jne @L4 ;if no space jmp back and try another
mov byte ptr[edi + ecx],0 ;space found put a 0 there to terminate it

invoke MessageBox,0,addr loc2,0,0 ;// this should conatin "owner" whats going on here?

@over:
invoke ExitProcess,NULL
end start
Posted on 2002-05-10 01:45:05 by smurf
I take it you want a more dynamic parser (one that doesnt assume the fields will be a static length)?

Anyways, ya, your overlooking something here. Its quite simple really. You load the destination variable EDI with the address of Loc2. And then you proceed to the next "phase" with the same cut'n'paste sections. The problem is, till now, these sections were dealing linearly with a previous EDI address, and indexed by ECX along with the source.

mov byte ptr,al

But when you reset the address, you didnt reset the ECX in @L4: . So your probably see nothing when you attempt to view Loc2. This is because, if ecx == 10 at the time entering @L4: , Loc2 in bytes would look like.

Loc2: 00 00 00 00 00 00 00 00 00 00 'o' 'w' 'n' 'e' 'r' ...

:alright:
NaN

PS: Coding with the comments are a nice improvement ;)
: The simplest fix, would be:

lea edi, Loc2 ; Get Base Address
sub edi, ecx ; Subtract ecx
@L4:
...
mov byte ptr,al ; now edi + ecx == Base Address
...
Posted on 2002-05-10 02:49:24 by NaN
thanks again NaN!:)
Posted on 2002-05-10 08:29:52 by smurf