Skip to content

Commit

Permalink
Create resolver thread by NtCreateThreadEx
Browse files Browse the repository at this point in the history
  • Loading branch information
DartVanya committed Sep 16, 2024
1 parent d01f1be commit 9d5e5b6
Showing 1 changed file with 57 additions and 6 deletions.
63 changes: 57 additions & 6 deletions plugins/ExtendedTools/objmgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ VOID NTAPI EtpObjectManagerSearchControlCallback(
_In_opt_ PVOID Context
);

NTSTATUS NTAPI EtpStartResolverThread(
POBJECT_CONTEXT Context
);

_Success_(return)
BOOLEAN PhGetTreeViewItemParam(
_In_ HWND TreeViewHandle,
Expand Down Expand Up @@ -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
)
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
{
Expand Down

0 comments on commit 9d5e5b6

Please sign in to comment.