From 20a0ed53f6edb0f2742682912a7c554d838efd9f Mon Sep 17 00:00:00 2001 From: Takumi4685 Date: Mon, 23 Dec 2019 09:08:00 +0900 Subject: [PATCH] if narrow down results with target address 0,tool only checks if pointer code can reaches heap region --- PointerSearcher/FindPath.cs | 20 +++++++++++++++++++- PointerSearcher/Form1.cs | 13 +++++++++---- PointerSearcher/IDumpDataReader.cs | 1 + PointerSearcher/NoexsDumpDataReader.cs | 5 ++++- 4 files changed, 33 insertions(+), 6 deletions(-) diff --git a/PointerSearcher/FindPath.cs b/PointerSearcher/FindPath.cs index 8052e1c..b0f3065 100644 --- a/PointerSearcher/FindPath.cs +++ b/PointerSearcher/FindPath.cs @@ -172,7 +172,25 @@ static public async Task>> NarrowDown(CancellationT token.ThrowIfCancellationRequested(); } long parseAddress = await Task.Run(() => dump.TryToParseAbs(path)); - if (parseAddress != dumps[dump]) + long targetAddress = dumps[dump]; + bool remove = false; + if (targetAddress == 0) + { + //if target address is 0,only check path is valid,can reach heap region + if (!dump.IsHeap(parseAddress)) + { + remove = true; + } + } + else + { + //if target address isn't 0,check if parsed address is equal to target address + if (parseAddress != targetAddress) + { + remove = true; + } + } + if (remove) { ndlist.Remove(path); i--; diff --git a/PointerSearcher/Form1.cs b/PointerSearcher/Form1.cs index 97762d7..a9b4aac 100644 --- a/PointerSearcher/Form1.cs +++ b/PointerSearcher/Form1.cs @@ -41,7 +41,7 @@ private async void buttonRead_Click(object sender, EventArgs e) buttonRead.Enabled = false; - IDumpDataReader reader = CreateDumpDataReader(dataGridView1.Rows[0]); + IDumpDataReader reader = CreateDumpDataReader(dataGridView1.Rows[0],false); if (reader == null) { throw new Exception("Invalid input" + Environment.NewLine + "Check highlighted cell"); @@ -204,7 +204,7 @@ private async void buttonNarrowDown_Click(object sender, EventArgs e) { continue; } - IDumpDataReader reader = CreateDumpDataReader(row); + IDumpDataReader reader = CreateDumpDataReader(row,true); if (reader != null) { long target = Convert.ToInt64(row.Cells[5].Value.ToString(), 16); @@ -277,7 +277,7 @@ private void ClearRowBackColor(DataGridViewRow row) row.Cells[i].Style.BackColor = Color.White; } } - private IDumpDataReader CreateDumpDataReader(DataGridViewRow row) + private IDumpDataReader CreateDumpDataReader(DataGridViewRow row,bool allowUnknownTarget) { bool canCreate = true; String path = ""; @@ -370,8 +370,13 @@ private IDumpDataReader CreateDumpDataReader(DataGridViewRow row) row.Cells[4].Style.BackColor = Color.Red; canCreate = false; } - if ((target < heapStart) || (heapEnd < target)) + if(allowUnknownTarget && (target == 0)) { + //if target address is set to 0,it means unknown address. + } + else if ((target < heapStart) || (heapEnd <= target)) + { + //if not unknown,target should be located at heap region row.Cells[5].Style.BackColor = Color.Red; canCreate = false; } diff --git a/PointerSearcher/IDumpDataReader.cs b/PointerSearcher/IDumpDataReader.cs index c7e7088..e59a866 100644 --- a/PointerSearcher/IDumpDataReader.cs +++ b/PointerSearcher/IDumpDataReader.cs @@ -9,5 +9,6 @@ internal interface IDumpDataReader PointerInfo Read(CancellationToken token, IProgress prog); long TryToParseAbs(List path); Address TryToParseRel(List path); + bool IsHeap(long address); } } diff --git a/PointerSearcher/NoexsDumpDataReader.cs b/PointerSearcher/NoexsDumpDataReader.cs index f132316..b566f70 100644 --- a/PointerSearcher/NoexsDumpDataReader.cs +++ b/PointerSearcher/NoexsDumpDataReader.cs @@ -245,7 +245,10 @@ Address IDumpDataReader.TryToParseRel(List path) MemoryType type = GetMemoryType(address); return new Address(type, address - GetStartAddress(type)); } - + bool IDumpDataReader.IsHeap(long address) + { + return IsHeapAddress(address); + } private bool IsMainHeapAddress(long evalAddress) { if ((mainStartAddress <= evalAddress) && (evalAddress < mainEndAddress))