what's in the EXE?
-
Hello i am wondering about the following things because i'd like to get an idea about a source code is related to the final EXE Let's say we have a class (i am working with VC7, assuming no optimizations at all) class CMyDlg : public CDialog { // Construction public: CMyDlg(CWnd* pParent = NULL); // standard constructor ... // data int d1, d2, d3; CString s1, s2, s3; ... ... //methods void method1 (int v1); void method2 (int v2); ... }; // Implementation for the CMyDlg Class ... CMyDlg::CMyDlg(CWnd* pParent /* = NULL*/) : CDialog(CMyDlg::IDD, pParent) { d1=100; d2=200; d3=300; s1="default"; s2=""; s3="hello"; } void CMyDlg::method1( int v1) { // do something ... } void CMyDlg::method2( int v2) { // do something ... } well, imagine to compile and get the EXE. Some questions: 1) If, for refactoring purposes i decide to rename the class into something like CMyOtherDlg, and leave everything else unchanged (data and methods), the resulting compiled code inside the EXE will be exactly the same? 2) What about changing also the members and methods names? 3) If i change (just for example) the declaration order and/or the inizialization order for the variables, will this 'matter' something or will have completely no influence on the final EXE? 4) Do the names used inside the source code mean 'something special' in the final EXE? Why, for example, if i examine the resulting EXE code, with an HEX editor i am able to find some MFC or API functions names and not the names of my functions/classes (at least it seems so to me)? Any info about the above will be greatly appreciated, as well as any web links helpful to understand (even from a general point of view, let's say an overview) about how the VC compiler 'translates' the source code, links it and finally produces the EXE. thanks in advance! best regards
-
Hello i am wondering about the following things because i'd like to get an idea about a source code is related to the final EXE Let's say we have a class (i am working with VC7, assuming no optimizations at all) class CMyDlg : public CDialog { // Construction public: CMyDlg(CWnd* pParent = NULL); // standard constructor ... // data int d1, d2, d3; CString s1, s2, s3; ... ... //methods void method1 (int v1); void method2 (int v2); ... }; // Implementation for the CMyDlg Class ... CMyDlg::CMyDlg(CWnd* pParent /* = NULL*/) : CDialog(CMyDlg::IDD, pParent) { d1=100; d2=200; d3=300; s1="default"; s2=""; s3="hello"; } void CMyDlg::method1( int v1) { // do something ... } void CMyDlg::method2( int v2) { // do something ... } well, imagine to compile and get the EXE. Some questions: 1) If, for refactoring purposes i decide to rename the class into something like CMyOtherDlg, and leave everything else unchanged (data and methods), the resulting compiled code inside the EXE will be exactly the same? 2) What about changing also the members and methods names? 3) If i change (just for example) the declaration order and/or the inizialization order for the variables, will this 'matter' something or will have completely no influence on the final EXE? 4) Do the names used inside the source code mean 'something special' in the final EXE? Why, for example, if i examine the resulting EXE code, with an HEX editor i am able to find some MFC or API functions names and not the names of my functions/classes (at least it seems so to me)? Any info about the above will be greatly appreciated, as well as any web links helpful to understand (even from a general point of view, let's say an overview) about how the VC compiler 'translates' the source code, links it and finally produces the EXE. thanks in advance! best regards
- In release mode, seems the name does not appear in the final .EXE. 2) Same answer 3) It affects the layout of the objects, and hence the final .EXE. 4) This is due to the fact that those names are used to dynamically link the appropriate methods at startup. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo
-
Hello i am wondering about the following things because i'd like to get an idea about a source code is related to the final EXE Let's say we have a class (i am working with VC7, assuming no optimizations at all) class CMyDlg : public CDialog { // Construction public: CMyDlg(CWnd* pParent = NULL); // standard constructor ... // data int d1, d2, d3; CString s1, s2, s3; ... ... //methods void method1 (int v1); void method2 (int v2); ... }; // Implementation for the CMyDlg Class ... CMyDlg::CMyDlg(CWnd* pParent /* = NULL*/) : CDialog(CMyDlg::IDD, pParent) { d1=100; d2=200; d3=300; s1="default"; s2=""; s3="hello"; } void CMyDlg::method1( int v1) { // do something ... } void CMyDlg::method2( int v2) { // do something ... } well, imagine to compile and get the EXE. Some questions: 1) If, for refactoring purposes i decide to rename the class into something like CMyOtherDlg, and leave everything else unchanged (data and methods), the resulting compiled code inside the EXE will be exactly the same? 2) What about changing also the members and methods names? 3) If i change (just for example) the declaration order and/or the inizialization order for the variables, will this 'matter' something or will have completely no influence on the final EXE? 4) Do the names used inside the source code mean 'something special' in the final EXE? Why, for example, if i examine the resulting EXE code, with an HEX editor i am able to find some MFC or API functions names and not the names of my functions/classes (at least it seems so to me)? Any info about the above will be greatly appreciated, as well as any web links helpful to understand (even from a general point of view, let's say an overview) about how the VC compiler 'translates' the source code, links it and finally produces the EXE. thanks in advance! best regards
- No, there generally shouldn't be any change to the exe (if you build in debug mode then you may see a few name changes, but thats all) 2) Same as above. The names of classes and functions are just symbolic - they all get stripped out when compiled (also again dependant on debug/release) 3) It can matter, depending on the byte alignment. For example, if you have: char m_MyChar; int m_MyInt; char m_MyChar2; And int m_MyInt; char m_MyChar; char m_MyChar2; The second version will be slightly more space efficient. The first m_MyChar will be byte aligned and so take up 4/8 bytes (I cant remember the exact value), of which only 1 byte is used. Then the int, then a 4/8 byte for the second char. Total is 12 (using 4 byte align, and 4 byte int). The second has 4 bytes for the int, and 2 bytes for the char... aligned as 4 bytes, so total is 8
-
Hello i am wondering about the following things because i'd like to get an idea about a source code is related to the final EXE Let's say we have a class (i am working with VC7, assuming no optimizations at all) class CMyDlg : public CDialog { // Construction public: CMyDlg(CWnd* pParent = NULL); // standard constructor ... // data int d1, d2, d3; CString s1, s2, s3; ... ... //methods void method1 (int v1); void method2 (int v2); ... }; // Implementation for the CMyDlg Class ... CMyDlg::CMyDlg(CWnd* pParent /* = NULL*/) : CDialog(CMyDlg::IDD, pParent) { d1=100; d2=200; d3=300; s1="default"; s2=""; s3="hello"; } void CMyDlg::method1( int v1) { // do something ... } void CMyDlg::method2( int v2) { // do something ... } well, imagine to compile and get the EXE. Some questions: 1) If, for refactoring purposes i decide to rename the class into something like CMyOtherDlg, and leave everything else unchanged (data and methods), the resulting compiled code inside the EXE will be exactly the same? 2) What about changing also the members and methods names? 3) If i change (just for example) the declaration order and/or the inizialization order for the variables, will this 'matter' something or will have completely no influence on the final EXE? 4) Do the names used inside the source code mean 'something special' in the final EXE? Why, for example, if i examine the resulting EXE code, with an HEX editor i am able to find some MFC or API functions names and not the names of my functions/classes (at least it seems so to me)? Any info about the above will be greatly appreciated, as well as any web links helpful to understand (even from a general point of view, let's say an overview) about how the VC compiler 'translates' the source code, links it and finally produces the EXE. thanks in advance! best regards