Skip to content

Commit 5f13f5f

Browse files
committed
Plugins: Fix dialog error checking
1 parent 69d9dcd commit 5f13f5f

File tree

6 files changed

+63
-29
lines changed

6 files changed

+63
-29
lines changed

plugins/ExtraPlugins/cloud.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -364,22 +364,19 @@ NTSTATUS QueryPluginsCallbackThread(
364364

365365
if (currentVersion < latestVersion)
366366
{
367-
// User is running an older version
368367
entry->State = PLUGIN_STATE_UPDATE;
369368
PostMessage(context->DialogHandle, ID_UPDATE_ADD, 0, (LPARAM)entry);
370369
}
371370
}
372371
else
373372
{
374-
// Plugin waiting to load?
375373
entry->State = PLUGIN_STATE_RESTART;
376374
PostMessage(context->DialogHandle, ID_UPDATE_ADD, 0, (LPARAM)entry);
377375
}
378376
}
379377
else
380-
{
381-
// New plugin available for download
382-
entry->State = PLUGIN_STATE_REMOTE;
378+
{
379+
entry->State = PLUGIN_STATE_REMOTE;
383380
PostMessage(context->DialogHandle, ID_UPDATE_ADD, 0, (LPARAM)entry);
384381
}
385382
}

plugins/ExtraPlugins/dialog.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ INT_PTR CALLBACK CloudPluginsDlgProc(
253253

254254
PhCenterWindow(hwndDlg, PhMainWndHandle);
255255
InitializePluginsTree(context, hwndDlg, context->TreeNewHandle);
256-
PhAddTreeNewFilter(GetPluginListFilterSupport(context), (PPH_TN_FILTER_FUNCTION)ProcessTreeFilterCallback, context);
256+
PhAddTreeNewFilter(GetPluginListFilterSupport(context), ProcessTreeFilterCallback, context);
257257

258258
PhInitializeLayoutManager(&context->LayoutManager, hwndDlg);
259259
PhAddLayoutItem(&context->LayoutManager, context->TreeNewHandle, NULL, PH_ANCHOR_ALL);
@@ -264,7 +264,7 @@ INT_PTR CALLBACK CloudPluginsDlgProc(
264264
PhLoadWindowPlacementFromSetting(SETTING_NAME_WINDOW_POSITION, SETTING_NAME_WINDOW_SIZE, hwndDlg);
265265

266266
EnumerateLoadedPlugins(context);
267-
SetWindowText(GetDlgItem(hwndDlg, IDC_DISABLED), PhGetString(PhaFormatString(L"Disabled Plugins (%lu)", PhDisabledPluginsCount())));
267+
SetWindowText(GetDlgItem(hwndDlg, IDC_DISABLED), PhaFormatString(L"Disabled Plugins (%lu)", PhDisabledPluginsCount())->Buffer);
268268
PhQueueItemWorkQueue(PhGetGlobalWorkQueue(), QueryPluginsCallbackThread, context);
269269
UpdateTreeView(context);
270270

@@ -627,9 +627,12 @@ INT_PTR CALLBACK CloudPluginsDlgProc(
627627
{
628628
PPLUGIN_NODE entry = (PPLUGIN_NODE)lParam;
629629

630-
PluginsAddTreeNode(context, entry);
630+
TreeNew_SetRedraw(context->TreeNewHandle, FALSE);
631631

632+
PluginsAddTreeNode(context, entry);
632633
UpdateTreeView(context);
634+
635+
TreeNew_SetRedraw(context->TreeNewHandle, TRUE);
633636
}
634637
break;
635638
case ID_UPDATE_COUNT:

plugins/ExtraPlugins/setup/page3.c

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,29 +39,15 @@ HRESULT CALLBACK ShowAvailableCallbackProc(
3939

4040
switch (uMsg)
4141
{
42-
case TDN_NAVIGATED:
43-
break;
4442
case TDN_BUTTON_CLICKED:
4543
{
4644
if ((INT)wParam == IDOK)
4745
{
48-
//if (UpdaterInstalledUsingSetup())
49-
{
50-
ShowProgressDialog(context);
51-
return S_FALSE;
52-
}
53-
//else
54-
{
55-
//PhShellExecute(hwndDlg, L"https://wj32.org/processhacker/downloads.php", NULL);
56-
}
46+
ShowProgressDialog(context);
47+
return S_FALSE;
5748
}
5849
}
5950
break;
60-
case TDN_HYPERLINK_CLICKED:
61-
{
62-
//TaskDialogLinkClicked(context);
63-
}
64-
break;
6551
}
6652

6753
return S_OK;
@@ -75,7 +61,7 @@ VOID ShowAvailableDialog(
7561

7662
memset(&config, 0, sizeof(TASKDIALOGCONFIG));
7763
config.cbSize = sizeof(TASKDIALOGCONFIG);
78-
config.dwFlags = TDF_USE_HICON_MAIN | TDF_ALLOW_DIALOG_CANCELLATION | TDF_CAN_BE_MINIMIZED | TDF_ENABLE_HYPERLINKS | TDF_SHOW_PROGRESS_BAR;
64+
config.dwFlags = TDF_USE_HICON_MAIN | TDF_ALLOW_DIALOG_CANCELLATION | TDF_CAN_BE_MINIMIZED | TDF_ENABLE_HYPERLINKS;
7965
config.dwCommonButtons = TDCBF_CANCEL_BUTTON;
8066
config.hMainIcon = Context->IconLargeHandle;
8167

plugins/Updater/page5.c

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ HRESULT CALLBACK FinalTaskDialogCallbackProc(
5555

5656
if (buttonId == IDRETRY)
5757
{
58-
ShowCheckingForUpdatesDialog(context);
58+
ShowCheckForUpdatesDialog(context);
5959
return S_FALSE;
6060
}
6161
else if (buttonId == IDYES)
@@ -244,7 +244,7 @@ VOID ShowUpdateFailedDialog(
244244
config.hMainIcon = Context->IconLargeHandle;
245245

246246
config.pszWindowTitle = L"Process Hacker - Updater";
247-
config.pszMainInstruction = L"Error while downloading the update";
247+
config.pszMainInstruction = L"Error downloading the update";
248248

249249
if (SignatureFailed)
250250
{
@@ -256,7 +256,34 @@ VOID ShowUpdateFailedDialog(
256256
}
257257
else
258258
{
259-
config.pszContent = L"Click Retry to download the update again.";
259+
if (Context->ErrorCode)
260+
{
261+
PPH_STRING message;
262+
263+
message = PhGetMessage(
264+
GetModuleHandle(L"winhttp.dll"),
265+
0xb,
266+
GetUserDefaultLangID(),
267+
Context->ErrorCode
268+
);
269+
270+
//if (PhIsNullOrEmptyString(message))
271+
// PhMoveReference(&message, PhGetNtMessage(Context->ErrorCode));
272+
273+
if (message)
274+
{
275+
config.pszContent = PhaFormatString(L"[%lu] %s", Context->ErrorCode, message->Buffer)->Buffer;
276+
PhDereferenceObject(message);
277+
}
278+
else
279+
{
280+
config.pszContent = L"Click Retry to download the update again.";
281+
}
282+
}
283+
else
284+
{
285+
config.pszContent = L"Click Retry to download the update again.";
286+
}
260287
}
261288

262289
config.cxWidth = 200;

plugins/Updater/updater.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ BOOLEAN QueryUpdateData(
344344
0
345345
)))
346346
{
347+
Context->ErrorCode = GetLastError();
347348
goto CleanupExit;
348349
}
349350

@@ -366,6 +367,7 @@ BOOLEAN QueryUpdateData(
366367
0
367368
)))
368369
{
370+
Context->ErrorCode = GetLastError();
369371
goto CleanupExit;
370372
}
371373

@@ -381,6 +383,7 @@ BOOLEAN QueryUpdateData(
381383
WINHTTP_FLAG_REFRESH | WINHTTP_FLAG_SECURE
382384
)))
383385
{
386+
Context->ErrorCode = GetLastError();
384387
goto CleanupExit;
385388
}
386389
}
@@ -396,6 +399,7 @@ BOOLEAN QueryUpdateData(
396399
WINHTTP_FLAG_REFRESH | WINHTTP_FLAG_SECURE
397400
)))
398401
{
402+
Context->ErrorCode = GetLastError();
399403
goto CleanupExit;
400404
}
401405
}
@@ -436,11 +440,15 @@ BOOLEAN QueryUpdateData(
436440
0
437441
))
438442
{
443+
Context->ErrorCode = GetLastError();
439444
goto CleanupExit;
440445
}
441446

