Re: Data Encapsulation?




"Neo" <momer114@xxxxxxxxxxx> a écrit dans le message de news:
%23VG7crxqGHA.3484@xxxxxxxxxxxxxxxxxxxxxxx
I was written this code; in VS2k5
<snip>>
A obj;

int temp = *((int *)&obj + 1);
char ch = *((char *)&obj + 8);
cout<< temp<<endl<<ch<<endl;

in Object Orient World we learn Data Encapsulation or Data Hiding for data
security.

In this code, what is the meaning of Data Encapsulation or Data Hiding for
data security?

The aim of data access restriction (protected, private) in OO language is to
protect against Murphy - that is the programmer inadvertently
reading/writing a variable it shouldn't be interested in.
It is not aimed at protecting against Machiavel - that is a hacker who want
to acess data that should be forbidden to it. If you nee that kind of
protection, you probably need cryptography, authentification, access
control, etc...
Anyway, as Vinzenz has said, your "solution" is a hack that depends on
knowledge of the compiler internals working (ie, data padding and
alignement, presence of a v-ptr, data member reorganization, etc...)

Note that this is true in all OO languages, it is not specific to C++.

Arnaud
MVP - VC


.



Relevant Pages

  • Re: My words
    ... Internet Connection Firewall for SP1 and Windows Firewall for SP2 ... download all the security updates - Critical updates with Express ... Get into Safe Mode and password protect it. ...
    (microsoft.public.windowsxp.newusers)
  • [NEWS] Lotus Domino View ACL Bypass
    ... Lotus Domino View ACL Bypass ... The following security advisory is sent to the securiteam mailing list, and can be found at the SecuriTeam web site: http://www.securiteam.com ... A Lotus Notes database contains documents that are organized into views. ... nor are they intended to protect the documents they ...
    (Securiteam)
  • Re: BEWARE: New EULA lets MS ADMIN YOUR Systems!
    ... Microsoft and owners of content secured with Windows Media DRM to limit the ... Digital Rights Management (Security). ... You agree that in order to protect ... Microsoft may provide security related updates to the OS ...
    (microsoft.public.security)
  • Re: Front End/Back End communication
    ... I believe we should further protect the FE Exchange Server: ... the FE is located on the internal network with typical full-stack access to ... There is no such thing as security perfection. ...
    (Focus-Microsoft)
  • Re: Finally, a secure computer
    ... > security at the IBM website is compromised, ... Therefore it is extremely unlikely that any hacker ... > a tiny system served by IIS or the PWS protect himself with the same ... > ICF which does not listen on ports but only opens to responses to messages ...
    (microsoft.public.inetserver.iis.security)