openvpnmsica: add ovpn-dco custom actions
PATCH 1/1 openvpnmsica: add ovpn-dco custom actions
From: Lev Stipakov <[email protected]...>
Add two custom actions to service ovpn-dco driver installation.
- EvaluateDriver
Runs under user privileges. Determines what action (install/uninstall) should be performed on ovpn-dco component.
- ProcessDriver
Runs under SYSTEM privileges. Performs driver (un)installation. During uninstall, all existing adapters with given hwid (ovpn-dco) are removed.
The logic is inspired by custom actions from tap-windows6 installer
(https://github.com/OpenVPN/tap-windows6/tree/master/msm).
--- src/openvpnmsica/Makefile.am | 2 +- src/openvpnmsica/openvpnmsica.c | 348 ++++++++++++++++++++++++++++++++ src/openvpnmsica/openvpnmsica.h | 30 +++ 3 files changed, 379 insertions(+), 1 deletion(-)
src/openvpnmsica/Makefile.am +1 -1
@@ -42,7 +42,7 @@ libopenvpnmsica_la_CFLAGS = \ -UNTDDI_VERSION -U_WIN32_WINNT \ -D_WIN32_WINNT=_WIN32_WINNT_VISTA \ -Wl,--kill-at -libopenvpnmsica_la_LDFLAGS = -ladvapi32 -lole32 -lmsi -lsetupapi -liphlpapi -lshell32 -lshlwapi -lversion -no-undefined -avoid-version +libopenvpnmsica_la_LDFLAGS = -ladvapi32 -lole32 -lmsi -lsetupapi -liphlpapi -lshell32 -lshlwapi -lversion -lnewdev -no-undefined -avoid-version endif libopenvpnmsica_la_SOURCES = \
src/openvpnmsica/openvpnmsica.c +348 -0
370 lines not on this page · raw message
src/openvpnmsica/openvpnmsica.h +30 -0
@@ -88,6 +88,10 @@ extern "C" {* with semicolon delimited list of all installed adapter GUIDs and active adapter GUIDs * respectively. * +* - Finds existing ovpn-dco adapters and set OVPNDCOADAPTERS and ACTIVEOVPNDCOADAPTERS properties +* with semicolon delimited list of all installed adapter GUIDs and active adapter GUIDs +* respectively. +* * @param hInstall Handle to the installation provided to the DLL custom action * * @return ERROR_SUCCESS on success; An error code otherwise
@@ -147,6 +151,32 @@ DLLEXP_DECL UINT __stdcall ProcessDeferredAction(_In_ MSIHANDLE hInstall); +/** +* Check what operation shall be performed on ovpn-dco driver +* and set data value (path to inf and user temp dir) for ProcessDriver action. +* +* @param hInstall Handle to the installation provided to the DLL custom action +* +* @return ERROR_SUCCESS on success; An error code otherwise +* See: https://msdn.microsoft.com/en-us/library/windows/desktop/aa368072.aspx +*/ +DLLEXP_DECL UINT __stdcall +EvaluateDriver(_In_ MSIHANDLE hInstall); + + +/** +* Install or uninstall ovpn-dco driver, removing all adapters using that driver. +* If reboot is required, creates reboot indication file in user's temp directory +* +* @param hInstall Handle to the installation provided to the DLL custom action +* +* @return ERROR_SUCCESS on success; An error code otherwise +* See: https://msdn.microsoft.com/en-us/library/windows/desktop/aa368072.aspx +*/ +DLLEXP_DECL UINT __stdcall +ProcessDriver(_In_ MSIHANDLE hInstall); + +/** * Schedule reboot after installation if reboot * indication file is found in user's temp directory
Signature · 1 line
2.23.0.windows.1
PATCH v2 1/1 openvpnmsica: add ovpn-dco custom actions
From: Lev Stipakov <[email protected]...>
Add two custom actions to service ovpn-dco driver installation.
- EvaluateDriver
Runs under user privileges. Determines what action (install/uninstall) should be performed on ovpn-dco component.
- ProcessDriver
Runs under SYSTEM privileges. Performs driver (un)installation. During uninstall, all existing adapters with given hwid (ovpn-dco) are removed.
The logic is inspired by custom actions from tap-windows6 installer
(https://github.com/OpenVPN/tap-windows6/tree/master/msm).
---
v2: fix string conversion warning
src/openvpnmsica/Makefile.am | 2 +- src/openvpnmsica/openvpnmsica.c | 348 ++++++++++++++++++++++++++++++++ src/openvpnmsica/openvpnmsica.h | 30 +++ 3 files changed, 379 insertions(+), 1 deletion(-)
src/openvpnmsica/Makefile.am +1 -1
@@ -42,7 +42,7 @@ libopenvpnmsica_la_CFLAGS = \ -UNTDDI_VERSION -U_WIN32_WINNT \ -D_WIN32_WINNT=_WIN32_WINNT_VISTA \ -Wl,--kill-at -libopenvpnmsica_la_LDFLAGS = -ladvapi32 -lole32 -lmsi -lsetupapi -liphlpapi -lshell32 -lshlwapi -lversion -no-undefined -avoid-version +libopenvpnmsica_la_LDFLAGS = -ladvapi32 -lole32 -lmsi -lsetupapi -liphlpapi -lshell32 -lshlwapi -lversion -lnewdev -no-undefined -avoid-version endif libopenvpnmsica_la_SOURCES = \
src/openvpnmsica/openvpnmsica.c +348 -0
370 lines not on this page · raw message
src/openvpnmsica/openvpnmsica.h +30 -0
@@ -88,6 +88,10 @@ extern "C" {* with semicolon delimited list of all installed adapter GUIDs and active adapter GUIDs * respectively. * +* - Finds existing ovpn-dco adapters and set OVPNDCOADAPTERS and ACTIVEOVPNDCOADAPTERS properties +* with semicolon delimited list of all installed adapter GUIDs and active adapter GUIDs +* respectively. +* * @param hInstall Handle to the installation provided to the DLL custom action * * @return ERROR_SUCCESS on success; An error code otherwise
@@ -147,6 +151,32 @@ DLLEXP_DECL UINT __stdcall ProcessDeferredAction(_In_ MSIHANDLE hInstall); +/** +* Check what operation shall be performed on ovpn-dco driver +* and set data value (path to inf and user temp dir) for ProcessDriver action. +* +* @param hInstall Handle to the installation provided to the DLL custom action +* +* @return ERROR_SUCCESS on success; An error code otherwise +* See: https://msdn.microsoft.com/en-us/library/windows/desktop/aa368072.aspx +*/ +DLLEXP_DECL UINT __stdcall +EvaluateDriver(_In_ MSIHANDLE hInstall); + + +/** +* Install or uninstall ovpn-dco driver, removing all adapters using that driver. +* If reboot is required, creates reboot indication file in user's temp directory +* +* @param hInstall Handle to the installation provided to the DLL custom action +* +* @return ERROR_SUCCESS on success; An error code otherwise +* See: https://msdn.microsoft.com/en-us/library/windows/desktop/aa368072.aspx +*/ +DLLEXP_DECL UINT __stdcall +ProcessDriver(_In_ MSIHANDLE hInstall); + +/** * Schedule reboot after installation if reboot * indication file is found in user's temp directory
Signature · 1 line
2.23.0.windows.1
PATCH v3 1/1 openvpnmsica: add ovpn-dco custom actions
From: Lev Stipakov <[email protected]...>
Add two custom actions to service ovpn-dco driver installation.
- EvaluateDriver
Runs under user privileges. Determines what action (install/uninstall) should be performed on ovpn-dco component.
- ProcessDriver
Runs under SYSTEM privileges. Performs driver (un)installation. During uninstall, all existing adapters with given hwid (ovpn-dco) are removed.
The logic is inspired by custom actions from tap-windows6 installer
(https://github.com/OpenVPN/tap-windows6/tree/master/msm).
---
v3:
- Remove GetComponentNameById() and use hardcoded component name instead
- Use WCHAR consistently
- add msg() calls on failure paths
- fix a few memory leaks
- minor cleanups
v2:
- fix string conversion warning
src/openvpnmsica/Makefile.am | 2 +- src/openvpnmsica/openvpnmsica.c | 315 ++++++++++++++++++++++++++++++-- src/openvpnmsica/openvpnmsica.h | 30 +++ 3 files changed, 334 insertions(+), 13 deletions(-)
src/openvpnmsica/Makefile.am +1 -1
@@ -42,7 +42,7 @@ libopenvpnmsica_la_CFLAGS = \ -UNTDDI_VERSION -U_WIN32_WINNT \ -D_WIN32_WINNT=_WIN32_WINNT_VISTA \ -Wl,--kill-at -libopenvpnmsica_la_LDFLAGS = -ladvapi32 -lole32 -lmsi -lsetupapi -liphlpapi -lshell32 -lshlwapi -lversion -no-undefined -avoid-version +libopenvpnmsica_la_LDFLAGS = -ladvapi32 -lole32 -lmsi -lsetupapi -liphlpapi -lshell32 -lshlwapi -lversion -lnewdev -no-undefined -avoid-version endif libopenvpnmsica_la_SOURCES = \
src/openvpnmsica/openvpnmsica.c +303 -12
373 lines not on this page · raw message
src/openvpnmsica/openvpnmsica.h +30 -0
@@ -88,6 +88,10 @@ extern "C" {* with semicolon delimited list of all installed adapter GUIDs and active adapter GUIDs * respectively. * +* - Finds existing ovpn-dco adapters and set OVPNDCOADAPTERS and ACTIVEOVPNDCOADAPTERS properties +* with semicolon delimited list of all installed adapter GUIDs and active adapter GUIDs +* respectively. +* * @param hInstall Handle to the installation provided to the DLL custom action * * @return ERROR_SUCCESS on success; An error code otherwise
@@ -147,6 +151,32 @@ DLLEXP_DECL UINT __stdcall ProcessDeferredAction(_In_ MSIHANDLE hInstall); +/** +* Check what operation shall be performed on ovpn-dco driver +* and set data value (path to inf and user temp dir) for ProcessDriver action. +* +* @param hInstall Handle to the installation provided to the DLL custom action +* +* @return ERROR_SUCCESS on success; An error code otherwise +* See: https://msdn.microsoft.com/en-us/library/windows/desktop/aa368072.aspx +*/ +DLLEXP_DECL UINT __stdcall +EvaluateDriver(_In_ MSIHANDLE hInstall); + + +/** +* Install or uninstall ovpn-dco driver, removing all adapters using that driver. +* If reboot is required, creates reboot indication file in user's temp directory +* +* @param hInstall Handle to the installation provided to the DLL custom action +* +* @return ERROR_SUCCESS on success; An error code otherwise +* See: https://msdn.microsoft.com/en-us/library/windows/desktop/aa368072.aspx +*/ +DLLEXP_DECL UINT __stdcall +ProcessDriver(_In_ MSIHANDLE hInstall); + +/** * Schedule reboot after installation if reboot * indication file is found in user's temp directory
Signature · 1 line
2.23.0.windows.1
Thanks to Simon for testing & advising Lev here.
I would have preferred to have the WCHAR fixes decoupled from "new functionality" - that makes reviewing easier. This said, the WCHAR fixes look good, and the rest looks at least "reasonable" - as I have no much idea what's going on there I can only look at "safe pointer use" etc.
Your patch has been applied to the master branch.
commit 055605783ee08767d871fbeffb6871368bdf1ada
Author: Lev Stipakov Date: Mon Feb 14 14:24:09 2022 +0200
openvpnmsica: add ovpn-dco custom actions
Signed-off-by: Lev Stipakov <[email protected]...>
Signed-off-by: Simon Rozman <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg23786.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering