Note that the point of Get/Set methods is so you cannot mistake a variable
for a property; the variables are protected (or private) and the Get/Set
methods are public and the only visible interface. Note that not
providing a Set mehod, the propery becomes read-only. In addition, you
can set breakpoints at the Get/Set routines only in unoptimized code. But
even with low-level optimizations, the following code is compiled inline
at the call site:
class something
{
protected:
SIZE_T count;
public:
void SetCount(SIZE_T n) { count = n; }
SIZE_T GetCount() { return count; }
}
====================
SIZE_T v = whatever -> GetCount();
whatever->SetCount(v + 1);
Debug mode code (example)
mov ecx, whatever
call somethin.GetCount
mov v, eax
mov eax, v
inc eax
push eax
mov ecx, whatever
call Something.SetCount
Optimized code (example)
mov ebx, whatever
mov eax, [ebx]
inc eax
mov[ebx], eax
(I compiled these in my head; if you do the actual experient, there may be
slightly different sequences)
Now, somebody will say “If you don’t put the bodies in the header file,
they have to be compiled as calls”, but if you enable Link-Time Code
Generation (LTCG) then even separate compilation will end up generating
inline code, no matter what the .cod file tells you.
joe
You can mark the underlying pages of an allocation as guard pages using
VirtualProtectEx . Windows then raises an exception whenever these pages
are
accessed but that includes read access as well.
It’s a pity that Windows does not offer us to install callbacks that
trigger
upon memory read or write (or even execute) access. Such a system could be
easily implemented by extending the page fault handler.
Some higher level languages offer a feature called ‘properties’ where
reading or writing to a variable is done through Get and Set methods. Very
powerful and one of the best language features I have seen ever, though
it’s
dangerous too because a property can be easily mistaken for a standard
variable and you need to know the implications.
//Daniel
>Is there a possibility to know that given memory page (of a single
> process)
>has changed without reading it’s content? I’m not interested in content
>itself. just want to know if it is different than I was checking it last
>time. I’m asking if MemoryManager in windows is tracking something like
>this? Something like last modification time/count or something?
NTDEV is sponsored by OSR
OSR is HIRING!! See http://www.osr.com/careers
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer