Skip to content

Ghidra is a software reverse engineering (SRE) framework

Merge remote-tracking branch 'origin/GP-3481_ghidra007_' into patch

Ryan Kurtzea5b5e4c2896
diff --cc Ghidra/Features/Decompiler/ghidra_scripts/classrecovery/RTTIGccClassRecoverer.java
index abfcf8ef65,56b6d1903d..b3ab29add3
--- a/Ghidra/Features/Decompiler/ghidra_scripts/classrecovery/RTTIGccClassRecoverer.java
+++ b/Ghidra/Features/Decompiler/ghidra_scripts/classrecovery/RTTIGccClassRecoverer.java
@@@ -2782,75 -2804,7 +2793,74 @@@ public class RTTIGccClassRecoverer exte
return str;
}
+
+ private String getStringFromMemory(Address address) {
+
+ int stringLen = getStringLen(address);
+ if(stringLen <= 0) {
+ return null;
+ }
+
+ TerminatedStringDataType sdt = new TerminatedStringDataType();
+ MemBuffer buf = new DumbMemBufferImpl(program.getMemory(), address);
+ return (String) sdt.getValue(buf, sdt.getDefaultSettings(), stringLen);
+
+ }
+
+ private int getStringLen(Address addr) {
+
+ int len = 0;
+
+ while(isAscii(addr)) {
+ len++;
+ addr = addr.add(1);
+ }
+
+ if(isNull(addr)) {
+ return len+1;
+ }
+
+ return 0;
+ }
+
+ private boolean isAsciiPrintable(char ch) {
+ return ch >= 32 && ch < 127;
+ }
+
+ private boolean isAscii(Address addr) {
+
+ Memory mem = program.getMemory();
+ try {
+ byte byte1 = mem.getByte(addr);
+ char c = (char) byte1;
+ if(isAsciiPrintable(c)) {
+ return true;
+ }
+ return false;
+
+ }
+ catch (MemoryAccessException e) {
+ return false;
+ }
+ }
+
+ private boolean isNull(Address addr) {
+
+ Memory mem = program.getMemory();
+ try {
+ byte byte1 = mem.getByte(addr);
+
+ if(byte1 == 0x0) {
+ return true;
+ }
+ return false;
+
+ }
+ catch (MemoryAccessException e) {
+ return false;
+ }
+ }
-
/**
* Method to check to see if there are any EXTERNAL block relocations
*