And again... replace all memory re/de/allocation with macros, that'll make it easier to debug memory related issues :)
Working on the replacing all memory allocation deallocation with macros.
Thanks and best regards,
czDrillard
Thanks and best regards,
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:
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:
best regards,
czDrillard
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
nice that you made it work :)
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
Personally I don't recommend mixing jmps with .if/.while etc etc