From e055207ceafdaef89c45095abc45412f7923acae Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Tue, 24 May 2016 10:31:53 +0200 Subject: [PATCH] Installer bootstrap utility introduced --- ZRColaInstall/ZRColaInstall.props | 21 ++++ ZRColaInstall/ZRColaInstall.rc | Bin 0 -> 2936 bytes ZRColaInstall/ZRColaInstallSl.vcxproj | 74 +++++++++++++ ZRColaInstall/ZRColaInstallSl.vcxproj.filters | 35 +++++++ ZRColaInstall/main.cpp | 97 ++++++++++++++++++ ZRColaInstall/stdafx.cpp | 20 ++++ ZRColaInstall/stdafx.h | 22 ++++ ZRColaUtils.sln | 11 ++ 8 files changed, 280 insertions(+) create mode 100644 ZRColaInstall/ZRColaInstall.props create mode 100644 ZRColaInstall/ZRColaInstall.rc create mode 100644 ZRColaInstall/ZRColaInstallSl.vcxproj create mode 100644 ZRColaInstall/ZRColaInstallSl.vcxproj.filters create mode 100644 ZRColaInstall/main.cpp create mode 100644 ZRColaInstall/stdafx.cpp create mode 100644 ZRColaInstall/stdafx.h diff --git a/ZRColaInstall/ZRColaInstall.props b/ZRColaInstall/ZRColaInstall.props new file mode 100644 index 0000000..984f794 --- /dev/null +++ b/ZRColaInstall/ZRColaInstall.props @@ -0,0 +1,21 @@ + + + + + + ..\output\$(Platform).$(Configuration)\ + false + + + + false + false + Default + false + + + true + + + + \ No newline at end of file diff --git a/ZRColaInstall/ZRColaInstall.rc b/ZRColaInstall/ZRColaInstall.rc new file mode 100644 index 0000000000000000000000000000000000000000..807a993edb7e5e27b5a32ced6d2d386f06451cc5 GIT binary patch literal 2936 zcmd6pTaVH}6vxlAiQl2(%Wk48i|d1lF=4q$7Aa`~FEJskT$YHGP*&0Sh5VB0?@Srm zE=2?Jfi%6$%>Uf}=ggV@{`F8MGLw%om0KCeP#nq08P^A{^oq`Wmj&1WbRWzO*!yzN z+}nCyfEmdOiJ^oB{c?xLEL{#CK21(%@3PKe(Ko zl5KQ&QbVF5P2^9F)dsUoW;?uVtT^b3W+GgTaUF}VIdeAQvU$+*t5%C~c8#m=j=v%adJ8_1`1I8uPs{N_$dw6Nup z+YVW7?;&R`RZW&^`1_iC`f_Fb)HteKS~V3i*&*jzHyT5{rnWWKit$;cwJx?%MLa7} z85Oi;t$Re>#d;fr+ENa(kiN7)lvpo^;N_Lb4Prk#}ENw&75PDd0+8|fUfTSIdG zFCBUMS010N)C^D5pDZ~Sp46(od(=jo=Nn>b60^&fFHgyLmSkJr83t6kYUGNHTbbBs z2gVXf4=-V{W-KPH=zeu!S1TZg7fZU1cJ?v0Ch#ysVn$5Cx|`dY&DIvLCbj0}0-m08 zU&uAj=v=T^`~JH|i_(f|P%T<>Is6Xfv&`wAGx-LWeMUp(wHxI?>gbv{LNhbq^l*@{ zPeolB8STfP48|wsK=iE9x&97cv%Rs5m5~nV-OA(~Mx(xAy?W2yQNQ(+bPT(pIRU1I z?ZrVB(;doMDiG;vFMSO>ALG~5csPesjbY5WwM0+Es`{Q@apWhF6v*tkJOiiPKQ`|u zR+o$wsrPvA_NeI!a~`ukHSMLU*|KZj>72W3pR`KVQ_H%JlG#u4tTi07d`6Tj?(90u zw%WpK!2Z4^ugk4UOWHbI>;75Pv$~w(ZhI!Z!@IDw*l>2p-cDzujW*qVp{eI|t!wv* fcD`25xv7x+4sT<>?{-t05B+2KUw>1_{rB+)1QTyD literal 0 HcmV?d00001 diff --git a/ZRColaInstall/ZRColaInstallSl.vcxproj b/ZRColaInstall/ZRColaInstallSl.vcxproj new file mode 100644 index 0000000..aa60eca --- /dev/null +++ b/ZRColaInstall/ZRColaInstallSl.vcxproj @@ -0,0 +1,74 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {0C2C89C2-C96B-41B6-AA99-7E7741E20F3A} + Win32Proj + ZRColaInstall + + + + Application + true + Unicode + + + Application + false + true + Unicode + + + + + + + + + + + + + + + + + + + + ZRCOLA_INSTALL_LANG="Sl";%(PreprocessorDefinitions) + MultiThreadedDebug + + + + + ZRCOLA_INSTALL_LANG="Sl";%(PreprocessorDefinitions) + MultiThreaded + + + + + + Create + Create + + + + + + + + + + + + \ No newline at end of file diff --git a/ZRColaInstall/ZRColaInstallSl.vcxproj.filters b/ZRColaInstall/ZRColaInstallSl.vcxproj.filters new file mode 100644 index 0000000..cd37c3b --- /dev/null +++ b/ZRColaInstall/ZRColaInstallSl.vcxproj.filters @@ -0,0 +1,35 @@ + + + + + {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 + + + + + Source Files + + + Source Files + + + + + Header Files + + + + + Resource Files + + + \ No newline at end of file diff --git a/ZRColaInstall/main.cpp b/ZRColaInstall/main.cpp new file mode 100644 index 0000000..b109cc3 --- /dev/null +++ b/ZRColaInstall/main.cpp @@ -0,0 +1,97 @@ +/* + Copyright 2015-2016 Amebis + + This file is part of ZRCola. + + ZRCola 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. + + ZRCola 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 ZRCola. If not, see . +*/ + +#include "stdafx.h" + + +/// +/// Main function +/// +extern "C" void WinMainCRTStartup() +{ + // Load "KERNEL32.DLL". + HMODULE hKernel32 = LoadLibrary(TEXT("KERNEL32.DLL")); + if (!hKernel32) + ExitProcess(1); + + // Get IsWow64Process() address. + BOOL (WINAPI *_IsWow64Process)(__in HANDLE hProcess, __out PBOOL Wow64Process) = (BOOL(WINAPI*)(__in HANDLE, __out PBOOL))::GetProcAddress(hKernel32, "IsWow64Process"); + + BOOL bIs64Bit; +#ifndef _WIN64 + // Determine if this is a 32-bit process under Windows-over-Windows64. + if (_IsWow64Process) { + // See what IsWow64Process() says. + if (!_IsWow64Process(::GetCurrentProcess(), &bIs64Bit)) { + // IsWow64Process() returned an error. Assume not 64-bit Windows. + bIs64Bit = FALSE; + } + } else { + // This platform does not have IsWow64Process(). Therefore, this is definitely not 64-bit Windows. + bIs64Bit = FALSE; + } +#else + // This is a running 64-bit process. The Windows must be 64 bit then. + bIs64Bit = TRUE; +#endif + + FreeLibrary(hKernel32); + + // Get temporary folder path. + static const LPTSTR pszTempFolderDefault = TEXT(""); + LPTSTR pszTempFolder; + DWORD dwLength; + if ((dwLength = GetEnvironmentVariable(TEXT("TEMP"), NULL, 0)) != 0 && + (pszTempFolder = (LPTSTR)LocalAlloc(LMEM_FIXED, (dwLength + 1)*sizeof(TCHAR))) != NULL) // +1 is for trailing backslash when missing! + { + dwLength = ::GetEnvironmentVariable(TEXT("TEMP"), pszTempFolder, dwLength); + + if (pszTempFolder[dwLength - 1] != TEXT('\\')) { + // Append trailing backslash. + pszTempFolder[dwLength ] = TEXT('\\'); + pszTempFolder[dwLength + 1] = 0; + } + } else + pszTempFolder = pszTempFolderDefault; + + // Format msiexec's command line. + LPTSTR pszParams; + DWORD_PTR aArgs[] = { + (DWORD_PTR)TEXT(ZRCOLA_INSTALL_LANG), + (DWORD_PTR)(bIs64Bit ? TEXT("64") : TEXT("32")), + (DWORD_PTR)pszTempFolder, + }; + FormatMessage( + FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_ARGUMENT_ARRAY | FORMAT_MESSAGE_FROM_STRING, + TEXT("/i \"http://www.amebis.si/prenos/ZRCola/_latest/ZRCola%1%2.msi\" /l* \"%3ZRCola%1%2.log\""), + 0, + 0, + (LPTSTR)&pszParams, + 1, + (va_list*)aArgs); + + // Launch installation. + int iResult = (int)ShellExecute(NULL, NULL, TEXT("msiexec.exe"), pszParams, NULL, SW_SHOWNORMAL) > 32; + + // Clean up. + LocalFree(pszParams); + if (pszTempFolder != pszTempFolderDefault) LocalFree(pszTempFolder); + + ExitProcess(iResult ? 0 : 2); +} diff --git a/ZRColaInstall/stdafx.cpp b/ZRColaInstall/stdafx.cpp new file mode 100644 index 0000000..ac111f1 --- /dev/null +++ b/ZRColaInstall/stdafx.cpp @@ -0,0 +1,20 @@ +/* + Copyright 2015-2016 Amebis + + This file is part of ZRCola. + + ZRCola 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. + + ZRCola 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 ZRCola. If not, see . +*/ + +#include "stdafx.h" diff --git a/ZRColaInstall/stdafx.h b/ZRColaInstall/stdafx.h new file mode 100644 index 0000000..ce204b1 --- /dev/null +++ b/ZRColaInstall/stdafx.h @@ -0,0 +1,22 @@ +/* + Copyright 2015-2016 Amebis + + This file is part of ZRCola. + + ZRCola 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. + + ZRCola 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 ZRCola. If not, see . +*/ + +#pragma once + +#include diff --git a/ZRColaUtils.sln b/ZRColaUtils.sln index ae4f509..58c26a9 100644 --- a/ZRColaUtils.sln +++ b/ZRColaUtils.sln @@ -18,6 +18,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "stdex", "lib\stdex\build\st EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libZRColaUI", "lib\libZRColaUI\build\libZRColaUI.vcxproj", "{C0A84BD2-3870-4CD6-B281-0AB322E3C579}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ZRColaInstall", "ZRColaInstall", "{7F5D45A3-B3D2-4B1D-B258-9B83395786E6}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZRColaInstallSl", "ZRColaInstall\ZRColaInstallSl.vcxproj", "{0C2C89C2-C96B-41B6-AA99-7E7741E20F3A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -64,6 +68,12 @@ Global {C0A84BD2-3870-4CD6-B281-0AB322E3C579}.Release|Win32.Build.0 = Release|Win32 {C0A84BD2-3870-4CD6-B281-0AB322E3C579}.Release|x64.ActiveCfg = Release|x64 {C0A84BD2-3870-4CD6-B281-0AB322E3C579}.Release|x64.Build.0 = Release|x64 + {0C2C89C2-C96B-41B6-AA99-7E7741E20F3A}.Debug|Win32.ActiveCfg = Debug|Win32 + {0C2C89C2-C96B-41B6-AA99-7E7741E20F3A}.Debug|Win32.Build.0 = Debug|Win32 + {0C2C89C2-C96B-41B6-AA99-7E7741E20F3A}.Debug|x64.ActiveCfg = Debug|Win32 + {0C2C89C2-C96B-41B6-AA99-7E7741E20F3A}.Release|Win32.ActiveCfg = Release|Win32 + {0C2C89C2-C96B-41B6-AA99-7E7741E20F3A}.Release|Win32.Build.0 = Release|Win32 + {0C2C89C2-C96B-41B6-AA99-7E7741E20F3A}.Release|x64.ActiveCfg = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -73,5 +83,6 @@ Global {A3A36689-AC35-4026-93DA-A3BA0C0E767C} = {A7D28E0C-BB96-444D-AAB0-F22A6483FE5F} {518777CC-0A59-4415-A12A-82751ED75343} = {A7D28E0C-BB96-444D-AAB0-F22A6483FE5F} {C0A84BD2-3870-4CD6-B281-0AB322E3C579} = {A7D28E0C-BB96-444D-AAB0-F22A6483FE5F} + {0C2C89C2-C96B-41B6-AA99-7E7741E20F3A} = {7F5D45A3-B3D2-4B1D-B258-9B83395786E6} EndGlobalSection EndGlobal