30 #define FILTER_CONTAINS 1
31 #define FILTER_CONTAINS_IGNORECASE 2
32 #define FILTER_REGEX 3
33 #define FILTER_REGEX_IGNORECASE 4
35 typedef struct _MEMORY_RESULTS_CONTEXT
50 static RECT MinimumSize = { -1, -1, -1, -1 };
63 context->Results = Results;
67 for (i = 0; i < Results->Count; i++)
70 windowHandle = CreateDialogParam(
77 ShowWindow(windowHandle, SW_SHOW);
80 static PPH_STRING PhpGetStringForSelectedResults(
81 _In_ HWND ListViewHandle,
91 for (i = 0; i < Results->Count; i++)
97 if (!(ListView_GetItemState(ListViewHandle, i, LVIS_SELECTED) & LVIS_SELECTED))
101 result = Results->Items[i];
110 static VOID FilterResults(
121 results = Context->Results;
123 SetCursor(LoadCursor(NULL, IDC_WAIT));
128 L
"Enter the filter pattern:",
147 for (i = 0; i < results->
Count; i++)
164 for (i = 0; i < results->
Count; i++)
173 _wcsupr(upperDisplay);
175 if (wcsstr(upperDisplay, upperChoice->
Buffer))
210 PhShowError(hwndDlg, L
"Unable to compile the regular expression: \"%S\" at position %d.",
217 expression_extra =
pcre_study(expression, 0, &errorString);
222 for (i = 0; i < results->
Count; i++)
255 if (!_resetstkoflw())
283 SetCursor(LoadCursor(NULL, IDC_ARROW));
295 if (uMsg != WM_INITDIALOG)
327 lvHandle = GetDlgItem(hwndDlg,
IDC_LIST);
339 PhAddLayoutItem(&context->LayoutManager, GetDlgItem(hwndDlg, IDOK), NULL,
348 if (MinimumSize.left == -1)
356 MapDialogRect(hwndDlg, &rect);
358 MinimumSize.left = 0;
361 ListView_SetItemCount(lvHandle, context->Results->Count);
373 MoveWindow(hwndDlg, windowRectangle.
Left, windowRectangle.
Top,
377 windowRectangle.
Left += 20;
378 windowRectangle.
Top += 20;
401 switch (LOWORD(wParam))
405 DestroyWindow(hwndDlg);
413 lvHandle = GetDlgItem(hwndDlg,
IDC_LIST);
414 selectedCount = ListView_GetSelectedCount(lvHandle);
416 if (selectedCount == 0)
419 string = PhpGetStringForSelectedResults(lvHandle, context->Results,
TRUE);
424 string = PhpGetStringForSelectedResults(lvHandle, context->Results,
FALSE);
430 SendMessage(hwndDlg, WM_NEXTDLGCTL, (WPARAM)lvHandle,
TRUE);
437 { L
"Text files (*.txt)", L
"*.txt" },
438 { L
"All files (*.*)", L
"*.*" }
469 string = PhpGetStringForSelectedResults(GetDlgItem(hwndDlg,
IDC_LIST), context->Results,
TRUE);
477 PhShowStatus(hwndDlg, L
"Unable to create the file", status, 0);
489 ULONG filterType = 0;
494 GetClientRect(GetDlgItem(hwndDlg,
IDC_FILTER), &buttonRect);
496 point.y = buttonRect.bottom;
498 ClientToScreen(GetDlgItem(hwndDlg,
IDC_FILTER), &point);
504 switch (selectedItem->
Id)
522 FilterResults(hwndDlg, context, filterType);
532 LPNMHDR header = (LPNMHDR)lParam;
535 lvHandle = GetDlgItem(hwndDlg,
IDC_LIST);
538 switch (header->code)
540 case LVN_GETDISPINFO:
542 NMLVDISPINFO *dispInfo = (NMLVDISPINFO *)header;
544 if (dispInfo->item.mask & LVIF_TEXT)
548 switch (dispInfo->item.iSubItem)
556 dispInfo->item.pszText,
557 dispInfo->item.cchTextMax,
569 dispInfo->item.pszText,
570 dispInfo->item.cchTextMax,
578 dispInfo->item.pszText,
579 dispInfo->item.cchTextMax,
590 if (header->hwndFrom == lvHandle)
594 if ((index = ListView_GetNextItem(
602 HANDLE processHandle;
603 MEMORY_BASIC_INFORMATION basicInfo;
617 sizeof(MEMORY_BASIC_INFORMATION),
623 showMemoryEditor->
ProcessId = context->ProcessId;
624 showMemoryEditor->
BaseAddress = basicInfo.BaseAddress;
625 showMemoryEditor->
RegionSize = basicInfo.RegionSize;
626 showMemoryEditor->
SelectOffset = (ULONG)((ULONG_PTR)result->
Address - (ULONG_PTR)basicInfo.BaseAddress);
631 NtClose(processHandle);
635 PhShowStatus(hwndDlg, L
"Unable to edit memory", status, 0);