News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Wierd stack corruption... on loop counter ?

Started by K_F, August 20, 2015, 09:07:53 PM

Previous topic - Next topic

K_F

Hi Ramon...
I'm having a weird problem here...
System = Win7 Pro, Service Pack = 1..something!

The data is written to the file OK, but the data counter (ECX [or EDX]) is being corrupted on the stack therefore the loop hangs.
EBX is fine.
I use the RegVal macro as quick look at registers, so don't think it's this as it's always worked fine.
FillBuffer - fills the array with zeros

It's in this code, as nothing else is happening at this point, so we're looking at a couple scenarios..
WinAPI, or WriteTextLine is corrupting the stack ?


Finally how does on set your stacksize in EC ?

Thanks
Van
;--- WRITE THE DATA ---
invoke SendMessage, GRP_DATA.h_lst_Data, LB_GETCOUNT, 0, 0
.if eax != LB_ERR
.if eax > 0
mov ecx, eax
xor ebx, ebx
@@:
RegVal ecx
RegVal ebx
push ecx
push ebx
Invoke FillBuffer, Addr s_BigBuff,512,0
Invoke SendMessage, GRP_DATA.h_lst_Data, LB_GETTEXT, ebx, Addr s_BigBuff
.if eax != LB_ERR
Invoke WriteTextLine, hFile, Addr s_BigBuff
.endif

pop ebx
pop ecx
inc ebx
dec ecx
cmp ecx, 0
jbe @F
jmp @B
@@:
.endif
.endif


Macro Used:
RegVal MACRO reg:REQ
push reg         
invoke FillBuffer, ADDR DebugSz, 256, 0
pop reg
push reg
invoke dwtoa, reg, ADDR DebugSz
invoke MessageBox, GlobWnd, ADDR DebugSz,TextAddr("REG VAL"), MB_OK
pop reg
ENDM
'Sire, Sire!... the peasants are Revolting !!!'
'Yes, they are.. aren't they....'

K_F

Hang on a bit... I think I might be me.. :shock:
don't tell anybody... :t
'Sire, Sire!... the peasants are Revolting !!!'
'Yes, they are.. aren't they....'

K_F

Resolved.. it.
After every instruction, I placed a RegVal ecx macro.. and it

- Corrupted on FillBuffer, commented this out..
- Even corrupted on MemFill..
- Then corrupted on SendMessage.. commented this out
- Corrupted on Write line.... ??

WTF...Now I'm beginning to freak out.

Closed EC restarted and changed my FillBuffer proc and manually implemented epilogues and prologues.

Worked on Fillbuffer.. then SendMessage then Writeline... Farrrk!! So got rid of all the RegVals and now all is fine.
It's not the closing/restarting of EC as I've done this at least 50x while looking for this solution...

.. and the solution is... I don't know... it just works so my hands are off
:badgrin:
'Sire, Sire!... the peasants are Revolting !!!'
'Yes, they are.. aren't they....'

jj2007

Quote from: K_F on August 21, 2015, 02:12:33 AM
Resolved.. it.
After every instruction, I placed a RegVal ecx macro.. and it

- Corrupted on FillBuffer, commented this out..
- Even corrupted on MemFill..
- Then corrupted on SendMessage.. commented this out
- Corrupted on Write line.... ??

What is this RegVal macro supposed to do, and where did you get it?

rsala

Hi Van,

Glad you could solve the problem!


jj2007:

Good question!
EC coder

K_F

Quote from: jj2007 on August 21, 2015, 05:33:35 AM
What is this RegVal macro supposed to do, and where did you get it?
Just a quickie/speed debugging macro I made up, to display a register value of interest.
It's in the code section on the first post.

RegVal MACRO reg:REQ
   push    reg         
   invoke   FillBuffer, ADDR DebugSz, 256, 0
   pop      reg
   push   reg
   invoke   dwtoa, reg, ADDR DebugSz
   invoke   MessageBox, GlobWnd, ADDR DebugSz,TextAddr("REG VAL"), MB_OK
   pop      reg
ENDM
'Sire, Sire!... the peasants are Revolting !!!'
'Yes, they are.. aren't they....'

jj2007

From what I see, RegVal ecx will trash eax and edx but otherwise it should be OK.

K_F

EDX.. thanks I've overlooked this... :icon14:
'Sire, Sire!... the peasants are Revolting !!!'
'Yes, they are.. aren't they....'

rsala

EC coder