Skip to content

Commit

Permalink
Fix crash opening memory results dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
dmex committed Oct 19, 2024
1 parent 6492b18 commit c9e1039
Showing 1 changed file with 31 additions and 38 deletions.
69 changes: 31 additions & 38 deletions SystemInformer/memrslt.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include <procprv.h>
#include <settings.h>

#include "../tools/thirdparty/pcre/pcre2.h"
#include <thirdparty.h>

#define FILTER_CONTAINS 1
#define FILTER_CONTAINS_IGNORECASE 2
Expand All @@ -33,44 +33,8 @@ typedef struct _MEMORY_RESULTS_CONTEXT
PH_LAYOUT_MANAGER LayoutManager;
} MEMORY_RESULTS_CONTEXT, *PMEMORY_RESULTS_CONTEXT;

INT_PTR CALLBACK PhpMemoryResultsDlgProc(
_In_ HWND hwndDlg,
_In_ UINT uMsg,
_In_ WPARAM wParam,
_In_ LPARAM lParam
);

static RECT MinimumSize = { -1, -1, -1, -1 };

VOID PhShowMemoryResultsDialog(
_In_ HANDLE ProcessId,
_In_ PPH_LIST Results
)
{
HWND windowHandle;
PMEMORY_RESULTS_CONTEXT context;
ULONG i;

context = PhAllocateZero(sizeof(MEMORY_RESULTS_CONTEXT));
context->ProcessId = ProcessId;
context->Results = Results;

PhReferenceObject(Results);

for (i = 0; i < Results->Count; i++)
PhReferenceMemoryResult(Results->Items[i]);

windowHandle = PhCreateDialog(
PhInstanceHandle,
MAKEINTRESOURCE(IDD_MEMRESULTS),
NULL,
PhpMemoryResultsDlgProc,
context
);
ShowWindow(windowHandle, SW_SHOW);
SetForegroundWindow(windowHandle);
}

static PPH_STRING PhpGetStringForSelectedResults(
_In_ HWND ListViewHandle,
_In_ PPH_LIST Results,
Expand Down Expand Up @@ -686,7 +650,7 @@ INT_PTR CALLBACK PhpMemoryResultsDlgProc(
showMemoryEditor->SelectOffset = (ULONG)((ULONG_PTR)result->Address - (ULONG_PTR)basicInfo.BaseAddress);
showMemoryEditor->SelectLength = (ULONG)result->Length;

SystemInformer_ShowMemoryResults(showMemoryEditor);
SystemInformer_ShowMemoryEditor(showMemoryEditor);
}

NtClose(processHandle);
Expand Down Expand Up @@ -752,3 +716,32 @@ INT_PTR CALLBACK PhpMemoryResultsDlgProc(

return FALSE;
}

VOID PhShowMemoryResultsDialog(
_In_ HANDLE ProcessId,
_In_ PPH_LIST Results
)
{
HWND windowHandle;
PMEMORY_RESULTS_CONTEXT context;
ULONG i;

context = PhAllocateZero(sizeof(MEMORY_RESULTS_CONTEXT));
context->ProcessId = ProcessId;
context->Results = Results;

PhReferenceObject(Results);

for (i = 0; i < Results->Count; i++)
PhReferenceMemoryResult(Results->Items[i]);

windowHandle = PhCreateDialog(
PhInstanceHandle,
MAKEINTRESOURCE(IDD_MEMRESULTS),
NULL,
PhpMemoryResultsDlgProc,
context
);
ShowWindow(windowHandle, SW_SHOW);
SetForegroundWindow(windowHandle);
}

0 comments on commit c9e1039

Please sign in to comment.