442447
if (!WinHttpReceiveResponse(httpRequestHandle, NULL))
448+
{
449+
Context->ErrorCode = GetLastError();
443450
goto CleanupExit;
451+
}
444452

445453
if (!ReadRequestString(httpRequestHandle, &stringBuffer, &stringBufferLength))
446454
goto CleanupExit;
@@ -625,6 +633,7 @@ NTSTATUS UpdateCheckThread(
625633
ULONGLONG latestVersion = 0;
626634

627635
context = (PPH_UPDATER_CONTEXT)Parameter;
636+
context->ErrorCode = STATUS_SUCCESS;
628637

629638
// Check if we have cached update data
630639
if (!context->HaveData)
@@ -798,6 +807,7 @@ NTSTATUS UpdateDownloadThread(
798807
&httpUrlComponents
799808
))
800809
{
810+
context->ErrorCode = GetLastError();
801811
goto CleanupExit;
802812
}
803813

@@ -831,6 +841,7 @@ NTSTATUS UpdateDownloadThread(
831841
0
832842
)))
833843
{
844+
context->ErrorCode = GetLastError();
834845
goto CleanupExit;
835846
}
836847

@@ -853,6 +864,7 @@ NTSTATUS UpdateDownloadThread(
853864
0
854865
)))
855866
{
867+
context->ErrorCode = GetLastError();
856868
goto CleanupExit;
857869
}
858870

