Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing GetFileVersionInfo*Ex* funcs #941

Closed
wants to merge 5 commits into from

Conversation

roblabla
Copy link

@roblabla roblabla commented Sep 7, 2020

Add a handful of missing functions from winver.h, namely GetFileVersionInfo(Size)?Ex(W|A), and the associated constant flags.

@retep998 retep998 added the waiting on review Waiting for a reviewer to review the PR label Sep 7, 2020
@roblabla roblabla force-pushed the missing-winver-funcs branch from 8bae7e2 to 56fe305 Compare September 7, 2020 14:57
@roblabla roblabla force-pushed the missing-winver-funcs branch from 166e32c to 6439019 Compare September 9, 2020 08:40
@nico-abram
Copy link

Relevant header code:

winver.h

DWORD APIENTRY GetFileVersionInfoSizeExA(_In_ DWORD dwFlags, _In_ LPCSTR lpwstrFilename, _Out_ LPDWORD lpdwHandle);
DWORD APIENTRY GetFileVersionInfoSizeExW(_In_ DWORD dwFlags, _In_ LPCWSTR lpwstrFilename, _Out_ LPDWORD lpdwHandle);

BOOL APIENTRY GetFileVersionInfoExA(_In_ DWORD dwFlags,
                                    _In_ LPCSTR lpwstrFilename,
                                    _Reserved_ DWORD dwHandle,
                                    _In_ DWORD dwLen,
                                    _Out_writes_bytes_(dwLen) LPVOID lpData);
BOOL APIENTRY GetFileVersionInfoExW(_In_ DWORD dwFlags,
                                    _In_ LPCWSTR lpwstrFilename,
                                    _Reserved_ DWORD dwHandle,
                                    _In_ DWORD dwLen,
                                    _Out_writes_bytes_(dwLen) LPVOID lpData);

verrsrc.h


/* 
    FILE_VER_GET_... flags are for use by 
    GetFileVersionInfoSizeEx
    GetFileVersionInfoExW
*/
#define FILE_VER_GET_LOCALISED  0x01
#define FILE_VER_GET_NEUTRAL    0x02
#define FILE_VER_GET_PREFETCHED 0x04

/* ----- Types and structures ----- */

typedef struct tagVS_FIXEDFILEINFO
{
    DWORD   dwSignature;            /* e.g. 0xfeef04bd */
    DWORD   dwStrucVersion;         /* e.g. 0x00000042 = "0.42" */
    DWORD   dwFileVersionMS;        /* e.g. 0x00030075 = "3.75" */
    DWORD   dwFileVersionLS;        /* e.g. 0x00000031 = "0.31" */
    DWORD   dwProductVersionMS;     /* e.g. 0x00030010 = "3.10" */
    DWORD   dwProductVersionLS;     /* e.g. 0x00000031 = "0.31" */
    DWORD   dwFileFlagsMask;        /* = 0x3F for version "0.42" */
    DWORD   dwFileFlags;            /* e.g. VFF_DEBUG | VFF_PRERELEASE */
    DWORD   dwFileOS;               /* e.g. VOS_DOS_WINDOWS16 */
    DWORD   dwFileType;             /* e.g. VFT_DRIVER */
    DWORD   dwFileSubtype;          /* e.g. VFT2_DRV_KEYBOARD */
    DWORD   dwFileDateMS;           /* e.g. 0 */
    DWORD   dwFileDateLS;           /* e.g. 0 */
} VS_FIXEDFILEINFO;

According to the contribution guidelines shouldn't the struct and consts go in a new verrsrc.rs file?

All definitions go into the source file that directly maps to the header the definition is from. 

Also, the parameter name for GetFileVersionInfoExA and GetFileVersionInfoExW lptstrFilename seems to not match the header (lpwstrFilename)
Same thing for GetFileVersionInfoSizeExA and GetFileVersionInfoSizeExW

Other than that, LGTM

@roblabla
Copy link
Author

Thanks for the review, will fix.

@roblabla
Copy link
Author

roblabla commented Nov 27, 2020

I took the opportunity to fix some other small mistakes in the winver.rs files (that were backward-compatible). I applied the requested changes, and further changed *mut c_void to LPVOID so it matches the header, and reordered some functions so they appear in the same order as the windows header files.

@nico-abram
Copy link

I think CI failed because of using use crate:: (I think it might not be supported by the MSRV of 1.6)

@roblabla roblabla force-pushed the missing-winver-funcs branch 2 times, most recently from 3c683dc to 40d0e56 Compare November 27, 2020 14:26
@roblabla roblabla force-pushed the missing-winver-funcs branch from 0402b19 to 5dedd8f Compare November 27, 2020 19:35
@roblabla
Copy link
Author

This is ready now.

Copy link

@nico-abram nico-abram left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@roblabla
Copy link
Author

#906 turns out there's an existing PR that's more complete than this one. This should be merged instead.

@roblabla roblabla closed this Nov 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting on review Waiting for a reviewer to review the PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants