Skip to content

Commit 524da0e

Browse files
committed
Refactor MSVC demangler finalization
Parse MSVC symbols into structured type nodes before finalization. This keeps thunk suffixes, calling conventions, member pointers, and implicit this parameters dependent on the final platform/view context.
1 parent 6a1de81 commit 524da0e

11 files changed

Lines changed: 3567 additions & 1401 deletions

File tree

demangle.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,19 @@ namespace BinaryNinja {
4747
bool DemangleMS(Architecture* arch, const std::string& mangledName, Ref<Type>& outType, QualifiedName& outVarName,
4848
BinaryView* view)
4949
{
50-
const bool simplify = Settings::Instance()->Get<bool>("analysis.types.templateSimplifier", view);
51-
return DemangleMS(arch, mangledName, outType, outVarName, simplify);
50+
BNType* localType = nullptr;
51+
char** localVarName = nullptr;
52+
size_t localSize = 0;
53+
if (!BNDemangleMSWithOptions(arch->GetObject(), mangledName.c_str(), &localType, &localVarName, &localSize,
54+
view ? view->GetObject() : nullptr))
55+
return false;
56+
outType = localType ? new Type(localType) : nullptr;
57+
for (size_t i = 0; i < localSize; i++)
58+
{
59+
outVarName.push_back(localVarName[i]);
60+
}
61+
BNFreeDemangledName(&localVarName, localSize);
62+
return true;
5263
}
5364

5465
bool DemangleMS(Architecture* arch, const std::string& mangledName, Ref<Type>& outType, QualifiedName& outVarName,

0 commit comments

Comments
 (0)