Skip to content

Commit

Permalink
if narrow down results with target address 0,tool only checks if poin…
Browse files Browse the repository at this point in the history
…ter code can reaches heap region
  • Loading branch information
Takumi4685 committed Dec 23, 2019
1 parent 049dcd0 commit 20a0ed5
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 6 deletions.
20 changes: 19 additions & 1 deletion PointerSearcher/FindPath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,25 @@ static public async Task<List<List<IReverseOrderPath>>> 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--;
Expand Down
13 changes: 9 additions & 4 deletions PointerSearcher/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 = "";
Expand Down Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions PointerSearcher/IDumpDataReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ internal interface IDumpDataReader
PointerInfo Read(CancellationToken token, IProgress<int> prog);
long TryToParseAbs(List<IReverseOrderPath> path);
Address TryToParseRel(List<IReverseOrderPath> path);
bool IsHeap(long address);
}
}
5 changes: 4 additions & 1 deletion PointerSearcher/NoexsDumpDataReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,10 @@ Address IDumpDataReader.TryToParseRel(List<IReverseOrderPath> 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))
Expand Down

0 comments on commit 20a0ed5

Please sign in to comment.