Click here to Skip to main content
15,913,773 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: class structure Pin
Cedric Moonen10-May-06 2:50
Cedric Moonen10-May-06 2:50 
GeneralRe: class structure Pin
Amr Shahin10-May-06 2:54
Amr Shahin10-May-06 2:54 
GeneralRe: class structure Pin
toxcct10-May-06 2:55
toxcct10-May-06 2:55 
GeneralRe: class structure Pin
Cedric Moonen10-May-06 3:00
Cedric Moonen10-May-06 3:00 
GeneralRe: class structure Pin
vikramlinux10-May-06 3:05
vikramlinux10-May-06 3:05 
AnswerRe: class structure Pin
Maximilien10-May-06 3:12
Maximilien10-May-06 3:12 
GeneralRe: class structure Pin
vikramlinux10-May-06 3:18
vikramlinux10-May-06 3:18 
AnswerRe: class structure Pin
Nick_Kisialiou10-May-06 6:25
Nick_Kisialiou10-May-06 6:25 
There is, but it is no longer C++. It is compiler implementation code which is not in C++ standard.
Class (memory) structure is something like this:
this_pointer -> [vtable_pointer, dataField1, dataField2, ...]
where vtable_pointer points to the table of virtual functions:
vtable_pointer -> [func1, func2, ...]

So, in theory, you can get access to class (public/private do not make sense in binary) members like this:
data1 = *((char*)(*this) + 4);
data2 = *((char*)(*this) + 8); // or 12 or 16 depending on the type of data1

Notice, I said in theory, because in practice the compiler aligns data fields the way it wants, even the order matters. So, if you have an integer data field and a double data field you may get something like this:
[4 bytes for vtable_pointer, 4 bytes garbage, 4 bytes int, 8 bytes double]

There is no simple way to figure out the order and the types of data fields unless you disasm the binary to see which memory locations are accessed from public functions that you know.

That's not much, but I hope it'll be helpful.



-- modified at 12:28 Wednesday 10th May, 2006
GeneralRe: class structure Pin
NiceNaidu10-May-06 19:36
NiceNaidu10-May-06 19:36 
GeneralRe: class structure Pin
NiceNaidu10-May-06 19:42
NiceNaidu10-May-06 19:42 
QuestionSetCursor for CMyStatic isn't working??? Pin
YaronNir10-May-06 2:22
YaronNir10-May-06 2:22 
AnswerRe: SetCursor for CMyStatic isn't working??? Pin
YaronNir10-May-06 2:46
YaronNir10-May-06 2:46 
GeneralRe: SetCursor for CMyStatic isn't working??? Pin
Nishad S10-May-06 3:01
Nishad S10-May-06 3:01 
GeneralRe: SetCursor for CMyStatic isn't working??? Pin
Hamid_RT10-May-06 3:10
Hamid_RT10-May-06 3:10 
QuestionEmail notify Pin
Vivek krishna10-May-06 2:19
Vivek krishna10-May-06 2:19 
AnswerRe: Email notify Pin
alan top10-May-06 2:27
alan top10-May-06 2:27 
GeneralRe: Email notify Pin
Vivek krishna10-May-06 2:54
Vivek krishna10-May-06 2:54 
AnswerRe: Email notify Pin
_AnsHUMAN_ 10-May-06 3:01
_AnsHUMAN_ 10-May-06 3:01 
Questioni want answerfor this question Pin
Reddyb10-May-06 2:19
Reddyb10-May-06 2:19 
AnswerRe: i want answerfor this question Pin
toxcct10-May-06 2:20
toxcct10-May-06 2:20 
AnswerRe: i want answerfor this question Pin
Hamid_RT10-May-06 2:24
Hamid_RT10-May-06 2:24 
Questionanswer i want Pin
Reddyb10-May-06 2:14
Reddyb10-May-06 2:14 
AnswerRe: answer i want Pin
toxcct10-May-06 2:17
toxcct10-May-06 2:17 
GeneralRe: answer i want Pin
Cedric Moonen10-May-06 2:18
Cedric Moonen10-May-06 2:18 
GeneralRe: answer i want Pin
Hamid_RT10-May-06 2:25
Hamid_RT10-May-06 2:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.