-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy path0853-Segmented-pointer-additions-wrong-offset-infere.patch
More file actions
34 lines (28 loc) · 2.04 KB
/
Copy path0853-Segmented-pointer-additions-wrong-offset-infere.patch
File metadata and controls
34 lines (28 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Gregory Morse <gregory.morse@live.com>
Date: Sun, 28 Jul 2019 18:49:30 +0200
Subject: [PATCH] 0853: Segmented pointer additions wrong offset inference
A reference such as ```es:[bx+1D70h]``` should print out correctly as: bx_var + 0x1d70. Currently it prints as an offset from coincidental data segment location found at 0x1D70 as &ram0x000006D0+bx_var. For es:[bx+1d80] it would be &ram0x000006D0+(bx+var+0x10) and so forth.
Looking at the next instruction to figure out where the output is bound does not seem like the ideal approach but its the easiest approach I could come up with as the SEGMENTOP would always come immediately after. Obviously the DS segment is not used so just guessing here is totally ridiculous when the SEGMENTOP that happens in the next opcode binds to the ES segment. Basically it ruins the clean output and wrongly queryies for nonsense addresses.
Tested and working.
Update coreaction.cc
Cleaned up for correct tracking of the output to the SEGMENTOP
---
Ghidra/Features/Decompiler/src/decompile/cpp/coreaction.cc | 3 +++
1 file changed, 3 insertions(+)
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/coreaction.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/coreaction.cc
index e75b090608..e139128888 100644
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/coreaction.cc
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/coreaction.cc
@@ -1122,6 +1122,9 @@ MapEntry *ActionConstantPtr::isPointer(AddrSpace *spc,Varnode *vn,PcodeOp *op,in
case CPUI_INT_ADD:
outvn = op->getOut();
if (outvn->getTypeDefFacing()->getMetatype()==TYPE_PTR) {
+ PcodeOp* outop = outvn->loneDescend();
+ if (outop != (PcodeOp*)0 && //if part of a segment op cannot process here!
+ outop->code() == CPUI_SEGMENTOP) return (MapEntry*)0;
// Is there another pointer base in this expression
if (op->getIn(1-slot)->getTypeReadFacing(op)->getMetatype()==TYPE_PTR)
return (MapEntry *)0; // If so, we are not a pointer
--
2.45.1