From 16cfbae44e0dbdcf93c5a320d1a064b9fe6c188b Mon Sep 17 00:00:00 2001 From: Sorenon Date: Thu, 11 Jun 2020 16:13:05 +0100 Subject: [PATCH 1/6] Added missing FileVersionAPI functionality Added missing functions to winver.rs Reordered winver.rs to match the order of the original header Replaced explicit pointers in winver.rs with their concise winapi equivalents Created versrc.rs and populated it with its constants and a struct type --- Cargo.toml | 1 + build.rs | 1 + src/um/mod.rs | 1 + src/um/versrc.rs | 105 +++++++++++++++++++++++++++++++++++++++++++++++ src/um/winver.rs | 95 ++++++++++++++++++++++++++++++++++-------- 5 files changed, 187 insertions(+), 16 deletions(-) create mode 100644 src/um/versrc.rs diff --git a/Cargo.toml b/Cargo.toml index e6fa54607..ebc470605 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -364,6 +364,7 @@ userenv = [] usp10 = [] utilapiset = [] uxtheme = [] +versrc = [] vsbackup = [] vss = [] vsserror = [] diff --git a/build.rs b/build.rs index ce691ded8..d8431aebd 100644 --- a/build.rs +++ b/build.rs @@ -344,6 +344,7 @@ const DATA: &'static [(&'static str, &'static [&'static str], &'static [&'static ("usp10", &["minwindef", "ntdef", "windef", "winerror", "wingdi", "winnt"], &["usp10"]), ("utilapiset", &["minwindef", "ntdef"], &["kernel32"]), ("uxtheme", &["commctrl", "minwindef", "windef", "wingdi", "winnt"], &["uxtheme"]), + ("versrc", &["minwindef", "winnt", "winuser"], &[]), ("vsbackup", &["guiddef", "minwindef", "unknwnbase", "vss", "vswriter", "winnt", "wtypes"], &["vssapi"]), ("vss", &["guiddef", "minwindef", "unknwnbase", "winnt"], &[]), ("vsserror", &["winnt"], &[]), diff --git a/src/um/mod.rs b/src/um/mod.rs index b7f0bca4e..601095f6a 100644 --- a/src/um/mod.rs +++ b/src/um/mod.rs @@ -249,6 +249,7 @@ pub mod gl; #[cfg(feature = "usp10")] pub mod usp10; #[cfg(feature = "utilapiset")] pub mod utilapiset; #[cfg(feature = "uxtheme")] pub mod uxtheme; +#[cfg(feature = "versrc")] pub mod versrc; #[cfg(feature = "vsbackup")] pub mod vsbackup; #[cfg(feature = "vss")] pub mod vss; #[cfg(feature = "vsserror")] pub mod vsserror; diff --git a/src/um/versrc.rs b/src/um/versrc.rs new file mode 100644 index 000000000..528310328 --- /dev/null +++ b/src/um/versrc.rs @@ -0,0 +1,105 @@ +// Licensed under the Apache License, Version 2.0 +// or the MIT license +// , at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms +//! Version Resource definitions +use shared::minwindef::DWORD; +use um::winnt::LPWSTR; +use um::winuser::RT_VERSION; +pub const VS_FILE_INFO: LPWSTR = RT_VERSION; +pub const VS_VERSION_INFO: DWORD = 1; +pub const VS_USER_DEFINED: DWORD = 100; +pub const VS_FFI_SIGNATURE: DWORD = 0xBD04EFFE; +pub const VS_FFI_STRUCVERSION: DWORD = 0x00010000; +pub const VS_FFI_FILEFLAGSMASK: DWORD = 0x0000003F; +pub const VS_FF_DEBUG: DWORD = 0x00000001; +pub const VS_FF_PRERELEASE: DWORD = 0x00000002; +pub const VS_FF_PATCHED: DWORD = 0x00000004; +pub const VS_FF_PRIVATEBUILD: DWORD = 0x00000008; +pub const VS_FF_INFOINFERRED: DWORD = 0x00000010; +pub const VS_FF_SPECIALBUILD: DWORD = 0x00000020; +pub const VOS_UNKNOWN: DWORD = 0x00000000; +pub const VOS_DOS: DWORD = 0x00010000; +pub const VOS_OS216: DWORD = 0x00020000; +pub const VOS_OS232: DWORD = 0x00030000; +pub const VOS_NT: DWORD = 0x00040000; +pub const VOS_WINCE: DWORD = 0x00050000; +pub const VOS__BASE: DWORD = 0x00000000; +pub const VOS__WINDOWS16: DWORD = 0x00000001; +pub const VOS__PM16: DWORD = 0x00000002; +pub const VOS__PM32: DWORD = 0x00000003; +pub const VOS__WINDOWS32: DWORD = 0x00000004; +pub const VOS_DOS_WINDOWS16: DWORD = 0x00010001; +pub const VOS_DOS_WINDOWS32: DWORD = 0x00010004; +pub const VOS_OS216_PM16: DWORD = 0x00020002; +pub const VOS_OS232_PM32: DWORD = 0x00030003; +pub const VOS_NT_WINDOWS32: DWORD = 0x00040004; +pub const VFT_UNKNOWN: DWORD = 0x00000000; +pub const VFT_APP: DWORD = 0x00000001; +pub const VFT_DLL: DWORD = 0x00000002; +pub const VFT_DRV: DWORD = 0x00000003; +pub const VFT_FONT: DWORD = 0x00000004; +pub const VFT_VXD: DWORD = 0x00000005; +pub const VFT_STATIC_LIB: DWORD = 0x00000007; +pub const VFT2_UNKNOWN: DWORD = 0x00000000; +pub const VFT2_DRV_PRINTER: DWORD = 0x00000001; +pub const VFT2_DRV_KEYBOARD: DWORD = 0x00000002; +pub const VFT2_DRV_LANGUAGE: DWORD = 0x00000003; +pub const VFT2_DRV_DISPLAY: DWORD = 0x00000004; +pub const VFT2_DRV_MOUSE: DWORD = 0x00000005; +pub const VFT2_DRV_NETWORK: DWORD = 0x00000006; +pub const VFT2_DRV_SYSTEM: DWORD = 0x00000007; +pub const VFT2_DRV_INSTALLABLE: DWORD = 0x00000008; +pub const VFT2_DRV_SOUND: DWORD = 0x00000009; +pub const VFT2_DRV_COMM: DWORD = 0x0000000A; +pub const VFT2_DRV_INPUTMETHOD: DWORD = 0x0000000B; +pub const VFT2_DRV_VERSIONED_PRINTER: DWORD = 0x0000000C; +pub const VFT2_FONT_RASTER: DWORD = 0x00000001; +pub const VFT2_FONT_VECTOR: DWORD = 0x00000002; +pub const VFT2_FONT_TRUETYPE: DWORD = 0x00000003; +pub const VFFF_ISSHAREDFILE: DWORD = 0x0001; +pub const VFF_CURNEDEST: DWORD = 0x0001; +pub const VFF_FILEINUSE: DWORD = 0x0002; +pub const VFF_BUFFTOOSMALL: DWORD = 0x0004; +pub const VIFF_FORCEINSTALL: DWORD = 0x0001; +pub const VIFF_DONTDELETEOLD: DWORD = 0x0002; +pub const VIF_TEMPFILE: DWORD = 0x00000001; +pub const VIF_MISMATCH: DWORD = 0x00000002; +pub const VIF_SRCOLD: DWORD = 0x00000004; +pub const VIF_DIFFLANG: DWORD = 0x00000008; +pub const VIF_DIFFCODEPG: DWORD = 0x00000010; +pub const VIF_DIFFTYPE: DWORD = 0x00000020; +pub const VIF_WRITEPROT: DWORD = 0x00000040; +pub const VIF_FILEINUSE: DWORD = 0x00000080; +pub const VIF_OUTOFSPACE: DWORD = 0x00000100; +pub const VIF_ACCESSVIOLATION: DWORD = 0x00000200; +pub const VIF_SHARINGVIOLATION: DWORD = 0x00000400; +pub const VIF_CANNOTCREATE: DWORD = 0x00000800; +pub const VIF_CANNOTDELETE: DWORD = 0x00001000; +pub const VIF_CANNOTRENAME: DWORD = 0x00002000; +pub const VIF_CANNOTDELETECUR: DWORD = 0x00004000; +pub const VIF_OUTOFMEMORY: DWORD = 0x00008000; +pub const VIF_CANNOTREADSRC: DWORD = 0x00010000; +pub const VIF_CANNOTREADDST: DWORD = 0x00020000; +pub const VIF_BUFFTOOSMALL: DWORD = 0x00040000; +pub const VIF_CANNOTLOADLZ32: DWORD = 0x00080000; +pub const VIF_CANNOTLOADCABINET: DWORD = 0x00100000; +pub const FILE_VER_GET_LOCALISED: DWORD = 0x01; +pub const FILE_VER_GET_NEUTRAL: DWORD = 0x02; +pub const FILE_VER_GET_PREFETCHED: DWORD = 0x04; +STRUCT!{struct VS_FIXEDFILEINFO{ + dwSignature: DWORD, + dwStrucVersion: DWORD, + dwFileVersionMS: DWORD, + dwFileVersionLS: DWORD, + dwProductVersionMS: DWORD, + dwProductVersionLS: DWORD, + dwFileFlagsMask: DWORD, + dwFileFlags: DWORD, + dwFileOS: DWORD, + dwFileType: DWORD, + dwFileSubtype: DWORD, + dwFileDateMS: DWORD, + dwFileDateLS: DWORD, +}} diff --git a/src/um/winver.rs b/src/um/winver.rs index 5d25c678f..a169b8509 100644 --- a/src/um/winver.rs +++ b/src/um/winver.rs @@ -4,41 +4,92 @@ // All files in the project carrying such notice may not be copied, modified, or distributed // except according to those terms //! Version management functions, types, and definitions -use ctypes::c_void; -use shared::minwindef::{BOOL, DWORD, LPCVOID, LPVOID, PUINT}; +use shared::minwindef::{BOOL, DWORD, LPCVOID, LPDWORD, LPVOID, PUINT}; use um::winnt::{LPCSTR, LPCWSTR, LPSTR, LPWSTR}; extern "system" { + pub fn VerFindFileA( + uFlags: DWORD, + szFileName: LPCSTR, + szWinDir: LPCSTR, + szAppDir: LPCSTR, + szCurDir: LPSTR, + puCurDirLen: PUINT, + szDestDir: LPSTR, + puDestDirLen: PUINT, + ) -> DWORD; + pub fn VerFindFileW( + uFlags: DWORD, + szFileName: LPCWSTR, + szWinDir: LPCWSTR, + szAppDir: LPCWSTR, + szCurDir: LPWSTR, + puCurDirLen: PUINT, + szDestDir: LPWSTR, + puDestDirLen: PUINT, + ) -> DWORD; + pub fn VerInstallFileA( + uFlags: DWORD, + szSrcFileName: LPCSTR, + szDestFileName: LPCSTR, + szSrcDir: LPCSTR, + szDestDir: LPCSTR, + szCurDir: LPCSTR, + szTmpFile: LPSTR, + puTmpFileLen: PUINT, + ) -> DWORD; + pub fn VerInstallFileW( + uFlags: DWORD, + szSrcFileName: LPCWSTR, + szDestFileName: LPCWSTR, + szSrcDir: LPCWSTR, + szDestDir: LPCWSTR, + szCurDir: LPCWSTR, + szTmpFile: LPWSTR, + puTmpFileLen: PUINT, + ) -> DWORD; pub fn GetFileVersionInfoSizeA( lptstrFilename: LPCSTR, - lpdwHandle: *mut DWORD, + lpdwHandle: LPDWORD, ) -> DWORD; pub fn GetFileVersionInfoSizeW( lptstrFilename: LPCWSTR, - lpdwHandle: *mut DWORD, + lpdwHandle: LPDWORD, ) -> DWORD; pub fn GetFileVersionInfoA( lptstrFilename: LPCSTR, dwHandle: DWORD, dwLen: DWORD, - lpData: *mut c_void, + lpData: LPVOID, ) -> BOOL; pub fn GetFileVersionInfoW( lptstrFilename: LPCWSTR, dwHandle: DWORD, dwLen: DWORD, - lpData: *mut c_void, + lpData: LPVOID, ) -> BOOL; - pub fn VerQueryValueA( - pBlock: LPCVOID, - lpSubBlock: LPCSTR, - lplpBuffer: &mut LPVOID, - puLen: PUINT, + pub fn GetFileVersionInfoSizeExA( + dwFlags: DWORD, + lpwstrFilename: LPCSTR, + lpdwHandle: LPDWORD, + ) -> DWORD; + pub fn GetFileVersionInfoSizeExW( + dwFlags: DWORD, + lpwstrFilename: LPCWSTR, + lpdwHandle: LPDWORD, + ) -> DWORD; + pub fn GetFileVersionInfoExA( + dwFlags: DWORD, + lpwstrFilename: LPCSTR, + dwHandle: DWORD, + dwLen: DWORD, + lpData: LPVOID, ) -> BOOL; - pub fn VerQueryValueW( - pBlock: LPCVOID, - lpSubBlock: LPCWSTR, - lplpBuffer: &mut LPVOID, - puLen: PUINT, + pub fn GetFileVersionInfoExW( + dwFlags: DWORD, + lpwstrFilename: LPCWSTR, + dwHandle: DWORD, + dwLen: DWORD, + lpData: LPVOID, ) -> BOOL; pub fn VerLanguageNameA( wLang: DWORD, @@ -50,4 +101,16 @@ extern "system" { szLang: LPWSTR, cchLang: DWORD, ) -> DWORD; + pub fn VerQueryValueA( + pBlock: LPCVOID, + lpSubBlock: LPCSTR, + lplpBuffer: &mut LPVOID, + puLen: PUINT, + ) -> BOOL; + pub fn VerQueryValueW( + pBlock: LPCVOID, + lpSubBlock: LPCWSTR, + lplpBuffer: &mut LPVOID, + puLen: PUINT, + ) -> BOOL; } From 2ccfa39ae0f6ca7b168ecdec12d6ebaf47262aed Mon Sep 17 00:00:00 2001 From: Bullch Date: Wed, 2 Dec 2020 13:13:05 +0000 Subject: [PATCH 2/6] Update Cargo.toml Co-authored-by: Robin Lambertz --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index ebc470605..0e0444ad3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -364,7 +364,7 @@ userenv = [] usp10 = [] utilapiset = [] uxtheme = [] -versrc = [] +verrsrc = [] vsbackup = [] vss = [] vsserror = [] From 7b5639b235e60c5996b4da6805bf17bcfd30dca5 Mon Sep 17 00:00:00 2001 From: Bullch Date: Wed, 2 Dec 2020 13:13:14 +0000 Subject: [PATCH 3/6] Update build.rs Co-authored-by: Robin Lambertz --- build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.rs b/build.rs index d8431aebd..0ec41490c 100644 --- a/build.rs +++ b/build.rs @@ -344,7 +344,7 @@ const DATA: &'static [(&'static str, &'static [&'static str], &'static [&'static ("usp10", &["minwindef", "ntdef", "windef", "winerror", "wingdi", "winnt"], &["usp10"]), ("utilapiset", &["minwindef", "ntdef"], &["kernel32"]), ("uxtheme", &["commctrl", "minwindef", "windef", "wingdi", "winnt"], &["uxtheme"]), - ("versrc", &["minwindef", "winnt", "winuser"], &[]), + ("verrsrc", &["minwindef", "winnt", "winuser"], &[]), ("vsbackup", &["guiddef", "minwindef", "unknwnbase", "vss", "vswriter", "winnt", "wtypes"], &["vssapi"]), ("vss", &["guiddef", "minwindef", "unknwnbase", "winnt"], &[]), ("vsserror", &["winnt"], &[]), From df733b35a184adc69fc51d8da9959b8a78d4d415 Mon Sep 17 00:00:00 2001 From: Bullch Date: Wed, 2 Dec 2020 13:13:21 +0000 Subject: [PATCH 4/6] Update src/um/mod.rs Co-authored-by: Robin Lambertz --- src/um/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/um/mod.rs b/src/um/mod.rs index 601095f6a..3d40a6e2c 100644 --- a/src/um/mod.rs +++ b/src/um/mod.rs @@ -249,7 +249,7 @@ pub mod gl; #[cfg(feature = "usp10")] pub mod usp10; #[cfg(feature = "utilapiset")] pub mod utilapiset; #[cfg(feature = "uxtheme")] pub mod uxtheme; -#[cfg(feature = "versrc")] pub mod versrc; +#[cfg(feature = "verrsrc")] pub mod verrsrc; #[cfg(feature = "vsbackup")] pub mod vsbackup; #[cfg(feature = "vss")] pub mod vss; #[cfg(feature = "vsserror")] pub mod vsserror; From 5328c18a9d80a5f1d1b3b47d19a12a3797a9e2c9 Mon Sep 17 00:00:00 2001 From: Bullch Date: Wed, 2 Dec 2020 13:13:52 +0000 Subject: [PATCH 5/6] Update src/um/versrc.rs Co-authored-by: Robin Lambertz --- src/um/versrc.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/um/versrc.rs b/src/um/versrc.rs index 528310328..77237ce58 100644 --- a/src/um/versrc.rs +++ b/src/um/versrc.rs @@ -10,7 +10,7 @@ use um::winuser::RT_VERSION; pub const VS_FILE_INFO: LPWSTR = RT_VERSION; pub const VS_VERSION_INFO: DWORD = 1; pub const VS_USER_DEFINED: DWORD = 100; -pub const VS_FFI_SIGNATURE: DWORD = 0xBD04EFFE; +pub const VS_FFI_SIGNATURE: DWORD = 0xFEEF04BD; pub const VS_FFI_STRUCVERSION: DWORD = 0x00010000; pub const VS_FFI_FILEFLAGSMASK: DWORD = 0x0000003F; pub const VS_FF_DEBUG: DWORD = 0x00000001; From 37999a34fe1a1316289d9cd86074ebac7b08c3c7 Mon Sep 17 00:00:00 2001 From: Bullch Date: Wed, 2 Dec 2020 13:18:36 +0000 Subject: [PATCH 6/6] Rename versrc.rs to verrsrc.rs --- src/um/{versrc.rs => verrsrc.rs} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/um/{versrc.rs => verrsrc.rs} (100%) diff --git a/src/um/versrc.rs b/src/um/verrsrc.rs similarity index 100% rename from src/um/versrc.rs rename to src/um/verrsrc.rs