Skip to content

Commit

Permalink
Merge pull request #17 from processhacker/master
Browse files Browse the repository at this point in the history
[pull] master from processhacker:master
  • Loading branch information
pull[bot] authored Sep 25, 2020
2 parents 54e13f7 + 978baf1 commit 644abe0
Show file tree
Hide file tree
Showing 5 changed files with 845 additions and 78 deletions.
4 changes: 3 additions & 1 deletion ProcessHacker/ProcessHacker.rc
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,9 @@ STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSM
CAPTION "Advanced"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
CONTROL "",IDC_SETTINGS,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,7,7,303,211
EDITTEXT IDC_SEARCH,171,3,144,14,ES_AUTOHSCROLL
PUSHBUTTON "Options",IDC_FILTEROPTIONS,2,3,50,14
CONTROL "",IDC_SETTINGS,"PhTreeNew",WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_TABSTOP | 0xa,2,19,313,204,WS_EX_CLIENTEDGE
END

IDD_GDIHANDLES DIALOGEX 0, 0, 351, 307
Expand Down
41 changes: 34 additions & 7 deletions ProcessHacker/findobj.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#define WM_PH_SEARCH_FINISHED (WM_APP + 802)
#define WM_PH_SEARCH_SHOWMENU (WM_APP + 803)

static PPH_OBJECT_TYPE PhFindObjectsItemType = NULL;
static HANDLE PhFindObjectsThreadHandle = NULL;
static HWND PhFindObjectsWindowHandle = NULL;
static PH_EVENT PhFindObjectsInitializedEvent = PH_EVENT_INIT;
Expand Down Expand Up @@ -232,7 +233,7 @@ VOID PhpDestroyHandleObjectNode(
PhClearReference(&Node->ObjectNameString);
PhClearReference(&Node->BestObjectName);

PhDereferenceObject(Node);
PhFree(Node);
}

PPH_HANDLE_OBJECT_TREE_ROOT_NODE PhpAddHandleObjectNode(
Expand All @@ -243,7 +244,7 @@ PPH_HANDLE_OBJECT_TREE_ROOT_NODE PhpAddHandleObjectNode(
static ULONG64 NextUniqueId = 0;
PPH_HANDLE_OBJECT_TREE_ROOT_NODE handleObjectNode;

handleObjectNode = PhCreateAlloc(sizeof(PH_HANDLE_OBJECT_TREE_ROOT_NODE));
handleObjectNode = PhAllocate(sizeof(PH_HANDLE_OBJECT_TREE_ROOT_NODE));
memset(handleObjectNode, 0, sizeof(PH_HANDLE_OBJECT_TREE_ROOT_NODE));
PhInitializeTreeNewNode(&handleObjectNode->Node);

Expand Down Expand Up @@ -1133,6 +1134,36 @@ NTSTATUS PhpFindObjectsThreadStart(
return STATUS_SUCCESS;
}

VOID PhpFindObjectsDeleteProcedure(
_In_ PVOID Object,
_In_ ULONG Flags
)
{
PPH_HANDLE_SEARCH_CONTEXT context = Object;

PhClearReference(&context->SearchString);
PhClearReference(&context->SearchTypeString);
}

PPH_HANDLE_SEARCH_CONTEXT PhCreateFindObjectContext(
VOID
)
{
static PH_INITONCE initOnce = PH_INITONCE_INIT;
PPH_HANDLE_SEARCH_CONTEXT context;

if (PhBeginInitOnce(&initOnce))
{
PhFindObjectsItemType = PhCreateObjectType(L"FindObjectsItem", 0, PhpFindObjectsDeleteProcedure);
PhEndInitOnce(&initOnce);
}

context = PhCreateObject(sizeof(PH_HANDLE_SEARCH_CONTEXT), PhFindObjectsItemType);
memset(context, 0, sizeof(PH_HANDLE_SEARCH_CONTEXT));

return context;
}

INT_PTR CALLBACK PhpFindObjectsDlgProc(
_In_ HWND hwndDlg,
_In_ UINT uMsg,
Expand All @@ -1144,8 +1175,7 @@ INT_PTR CALLBACK PhpFindObjectsDlgProc(

if (uMsg == WM_INITDIALOG)
{
context = PhCreateAlloc(sizeof(PH_HANDLE_SEARCH_CONTEXT));
memset(context, 0, sizeof(PH_HANDLE_SEARCH_CONTEXT));
context = PhCreateFindObjectContext();

PhSetWindowContext(hwndDlg, PH_WINDOW_CONTEXT_DEFAULT, context);
}
Expand Down Expand Up @@ -1229,9 +1259,6 @@ INT_PTR CALLBACK PhpFindObjectsDlgProc(
context->SearchThreadHandle = NULL;
}

PhClearReference(&context->SearchString);
PhClearReference(&context->SearchTypeString);

if (context->SearchRegexCompiledExpression)
{
pcre2_code_free(context->SearchRegexCompiledExpression);
Expand Down
Loading

0 comments on commit 644abe0

Please sign in to comment.