@@ -866,6 +878,7 @@ NTSTATUS UpdateDownloadThread(
866878
WINHTTP_FLAG_REFRESH | (httpUrlComponents.nScheme == INTERNET_SCHEME_HTTPS ? WINHTTP_FLAG_SECURE : 0)
867879
)))
868880
{
881+
context->ErrorCode = GetLastError();
869882
goto CleanupExit;
870883
}
871884

@@ -887,12 +900,18 @@ NTSTATUS UpdateDownloadThread(
887900
0
888901
))
889902
{
903+
context->ErrorCode = GetLastError();
890904
goto CleanupExit;
891905
}
892906

893907
SendMessage(context->DialogHandle, TDM_UPDATE_ELEMENT_TEXT, TDE_MAIN_INSTRUCTION, (LPARAM)L"Waiting for response...");
894908

895-
if (WinHttpReceiveResponse(httpRequestHandle, NULL))
909+
if (!WinHttpReceiveResponse(httpRequestHandle, NULL))
910+
{
911+
context->ErrorCode = GetLastError();
912+
goto CleanupExit;
913+
}
914+
else
896915
{
897916
ULONG bytesDownloaded = 0;
898917
ULONG downloadedBytes = 0;
@@ -924,6 +943,7 @@ NTSTATUS UpdateDownloadThread(
924943
0
925944
))
926945
{
946+
context->ErrorCode = GetLastError();
927947
goto CleanupExit;
928948
}
929949

plugins/Updater/updater.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ typedef struct _PH_UPDATER_CONTEXT
8686

8787
HWND DialogHandle;
8888

89+
ULONG ErrorCode;
8990
ULONG MinorVersion;
9091
ULONG MajorVersion;
9192
ULONG RevisionVersion;

0 commit comments

Comments
 (0)