@@ -26,8 +26,8 @@ use binaryninja::platform::Platform;
2626use binaryninja:: rc:: Ref ;
2727use binaryninja:: types:: {
2828 BaseStructure , EnumerationBuilder , EnumerationMember , FunctionParameter , MemberAccess ,
29- MemberScope , NamedTypeReference , NamedTypeReferenceClass , QualifiedName , StructureBuilder ,
30- StructureMember , StructureType , Type , TypeBuilder , TypeClass ,
29+ MemberScope , NamedTypeReference , NamedTypeReferenceClass , StructureBuilder , StructureMember ,
30+ StructureType , Type , TypeBuilder , TypeClass ,
3131} ;
3232use log:: warn;
3333use pdb:: Error :: UnimplementedTypeKind ;
@@ -136,7 +136,7 @@ pub struct ParsedMemberFunction {
136136#[ derive( Debug , Clone ) ]
137137pub struct VirtualBaseClass {
138138 /// Base class name
139- pub base_name : QualifiedName ,
139+ pub base_name : String ,
140140 /// Base class type
141141 pub base_type : Ref < Type > ,
142142 /// Offset in this class where the base's fields are located
@@ -153,7 +153,7 @@ pub enum ParsedType {
153153 /// No info other than type data
154154 Bare ( Ref < Type > ) ,
155155 /// Named fully parsed class/enum/union/etc type
156- Named ( QualifiedName , Ref < Type > ) ,
156+ Named ( String , Ref < Type > ) ,
157157 /// Function procedure
158158 Procedure ( ParsedProcedureType ) ,
159159 /// Bitfield entries
@@ -163,7 +163,7 @@ pub enum ParsedType {
163163 /// One member in a structure/union
164164 Member ( ParsedMember ) ,
165165 /// Base class name and offset details
166- BaseClass ( QualifiedName , StructureMember ) ,
166+ BaseClass ( String , StructureMember ) ,
167167 /// One member in an enumeration
168168 Enumerate ( EnumerationMember ) ,
169169 /// List of arguments to a function
@@ -352,7 +352,8 @@ impl<'a, S: Source<'a> + 'a> PDBParserInstance<'a, S> {
352352 let name = ty
353353 . get_named_type_reference ( )
354354 . ok_or ( anyhow ! ( "expected ntr" ) ) ?
355- . name ( ) ;
355+ . name ( )
356+ . to_string ( ) ;
356357 if Self :: is_name_anonymous ( & name) {
357358 continue ;
358359 }
@@ -405,9 +406,8 @@ impl<'a, S: Source<'a> + 'a> PDBParserInstance<'a, S> {
405406
406407 // Cleanup a couple builtin names
407408 for & name in BUILTIN_NAMES {
408- let builtin_qualified_name = QualifiedName :: from ( name) ;
409- if self . named_types . contains_key ( & builtin_qualified_name) {
410- self . named_types . remove ( & builtin_qualified_name) ;
409+ if self . named_types . contains_key ( name) {
410+ self . named_types . remove ( name) ;
411411 self . log ( || format ! ( "Remove builtin type {}" , name) ) ;
412412 }
413413 }
@@ -742,7 +742,7 @@ impl<'a, S: Source<'a> + 'a> PDBParserInstance<'a, S> {
742742 self . log ( || format ! ( "Got Class type: {:x?}" , data) ) ;
743743
744744 let raw_class_name = data. name . to_string ( ) ;
745- let class_name = QualifiedName :: from ( raw_class_name) ;
745+ let class_name = raw_class_name. to_string ( ) ;
746746
747747 self . log ( || format ! ( "Named: {}" , class_name) ) ;
748748
@@ -776,7 +776,7 @@ impl<'a, S: Source<'a> + 'a> PDBParserInstance<'a, S> {
776776 structure. packed ( data. properties . packed ( ) ) ;
777777
778778 if let Some ( fields) = data. fields {
779- self . namespace_stack . push ( class_name. to_string ( ) ) ;
779+ self . namespace_stack . push ( class_name. clone ( ) ) ;
780780 let success = self . parse_structure_fields ( & mut structure, fields, finder) ;
781781 self . namespace_stack . pop ( ) ;
782782 let _ = success?;
@@ -852,7 +852,6 @@ impl<'a, S: Source<'a> + 'a> PDBParserInstance<'a, S> {
852852 & format ! (
853853 "`{}`" ,
854854 self . namespace_stack
855- . items
856855 . last( )
857856 . ok_or_else( || anyhow!( "Expected class in ns stack" ) ) ?
858857 ) ,
@@ -925,7 +924,6 @@ impl<'a, S: Source<'a> + 'a> PDBParserInstance<'a, S> {
925924 warn ! (
926925 "Class `{}` uses virtual inheritance. Type information may be inaccurate." ,
927926 self . namespace_stack
928- . items
929927 . last( )
930928 . ok_or_else( || anyhow!( "Expected class in ns stack" ) ) ?
931929 ) ;
@@ -938,7 +936,6 @@ impl<'a, S: Source<'a> + 'a> PDBParserInstance<'a, S> {
938936 warn ! (
939937 "Class `{}` has multiple base classes. Type information may be inaccurate." ,
940938 self . namespace_stack
941- . items
942939 . last( )
943940 . ok_or_else( || anyhow!( "Expected class in ns stack" ) ) ?
944941 ) ;
@@ -957,8 +954,7 @@ impl<'a, S: Source<'a> + 'a> PDBParserInstance<'a, S> {
957954 for base_class in & base_classes {
958955 match base_class {
959956 ParsedType :: BaseClass ( base_name, _base_type) => {
960- let mut vt_base_name = base_name. clone ( ) ;
961- vt_base_name. items . push ( "VTable" . to_string ( ) ) ;
957+ let vt_base_name = format ! ( "{}::VTable" , base_name) ;
962958
963959 match self . named_types . get ( & vt_base_name) {
964960 Some ( vt_base_type)
@@ -1034,8 +1030,8 @@ impl<'a, S: Source<'a> + 'a> PDBParserInstance<'a, S> {
10341030 return Err ( anyhow ! ( "Expected class in ns stack" ) ) ;
10351031 }
10361032
1037- let mut vt_name = self . namespace_stack . clone ( ) ;
1038- vt_name. items . push ( " VTable". to_string ( ) ) ;
1033+ let class_name = self . namespace_stack . last ( ) . cloned ( ) . unwrap_or_default ( ) ;
1034+ let vt_name = format ! ( "{}:: VTable", class_name ) ;
10391035 self . named_types . insert ( vt_name. clone ( ) , vt_type. clone ( ) ) ;
10401036
10411037 let vt_pointer = Type :: pointer (
@@ -1268,9 +1264,12 @@ impl<'a, S: Source<'a> + 'a> PDBParserInstance<'a, S> {
12681264 ) -> Result < Option < Box < ParsedType > > > {
12691265 self . log ( || format ! ( "Got Nested type: {:x?}" , data) ) ;
12701266 let mut class_name_ns = self . namespace_stack . clone ( ) ;
1271- class_name_ns. push ( data. name . to_string ( ) . into ( ) ) ;
1267+ class_name_ns. push ( data. name . to_string ( ) . to_string ( ) ) ;
12721268 let ty = self . type_index_to_bare ( data. nested_type , finder, false ) ?;
1273- Ok ( Some ( Box :: new ( ParsedType :: Named ( class_name_ns, ty) ) ) )
1269+ Ok ( Some ( Box :: new ( ParsedType :: Named (
1270+ class_name_ns. join ( "::" ) ,
1271+ ty,
1272+ ) ) ) )
12741273 }
12751274
12761275 fn handle_base_class_type (
@@ -1289,15 +1288,16 @@ impl<'a, S: Source<'a> + 'a> PDBParserInstance<'a, S> {
12891288 let name = t
12901289 . get_named_type_reference ( )
12911290 . ok_or ( anyhow ! ( "Expected NTR to have NTR" ) ) ?
1292- . name ( ) ;
1291+ . name ( )
1292+ . to_string ( ) ;
12931293 ( name, t. clone ( ) )
12941294 }
12951295 e => return Err ( anyhow ! ( "Unexpected base class type: {:x?}" , e) ) ,
12961296 } ;
12971297
12981298 // Try to resolve the full base type
12991299 let resolved_type = match self . try_type_index_to_bare ( data. base_class , finder, true ) ? {
1300- Some ( ty) => Type :: named_type_from_type ( member_name. clone ( ) , ty. as_ref ( ) ) ,
1300+ Some ( ty) => Type :: named_type_from_type ( & member_name, ty. as_ref ( ) ) ,
13011301 None => t. clone ( ) ,
13021302 } ;
13031303
@@ -1313,7 +1313,7 @@ impl<'a, S: Source<'a> + 'a> PDBParserInstance<'a, S> {
13131313 member_name. clone ( ) ,
13141314 StructureMember :: new (
13151315 Conf :: new ( resolved_type, MAX_CONFIDENCE ) ,
1316- member_name. to_string ( ) ,
1316+ member_name,
13171317 base_offset as u64 ,
13181318 access,
13191319 scope,
@@ -1334,7 +1334,8 @@ impl<'a, S: Source<'a> + 'a> PDBParserInstance<'a, S> {
13341334 let name = t
13351335 . get_named_type_reference ( )
13361336 . ok_or ( anyhow ! ( "Expected NTR to have NTR" ) ) ?
1337- . name ( ) ;
1337+ . name ( )
1338+ . to_string ( ) ;
13381339 ( name, t. clone ( ) )
13391340 }
13401341 e => return Err ( anyhow ! ( "Unexpected base class type: {:x?}" , e) ) ,
@@ -1523,7 +1524,7 @@ impl<'a, S: Source<'a> + 'a> PDBParserInstance<'a, S> {
15231524 self . log ( || format ! ( "Got Enumeration type: {:x?}" , data) ) ;
15241525
15251526 let raw_enum_name = data. name . to_string ( ) ;
1526- let enum_name = QualifiedName :: from ( raw_enum_name) ;
1527+ let enum_name = raw_enum_name. to_string ( ) ;
15271528 self . log ( || format ! ( "Named: {}" , enum_name) ) ;
15281529
15291530 if data. properties . forward_reference ( ) {
@@ -1651,7 +1652,7 @@ impl<'a, S: Source<'a> + 'a> PDBParserInstance<'a, S> {
16511652 self . log ( || format ! ( "Got Union type: {:x?}" , data) ) ;
16521653
16531654 let raw_union_name = data. name . to_string ( ) ;
1654- let union_name = QualifiedName :: from ( raw_union_name) ;
1655+ let union_name = raw_union_name. to_string ( ) ;
16551656 self . log ( || format ! ( "Named: {}" , union_name) ) ;
16561657
16571658 if data. properties . forward_reference ( ) {
@@ -1908,7 +1909,8 @@ impl<'a, S: Source<'a> + 'a> PDBParserInstance<'a, S> {
19081909 let name = type_
19091910 . get_named_type_reference ( )
19101911 . ok_or ( anyhow ! ( "expected ntr" ) ) ?
1911- . name ( ) ;
1912+ . name ( )
1913+ . to_string ( ) ;
19121914 if let Some ( full_ntr) = self . named_types . get ( & name) {
19131915 type_ = Type :: named_type_from_type ( name, full_ntr. as_ref ( ) ) ;
19141916 }
@@ -1955,7 +1957,8 @@ impl<'a, S: Source<'a> + 'a> PDBParserInstance<'a, S> {
19551957 let name = type_
19561958 . get_named_type_reference ( )
19571959 . ok_or ( anyhow ! ( "expected ntr" ) ) ?
1958- . name ( ) ;
1960+ . name ( )
1961+ . to_string ( ) ;
19591962 if Self :: is_name_anonymous ( & name) {
19601963 if let Some ( inner) = inner. as_ref ( ) {
19611964 type_ = inner. clone ( ) ;
@@ -1992,8 +1995,8 @@ impl<'a, S: Source<'a> + 'a> PDBParserInstance<'a, S> {
19921995 }
19931996
19941997 /// Is this name one of the stupid microsoft unnamed type names
1995- fn is_name_anonymous ( name : & QualifiedName ) -> bool {
1996- match name. items . last ( ) {
1998+ fn is_name_anonymous ( name : & String ) -> bool {
1999+ match name. split ( "::" ) . last ( ) {
19972000 Some ( item) if item == "<anonymous-tag>" => true ,
19982001 Some ( item) if item. contains ( "<unnamed-" ) => true ,
19992002 _ => false ,
0 commit comments