Hello everybody,

Any body know why this line of code would clear the szValueName buffer?

	invoke lstrcpy,ADDR szTempBuf,ADDR szKeyCurrentName
invoke lstrcat,ADDR szTempBuf,ADDR szBackSlash
invoke lstrcat,ADDR szTempBuf,ADDR szKeyUrl
invoke lstrcat,ADDR szTempBuf,ADDR szBackSlash
                invoke lstrcat,ADDR szTempBuf,ADDR szValueName
invoke SendMessage,hWndStatus,SB_SETTEXT,0,ADDR szTempBuf ;(error occurs during this call)


This is a registry key I created like HKEY_CURRENT_USER/Software/MyProgram/Settings/Values
It is properly displayed in the status bar but when I watch with a debugger the value in the szValueName buffer is zeroed.  Why would that be?  What could cause it?

Any ideas suggestions much appreciated.

best regards,

czDrillard
Posted on 2005-12-22 08:51:10 by czDrillard
How are your string buffers defined? Maybe the strings are too long and overflow the destination buffer.
Posted on 2005-12-22 10:49:53 by QvasiModo
Thanks QvasiModo, strings are 1024 bytes.  Don't seem to overflow.
Posted on 2005-12-22 22:08:12 by czDrillard
Put a dummy variable before the szValueName in your data section to stop overrun.

dummy_variable DB 10000 dup (0)
szValueName DB '123', 0
Posted on 2005-12-27 12:04:08 by roaknog
Hello roaknog, thanks for your reply.  This seems to work.  But why does it?  Could you explain the logic behind it?

best regards,

czDrillard
Posted on 2005-12-28 08:34:43 by czDrillard
The dummy variable is absorbing the buffer overrun.  It does not necessarily have to be that size.  Perhaps other variables could be enlarged in the data section area instead. 

Your data area is organized at the beginning in the order you lay out.  Your code that follows, is also organized by you Microsoft and the people of Masm32, and it runs through your data area. 

Inserting the variable is a sloppy programming technique.  But it is my technique.  I would think the overrun is caused by the lstrcat instead of the status window.  Creating your own lstrcat funtion might fix it too, if a change in other variable sizes doesn't also fix it.
Posted on 2005-12-28 08:55:07 by roaknog
Check in your debugger with a breakpoint on Memory Access on Write with szValueName to see where it gets overwritten.
Posted on 2005-12-28 08:59:23 by JimmyClif
Thanks for all replies,
A few days ago I removed all the lstrcat functions and just wrote szValueName directly to the status bar.  No problems.  Hmmm...

Btw, I'm using VC6 debugger.  Is it possible to break on memory access.  I know I could do this with the old softice.

best regards,

czDrillard
Posted on 2005-12-29 08:39:29 by czDrillard
A few days ago I removed all the lstrcat functions and just wrote szValueName directly to the status bar.  No problems.  Hmmm...
This would suggest a missing sz terminator.

Every once in a while you run into a sz list terminated with a double null.

Regards,  P1  8)
Posted on 2005-12-30 20:37:59 by Pone