Skip to content

Ghidra is a software reverse engineering (SRE) framework

Replaces buggy getLength() calls with getCount()

Toshi Piazzab89be26da20f
diff --git a/Ghidra/Features/PDB/src/pdb/cpp/iterate.cpp b/Ghidra/Features/PDB/src/pdb/cpp/iterate.cpp
index f4ee2c7605..ed68947a9c 100644
--- a/Ghidra/Features/PDB/src/pdb/cpp/iterate.cpp
+++ b/Ghidra/Features/PDB/src/pdb/cpp/iterate.cpp
@@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
- * NOTE: Added option to omit unused information from output.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/Ghidra/Features/PDB/src/pdb/cpp/print.cpp b/Ghidra/Features/PDB/src/pdb/cpp/print.cpp
index 492d6b69b8..f8ab305e0f 100644
--- a/Ghidra/Features/PDB/src/pdb/cpp/print.cpp
+++ b/Ghidra/Features/PDB/src/pdb/cpp/print.cpp
@@ -150,18 +150,9 @@ std::wstring printType( IDiaSymbol * pType, const std::wstring& suffix ) {
if ( pBaseType == NULL ) {
return L"";
}
- ULONGLONG lenArray = getLength( *pType );
- ULONGLONG lenElem = getLength( *pBaseType );
- ULONGLONG sz;
- if (lenElem == 0) {
- sz = 1;//prevent divide by zero...
- }
- else {
- sz = lenArray / lenElem;
- }
const size_t strLen = suffix.length() + 64 + 3; // length of suffix + wag_for_numeric_value + "[]\0"
std::vector<wchar_t> str(strLen);
- swprintf_s(str.data(), strLen, L"%s[%I64d]", suffix.c_str(), sz);
+ swprintf_s(str.data(), strLen, L"%s[%d]", suffix.c_str(), getCount( *pType ));
return printType(pBaseType, str.data());
}
diff --git a/Ghidra/Features/PDB/src/pdb/cpp/symbol.cpp b/Ghidra/Features/PDB/src/pdb/cpp/symbol.cpp
index c137933dfd..9f08ac4cad 100644
--- a/Ghidra/Features/PDB/src/pdb/cpp/symbol.cpp
+++ b/Ghidra/Features/PDB/src/pdb/cpp/symbol.cpp
@@ -231,6 +231,11 @@ ULONGLONG getLength(IDiaSymbol& symbol) {
symbol.get_length( &len );
return len;
}
+DWORD getCount(IDiaSymbol &symbol) {
+ DWORD count = 0;
+ symbol.get_count( &count );
+ return count;
+}
DWORD getTag(IDiaSymbol& symbol) {
DWORD tag = 0;
symbol.get_symTag( &tag );
diff --git a/Ghidra/Features/PDB/src/pdb/headers/symbol.h b/Ghidra/Features/PDB/src/pdb/headers/symbol.h
index 5227a7311c..1ab70a48a6 100644
--- a/Ghidra/Features/PDB/src/pdb/headers/symbol.h
+++ b/Ghidra/Features/PDB/src/pdb/headers/symbol.h
@@ -27,6 +27,7 @@ std::wstring getName(IDiaSymbol& pSymbol);
std::wstring getUndecoratedName(IDiaSymbol& pSymbol);
DWORD getRVA(IDiaSymbol& pSymbol);
ULONGLONG getLength(IDiaSymbol& pSymbol);
+DWORD getCount(IDiaSymbol& pSymbol);
DWORD getTag(IDiaSymbol& pSymbol);
std::wstring getTagAsString(IDiaSymbol& pSymbol);
DWORD getKind(IDiaSymbol& pSymbol);