From 9d5e5b60d6dc10b5a18f3628c625e141a9f81aaf Mon Sep 17 00:00:00 2001 From: Dart Vanya Date: Mon, 16 Sep 2024 06:26:16 +0300 Subject: [PATCH] Create resolver thread by NtCreateThreadEx --- plugins/ExtendedTools/objmgr.c | 63 ++++++++++++++++++++++++++++++---- 1 file changed, 57 insertions(+), 6 deletions(-) diff --git a/plugins/ExtendedTools/objmgr.c b/plugins/ExtendedTools/objmgr.c index 4efba25c5b45..915c88b0d19e 100644 --- a/plugins/ExtendedTools/objmgr.c +++ b/plugins/ExtendedTools/objmgr.c @@ -110,6 +110,10 @@ VOID NTAPI EtpObjectManagerSearchControlCallback( _In_opt_ PVOID Context ); +NTSTATUS NTAPI EtpStartResolverThread( + POBJECT_CONTEXT Context + ); + _Success_(return) BOOLEAN PhGetTreeViewItemParam( _In_ HWND TreeViewHandle, @@ -838,11 +842,44 @@ NTSTATUS EtEnumCurrentDirectoryObjects( if (SortOrder != NoSortOrder) ExtendedListView_SortItems(Context->ListViewHandle); - PhCreateThreadEx(&Context->TargetResolverThread, PhpTargetResolverThreadStart, Context); + //PhCreateThreadEx(&Context->TargetResolverThread, PhpTargetResolverThreadStart, Context); + + EtpStartResolverThread(Context); return STATUS_SUCCESS; } +NTSTATUS NTAPI EtpStartResolverThread( + POBJECT_CONTEXT Context +) +{ + OBJECT_ATTRIBUTES objectAttributes; + UCHAR buffer[FIELD_OFFSET(PS_ATTRIBUTE_LIST, Attributes) + sizeof(PS_ATTRIBUTE[1])] = { 0 }; + PPS_ATTRIBUTE_LIST attributeList = (PPS_ATTRIBUTE_LIST)buffer; + CLIENT_ID clientId = { 0 }; + + InitializeObjectAttributes(&objectAttributes, NULL, 0, NULL, NULL); + attributeList->TotalLength = sizeof(buffer); + attributeList->Attributes[0].Attribute = PS_ATTRIBUTE_CLIENT_ID; + attributeList->Attributes[0].Size = sizeof(CLIENT_ID); + attributeList->Attributes[0].ValuePtr = &clientId; + attributeList->Attributes[0].ReturnLength = NULL; + + return NtCreateThreadEx( + &Context->TargetResolverThread, + THREAD_ALL_ACCESS, + &objectAttributes, + NtCurrentProcess(), + PhpTargetResolverThreadStart, + Context, + 0, + 0, + 0, + 0, + attributeList + ); +} + VOID EtObjectManagerFreeListViewItems( _In_ POBJECT_CONTEXT Context ) @@ -1831,10 +1868,17 @@ INT_PTR CALLBACK WinObjDlgProc( if (entry = PhGetSelectedListViewItemParam(context->ListViewHandle)) { - if (entry->typeIndex == ET_OBJECT_SYMLINK && GetKeyState(VK_SHIFT) > 0) + if (entry->typeIndex == ET_OBJECT_SYMLINK && !(GetKeyState(VK_SHIFT) < 0)) { - PhSetWindowText(context->SearchBoxHandle, NULL); - EtpObjectManagerOpenTarget(hwndDlg, context, entry); + if (PhStartsWithString2(entry->Target, L"C:\\", TRUE)) + { + PhShellExecute(hwndDlg, entry->Target->Buffer, NULL); + } + else + { + PhSetWindowText(context->SearchBoxHandle, NULL); + EtpObjectManagerOpenTarget(hwndDlg, context, entry); + } } else EtpObjectManagerObjectProperties(hwndDlg, context, entry); @@ -1915,9 +1959,16 @@ INT_PTR CALLBACK WinObjDlgProc( if (isSymlink && id == 1) { - PhSetWindowText(context->SearchBoxHandle, NULL); + if (PhStartsWithString2(entry->Target, L"C:\\", TRUE)) + { + PhShellExecute(hwndDlg, entry->Target->Buffer, NULL); + } + else + { + PhSetWindowText(context->SearchBoxHandle, NULL); - EtpObjectManagerOpenTarget(hwndDlg, context, entry); + EtpObjectManagerOpenTarget(hwndDlg, context, entry); + } } else if (isDevice && id == 2) {