From patchwork Thu Jan 19 08:59:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lev Stipakov X-Patchwork-Id: 3007 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7300:c95:b0:82:e4b3:40a0 with SMTP id p21csp367812dyk; Thu, 19 Jan 2023 01:01:34 -0800 (PST) X-Google-Smtp-Source: AMrXdXtXUiq1mwbOf5BW2sx7FdRdptnC1PBOblRlS0fEf4jcmNsZGgWimlqy1efrfgYjfBErGLJQ X-Received: by 2002:a05:6102:c04:b0:3ca:6d6b:bcaf with SMTP id x4-20020a0561020c0400b003ca6d6bbcafmr7027740vss.29.1674118893882; Thu, 19 Jan 2023 01:01:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674118893; cv=none; d=google.com; s=arc-20160816; b=D0A3NFi5COBGJKx9x6vsqnJFegCJYeaSX7jUyyUPcJNBccGuyuGbvgF6bjkZncOdvN rzaKJBdL8Zo4eM9ppSSOGOqXr3UaDj1XIoXaOq6xjJQB/dzLeT62hI2Al4d2n1ksuViA 3aI2bxlhoTYKEpjydgGwGKSsQjyCAd+M+BYOe98OO6VPcMuRJIs3QQtpQRlI/iK2g8j6 52rRUjYL7TqCPaJP59JJFNgtwcTYn15MgY/EV6pTNOq4Q6UZpUDQ4ZD5hk0ARBqh9eIJ jXP5xpcJ2LPOsq5K/Gz465Axa9zFxg7hrChCn0dFeplUcqz6c0pMgMmdmzbo4DXlQhpg nYaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:content-transfer-encoding:cc:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:message-id:date:to:from:dkim-signature:dkim-signature :dkim-signature; bh=wRYEkpqf0VaKDnwslE6LCBT/AhH5kKMlRrc3aPMnXx4=; b=IY8U/qhLnRb4olODPL5s8i6CJLXPUL/+ak1QU7NfK1oXP8C1f5xX19WZKxqhlFFstK xmILPIvfxKEq8zAPfl89Qn4r2PreocTPInPbI/aQVKpgbqwBY0M37KC4RCerrfGaJEbM fedLjltRN3g+kBmZAL9s027alX8+s2/mxaM1yJn/7JBnDAUlULITHkJMLTz/deSp+5dX v4jU02cylyXeu0d028DItKXyRV84/nhFwViqn5oKP6/sEMkrm3urAWAGCOy/c6CRZWBw uiKg6sXWr9yIdHKptkctqTUxox0CyhZMGWI6D/EOLP2AI/nnrlsZaEbiFdoLVX+NeuA5 q9NQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=T3cSHGfj; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=I7o6JpKU; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=WXhSnPbG; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id c7-20020a9f3d87000000b0061749eea04csi1289913uai.66.2023.01.19.01.01.33 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Jan 2023 01:01:33 -0800 (PST) Received-SPF: pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) client-ip=216.105.38.7; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=T3cSHGfj; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=I7o6JpKU; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=WXhSnPbG; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1pIQmj-0000CV-9F; Thu, 19 Jan 2023 09:00:36 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pIQmY-0000CA-KT for openvpn-devel@lists.sourceforge.net; Thu, 19 Jan 2023 09:00:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=gXpqkvxLsqay8M4b5NH8IQ4POOpMom8JPH4zIUcygVQ=; b=T3cSHGfjQfxbZHwhMSvlVxOOtn lD8BPAMoSdSP7sVA+dUaoFZNY3E79QYidvu1BfaDdraiCnJ0K4OBnUAKg49nncGjLciAMSbPgYMUb DKzvEC+GZpOz1KOLqXy05ocamHvmVok0Ry+GytsdSLGOFnSQ1zghGGE6i/cLFwnjGpOI=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject:Cc:To:From :Sender:Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=gXpqkvxLsqay8M4b5NH8IQ4POOpMom8JPH4zIUcygVQ=; b=I 7o6JpKUnxgMy6SqtgKb6rDo8P1Ywlu8kJmO6v3YDSK2vSNihJMao1qkdbW6flo1Id0+pfPjGv44Fm Ee90zdOaDjlxBK2Gu0fcJGO5Z7EkdNmyUlRFQwZq6XHf0SqWzCDMSxatHgMu5BRAhcVmq5OQivTcO d1AWrr4vu/kpI8vU=; Received: from mail-il1-f176.google.com ([209.85.166.176]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1pIQmQ-0006OL-VP for openvpn-devel@lists.sourceforge.net; Thu, 19 Jan 2023 09:00:24 +0000 Received: by mail-il1-f176.google.com with SMTP id h15so579177ilh.4 for ; Thu, 19 Jan 2023 01:00:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=gXpqkvxLsqay8M4b5NH8IQ4POOpMom8JPH4zIUcygVQ=; b=WXhSnPbGO9T9jGgDjxjqQhNqErZZd2IZoN+NVkHKj8suTzs4+BoUsntvv124wbvgTZ iOClT3I3B4edK7JdgLdrPd3TjfWBNsYRxG+OZRuxDmCwPhd9YhlwvFAWzLJ6Ql/zcNNR H4XClauq5bOXXIYRv6/FMkQ7UEPQ1Ap4Rpb2j649N7sowEtkgC5jkAoJqf+e/0w5WGR4 z8Z0Hig+mwIwrR1Oc1fQN4u/BQKmgXa5OGKbplG8gAX3kTGTcmCbLO6Pley+Lnq0LH5q g2LMr9jQBTxtzKV2rVk6860fPjNJ+/uhnLqYwXvAoY40cg0PsG5fLzNQNtIwpdaGUji0 0vVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=gXpqkvxLsqay8M4b5NH8IQ4POOpMom8JPH4zIUcygVQ=; b=lfdoTft4FmYBhPqa93fwLoAnRRu2kTsVjldQ6a9sGWMG1IpfzBFYGEiitTjgek378c KXMB+diSPCMbbhgpYoN59SeSlwU+sbgAn89nSAohRfMGvbU78v5riwdsPc9WYV4BpCMU 8CqBE18S4V9uCePl6bbfqwLW/mqn/HiIjD5oOq96+GQY5id7hXupWjdaLQ7K4QFv8ePj 1pDjLHA8V2XsOg7SiKfiyBqgKc/zvnB/3kHICR1lZ8FySIzpq4pWhAt0cznfB1e7N1nV Xed76uCQVG0OwKz5zkiA/HAGGIUYfh8d6hsz5HJlVgauMXXmwrLCGt1HdYH4Gck8f0Ag aVHg== X-Gm-Message-State: AFqh2krcBDbHo650ifQ8xUhikuFLceNYG5d+1mxQLGV9Sv9ZXmsHlr3Y ti3Oxrp3+3cSIVK1bj9CYZLywkdRYK8= X-Received: by 2002:a05:6e02:663:b0:302:9921:2ee2 with SMTP id l3-20020a056e02066300b0030299212ee2mr7539440ilt.25.1674118813051; Thu, 19 Jan 2023 01:00:13 -0800 (PST) Received: from localhost.localdomain ([2a00:1d50:3:0:4141:64fa:38f2:57db]) by smtp.gmail.com with ESMTPSA id a6-20020a056e020e0600b0030edd1501a0sm5402532ilk.74.2023.01.19.01.00.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 01:00:12 -0800 (PST) From: Lev Stipakov To: openvpn-devel@lists.sourceforge.net Date: Thu, 19 Jan 2023 10:59:59 +0200 Message-Id: <20230119085959.157-1-lstipakov@gmail.com> X-Mailer: git-send-email 2.38.1.windows.1 MIME-Version: 1.0 X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "util-spamd-2.v13.lw.sourceforge.com", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Lev Stipakov Those have been moved into MSM to be reused by openvpn-gui and Connect. Signed-off-by: Lev Stipakov --- src/openvpnmsica/openvpnmsica.c | 283 1 file changed, 283 deletions(-) Content analysis details: (-0.2 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [lstipakov[at]gmail.com] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.166.176 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.166.176 listed in wl.mailspike.net] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-Headers-End: 1pIQmQ-0006OL-VP Subject: [Openvpn-devel] [PATCH] openvpnmsica: remove dco installer custom actions X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lev Stipakov Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: =?utf-8?q?1755440893038401541?= X-GMAIL-MSGID: =?utf-8?q?1755440893038401541?= From: Lev Stipakov Those have been moved into MSM to be reused by openvpn-gui and Connect. Signed-off-by: Lev Stipakov Acked-by: Gert Doering --- src/openvpnmsica/openvpnmsica.c | 283 -------------------------------- 1 file changed, 283 deletions(-) diff --git a/src/openvpnmsica/openvpnmsica.c b/src/openvpnmsica/openvpnmsica.c index 229eff00..af12b2c4 100644 --- a/src/openvpnmsica/openvpnmsica.c +++ b/src/openvpnmsica/openvpnmsica.c @@ -64,12 +64,6 @@ #define MSICA_ADAPTER_TICK_SIZE (16*1024) /** Amount of tick space to reserve for one TAP/TUN adapter creation/deletition. */ #define FILE_NEED_REBOOT L".ovpn_need_reboot" -#define CMP_OVPN_DCO_INF L"CMP_ovpn_dco.inf" -#define ACTION_ADD_DRIVER L"AddDriver" -#define ACTION_DELETE_DRIVER L"DeleteDriver" -#define ACTION_NOOP L"Noop" -#define FILE_OVPN_DCO_INF L"ovpn-dco.inf" -#define OVPN_DCO_HWID L"ovpn-dco" /** * Joins an argument sequence and sets it to the MSI property. @@ -1196,280 +1190,3 @@ CheckAndScheduleReboot(_In_ MSIHANDLE hInstall) } return ERROR_SUCCESS; } - -static BOOL -IsInstalling(_In_ INSTALLSTATE InstallState, _In_ INSTALLSTATE ActionState) -{ - return INSTALLSTATE_LOCAL == ActionState || INSTALLSTATE_SOURCE == ActionState - || (INSTALLSTATE_DEFAULT == ActionState - && (INSTALLSTATE_LOCAL == InstallState || INSTALLSTATE_SOURCE == InstallState)); -} - -static BOOL -IsReInstalling(_In_ INSTALLSTATE InstallState, _In_ INSTALLSTATE ActionState) -{ - return (INSTALLSTATE_LOCAL == ActionState || INSTALLSTATE_SOURCE == ActionState - || INSTALLSTATE_DEFAULT == ActionState) - && (INSTALLSTATE_LOCAL == InstallState || INSTALLSTATE_SOURCE == InstallState); -} - -static BOOL -IsUninstalling(_In_ INSTALLSTATE InstallState, _In_ INSTALLSTATE ActionState) -{ - return (INSTALLSTATE_ABSENT == ActionState || INSTALLSTATE_REMOVED == ActionState) - && (INSTALLSTATE_LOCAL == InstallState || INSTALLSTATE_SOURCE == InstallState); -} - -UINT __stdcall -EvaluateDriver(_In_ MSIHANDLE hInstall) -{ -#ifdef _MSC_VER -#pragma comment(linker, DLLEXP_EXPORT) -#endif - - debug_popup(__FUNCTION__); - - UINT ret; - BOOL bIsCoInitialized = SUCCEEDED(CoInitialize(NULL)); - - OPENVPNMSICA_SAVE_MSI_SESSION(hInstall); - - INSTALLSTATE InstallState, ActionState; - ret = MsiGetComponentStateW(hInstall, CMP_OVPN_DCO_INF, &InstallState, &ActionState); - if (ret != ERROR_SUCCESS) - { - SetLastError(ret); - msg(M_NONFATAL | M_ERRNO, "%s: MsiGetComponentState(\"%ls\") failed", __FUNCTION__, CMP_OVPN_DCO_INF); - goto cleanup; - } - - /* get user-specific temp path, to where we create reboot indication file */ - WCHAR tempPath[MAX_PATH]; - GetTempPathW(MAX_PATH, tempPath); - - WCHAR pathToInf[MAX_PATH]; - DWORD pathLen = _countof(pathToInf); - ret = MsiGetPropertyW(hInstall, L"OVPNDCO", pathToInf, &pathLen); - if (ret != ERROR_SUCCESS) - { - SetLastError(ret); - msg(M_NONFATAL | M_ERRNO, "%s: MsiGetProperty failed", __FUNCTION__); - goto cleanup; - } - - WCHAR action[0x400]; - if ((IsReInstalling(InstallState, ActionState) || IsInstalling(InstallState, ActionState))) - { - swprintf_s(action, _countof(action), L"%s|%s%s|%s", ACTION_ADD_DRIVER, pathToInf, FILE_OVPN_DCO_INF, tempPath); - } - else if (IsUninstalling(InstallState, ActionState)) - { - swprintf_s(action, _countof(action), L"%s|%s%s|%s", ACTION_DELETE_DRIVER, pathToInf, FILE_OVPN_DCO_INF, tempPath); - } - else - { - swprintf_s(action, _countof(action), L"%s||", ACTION_NOOP); - } - - ret = MsiSetPropertyW(hInstall, L"OvpnDcoProcess", action); - -cleanup: - if (bIsCoInitialized) - { - CoUninitialize(); - } - return ret; -} - -static BOOL -GetPublishedDriverName(_In_z_ LPCWSTR hwid, _Out_writes_z_(len) LPWSTR publishedName, _In_ DWORD len) -{ - wcscpy_s(publishedName, len, L""); - - HDEVINFO devInfoSet = SetupDiGetClassDevsW(&GUID_DEVCLASS_NET, NULL, NULL, 0); - if (!devInfoSet) - { - msg(M_NONFATAL | M_ERRNO, "%s: SetupDiGetClassDevsW failed", __FUNCTION__); - return FALSE; - } - BOOL res = FALSE; - if (!SetupDiBuildDriverInfoList(devInfoSet, NULL, SPDIT_CLASSDRIVER)) - { - msg(M_NONFATAL | M_ERRNO, "%s: SetupDiBuildDriverInfoList failed", __FUNCTION__); - goto cleanupDeviceInfoSet; - } - for (DWORD idx = 0;; ++idx) - { - SP_DRVINFO_DATA_W drvInfo = { .cbSize = sizeof(drvInfo) }; - if (!SetupDiEnumDriverInfoW(devInfoSet, NULL, SPDIT_CLASSDRIVER, idx, &drvInfo)) - { - if (GetLastError() == ERROR_NO_MORE_ITEMS) - { - break; - } - msg(M_NONFATAL | M_ERRNO, "%s: SetupDiEnumDriverInfoW failed", __FUNCTION__); - goto cleanupDriverInfoList; - } - DWORD size; - if (SetupDiGetDriverInfoDetailW(devInfoSet, NULL, &drvInfo, NULL, 0, &size) || GetLastError() != ERROR_INSUFFICIENT_BUFFER) - { - msg(M_NONFATAL | M_ERRNO, "%s: SetupDiGetDriverInfoDetailW failed", __FUNCTION__); - goto cleanupDriverInfoList; - } - PSP_DRVINFO_DETAIL_DATA_W drvDetails = calloc(1, size); - if (!drvDetails) - { - msg(M_NONFATAL, "%s: calloc(1, %u) failed", __FUNCTION__, size); - goto cleanupDriverInfoList; - } - drvDetails->cbSize = sizeof(*drvDetails); - if (!SetupDiGetDriverInfoDetailW(devInfoSet, NULL, &drvInfo, drvDetails, size, &size)) - { - msg(M_NONFATAL | M_ERRNO, "%s: SetupDiGetDriverInfoDetailW failed", __FUNCTION__); - free(drvDetails); - goto cleanupDriverInfoList; - } - if (wcscmp(hwid, drvDetails->HardwareID) == 0) - { - PathStripPathW(drvDetails->InfFileName); - wcscpy_s(publishedName, len, drvDetails->InfFileName); - free(drvDetails); - res = TRUE; - break; - } - free(drvDetails); - } - -cleanupDriverInfoList: - SetupDiDestroyDriverInfoList(devInfoSet, NULL, SPDIT_CLASSDRIVER); -cleanupDeviceInfoSet: - SetupDiDestroyDeviceInfoList(devInfoSet); - return res; -} - -static void -DeleteDriver(_In_z_ LPCWSTR pathToTmp) -{ - /* get list of adapters for hwid */ - struct tap_adapter_node *pAdapterList = NULL; - DWORD ret = tap_list_adapters(NULL, OVPN_DCO_HWID, &pAdapterList); - if (ret != ERROR_SUCCESS) - { - msg(M_NONFATAL, "%s", "Failed to get adapter list: %d", __FUNCTION__, ret); - } - - /* delete all adapters */ - BOOL rebootRequired = FALSE; - for (struct tap_adapter_node *pAdapter = pAdapterList; pAdapter != NULL; pAdapter = pAdapter->pNext) - { - tap_delete_adapter(NULL, &pAdapter->guid, &rebootRequired); - } - - /* delete driver */ - WCHAR publishedName[MAX_PATH] = { 0 }; - if (GetPublishedDriverName(OVPN_DCO_HWID, publishedName, _countof(publishedName))) - { - if (!SetupUninstallOEMInfW(publishedName, 0, NULL)) - { - msg(M_NONFATAL | M_ERRNO, "%s: SetupUninstallOEMInfW(\"%ls\") failed", __FUNCTION__, publishedName); - } - } - - if (rebootRequired) - { - CreateRebootFile(pathToTmp); - } -} - -static void -AddDriver(_In_z_ LPCWSTR pathToInf, _In_z_ LPCWSTR pathToTmp) -{ - /* copy driver to driver store */ - if (!SetupCopyOEMInfW(pathToInf, NULL, SPOST_PATH, 0, NULL, 0, NULL, NULL)) - { - msg(M_NONFATAL | M_ERRNO, "%s: SetupCopyOEMInf(\"%ls\") failed", __FUNCTION__, pathToInf); - return; - } - - /* update driver for existing devices (if any) */ - BOOL rebootRequired = FALSE; - if (!UpdateDriverForPlugAndPlayDevicesW(NULL, OVPN_DCO_HWID, pathToInf, INSTALLFLAG_NONINTERACTIVE | INSTALLFLAG_FORCE, &rebootRequired)) - { - /* ERROR_NO_SUCH_DEVINST means that no devices exist, which is normal case - device (adapter) is created at later stage */ - if (GetLastError() != ERROR_NO_SUCH_DEVINST) - { - msg(M_NONFATAL | M_ERRNO, "%s: UpdateDriverForPlugAndPlayDevices(\"%ls\", \"%ls\") failed", __FUNCTION__, OVPN_DCO_HWID, pathToInf); - return; - } - } - if (rebootRequired) - { - CreateRebootFile(pathToTmp); - } -} - -UINT __stdcall -ProcessDriver(_In_ MSIHANDLE hInstall) -{ -#ifdef _MSC_VER -#pragma comment(linker, DLLEXP_EXPORT) -#endif - - debug_popup(__FUNCTION__); - - UINT ret = 0; - BOOL bIsCoInitialized = SUCCEEDED(CoInitialize(NULL)); - - OPENVPNMSICA_SAVE_MSI_SESSION(hInstall); - - LPWSTR customData = NULL; - ret = msi_get_string(hInstall, L"CustomActionData", &customData); - if (ret != ERROR_SUCCESS) - { - goto cleanup; - } - - int i = 0; - WCHAR action[0x400] = { 0 }; - WCHAR pathToInf[MAX_PATH] = { 0 }; - WCHAR pathToTmp[MAX_PATH] = { 0 }; - - WCHAR *pos = NULL; - WCHAR *token = wcstok_s(customData, L"|", &pos); - /* action|path_to_inf_file|path_to_tmp_dir */ - while (token) - { - switch (i++) - { - case 0: - wcscpy_s(action, _countof(action), token); - break; - - case 1: - wcscpy_s(pathToInf, _countof(pathToInf), token); - break; - - case 2: - wcscpy_s(pathToTmp, _countof(pathToTmp), token); - break; - } - token = wcstok_s(NULL, L"|", &pos); - } - - if (wcscmp(action, ACTION_ADD_DRIVER) == 0) - { - AddDriver(pathToInf, pathToTmp); - } - else if (wcscmp(action, ACTION_DELETE_DRIVER) == 0) - { - DeleteDriver(pathToTmp); - } - -cleanup: - free(customData); - if (bIsCoInitialized) - { - CoUninitialize(); - } - return ret; -}