Skip to content

Commit 86fc2f8

Browse files
committed
Updater: Improve dialog text and error checking
1 parent e1b0391 commit 86fc2f8

File tree

8 files changed

+95
-99
lines changed

8 files changed

+95
-99
lines changed

plugins/Updater/page1.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,7 @@ HRESULT CALLBACK CheckForUpdatesCallbackProc(
4040
switch (uMsg)
4141
{
4242
case TDN_NAVIGATED:
43-
{
44-
// Taskdialog is now initialized
45-
PhSetEvent(&InitializedEvent);
46-
}
43+
PhSetEvent(&InitializedEvent);
4744
break;
4845
case TDN_BUTTON_CLICKED:
4946
{
@@ -70,17 +67,16 @@ VOID ShowCheckForUpdatesDialog(
7067
config.dwFlags = TDF_USE_HICON_MAIN | TDF_ALLOW_DIALOG_CANCELLATION | TDF_CAN_BE_MINIMIZED | TDF_ENABLE_HYPERLINKS;
7168
config.dwCommonButtons = TDCBF_CLOSE_BUTTON;
7269
config.hMainIcon = Context->IconLargeHandle;
73-
74-
config.pszWindowTitle = L"Process Hacker - Updater";
75-
config.pszMainInstruction = L"Check for new Process Hacker releases?";
76-
//config.pszContent = L"The updater will check for new Process Hacker releases and optionally download and install the update.\r\n\r\nClick the check for updates button to continue.";
77-
config.pszContent = L"Select \"check for updates\" to continue.\r\n";
78-
7970
config.cxWidth = 200;
8071
config.pButtons = TaskDialogButtonArray;
8172
config.cButtons = ARRAYSIZE(TaskDialogButtonArray);
8273
config.pfCallback = CheckForUpdatesCallbackProc;
8374
config.lpCallbackData = (LONG_PTR)Context;
8475

76+
config.pszWindowTitle = L"Process Hacker - Updater";
77+
config.pszMainInstruction = L"Check for new Process Hacker releases?";
78+
//config.pszContent = L"The updater will check for new Process Hacker releases and optionally download and install the update.\r\n\r\nClick the check for updates button to continue.";
79+
config.pszContent = L"Select \"check for updates\" to continue.\r\n";
80+
8581
SendMessage(Context->DialogHandle, TDM_NAVIGATE_PAGE, 0, (LPARAM)&config);
8682
}

plugins/Updater/page2.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,12 @@ VOID ShowCheckingForUpdatesDialog(
5959
config.dwFlags = TDF_USE_HICON_MAIN | TDF_ALLOW_DIALOG_CANCELLATION | TDF_CAN_BE_MINIMIZED | TDF_SHOW_MARQUEE_PROGRESS_BAR;
6060
config.dwCommonButtons = TDCBF_CLOSE_BUTTON;
6161
config.hMainIcon = Context->IconLargeHandle;
62-
63-
config.pszWindowTitle = L"Process Hacker - Updater";
64-
config.pszMainInstruction = L"Checking for new releases...";
65-
6662
config.cxWidth = 200;
6763
config.pfCallback = CheckingForUpdatesCallbackProc;
6864
config.lpCallbackData = (LONG_PTR)Context;
6965

66+
config.pszWindowTitle = L"Process Hacker - Updater";
67+
config.pszMainInstruction = L"Checking for new releases...";
68+
7069
SendMessage(Context->DialogHandle, TDM_NAVIGATE_PAGE, 0, (LPARAM)&config);
7170
}

plugins/Updater/page3.c

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,7 @@ HRESULT CALLBACK ShowAvailableCallbackProc(
4040
switch (uMsg)
4141
{
4242
case TDN_NAVIGATED:
43-
{
44-
// Taskdialog is now initialized (Required if the background startup check starts here)
45-
PhSetEvent(&InitializedEvent);
46-
}
43+
PhSetEvent(&InitializedEvent);
4744
break;
4845
case TDN_BUTTON_CLICKED:
4946
{
@@ -89,30 +86,31 @@ VOID ShowAvailableDialog(
8986
config.dwFlags = TDF_USE_HICON_MAIN | TDF_ALLOW_DIALOG_CANCELLATION | TDF_CAN_BE_MINIMIZED | TDF_ENABLE_HYPERLINKS;
9087
config.dwCommonButtons = TDCBF_CANCEL_BUTTON;
9188
config.hMainIcon = Context->IconLargeHandle;
89+
config.cxWidth = 200;
90+
config.pButtons = TaskDialogButtonArray;
91+
config.cButtons = ARRAYSIZE(TaskDialogButtonArray);
92+
config.lpCallbackData = (LONG_PTR)Context;
93+
config.pfCallback = ShowAvailableCallbackProc;
9294
config.pszWindowTitle = L"Process Hacker - Updater";
9395

9496
if (PhGetIntegerSetting(SETTING_NAME_NIGHTLY_BUILD))
9597
{
96-
config.pszMainInstruction = PhaFormatString(L"Process Hacker Nightly Build %lu.%lu.%lu",
97-
Context->MajorVersion,
98-
Context->MinorVersion,
99-
Context->RevisionVersion
100-
)->Buffer;
101-
config.pszContent = PhaFormatString(L"Version: %lu.%lu.%lu\r\nDownload size: %s",
98+
config.pszMainInstruction = L"A new Process Hacker nightly build is available";
99+
config.pszContent = PhaFormatString(L"Build: %lu.%lu.%lu\r\nDownload size: %s",
102100
Context->MajorVersion,
103101
Context->MinorVersion,
104102
Context->RevisionVersion,
105103
PhGetStringOrEmpty(Context->Size)
106104
)->Buffer;
107105

108-
if (!PhIsNullOrEmptyString(Context->BuildMessage))
109-
config.pszExpandedInformation = PhGetStringOrEmpty(Context->BuildMessage);
110-
else
106+
if (PhIsNullOrEmptyString(Context->BuildMessage))
111107
config.pszExpandedInformation = L"<A HREF=\"executablestring\">View Changelog</A>";
108+
else
109+
config.pszExpandedInformation = PhGetStringOrEmpty(Context->BuildMessage);
112110
}
113111
else
114112
{
115-
config.pszMainInstruction = L"An update for Process Hacker is available";
113+
config.pszMainInstruction = L"A new Process Hacker release is available";
116114
config.pszContent = PhaFormatString(L"Version: %lu.%lu.%lu\r\nDownload size: %s",
117115
Context->MajorVersion,
118116
Context->MinorVersion,
@@ -122,12 +120,5 @@ VOID ShowAvailableDialog(
122120
config.pszExpandedInformation = L"<A HREF=\"executablestring\">View Changelog</A>";
123121
}
124122

125-
config.cxWidth = 200;
126-
config.pButtons = TaskDialogButtonArray;
127-
config.cButtons = ARRAYSIZE(TaskDialogButtonArray);
128-
129-
config.lpCallbackData = (LONG_PTR)Context;
130-
config.pfCallback = ShowAvailableCallbackProc;
131-
132123
SendMessage(Context->DialogHandle, TDM_NAVIGATE_PAGE, 0, (LPARAM)&config);
133124
}

plugins/Updater/page4.c

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ VOID ShowProgressDialog(
6464
config.dwFlags = TDF_USE_HICON_MAIN | TDF_ALLOW_DIALOG_CANCELLATION | TDF_CAN_BE_MINIMIZED | TDF_EXPAND_FOOTER_AREA | TDF_ENABLE_HYPERLINKS | TDF_SHOW_PROGRESS_BAR;
6565
config.dwCommonButtons = TDCBF_CANCEL_BUTTON;
6666
config.hMainIcon = Context->IconLargeHandle;
67+
config.cxWidth = 200;
68+
config.lpCallbackData = (LONG_PTR)Context;
69+
config.pfCallback = ShowProgressCallbackProc;
6770

6871
config.pszWindowTitle = L"Process Hacker - Updater";
6972
config.pszMainInstruction = PhaFormatString(L"Downloading update %lu.%lu.%lu...",
@@ -73,18 +76,10 @@ VOID ShowProgressDialog(
7376
)->Buffer;
7477
config.pszContent = L"Downloaded: ~ of ~ (0%)\r\nSpeed: ~ KB/s";
7578

76-
if (PhGetIntegerSetting(SETTING_NAME_NIGHTLY_BUILD) && !PhIsNullOrEmptyString(Context->BuildMessage))
77-
{
78-
config.pszExpandedInformation = PhGetStringOrEmpty(Context->BuildMessage);
79-
}
80-
else
81-
{
79+
if (PhIsNullOrEmptyString(Context->BuildMessage))
8280
config.pszExpandedInformation = L"<A HREF=\"executablestring\">View Changelog</A>";
83-
}
84-
85-
config.cxWidth = 200;
86-
config.lpCallbackData = (LONG_PTR)Context;
87-
config.pfCallback = ShowProgressCallbackProc;
81+
else
82+
config.pszExpandedInformation = PhGetStringOrEmpty(Context->BuildMessage);
8883

8984
SendMessage(Context->DialogHandle, TDM_NAVIGATE_PAGE, 0, (LPARAM)&config);
9085
}

plugins/Updater/page5.c

Lines changed: 55 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,14 @@ HRESULT CALLBACK FinalTaskDialogCallbackProc(
5151
break;
5252
case TDN_BUTTON_CLICKED:
5353
{
54-
if ((INT)wParam == IDRETRY)
54+
INT buttonId = (INT)wParam;
55+
56+
if (buttonId == IDRETRY)
5557
{
5658
ShowCheckingForUpdatesDialog(context);
5759
return S_FALSE;
5860
}
59-
60-
if ((INT)wParam == IDYES)
61+
else if (buttonId == IDYES)
6162
{
6263
SHELLEXECUTEINFO info = { sizeof(SHELLEXECUTEINFO) };
6364

@@ -109,62 +110,81 @@ VOID ShowUpdateInstallDialog(
109110
config.dwFlags = TDF_USE_HICON_MAIN | TDF_ALLOW_DIALOG_CANCELLATION | TDF_CAN_BE_MINIMIZED;
110111
config.dwCommonButtons = TDCBF_CLOSE_BUTTON;
111112
config.hMainIcon = Context->IconLargeHandle;
113+
config.cxWidth = 200;
114+
config.pfCallback = FinalTaskDialogCallbackProc;
115+
config.lpCallbackData = (LONG_PTR)Context;
116+
config.pButtons = TaskDialogButtonArray;
117+
config.cButtons = ARRAYSIZE(TaskDialogButtonArray);
112118

113119
config.pszWindowTitle = L"Process Hacker - Updater";
114120
config.pszMainInstruction = L"Ready to install update";
115121
config.pszContent = L"The update has been successfully downloaded and verified.\r\n\r\nClick Install to continue.";
116122

117-
config.pButtons = TaskDialogButtonArray;
118-
config.cButtons = ARRAYSIZE(TaskDialogButtonArray);
119-
120-
config.cxWidth = 200;
121-
config.pfCallback = FinalTaskDialogCallbackProc;
122-
config.lpCallbackData = (LONG_PTR)Context;
123-
124123
SendMessage(Context->DialogHandle, TDM_NAVIGATE_PAGE, 0, (LPARAM)&config);
125124
}
126125

127126
VOID ShowLatestVersionDialog(
128127
_In_ PPH_UPDATER_CONTEXT Context
129128
)
130129
{
131-
PPH_UPDATER_CONTEXT context;
132130
TASKDIALOGCONFIG config;
133131

134-
context = (PPH_UPDATER_CONTEXT)Context;
135-
136132
memset(&config, 0, sizeof(TASKDIALOGCONFIG));
137133
config.cbSize = sizeof(TASKDIALOGCONFIG);
138134
config.dwFlags = TDF_USE_HICON_MAIN | TDF_ALLOW_DIALOG_CANCELLATION | TDF_CAN_BE_MINIMIZED | TDF_ENABLE_HYPERLINKS;
139135
config.dwCommonButtons = TDCBF_CLOSE_BUTTON;
140-
config.hMainIcon = context->IconLargeHandle;
136+
config.hMainIcon = Context->IconLargeHandle;
137+
config.cxWidth = 200;
138+
config.pfCallback = FinalTaskDialogCallbackProc;
139+
config.lpCallbackData = (LONG_PTR)Context;
141140

142141
config.pszWindowTitle = L"Process Hacker - Updater";
143142

144143
if (PhGetIntegerSetting(SETTING_NAME_NIGHTLY_BUILD))
145144
{
146-
config.pszMainInstruction = L"You're running the latest nightly build.";
145+
LARGE_INTEGER time;
146+
SYSTEMTIME systemTime = { 0 };
147+
SYSTEMTIME localTime = { 0 };
148+
PIMAGE_DOS_HEADER imageDosHeader;
149+
PIMAGE_NT_HEADERS imageNtHeader;
150+
151+
// HACK
152+
imageDosHeader = (PIMAGE_DOS_HEADER)PluginInstance->DllBase;
153+
imageNtHeader = (PIMAGE_NT_HEADERS)PTR_ADD_OFFSET(PluginInstance->DllBase, (ULONG)imageDosHeader->e_lfanew);
154+
155+
RtlSecondsSince1970ToTime(imageNtHeader->FileHeader.TimeDateStamp, &time);
156+
PhLargeIntegerToLocalSystemTime(&systemTime, &time);
157+
SystemTimeToTzSpecificLocalTime(NULL, &systemTime, &localTime);
158+
159+
config.pszMainInstruction = L"You're running the latest nightly build";
147160
config.pszContent = PhaFormatString(
148-
L"Alpha build: v%lu.%lu.%lu",
149-
context->CurrentMajorVersion,
150-
context->CurrentMinorVersion,
151-
context->CurrentRevisionVersion
161+
L"Version: v%lu.%lu.%lu\r\nCompiled: %s",
162+
Context->CurrentMajorVersion,
163+
Context->CurrentMinorVersion,
164+
Context->CurrentRevisionVersion,
165+
PhaFormatDateTime(&localTime)->Buffer
152166
)->Buffer;
167+
168+
if (PhIsNullOrEmptyString(Context->BuildMessage))
169+
config.pszExpandedInformation = L"<A HREF=\"executablestring\">View Changelog</A>";
170+
else
171+
config.pszExpandedInformation = PhGetStringOrEmpty(Context->BuildMessage);
153172
}
154173
else
155174
{
156-
config.pszMainInstruction = L"You're running the latest version.";
175+
config.pszMainInstruction = L"You're running the latest version";
157176
config.pszContent = PhaFormatString(
158-
L"Stable release build: v%lu.%lu.%lu\r\n\r\n<A HREF=\"executablestring\">View Changelog</A>",
159-
context->CurrentMajorVersion,
160-
context->CurrentMinorVersion,
161-
context->CurrentRevisionVersion
177+
L"Stable release build: v%lu.%lu.%lu\r\n\r\n",
178+
Context->CurrentMajorVersion,
179+
Context->CurrentMinorVersion,
180+
Context->CurrentRevisionVersion
162181
)->Buffer;
163-
}
164182

165-
config.cxWidth = 200;
166-
config.pfCallback = FinalTaskDialogCallbackProc;
167-
config.lpCallbackData = (LONG_PTR)Context;
183+
if (PhIsNullOrEmptyString(Context->BuildMessage))
184+
config.pszExpandedInformation = L"<A HREF=\"executablestring\">View Changelog</A>";
185+
else
186+
config.pszExpandedInformation = PhGetStringOrEmpty(Context->BuildMessage);
187+
}
168188

169189
SendMessage(Context->DialogHandle, TDM_NAVIGATE_PAGE, 0, (LPARAM)&config);
170190
}
@@ -173,16 +193,13 @@ VOID ShowNewerVersionDialog(
173193
_In_ PPH_UPDATER_CONTEXT Context
174194
)
175195
{
176-
PPH_UPDATER_CONTEXT context;
177196
TASKDIALOGCONFIG config;
178197

179-
context = (PPH_UPDATER_CONTEXT)Context;
180-
181198
memset(&config, 0, sizeof(TASKDIALOGCONFIG));
182199
config.cbSize = sizeof(TASKDIALOGCONFIG);
183200
config.dwFlags = TDF_USE_HICON_MAIN | TDF_ALLOW_DIALOG_CANCELLATION | TDF_CAN_BE_MINIMIZED;
184201
config.dwCommonButtons = TDCBF_CLOSE_BUTTON;
185-
config.hMainIcon = context->IconLargeHandle;
202+
config.hMainIcon = Context->IconLargeHandle;
186203

187204
config.pszWindowTitle = L"Process Hacker - Updater";
188205

@@ -191,19 +208,19 @@ VOID ShowNewerVersionDialog(
191208
config.pszMainInstruction = L"You're running the latest nightly build";
192209
config.pszContent = PhaFormatString(
193210
L"Pre-release build: v%lu.%lu.%lu\r\n",
194-
context->CurrentMajorVersion,
195-
context->CurrentMinorVersion,
196-
context->CurrentRevisionVersion
211+
Context->CurrentMajorVersion,
212+
Context->CurrentMinorVersion,
213+
Context->CurrentRevisionVersion
197214
)->Buffer;
198215
}
199216
else
200217
{
201218
config.pszMainInstruction = L"You're running a pre-release version!";
202219
config.pszContent = PhaFormatString(
203220
L"Pre-release build: v%lu.%lu.%lu\r\n",
204-
context->CurrentMajorVersion,
205-
context->CurrentMinorVersion,
206-
context->CurrentRevisionVersion
221+
Context->CurrentMajorVersion,
222+
Context->CurrentMinorVersion,
223+
Context->CurrentRevisionVersion
207224
)->Buffer;
208225
}
209226

plugins/Updater/updater.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,7 @@ NTSTATUS UpdateDownloadThread(
927927
}
928928

929929
// Initialize hash algorithm.
930-
if (!UpdaterInitializeHash(&hashContext))
930+
if (!(hashContext = UpdaterInitializeHash()))
931931
goto CleanupExit;
932932

933933
// Zero the buffer.
@@ -1001,8 +1001,6 @@ NTSTATUS UpdateDownloadThread(
10011001
}
10021002
}
10031003

1004-
downloadSuccess = TRUE;
1005-
10061004
if (UpdaterVerifyHash(hashContext, context->Hash))
10071005
{
10081006
hashSuccess = TRUE;
@@ -1012,6 +1010,11 @@ NTSTATUS UpdateDownloadThread(
10121010
{
10131011
signatureSuccess = TRUE;
10141012
}
1013+
1014+
if (hashSuccess && signatureSuccess)
1015+
{
1016+
downloadSuccess = TRUE;
1017+
}
10151018
}
10161019

10171020
CleanupExit:

plugins/Updater/updater.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,8 @@ typedef struct _UPDATER_HASH_CONTEXT
192192
PVOID Hash;
193193
} UPDATER_HASH_CONTEXT, *PUPDATER_HASH_CONTEXT;
194194

195-
BOOLEAN UpdaterInitializeHash(
196-
_Out_ PUPDATER_HASH_CONTEXT *Context
195+
PUPDATER_HASH_CONTEXT UpdaterInitializeHash(
196+
VOID
197197
);
198198

199199
BOOLEAN UpdaterUpdateHash(

0 commit comments

Comments
 (0)