Skip to content

Commit

Permalink
fix section resolving
Browse files Browse the repository at this point in the history
  • Loading branch information
DartVanya committed Nov 23, 2024
1 parent 42594b6 commit 932b6aa
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 33 deletions.
10 changes: 7 additions & 3 deletions plugins/ExtendedTools/objmgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -790,13 +790,14 @@ NTSTATUS EtpTargetResolverThreadStart(
if (curentFilter)
PhDereferenceObject(curentFilter);

//ExtendedListView_SetColumnWidth(context->ListViewHandle, 0, ELVSCW_AUTOSIZE_REMAININGSPACE);

context->BreakResolverThread = NULL;
status = STATUS_SUCCESS;
}
else
{
if (status == STATUS_NOT_ALL_ASSIGNED)
status = STATUS_ABANDONED;
}

PhFree(threadContext);
return status;
Expand Down Expand Up @@ -1047,7 +1048,7 @@ NTSTATUS EtpTargetResolverWorkThreadStart(
PPH_STRING newFileName;
SECTION_BASIC_INFORMATION basicInfo;

if (NT_SUCCESS(PhGetSectionFileName(objectHandle, &fileName)))
if (NT_SUCCESS(status = PhGetSectionFileName(objectHandle, &fileName)))
{
if (newFileName = PhResolveDevicePrefix(&fileName->sr))
PhMoveReference(&fileName, newFileName);
Expand Down Expand Up @@ -2506,7 +2507,10 @@ VOID EtpObjectManagerCopyObjectAddress(
PPH_HANDLE_ITEM handleItem;

if (status == STATUS_NOT_ALL_ASSIGNED)
{
NtClose(objectHandle);
return;
}

if (processId != NtCurrentProcessId())
{
Expand Down
60 changes: 30 additions & 30 deletions plugins/ExtendedTools/objprp.c
Original file line number Diff line number Diff line change
Expand Up @@ -416,33 +416,37 @@ VOID EtHandlePropertiesWindowInitialized(
}
}
}
else if (((ULONG_PTR)context->OwnerPlugin == ((ULONG_PTR)PluginInstance | OBJECT_CHILD_HANDLEPROP_WINDOW)) &&
!PhIsNullOrEmptyString(context->HandleItem->ObjectName) &&
!PhEqualString(context->HandleItem->ObjectName, context->HandleItem->BestObjectName, TRUE))
else if (((ULONG_PTR)context->OwnerPlugin == ((ULONG_PTR)PluginInstance | OBJECT_CHILD_HANDLEPROP_WINDOW)))
{
// I don't know why new row always appending in the back. This stupid full rebuild of section only one workaround
PPH_STRING accessString = PH_AUTO(PhGetListViewItemText(context->ListViewHandle, context->ListViewRowCache[PH_PLUGIN_HANDLE_GENERAL_INDEX_ACCESSMASK], 1));
PhRemoveListViewItem(context->ListViewHandle, context->ListViewRowCache[PH_PLUGIN_HANDLE_GENERAL_INDEX_ACCESSMASK]);
PhRemoveListViewItem(context->ListViewHandle, context->ListViewRowCache[PH_PLUGIN_HANDLE_GENERAL_INDEX_OBJECT]);
PhRemoveListViewItem(context->ListViewHandle, context->ListViewRowCache[PH_PLUGIN_HANDLE_GENERAL_INDEX_TYPE]);
PhRemoveListViewItem(context->ListViewHandle, context->ListViewRowCache[PH_PLUGIN_HANDLE_GENERAL_INDEX_NAME]);

context->ListViewRowCache[PH_PLUGIN_HANDLE_GENERAL_INDEX_NAME] = PhAddListViewGroupItem(context->ListViewHandle,
PH_PLUGIN_HANDLE_GENERAL_CATEGORY_BASICINFO, 0, L"Name", NULL);
INT origNameIndex = PhAddListViewGroupItem(context->ListViewHandle,
PH_PLUGIN_HANDLE_GENERAL_CATEGORY_BASICINFO, 1, L"Original name", NULL);
context->ListViewRowCache[PH_PLUGIN_HANDLE_GENERAL_INDEX_TYPE] = PhAddListViewGroupItem(context->ListViewHandle,
PH_PLUGIN_HANDLE_GENERAL_CATEGORY_BASICINFO, 2, L"Type", NULL);
context->ListViewRowCache[PH_PLUGIN_HANDLE_GENERAL_INDEX_OBJECT] = PhAddListViewGroupItem(context->ListViewHandle,
PH_PLUGIN_HANDLE_GENERAL_CATEGORY_BASICINFO, 3, L"Object address", NULL);
context->ListViewRowCache[PH_PLUGIN_HANDLE_GENERAL_INDEX_ACCESSMASK] = PhAddListViewGroupItem(context->ListViewHandle,
PH_PLUGIN_HANDLE_GENERAL_CATEGORY_BASICINFO, 4, L"Granted access", NULL);

PhSetListViewSubItem(context->ListViewHandle, context->ListViewRowCache[PH_PLUGIN_HANDLE_GENERAL_INDEX_NAME], 1, PhGetString(context->HandleItem->BestObjectName));
PhSetListViewSubItem(context->ListViewHandle, origNameIndex, 1, PhGetString(context->HandleItem->ObjectName));
PhSetListViewSubItem(context->ListViewHandle, context->ListViewRowCache[PH_PLUGIN_HANDLE_GENERAL_INDEX_TYPE], 1, PhGetString(context->HandleItem->TypeName));
PhSetListViewSubItem(context->ListViewHandle, context->ListViewRowCache[PH_PLUGIN_HANDLE_GENERAL_INDEX_OBJECT], 1, context->HandleItem->ObjectString);
PhSetListViewSubItem(context->ListViewHandle, context->ListViewRowCache[PH_PLUGIN_HANDLE_GENERAL_INDEX_ACCESSMASK], 1, PhGetString(accessString));
PhRemoveListViewItem(context->ListViewHandle, PH_PLUGIN_HANDLE_GENERAL_INDEX_HANDLE_REFERENCES);

if (!PhIsNullOrEmptyString(context->HandleItem->ObjectName) &&
!PhEqualString(context->HandleItem->ObjectName, context->HandleItem->BestObjectName, TRUE))
{
// I don't know why new row always appending in the back. This stupid full rebuild of section only one workaround
PPH_STRING accessString = PH_AUTO(PhGetListViewItemText(context->ListViewHandle, context->ListViewRowCache[PH_PLUGIN_HANDLE_GENERAL_INDEX_ACCESSMASK], 1));
PhRemoveListViewItem(context->ListViewHandle, context->ListViewRowCache[PH_PLUGIN_HANDLE_GENERAL_INDEX_ACCESSMASK]);
PhRemoveListViewItem(context->ListViewHandle, context->ListViewRowCache[PH_PLUGIN_HANDLE_GENERAL_INDEX_OBJECT]);
PhRemoveListViewItem(context->ListViewHandle, context->ListViewRowCache[PH_PLUGIN_HANDLE_GENERAL_INDEX_TYPE]);
PhRemoveListViewItem(context->ListViewHandle, context->ListViewRowCache[PH_PLUGIN_HANDLE_GENERAL_INDEX_NAME]);

context->ListViewRowCache[PH_PLUGIN_HANDLE_GENERAL_INDEX_NAME] = PhAddListViewGroupItem(context->ListViewHandle,
PH_PLUGIN_HANDLE_GENERAL_CATEGORY_BASICINFO, 0, L"Name", NULL);
INT origNameIndex = PhAddListViewGroupItem(context->ListViewHandle,
PH_PLUGIN_HANDLE_GENERAL_CATEGORY_BASICINFO, 1, L"Original name", NULL);
context->ListViewRowCache[PH_PLUGIN_HANDLE_GENERAL_INDEX_TYPE] = PhAddListViewGroupItem(context->ListViewHandle,
PH_PLUGIN_HANDLE_GENERAL_CATEGORY_BASICINFO, 2, L"Type", NULL);
context->ListViewRowCache[PH_PLUGIN_HANDLE_GENERAL_INDEX_OBJECT] = PhAddListViewGroupItem(context->ListViewHandle,
PH_PLUGIN_HANDLE_GENERAL_CATEGORY_BASICINFO, 3, L"Object address", NULL);
context->ListViewRowCache[PH_PLUGIN_HANDLE_GENERAL_INDEX_ACCESSMASK] = PhAddListViewGroupItem(context->ListViewHandle,
PH_PLUGIN_HANDLE_GENERAL_CATEGORY_BASICINFO, 4, L"Granted access", NULL);

PhSetListViewSubItem(context->ListViewHandle, context->ListViewRowCache[PH_PLUGIN_HANDLE_GENERAL_INDEX_NAME], 1, PhGetString(context->HandleItem->BestObjectName));
PhSetListViewSubItem(context->ListViewHandle, origNameIndex, 1, PhGetString(context->HandleItem->ObjectName));
PhSetListViewSubItem(context->ListViewHandle, context->ListViewRowCache[PH_PLUGIN_HANDLE_GENERAL_INDEX_TYPE], 1, PhGetString(context->HandleItem->TypeName));
PhSetListViewSubItem(context->ListViewHandle, context->ListViewRowCache[PH_PLUGIN_HANDLE_GENERAL_INDEX_OBJECT], 1, context->HandleItem->ObjectString);
PhSetListViewSubItem(context->ListViewHandle, context->ListViewRowCache[PH_PLUGIN_HANDLE_GENERAL_INDEX_ACCESSMASK], 1, PhGetString(accessString));
}
}

// General ET plugin extensions
Expand Down Expand Up @@ -1459,8 +1463,6 @@ VOID EtUpdateHandleItem(

if (PhIsNullOrEmptyString(HandleItem->TypeName))
HandleItem->TypeName = PhGetObjectTypeIndexName(HandleItem->TypeIndex);

HandleItem->RefCnt = ULONG_MAX;
}

VOID EtpShowHandleProperties(
Expand Down Expand Up @@ -1580,8 +1582,6 @@ static NTSTATUS EtpProcessHandleOpenCallback(
{
PHANDLE_OPEN_CONTEXT context = Context;

*Handle = NULL;

return EtDuplicateHandleFromProcessEx(Handle, DesiredAccess, context->ProcessId, NULL, context->HandleItem->Handle);
}

Expand Down

0 comments on commit 932b6aa

Please sign in to comment.