Add filename fallback #2478
This commit is contained in:
@@ -475,4 +475,9 @@ PhDuplicateProcessNodeList(
|
||||
);
|
||||
// end_phapppub
|
||||
|
||||
NTSTATUS PhGetProcessItemFileNameWin32(
|
||||
_In_ PPH_PROCESS_ITEM ProcessItem,
|
||||
_Out_ PPH_STRING *FileNameWin32
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -783,7 +783,7 @@ PPH_STRING PhGetServiceTooltipText(
|
||||
|
||||
// File information
|
||||
|
||||
if (fileName = PhGetServiceHandleFileName(serviceHandle, &Service->Name->sr))
|
||||
if (NT_SUCCESS(PhGetServiceHandleFileName(serviceHandle, &Service->Name->sr, &fileName)))
|
||||
{
|
||||
PH_IMAGE_VERSION_INFO versionInfo;
|
||||
PPH_STRING versionInfoText;
|
||||
|
||||
+39
-19
@@ -1972,22 +1972,26 @@ VOID PhMwpOnCommand(
|
||||
|
||||
if (processItem)
|
||||
{
|
||||
if (
|
||||
!PhIsNullOrEmptyString(processItem->FileName) &&
|
||||
PhDoesFileExist(&processItem->FileName->sr)
|
||||
)
|
||||
NTSTATUS status;
|
||||
PPH_STRING fileName;
|
||||
|
||||
status = PhGetProcessItemFileNameWin32(processItem, &fileName);
|
||||
|
||||
if (NT_SUCCESS(status))
|
||||
{
|
||||
PhShellExecuteUserString(
|
||||
WindowHandle,
|
||||
L"FileBrowseExecutable",
|
||||
PhGetString(processItem->FileName),
|
||||
PhGetString(fileName),
|
||||
FALSE,
|
||||
L"Make sure the Explorer executable file is present."
|
||||
);
|
||||
|
||||
PhDereferenceObject(fileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
PhShowStatus(WindowHandle, L"Unable to locate the file.", STATUS_NOT_FOUND, 0);
|
||||
PhShowStatus(WindowHandle, L"Unable to locate the file.", status, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2142,25 +2146,41 @@ VOID PhMwpOnCommand(
|
||||
case ID_SERVICE_OPENFILELOCATION:
|
||||
{
|
||||
PPH_SERVICE_ITEM serviceItem = PhGetSelectedServiceItem();
|
||||
NTSTATUS status;
|
||||
SC_HANDLE serviceHandle;
|
||||
|
||||
if (serviceItem && NT_SUCCESS(PhOpenService(&serviceHandle, SERVICE_QUERY_CONFIG, PhGetString(serviceItem->Name))))
|
||||
if (serviceItem)
|
||||
{
|
||||
PPH_STRING fileName;
|
||||
status = PhOpenService(&serviceHandle, SERVICE_QUERY_CONFIG, PhGetString(serviceItem->Name));
|
||||
|
||||
if (fileName = PhGetServiceHandleFileName(serviceHandle, &serviceItem->Name->sr))
|
||||
if (NT_SUCCESS(status))
|
||||
{
|
||||
PhShellExecuteUserString(
|
||||
WindowHandle,
|
||||
L"FileBrowseExecutable",
|
||||
fileName->Buffer,
|
||||
FALSE,
|
||||
L"Make sure the Explorer executable file is present."
|
||||
);
|
||||
PhDereferenceObject(fileName);
|
||||
}
|
||||
PPH_STRING fileName;
|
||||
|
||||
PhCloseServiceHandle(serviceHandle);
|
||||
status = PhGetServiceHandleFileName(serviceHandle, &serviceItem->Name->sr, &fileName);
|
||||
|
||||
if (NT_SUCCESS(status))
|
||||
{
|
||||
PhShellExecuteUserString(
|
||||
WindowHandle,
|
||||
L"FileBrowseExecutable",
|
||||
fileName->Buffer,
|
||||
FALSE,
|
||||
L"Make sure the Explorer executable file is present."
|
||||
);
|
||||
PhDereferenceObject(fileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
PhShowStatus(WindowHandle, L"Unable to locate the file.", status, 0);
|
||||
}
|
||||
|
||||
PhCloseServiceHandle(serviceHandle);
|
||||
}
|
||||
else
|
||||
{
|
||||
PhShowStatus(WindowHandle, L"Unable to locate the file.", status, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -5900,3 +5900,28 @@ BOOLEAN PhpShouldShowImageCoherency(
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
NTSTATUS PhGetProcessItemFileNameWin32(
|
||||
_In_ PPH_PROCESS_ITEM ProcessItem,
|
||||
_Out_ PPH_STRING* FileNameWin32
|
||||
)
|
||||
{
|
||||
if (ProcessItem->QueryHandle)
|
||||
{
|
||||
PPH_STRING fileName;
|
||||
|
||||
if (NT_SUCCESS(PhGetProcessImageFileNameWin32(ProcessItem->QueryHandle, &fileName)))
|
||||
{
|
||||
*FileNameWin32 = fileName;
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
if (ProcessItem->FileName)
|
||||
{
|
||||
*FileNameWin32 = PhGetFileName(ProcessItem->FileName);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
|
||||
+30
-14
@@ -239,7 +239,7 @@ INT_PTR CALLBACK PhpServicesPageProc(
|
||||
{
|
||||
PPH_STRING fileName;
|
||||
|
||||
if (fileName = PhGetServiceHandleFileName(serviceHandle, &serviceItem->Name->sr))
|
||||
if (NT_SUCCESS(PhGetServiceHandleFileName(serviceHandle, &serviceItem->Name->sr, &fileName)))
|
||||
{
|
||||
PhSetListViewSubItem(context->ListViewHandle, lvItemIndex, 2, PhGetStringOrEmpty(fileName));
|
||||
PhDereferenceObject(fileName);
|
||||
@@ -596,25 +596,41 @@ INT_PTR CALLBACK PhpServicesPageProc(
|
||||
case ID_SERVICE_OPENFILELOCATION:
|
||||
{
|
||||
PPH_SERVICE_ITEM serviceItem = (PPH_SERVICE_ITEM)listviewItems[0];
|
||||
NTSTATUS status;
|
||||
SC_HANDLE serviceHandle;
|
||||
|
||||
if (serviceItem && NT_SUCCESS(PhOpenService(&serviceHandle, SERVICE_QUERY_CONFIG, PhGetString(serviceItem->Name))))
|
||||
if (serviceItem)
|
||||
{
|
||||
PPH_STRING fileName;
|
||||
status = PhOpenService(&serviceHandle, SERVICE_QUERY_CONFIG, PhGetString(serviceItem->Name));
|
||||
|
||||
if (fileName = PhGetServiceHandleFileName(serviceHandle, &serviceItem->Name->sr))
|
||||
if (NT_SUCCESS(status))
|
||||
{
|
||||
PhShellExecuteUserString(
|
||||
hwndDlg,
|
||||
L"FileBrowseExecutable",
|
||||
fileName->Buffer,
|
||||
FALSE,
|
||||
L"Make sure the Explorer executable file is present."
|
||||
);
|
||||
PhDereferenceObject(fileName);
|
||||
}
|
||||
PPH_STRING fileName;
|
||||
|
||||
PhCloseServiceHandle(serviceHandle);
|
||||
status = PhGetServiceHandleFileName(serviceHandle, &serviceItem->Name->sr, &fileName);
|
||||
|
||||
if (NT_SUCCESS(status))
|
||||
{
|
||||
PhShellExecuteUserString(
|
||||
hwndDlg,
|
||||
L"FileBrowseExecutable",
|
||||
PhGetString(fileName),
|
||||
FALSE,
|
||||
L"Make sure the Explorer executable file is present."
|
||||
);
|
||||
PhDereferenceObject(fileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
PhShowStatus(hwndDlg, L"Unable to locate the file.", status, 0);
|
||||
}
|
||||
|
||||
PhCloseServiceHandle(serviceHandle);
|
||||
}
|
||||
else
|
||||
{
|
||||
PhShowStatus(hwndDlg, L"Unable to locate the file.", status, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -367,11 +367,12 @@ PhGetServiceConfigFileName(
|
||||
);
|
||||
|
||||
PHLIBAPI
|
||||
PPH_STRING
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
PhGetServiceHandleFileName(
|
||||
_In_ SC_HANDLE ServiceHandle,
|
||||
_In_ PPH_STRINGREF ServiceName
|
||||
_In_ PPH_STRINGREF ServiceName,
|
||||
_Out_ PPH_STRING* ServiceFileName
|
||||
);
|
||||
|
||||
PHLIBAPI
|
||||
|
||||
Reference in New Issue
Block a user