The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: Gunner on November 28, 2009, 09:16:23 PM

Title: At witts end with parsing
Post by: Gunner on November 28, 2009, 09:16:23 PM
Ok, figured I would write a tool to make my life easier.  Idea is to copy some text from a table in a html doc and paste it to a text box, then parse the text and grab what I need instead of copy and paste each line in column 1...  So I was just playing with some other parse code I have and cannot get this to work, am I out of the loop that long that I am missing the obvious?  When I PrintStringByAddr edi I get nothing
LOCAL Len:DWORD

    push    NULL
    push    NULL
    push    WM_GETTEXTLENGTH
    push    hText
    call    SendMessage
    add     eax, 1
    mov     Len, eax
   
    invoke HeapAlloc, hHeap, HEAP_ZERO_MEMORY, Len
    mov     esi, eax
       
    push    esi
    push    Len
    push    WM_GETTEXT
    push    hText
    call    SendMessage
   
    mov     eax, 2
    mul     Len
    mov     Len, eax

     
    invoke HeapAlloc, hHeap, HEAP_ZERO_MEMORY, Len
    mov     edi, eax
       
    @@:
        mov al, byte ptr[esi]               
        test al, al
        jz @F       
        mov byte ptr[edi], al
        inc edi
        ;dec edi ;<-- kinda works, string is backwards
        inc esi       
        jmp @B
    @@:
   
    PrintStringByAddr edi ;<-----------Nothing!
         
    push edi
    push 0
    push hHeap
    call HeapFree
         
    push esi
    push 0
    push hHeap
    call HeapFree
            ret


What am I missing?
Title: Re: At witts end with parsing
Post by: dedndave on November 28, 2009, 10:13:21 PM
simplify the loop a little bit - notice how it writes the null terminator for you
and save/restore edi

        push    edi

@@:     mov     al,[esi]
        mov     [edi],al
        inc     esi
        inc     edi
        test    al,al
        jnz     @B

        pop     edi
Title: Re: At witts end with parsing
Post by: Gunner on November 28, 2009, 10:29:12 PM
Thank you soooo much!  :dance: :U
Title: Re: At witts end with parsing
Post by: jj2007 on November 29, 2009, 12:54:25 AM
OT: Gunner, you are on rank 6 for googling PrintStringByAddr. Congrats :cheekygreen:
Title: Re: At witts end with parsing
Post by: Gunner on November 29, 2009, 01:05:27 AM
Quote from: jj2007 on November 29, 2009, 12:54:25 AM
OT: Gunner, you are on rank 6 for googling PrintStringByAddr. Congrats :cheekygreen:

That is too funny  :bg