From 8d72f50e101ca66cb3296b814cd5e88846b5bd08 Mon Sep 17 00:00:00 2001
From: Patrick Simpson
Date: Tue, 13 Nov 2018 14:51:18 +0200
Subject: [PATCH] [KOE-178] Fix for invalid account id in message service
configuration
---
src/AcaciaZPushPlugin/AcaciaZPushPlugin.sln | 6 ++++--
.../EASAccount/EASAccount.cpp | 18 ++++++++++++------
.../OutlookRestarter/OutlookRestarter.cs | 4 ++--
3 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin.sln b/src/AcaciaZPushPlugin/AcaciaZPushPlugin.sln
index b1b18bf..08089bd 100644
--- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin.sln
+++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin.sln
@@ -57,12 +57,14 @@ Global
{222C4DA5-FA31-471A-B127-5E0C6AD2CB3C}.Release|x64.Build.0 = Release|Any CPU
{222C4DA5-FA31-471A-B127-5E0C6AD2CB3C}.Release|x86.ActiveCfg = Release|Any CPU
{222C4DA5-FA31-471A-B127-5E0C6AD2CB3C}.Release|x86.Build.0 = Release|Any CPU
- {437F3764-1E65-4AED-88FA-7C5B2F2FAF15}.Debug|Any CPU.ActiveCfg = Debug|Win32
+ {437F3764-1E65-4AED-88FA-7C5B2F2FAF15}.Debug|Any CPU.ActiveCfg = Debug|x64
+ {437F3764-1E65-4AED-88FA-7C5B2F2FAF15}.Debug|Any CPU.Build.0 = Debug|x64
{437F3764-1E65-4AED-88FA-7C5B2F2FAF15}.Debug|x64.ActiveCfg = Debug|x64
{437F3764-1E65-4AED-88FA-7C5B2F2FAF15}.Debug|x64.Build.0 = Debug|x64
{437F3764-1E65-4AED-88FA-7C5B2F2FAF15}.Debug|x86.ActiveCfg = Debug|Win32
{437F3764-1E65-4AED-88FA-7C5B2F2FAF15}.Debug|x86.Build.0 = Debug|Win32
- {437F3764-1E65-4AED-88FA-7C5B2F2FAF15}.Release|Any CPU.ActiveCfg = Release|Win32
+ {437F3764-1E65-4AED-88FA-7C5B2F2FAF15}.Release|Any CPU.ActiveCfg = Release|x64
+ {437F3764-1E65-4AED-88FA-7C5B2F2FAF15}.Release|Any CPU.Build.0 = Release|x64
{437F3764-1E65-4AED-88FA-7C5B2F2FAF15}.Release|x64.ActiveCfg = Release|x64
{437F3764-1E65-4AED-88FA-7C5B2F2FAF15}.Release|x64.Build.0 = Release|x64
{437F3764-1E65-4AED-88FA-7C5B2F2FAF15}.Release|x86.ActiveCfg = Release|Win32
diff --git a/src/AcaciaZPushPlugin/EASAccount/EASAccount.cpp b/src/AcaciaZPushPlugin/EASAccount/EASAccount.cpp
index f63a0d6..7ca817b 100644
--- a/src/AcaciaZPushPlugin/EASAccount/EASAccount.cpp
+++ b/src/AcaciaZPushPlugin/EASAccount/EASAccount.cpp
@@ -173,6 +173,7 @@ public:
// Set up the account
OpenProfileAdmin();
EncryptPassword();
+ FetchAccountKey();
CreateMessageService();
GetEntryId();
CreateAccount();
@@ -306,10 +307,10 @@ private:
msprops[3].Value.bin.lpb = &encryptedPassword[0];
msprops[4].ulPropTag = PR_RESOURCE_FLAGS;
- msprops[4].Value.l = SERVICE_NO_PRIMARY_IDENTITY | SERVICE_CREATE_WITH_STORE;
+ msprops[4].Value.l = SERVICE_NO_PRIMARY_IDENTITY | SERVICE_CREATE_WITH_STORE | SERVICE_SINGLE_COPY;
msprops[5].ulPropTag = 0x67060003;
- msprops[5].Value.l = 4;
+ msprops[5].Value.l = accountId;
VERBOSE(L"CreateMessageService: 2\n");
CHECK_H(lpServiceAdmin2->ConfigureMsgService(&service, 0, SERVICE_UI_ALLOWED, 6, msprops), "ConfigureMSGService");
@@ -372,16 +373,21 @@ private:
CHECK_L(RegOpenKey(hKeyAccounts, accountId.c_str(), &hKeyNewAccount), "OpenAccountKey");
}
- void AllocateAccountKey()
+ void FetchAccountKey()
{
OpenAccountsKey();
- wchar_t keyPath[MAX_PATH];
-
// Get the NextAccountID value
DWORD size = sizeof(accountId);
CHECK_L(RegQueryValueEx(hKeyAccounts, VALUE_NEXT_ACCOUNT_ID, nullptr, nullptr, (LPBYTE)&accountId, &size), "GetNextAccountId");
-
+ }
+
+ void AllocateAccountKey()
+ {
+ FetchAccountKey();
+
+ wchar_t keyPath[MAX_PATH];
+
// Create the subkey
swprintf_s(keyPath, ARRAYSIZE(keyPath), L"%.8X", accountId);
CHECK_L(RegCreateKey(hKeyAccounts, keyPath, &hKeyNewAccount), "CreateAccountKey");
diff --git a/src/AcaciaZPushPlugin/OutlookRestarter/OutlookRestarter.cs b/src/AcaciaZPushPlugin/OutlookRestarter/OutlookRestarter.cs
index 31b1969..7e79843 100644
--- a/src/AcaciaZPushPlugin/OutlookRestarter/OutlookRestarter.cs
+++ b/src/AcaciaZPushPlugin/OutlookRestarter/OutlookRestarter.cs
@@ -98,9 +98,9 @@ namespace OutlookRestarter
// Start the process
Process process = new Process();
process.StartInfo = new ProcessStartInfo(procPath, argsString);
- Logger.Instance.Debug(typeof(OutlookRestarter), "Starting process: {0}", process);
+ Logger.Instance.Debug(typeof(OutlookRestarter), "Starting process: {0} - {1}", procPath, argsString);
process.Start();
- Logger.Instance.Debug(typeof(OutlookRestarter), "Started process: {0}", process);
+ Logger.Instance.Debug(typeof(OutlookRestarter), "Started process: {0} - {1}", procPath, argsString);
}
}
catch(Exception e)