Page 1 of 1
Enforcer hits ?
Posted: Wed Mar 01, 2006 9:54 pm
by Flype
When i do this :
Code: Select all
a$ = "pure"
PokeS(@a$,"purebasic")
Debug a$
Here, i write illegaly to memory.
Does exists a tool that can monitor illegal writes to memory ?
Posted: Wed Mar 01, 2006 10:16 pm
by Trond
The debugger will complain if you write outside the allocated string buffer.
Posted: Wed Mar 01, 2006 10:32 pm
by freak
Only if the memory area after your allocated buffer is marked as invalid or readonly.
Usually small buffer overflows are not catched, because the remainder of the
memory page where your buffer is located is not marked invalid, and therefore
produces no error when written to.
Posted: Wed Mar 01, 2006 10:38 pm
by thefool
Buffer overrides

Posted: Thu Mar 02, 2006 9:57 am
by Flype
@freak
thanx for the explanation.
how to declare such memory areas as invalid ?
and a tool ? a microsoft one perhaps...
Posted: Thu Mar 02, 2006 11:32 am
by Fred
A good way on Windows is to use HeapValidate() to help tracking down such bug. It's not easy if the overflow is only 1 byte for example, as Windows always reserve by block of 16 bytes. So writting after won't produce anything wrong.
Posted: Thu Mar 02, 2006 1:45 pm
by Flype
fred, let's have fun :
( from AWEAR, french forum )
Code: Select all
PokeS(@"true", PeekS(@"false"))
x$ = "true"
Debug x$
Debug "true"
I don't think it's a bug, it seems normal but surprising me first time.

Posted: Thu Mar 02, 2006 3:04 pm
by Fred
you writting directly in the data section, no wonder
