Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. what's in the EXE?

what's in the EXE?

Scheduled Pinned Locked Moved C / C++ / MFC
c++jsontutorialquestionlounge
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    lbc
    wrote on last edited by
    #1

    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

    J A J 3 Replies Last reply
    0
    • L lbc

      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

      J Offline
      J Offline
      Joaquin M Lopez Munoz
      wrote on last edited by
      #2
      1. 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
      1 Reply Last reply
      0
      • L lbc

        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

        A Offline
        A Offline
        Anonymous
        wrote on last edited by
        #3
        1. 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
        1 Reply Last reply
        0
        • L lbc

          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

          J Offline
          J Offline
          JohnMcL
          wrote on last edited by
          #4

          to 3) Another thing: If you try to save this class by serialisation the order will also be changed, so the files produced by the different .exe would be different.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups