And again... replace all memory re/de/allocation with macros, that'll make it easier to debug memory related issues :)
Posted on 2005-08-30 12:15:41 by f0dder
Working on the replacing all memory allocation deallocation with macros.

Thanks and best regards,

czDrillard
Posted on 2005-08-30 19:12:56 by czDrillard
Thanks to everybody helping and my stupidity I got program working.  Big problem was here, I don't know how I missed it before but sometimes even the most obvious mistakes are invisible to the people making them:

    invoke GlobalSize,hMemory
    mov ecx,eax
    mov edi,pMemory
    xor eax,eax
    mov ax,7a63h

    @Begin:

.if ecx<=00h
    jmp @End

.else
    stosw
    sub ecx,02h
    jmp @Begin

        .endif

    @End:


This works perfectly for files whose lengths are even numbers.  If file is odd number length then ecx ends up as 1 which is greater than 0 so two bytes are written and ecx ends up with a value of -1.  Of course it is too late and one byte has been written into illegal address space.  So I changed code to this and works good.  No more exceptions:
	 invoke GlobalSize,hMemory
    mov ecx,eax
    mov edi,pMemory
    xor eax,eax
    mov ax,7a63h

    @Begin:

.if ecx==00h
    jmp @End

.elseif ecx==1
    xor eax,eax
    mov al,63h
    stosb
    sub ecx,01h
    jmp @Begin

.else
    stosw
    sub ecx,02h
    jmp @Begin

        .endif

    @End:


best regards,

czDrillard
Posted on 2005-09-03 11:46:17 by czDrillard
nice that you made it work :)
Posted on 2005-09-03 12:39:18 by f0dder
I just hope you know what you are doing in the future. The code don't look very friendly. For your case ecx == 1 why do you have to dec ecx and then jmp back to @begin when you can jmp straight to @end

Personally I don't recommend mixing jmps with .if/.while etc etc
Posted on 2005-09-03 12:57:35 by roticv