Skip to content

Commit 30c2378

Browse files
committed
Fix service properties null configuration compatibility
1 parent c44b9b3 commit 30c2378

File tree

1 file changed

+15
-23
lines changed

1 file changed

+15
-23
lines changed

ProcessHacker/srvprp.c

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -413,10 +413,10 @@ INT_PTR CALLBACK PhpServiceGeneralDlgProc(
413413
ULONG newServiceType;
414414
ULONG newServiceStartType;
415415
ULONG newServiceErrorControl;
416-
PPH_STRING newServiceGroup;
417-
PPH_STRING newServiceBinaryPath;
418-
PPH_STRING newServiceUserAccount;
419-
PPH_STRING newServicePassword;
416+
PPH_STRING newServiceGroup = NULL;
417+
PPH_STRING newServiceBinaryPath = NULL;
418+
PPH_STRING newServiceUserAccount = NULL;
419+
PPH_STRING newServicePassword = NULL;
420420

421421
SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, PSNRET_NOERROR);
422422

@@ -432,23 +432,15 @@ INT_PTR CALLBACK PhpServiceGeneralDlgProc(
432432
newServiceStartType = PhGetServiceStartTypeInteger(newServiceStartTypeString->Buffer);
433433
newServiceErrorControl = PhGetServiceErrorControlInteger(newServiceErrorControlString->Buffer);
434434

435-
newServiceGroup = PH_AUTO(PhGetWindowText(GetDlgItem(hwndDlg, IDC_GROUP)));
436-
newServiceBinaryPath = PH_AUTO(PhGetWindowText(GetDlgItem(hwndDlg, IDC_BINARYPATH)));
437-
newServiceUserAccount = PH_AUTO(PhGetWindowText(GetDlgItem(hwndDlg, IDC_USERACCOUNT)));
438-
435+
if (GetWindowTextLength(GetDlgItem(hwndDlg, IDC_GROUP)))
436+
newServiceGroup = PH_AUTO(PhGetWindowText(GetDlgItem(hwndDlg, IDC_GROUP)));
437+
if (GetWindowTextLength(GetDlgItem(hwndDlg, IDC_BINARYPATH)))
438+
newServiceBinaryPath = PH_AUTO(PhGetWindowText(GetDlgItem(hwndDlg, IDC_BINARYPATH)));
439+
if (GetWindowTextLength(GetDlgItem(hwndDlg, IDC_USERACCOUNT)))
440+
newServiceUserAccount = PH_AUTO(PhGetWindowText(GetDlgItem(hwndDlg, IDC_USERACCOUNT)));
441+
439442
if (Button_GetCheck(GetDlgItem(hwndDlg, IDC_PASSWORDCHECK)) == BST_CHECKED)
440-
{
441443
newServicePassword = PhGetWindowText(GetDlgItem(hwndDlg, IDC_PASSWORD));
442-
}
443-
else
444-
{
445-
newServicePassword = NULL;
446-
}
447-
448-
if (newServiceType == SERVICE_KERNEL_DRIVER && newServiceUserAccount->Length == 0)
449-
{
450-
newServiceUserAccount = NULL;
451-
}
452444

453445
serviceHandle = PhOpenService(serviceItem->Name->Buffer, SERVICE_CHANGE_CONFIG);
454446

@@ -459,8 +451,8 @@ INT_PTR CALLBACK PhpServiceGeneralDlgProc(
459451
newServiceType,
460452
newServiceStartType,
461453
newServiceErrorControl,
462-
newServiceBinaryPath->Buffer,
463-
newServiceGroup->Buffer,
454+
PhGetString(newServiceBinaryPath),
455+
PhGetString(newServiceGroup),
464456
NULL,
465457
NULL,
466458
PhGetString(newServiceUserAccount),
@@ -502,8 +494,8 @@ INT_PTR CALLBACK PhpServiceGeneralDlgProc(
502494
newServiceType,
503495
newServiceStartType,
504496
newServiceErrorControl,
505-
newServiceBinaryPath->Buffer,
506-
newServiceGroup->Buffer,
497+
PhGetString(newServiceBinaryPath),
498+
PhGetString(newServiceGroup),
507499
NULL,
508500
NULL,
509501
PhGetString(newServiceUserAccount),

0 commit comments

Comments
 (0)