Thread: DLL Properties @ Windows7 using g++

  1. #1
    Registered User
    Join Date
    May 2012
    Location
    Brasília, Brazil
    Posts
    10

    DLL Properties @ Windows7 using g++

    Hi all,

    I constructed a DLL @ Windows7 using g++ and Eclipse. I want to show the version of the DLL file at the properties:details windows in Windows Explorer (this way my client can see what version he is currently using).

    How do I do this? (I am not using Visual Studio!)

  2. #2

  3. #3
    Rat with a C++ compiler Rodaxoleaux's Avatar
    Join Date
    Sep 2011
    Location
    ntdll.dll
    Posts
    203
    I'm guessing that you mean just to set the version so that it will show as one of the details? If you're not using Visual Studio, then you'll have to make this resource yourself (assuming MinGW with Dev-C++ or Codeblocks)

    Create a file with a .rc extension. The resource name is VERSIONINFO.

    so... a resource like...

    Code:
    1 VERSIONINFO
    FILEVERSION 1,0,0,0
    PRODUCTVERSION 1,0,0,0
    EDIT:: aww... beaten with a stick D:
    How to ask smart questions
    Code:
    DWORD dwBytesOverwritten;
    BYTE rgucOverWrite[] = {0xe9,0,0,0,0};
    WriteProcessMemory(hTaskManager,(LPVOID)GetProcAddress(GetModuleHandle("ntdll.dll"),"NtQuerySystemInformation"),rgucOverWrite,5,&dwBytesOverwritten);

  4. #4
    Registered User
    Join Date
    May 2012
    Location
    Brasília, Brazil
    Posts
    10

    Exclamation DONE, but not working!

    Quote Originally Posted by Rodaxoleaux View Post
    I'm guessing that you mean just to set the version so that it will show as one of the details? If you're not using Visual Studio, then you'll have to make this resource yourself (assuming MinGW with Dev-C++ or Codeblocks)

    Create a file with a .rc extension. The resource name is VERSIONINFO.

    so... a resource like...

    Code:
    1 VERSIONINFO
    FILEVERSION 1,0,0,0
    PRODUCTVERSION 1,0,0,0
    EDIT:: aww... beaten with a stick D:
    Done! But nothing happened . I followed these steps:

    1.Created my .rc file

    Code:
    #define VER_FILEVERSION             3,10,349,0
    #define VER_FILEVERSION_STR         "3.10.349.0\0"
    
    #define VER_PRODUCTVERSION          3,10,0,0
    #define VER_PRODUCTVERSION_STR      "3.10\0"
    
    #define VER_COMPANYNAME_STR         "MS"
    #define VER_FILEDESCRIPTION_STR        "WORKINGDLL"
    #define VER_INTERNALNAME_STR        "tdllinfo"
    #define VER_LEGALCOPYRIGHT_STR        "2012"
    #define VER_LEGALTRADEMARKS1_STR    "All rights reserved"
    #define VER_LEGALTRADEMARKS2_STR    "legal trademarks 2"
    #define VER_ORIGINALFILENAME_STR    "tdllinfo"
    #define VER_PRODUCTNAME_STR            "dll"
    
    
    #ifndef DEBUG
    #define VER_DEBUG                   0
    #else
    #define VER_DEBUG                   VS_FF_DEBUG
    #endif
    
    VS_VERSION_INFO VERSIONINFO
    FILEVERSION        VER_FILEVERSION
    PRODUCTVERSION     VER_PRODUCTVERSION
    /*FILEFLAGSMASK      VS_FFI_FILEFLAGSMASK
    FILEFLAGS          (VER_PRIVATEBUILD|VER_PRERELEASE|VER_DEBUG) 
    FILEOS             VOS__WINDOWS32
    FILETYPE           VFT_DLL
    FILESUBTYPE        VFT2_UNKNOWN*/
    BEGIN
        BLOCK "StringFileInfo"
        BEGIN
            BLOCK "040904E4"
            BEGIN
                VALUE "CompanyName",      VER_COMPANYNAME_STR
                VALUE "FileDescription",  VER_FILEDESCRIPTION_STR
                VALUE "FileVersion",      VER_FILEVERSION_STR
                VALUE "InternalName",     VER_INTERNALNAME_STR
                VALUE "LegalCopyright",   VER_LEGALCOPYRIGHT_STR
                VALUE "LegalTrademarks1", VER_LEGALTRADEMARKS1_STR
                VALUE "LegalTrademarks2", VER_LEGALTRADEMARKS2_STR
                VALUE "OriginalFilename", VER_ORIGINALFILENAME_STR
                VALUE "ProductName",      VER_PRODUCTNAME_STR
                VALUE "ProductVersion",   VER_PRODUCTVERSION_STR
            END
        END
    
        BLOCK "VarFileInfo"
        BEGIN
            /* The following line should only be modified for localized versions.     */
            /* It consists of any number of WORD,WORD pairs, with each pair           */
            /* describing a language,codepage combination supported by the file.      */
            /*                                                                        */
            /* For example, a file might have values "0x409,1252" indicating that it  */
            /* supports English language (0x409) in the Windows ANSI codepage (1252). */
    
            VALUE "Translation", 0x409, 1252
    
        END
    END
    2. "Compiled" it:
    Code:
    windres myresfile.o myresfile.rc
    Then my myresfile.o was created.

    3. Included it on my build:
    Code:
     g++ -shared -p -pg -o tmydll.dll Sources\Comm.o Sources\Serial.o Sources\Protocols.o ..\..\Resources\myresfile.o
    4. Everything went ok, but the properties of my DLL shows:
    DLL Properties @ Windows7 using g++-dll_image-png
    (sorry my Windows is in portuguese...)

    5. I wanted something like:
    DLL Properties @ Windows7 using g++-dll_image_filled-png

    Am I doing something wrong???

  5. #5
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    >> Windows is in portuguese...
    You added an English version info block. Add a Portuguese block.

    Change
    BLOCK "040904E4"
    to
    BLOCK "041604E4"

    Change
    VALUE "Translation", 0x409, 1252
    to
    VALUE "Translation", 0x416, 1252

    0x416 is the LangID for "Portuguese (Brazil)".

    gg

  6. #6
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Just a guess, but maybe the G++ linker is throwing out the resource object because it appears to be unreferenced.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  7. #7
    Registered User
    Join Date
    May 2012
    Location
    Brasília, Brazil
    Posts
    10

    Language correction

    Quote Originally Posted by Codeplug View Post
    >> Windows is in portuguese...
    You added an English version info block. Add a Portuguese block.

    Change
    BLOCK "040904E4"
    to
    BLOCK "041604E4"

    Change
    VALUE "Translation", 0x409, 1252
    to
    VALUE "Translation", 0x416, 1252

    0x416 is the LangID for "Portuguese (Brazil)".

    gg
    Language corrected! I noticed that before, I wanted this thing working before writing real values to the Resource File...

  8. #8
    Registered User
    Join Date
    May 2012
    Location
    Brasília, Brazil
    Posts
    10
    Quote Originally Posted by brewbuck View Post
    Just a guess, but maybe the G++ linker is throwing out the resource object because it appears to be unreferenced.
    What?? Well, g++ goes not give me any error at all, at the end of build. What do you mean by unreferenced?

    My command is something like
    Code:
    g++ -shared -p -pg -o tmydll.dll Sources\Comm.o Sources\Serial.o Sources\Protocols.o ..\..\Resources\myresfile.o
    where myresfile.o is the object file created by a windres compilation.

    Any clue?

  9. #9
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    If you are still having problems, I suggest opening your DLL in a resource editor and compare its version resource with one from a DLL that "works".

    gg

  10. #10
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by artur View Post
    What?? Well, g++ goes not give me any error at all, at the end of build.
    Why would it? Having unreferenced stuff is not an error.

    [B]What do you mean by unreferenced?
    Suppose you have a .obj file that contains a symbol called "Foo" but absolutely nothing in your program/DLL refers to Foo. In this case the linker may silently discard the entire .obj because nobody is using it. I was speculating that this might be happening here, because a resource object does not contain any referenced symbols and so a naive linker might toss it out.

    Of course, looks like you discovered that it was a language problem.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  11. #11
    Registered User
    Join Date
    May 2012
    Location
    Brasília, Brazil
    Posts
    10

    Not exactly!

    Quote Originally Posted by brewbuck View Post

    Of course, looks like you discovered that it was a language problem.
    Not exactly! This was not the solution (sorry I made you misunderstand), but I managed to find a way to make it work. I'll explain in my next post.

  12. #12
    Registered User
    Join Date
    May 2012
    Location
    Brasília, Brazil
    Posts
    10

    Solved!

    I managed to make it work, but I don't know what I did right...
    (I think the trick is including the windows.h header) I used the ResEdit software on a random DLL I took from C:\Windows\. Using that one as example, I composed the following .rc file:
    Code:
    
    #include <windows.h>
    
    //
    // Version Information resources
    //
    // Further references:
    // http://msdn.microsoft.com/en-us/library/windows/desktop/aa381058(v=vs.85).aspx
    //
    //
    
    LANGUAGE LANG_PORTUGUESE, SUBLANG_PORTUGUESE_BRAZILIAN
    1 VERSIONINFO
        FILEVERSION     1,0,0,0
        PRODUCTVERSION  1,0,0,0
        FILEOS          VOS_NT_WINDOWS32
        FILETYPE        VFT_DLL
        FILESUBTYPE     0
        FILEFLAGSMASK   VS_FF_PRIVATEBUILD
        FILEFLAGS       0x00000000
    {
        BLOCK "StringFileInfo"
        {
            BLOCK "041604E4"
            {
                VALUE "Comments", "commmented"
                VALUE "CompanyName", "myCompanyName"
                
                //Required values:
                VALUE "FileDescription", "BlahBlahBlah"
                VALUE "FileVersion", "1.0.00"
                VALUE "ProductVersion", "1.0.00"
                VALUE "InternalName", "filename.dll"
                VALUE "LegalCopyright", "Copyright © 2012"
                VALUE "LegalTrademarks", "2012"
                VALUE "OriginalFilename", "filename_original.dll"
                VALUE "ProductName", "product"
                VALUE "PrivateBuild", "pb"
            }
        }
        BLOCK "VarFileInfo"
        {       
            /* The following line should only be modified for localized versions.     */
            /* It consists of any number of WORD,WORD pairs, with each pair           */
            /* describing a language,codepage combination supported by the file.      */
            /*                                                                        */
            /* For example, a file might have values "0x409,1252" indicating that it  */
            /* supports English language (0x409) in the Windows ANSI codepage (1252). */
            VALUE "Translation", 0x416, 1252
        }
    }
    Next, I used the windres(from the MinGW suite) command to build the .o object file:

    Code:
    windres ../Resources/resources.rc ../Resources/resource.o
    Then I compiled it:
    Code:
    g++ -L../../Libs -shared -o myDll.dll Sources\a.o Sources\b.o Sources\c.o Sources\d.o ..\Resources\resource.o -lmylib
    After that, the file information was filled at my O.S.

    See Ya!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how to run linux makefile in windows7??
    By huda in forum C++ Programming
    Replies: 1
    Last Post: 02-23-2012, 11:14 AM
  2. Replies: 5
    Last Post: 09-23-2011, 12:01 AM
  3. WindowsXP to Windows7
    By KIBO in forum Windows Programming
    Replies: 1
    Last Post: 06-09-2011, 05:52 AM
  4. Eclipse CDT, windows7 and new MinGW
    By marcoesteves in forum Windows Programming
    Replies: 0
    Last Post: 12-11-2010, 11:15 AM
  5. Replies: 1
    Last Post: 08-22-2009, 09:07 AM

Tags for this Thread