From 33a72acac71a5ed2c68a3ddbb9df592acd8e9ed1 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Sat, 18 Jun 2016 10:51:12 +0200 Subject: [PATCH] MsiUseFeature utility added (closes #3) --- CredWrite/StdAfx.h | 15 --- Makefile | Bin 27244 -> 27968 bytes MsiUseFeature/.gitignore | 2 + MsiUseFeature/Main.cpp | 69 +++++++++++++ MsiUseFeature/MsiUseFeature.props | 14 +++ MsiUseFeature/MsiUseFeature.rc | Bin 0 -> 4876 bytes MsiUseFeature/MsiUseFeature.vcxproj | 106 ++++++++++++++++++++ MsiUseFeature/MsiUseFeature.vcxproj.filters | 38 +++++++ MsiUseFeature/README.md | 17 ++++ MsiUseFeature/StdAfx.cpp | 21 ++++ MsiUseFeature/StdAfx.h | 32 ++++++ VS10Solution.sln | 11 ++ 12 files changed, 310 insertions(+), 15 deletions(-) create mode 100644 MsiUseFeature/.gitignore create mode 100644 MsiUseFeature/Main.cpp create mode 100644 MsiUseFeature/MsiUseFeature.props create mode 100644 MsiUseFeature/MsiUseFeature.rc create mode 100644 MsiUseFeature/MsiUseFeature.vcxproj create mode 100644 MsiUseFeature/MsiUseFeature.vcxproj.filters create mode 100644 MsiUseFeature/README.md create mode 100644 MsiUseFeature/StdAfx.cpp create mode 100644 MsiUseFeature/StdAfx.h diff --git a/CredWrite/StdAfx.h b/CredWrite/StdAfx.h index 33ee145..3103120 100644 --- a/CredWrite/StdAfx.h +++ b/CredWrite/StdAfx.h @@ -32,18 +32,3 @@ #include #include - -//#include "../include/Version.h" -// -//#include "../EAPMethods/include/EAP.h" -//#include "../EAPMethods/include/PAP.h" -// -//#include -//#include -//#include -//#include -// -//#include -//#include -// -//#include diff --git a/Makefile b/Makefile index e05b4ae28eb5a6d5af845d40d51a993fd08a7baa..e7242da8b2795bc21f9dc44fdb9faa28b6dc0130 100644 GIT binary patch delta 251 zcmaEJh4H{G#tlBMlXWyXCjWEM68B{&X2@g+1(K-@Za|#KP{L5kP&An_UUajMD-+-3 zf*=E&iq;4D;*#6U9o)`}OA=_h@#F^)N|R+`JvKjx_`!%z;pPKTVN7@wSWnK0727Nm NtAkU~X2$qzZU75zK+ymI delta 79 zcmX?bi}B4B#tlBMn^(Cq@ok49uP6tm$$r*slf9xsCO?P~nw(<<#8GOS bC&bQT1gQW@cx=8E|AY~$%42g@(lsss5T76L diff --git a/MsiUseFeature/.gitignore b/MsiUseFeature/.gitignore new file mode 100644 index 0000000..9c8716a --- /dev/null +++ b/MsiUseFeature/.gitignore @@ -0,0 +1,2 @@ +/temp +/*.user diff --git a/MsiUseFeature/Main.cpp b/MsiUseFeature/Main.cpp new file mode 100644 index 0000000..e8c8f4b --- /dev/null +++ b/MsiUseFeature/Main.cpp @@ -0,0 +1,69 @@ +/* + Copyright 2015-2016 Amebis + Copyright 2016 GÉANT + + This file is part of GÉANTLink. + + GÉANTLink is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + GÉANTLink is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GÉANTLink. If not, see . +*/ + +#include "StdAfx.h" + +#pragma comment(lib, "Msi.lib") + +using namespace std; +using namespace winstd; + + +static int MsiUseFeature() +{ + int nArgs; + unique_ptr > pwcArglist(CommandLineToArgvW(GetCommandLineW(), &nArgs)); + if (pwcArglist == NULL) { + OutputDebugStr(_T("CommandLineToArgvW failed (error %u).\n"), GetLastError()); + return 1; + } + + if (nArgs < 2) { + OutputDebugStr(_T("Not enough parameters.\n")); + return -1; + } + + // Query the feature state. + if (MsiQueryFeatureStateW(_L(PRODUCT_VERSION_GUID), pwcArglist[1]) == INSTALLSTATE_UNKNOWN) { + OutputDebugStr(_T("The product is not installed or feature state is unknown.\n")); + return 1; + } + + // Perform the Microsoft Installer's feature completeness check. + if (MsiUseFeatureW(_L(PRODUCT_VERSION_GUID), pwcArglist[1]) != INSTALLSTATE_LOCAL) { + OutputDebugStr(_T("The feature is not installed locally.\n")); + return 2; + } + + return 0; +} + + +int CALLBACK WinMain(_In_ HINSTANCE hInstance, _In_ HINSTANCE hPrevInstance, _In_ LPSTR lpCmdLine, _In_ int nCmdShow) +{ + UNREFERENCED_PARAMETER(hInstance); + UNREFERENCED_PARAMETER(hPrevInstance); + UNREFERENCED_PARAMETER(lpCmdLine); + UNREFERENCED_PARAMETER(nCmdShow); + + int res = MsiUseFeature(); + assert(!_CrtDumpMemoryLeaks()); + return res; +} diff --git a/MsiUseFeature/MsiUseFeature.props b/MsiUseFeature/MsiUseFeature.props new file mode 100644 index 0000000..2b4b508 --- /dev/null +++ b/MsiUseFeature/MsiUseFeature.props @@ -0,0 +1,14 @@ + + + + + + ..\output\$(Platform).$(Configuration)\ + + + + ..\lib\WinStd\include;%(AdditionalIncludeDirectories) + + + + \ No newline at end of file diff --git a/MsiUseFeature/MsiUseFeature.rc b/MsiUseFeature/MsiUseFeature.rc new file mode 100644 index 0000000000000000000000000000000000000000..591492944da751384f35556e683b114e10bea465 GIT binary patch literal 4876 zcmdUy>uwuG6vxkJB;H|hrK+vKaZ9NLL`b>VPN-u?Stli*tX%BGs=Kjlhf=98#G~+1 z!0&&?)7_01(uRHrTG_KZb1wgLoteM>T(c+krF~(^^4YR0o7y{@+1M`Z(iY4=vxYsj z@9dl9+Y9D4?2QfW6sq}0@{6l&f56$bzVj6I_R%F-iH#U1$WE5uQ#%2Ta9pugl+l4A zv)5K%k(TR;G*Q|JSwojTcX+*;81G3*Scg=XlT*fHcbH}l8kDRi)SYi_*QJvcw zTrJag@|L#JF|tt^zR8GN!kSQl5?cxq5KT-lZ~N=cBvifA5zT>cFHmsDk8)cKfid0JkbIAxXQPsxI+n957aCq*Sh z=h9JxI9)CgDyj)Nqa0N{PO(10OY;ASapE2dc~Z3SmF<%CJJutreK=GF$BeIdJKzab zacn;_C+Wf>;!J(4}zIp-XrR85R6kL~*yQ9xc(SzLc#A zHV^U4iAP~xQUAy8yM(9&FHYP`ilMSK)V1nn?BDX>3BNPA)cbDc?_E$Atybl#b}o<{ zV_V(F61=M(mqEYqOj2G6@j8|)c&7BJHJ-Qr)RCEyC3Wa$ysvpq zN>R(c`}st43AwI#ssfc`i9MnYGQQN&l}{;e>S;sP)xVUt+HtOVQ+&d%8GWOef8~+T z?x%i#j>HY>?-v_TU#drS4pnfInQiK?<8t5Idw3PYD$c%FX&a8F?PT@en(g};9p%c#Tz|5 zHel>}PZW1?CC-a8o}|=EJ5ZG=)iDo{wvFGm=%%YW_K3yLc>Z=eX}z6J*>m&}bekX& z;%&D-T2V&v|F$JYq~+P%Ca&^zYA=adh9G~J>PIzL zrrIF3+HIRit6D$6*GFjYLy>!al`D(wo{-~rm2gMmbIUha98DFZgm-JZf%e` zq^oJyxlKlcKHmUST5l`s|=`tBAoKo*<0A6TgWcmSm%$h>&2?5mX@y;r8ew2 ze)^u@b54tm8?!0nJItNzCAo3eyo#C z{MXz|=h43P+PP9}zFM9($E=mDjws?-MiV`@4Td>;oNkc$89t)g@|{roRfe~vL#OCn zw?k(bop*OwoxrP;$6XMV&n!W6xsR=O-IUxqC}mZ&GLB_yJD|I8^s6`K+}72*^zYag z?$a;0PuKXmi7f9119HDf91p0LfKO2`-@Oxi$V`6U{S<%oJVqBpA#+P&1oc(Sq&?y} zChOD{TKsgb(K%*FE)D4d%DG}yMUTa??74k7bx*z~M;3H|qOP01=wiKYF46wGYWchw zp|ezZmt37Gca|fpoc*VsQubjVX{!1;b&}uBL*A+Dg^r^Nf9l!RD8(m7o4?7k4~S&! R;xTqQJAJOx?)^R;{tc}+qT2uf literal 0 HcmV?d00001 diff --git a/MsiUseFeature/MsiUseFeature.vcxproj b/MsiUseFeature/MsiUseFeature.vcxproj new file mode 100644 index 0000000..abbe006 --- /dev/null +++ b/MsiUseFeature/MsiUseFeature.vcxproj @@ -0,0 +1,106 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {679D03C5-CD70-4FFA-93F8-A4AB3637509B} + Win32Proj + MsiUseFeature + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Create + Create + Create + Create + + + + + + + + + + + + \ No newline at end of file diff --git a/MsiUseFeature/MsiUseFeature.vcxproj.filters b/MsiUseFeature/MsiUseFeature.vcxproj.filters new file mode 100644 index 0000000..8cb3a4c --- /dev/null +++ b/MsiUseFeature/MsiUseFeature.vcxproj.filters @@ -0,0 +1,38 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Header Files + + + + + Source Files + + + Source Files + + + + + + + + Resource Files + + + \ No newline at end of file diff --git a/MsiUseFeature/README.md b/MsiUseFeature/README.md new file mode 100644 index 0000000..33bfbe1 --- /dev/null +++ b/MsiUseFeature/README.md @@ -0,0 +1,17 @@ +#MsiUseFeature +Checks the installation state of the given feature of GÉANTLink product + +##Usage +``` +MsiUseFeature +``` + +- `feature name` - The name of the feature to check (i.e. "featEAPTTLS"; see Feature table of product MSI file) + +Note: The MSI product code changes on every release. Therefore, `MsiUseFeature` utility with identical version should be used. + +Return codes: +- -1 = Invalid parameters +- 0 = Success +- 1 = The product is not installed or feature state is unknown +- 2 = The feature is not installed locally diff --git a/MsiUseFeature/StdAfx.cpp b/MsiUseFeature/StdAfx.cpp new file mode 100644 index 0000000..4af5ec1 --- /dev/null +++ b/MsiUseFeature/StdAfx.cpp @@ -0,0 +1,21 @@ +/* + Copyright 2015-2016 Amebis + Copyright 2016 GÉANT + + This file is part of GÉANTLink. + + GÉANTLink is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + GÉANTLink is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GÉANTLink. If not, see . +*/ + +#include "StdAfx.h" diff --git a/MsiUseFeature/StdAfx.h b/MsiUseFeature/StdAfx.h new file mode 100644 index 0000000..1f4453d --- /dev/null +++ b/MsiUseFeature/StdAfx.h @@ -0,0 +1,32 @@ +/* + Copyright 2015-2016 Amebis + Copyright 2016 GÉANT + + This file is part of GÉANTLink. + + GÉANTLink is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + GÉANTLink is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GÉANTLink. If not, see . +*/ + +#pragma once + +#include "../include/Version.h" + +#include +#include + +#include +#include +#include + +#include diff --git a/VS10Solution.sln b/VS10Solution.sln index 990d55b..98b95b5 100644 --- a/VS10Solution.sln +++ b/VS10Solution.sln @@ -38,6 +38,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TLS_UI", "lib\TLS_UI\build\ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TTLS_UI", "lib\TTLS_UI\build\TTLS_UI.vcxproj", "{42F0F0F4-C928-4860-A4E4-94991C2C3D90}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MsiUseFeature", "MsiUseFeature\MsiUseFeature.vcxproj", "{679D03C5-CD70-4FFA-93F8-A4AB3637509B}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -150,6 +152,14 @@ Global {42F0F0F4-C928-4860-A4E4-94991C2C3D90}.Release|Win32.Build.0 = Release|Win32 {42F0F0F4-C928-4860-A4E4-94991C2C3D90}.Release|x64.ActiveCfg = Release|x64 {42F0F0F4-C928-4860-A4E4-94991C2C3D90}.Release|x64.Build.0 = Release|x64 + {679D03C5-CD70-4FFA-93F8-A4AB3637509B}.Debug|Win32.ActiveCfg = Debug|Win32 + {679D03C5-CD70-4FFA-93F8-A4AB3637509B}.Debug|Win32.Build.0 = Debug|Win32 + {679D03C5-CD70-4FFA-93F8-A4AB3637509B}.Debug|x64.ActiveCfg = Debug|x64 + {679D03C5-CD70-4FFA-93F8-A4AB3637509B}.Debug|x64.Build.0 = Debug|x64 + {679D03C5-CD70-4FFA-93F8-A4AB3637509B}.Release|Win32.ActiveCfg = Release|Win32 + {679D03C5-CD70-4FFA-93F8-A4AB3637509B}.Release|Win32.Build.0 = Release|Win32 + {679D03C5-CD70-4FFA-93F8-A4AB3637509B}.Release|x64.ActiveCfg = Release|x64 + {679D03C5-CD70-4FFA-93F8-A4AB3637509B}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -168,5 +178,6 @@ Global {9A25C261-8ADE-4938-8393-E857EF0E37E9} = {E66A3FE1-4EE4-401F-8EAD-BE518B230393} {42F0F0F4-C928-4860-A4E4-94991C2C3D90} = {E66A3FE1-4EE4-401F-8EAD-BE518B230393} {2D3CE079-7EB1-4F47-B79E-F0310671ECCB} = {7B5EC9B7-208C-426A-941D-DAF9271BD4A4} + {679D03C5-CD70-4FFA-93F8-A4AB3637509B} = {7B5EC9B7-208C-426A-941D-DAF9271BD4A4} EndGlobalSection EndGlobal