[Exceptional C++ Style] Re: [Exception C++ Style] Item 15 - U sesandAbuses of Access Rights

David Sykes d.sykes at pindar.com
Tue Dec 14 10:00:06 EST 2004


> I have to be honest, until I read this item I had never 
> thought of doing any
> of the things it explores. Possibly it may do more harm than good....?
> 
> 

I'd say the greatest value is knowing that this sort of thing is possible,
so that if you are unfortunate enough to end up maintaining code written by
some maniac who did do this stuff at least you have a hope of guessing what
might be going on.

The first three methods rely on you knowing the layout of the data, so a
more straightforward way of accessing the member variables might be to just
get a pointer to the data and set it directly. At least this way it is clear
you are doing something you shouldn't.

*((int *)(((char *)&obj)+4)) = 2;	//	Smash and grab

JNI lets you fiddle with javas private bits to your hearts content, and you
even get a free dev kit to make it more pleasant

David Sykes
[ *** LongSig auto truncated *** ]

--- StripMime Report -- processed MIME parts ---
multipart/alternative
  text/plain (text body -- kept)
---



More information about the Effective-cpp mailing list