mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 02:39:44 +02:00
Pass through "this" data-type even if prototype is unlocked
This commit is contained in:
parent
004a99bb87
commit
fe7fa96113
3 changed files with 42 additions and 0 deletions
|
@ -289,6 +289,17 @@ void ScopeLocal::collectNameRecs(void)
|
|||
Symbol *sym = *iter++;
|
||||
if (sym->isNameLocked()&&(!sym->isTypeLocked())) {
|
||||
addRecommendName(sym);
|
||||
if (sym->isThisPointer()) { // If there is a "this" pointer
|
||||
Datatype *dt = sym->getType();
|
||||
if (dt->getMetatype() == TYPE_PTR) {
|
||||
if (((TypePointer *)dt)->getPtrTo()->getMetatype() == TYPE_STRUCT) {
|
||||
// If the "this" pointer points to a class, try to preserve the data-type
|
||||
// even though the symbol is not preserved.
|
||||
SymbolEntry *entry = sym->getFirstWholeMap();
|
||||
typeRecommend.push_back(TypeRecommend(entry->getAddr(),dt));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1302,6 +1313,20 @@ void ScopeLocal::recoverNameRecommendationsForSymbols(void)
|
|||
}
|
||||
}
|
||||
|
||||
/// Run through the recommended list, search for an input Varnode matching the storage address
|
||||
/// and try to apply the data-type to it. Do not override existing type lock.
|
||||
void ScopeLocal::applyTypeRecommendations(void)
|
||||
|
||||
{
|
||||
list<TypeRecommend>::const_iterator iter;
|
||||
for(iter=typeRecommend.begin();iter!=typeRecommend.end();++iter) {
|
||||
Datatype *dt = (*iter).getType();
|
||||
Varnode *vn = fd->findVarnodeInput(dt->getSize(), (*iter).getAddress());
|
||||
if (vn != (Varnode *)0)
|
||||
vn->updateType(dt, true, false);
|
||||
}
|
||||
}
|
||||
|
||||
/// The symbol is stored as a name recommendation and then removed from the scope.
|
||||
/// Name recommendations are associated either with a storage address and usepoint, or a dynamic hash.
|
||||
/// The name may be reattached to a Symbol after decompilation.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue