11mod types;
2+ use idb_rs:: { IDAKind , IDAUsize } ;
23use types:: * ;
34mod addr_info;
45use addr_info:: * ;
@@ -118,7 +119,7 @@ fn parse_idb_info(
118119 } ;
119120 trace ! ( "Parsing a IDB file" ) ;
120121 let file = std:: io:: BufReader :: new ( file) ;
121- let mut parser = idb_rs:: IDBParser :: new ( file) ?;
122+ let mut parser = idb_rs:: IDBParserVariants :: new ( file) ?;
122123 if let Some ( til_section) = parser. til_section_offset ( ) {
123124 trace ! ( "Parsing the TIL section" ) ;
124125 let til = parser. read_til_section ( til_section) ?;
@@ -130,7 +131,14 @@ fn parse_idb_info(
130131 trace ! ( "Parsing the ID0 section" ) ;
131132 let id0 = parser. read_id0_section ( id0_section) ?;
132133 // progress 50%-100%
133- parse_id0_section_info ( debug_info, bv, debug_file, & id0) ?;
134+ match id0 {
135+ idb_rs:: IDAVariants :: IDA32 ( id0) => {
136+ parse_id0_section_info :: < idb_rs:: IDA32 > ( debug_info, bv, debug_file, & id0) ?
137+ }
138+ idb_rs:: IDAVariants :: IDA64 ( id0) => {
139+ parse_id0_section_info :: < idb_rs:: IDA64 > ( debug_info, bv, debug_file, & id0) ?
140+ }
141+ }
134142 }
135143
136144 Ok ( ( ) )
@@ -148,7 +156,7 @@ fn parse_til_info(
148156 } ;
149157 let mut file = std:: io:: BufReader :: new ( file) ;
150158 trace ! ( "Parsing the TIL section" ) ;
151- let til = TILSection :: read ( & mut file, idb_rs :: IDBSectionCompression :: None ) ?;
159+ let til = TILSection :: read ( & mut file) ?;
152160 import_til_section ( debug_info, debug_file, & til, progress)
153161}
154162
@@ -218,11 +226,11 @@ pub fn import_til_section(
218226 Ok ( ( ) )
219227}
220228
221- fn parse_id0_section_info (
229+ fn parse_id0_section_info < K : IDAKind > (
222230 debug_info : & mut DebugInfo ,
223231 bv : & BinaryView ,
224232 debug_file : & BinaryView ,
225- id0 : & ID0Section ,
233+ id0 : & ID0Section < K > ,
226234) -> Result < ( ) > {
227235 let version = match id0. ida_info ( ) ? {
228236 idb_rs:: id0:: IDBParam :: V1 ( IDBParam1 { version, .. } )
@@ -238,9 +246,9 @@ fn parse_id0_section_info(
238246 ty,
239247 } = info;
240248 // TODO set comments to address here
241- for function in & bv. functions_containing ( addr) {
249+ for function in & bv. functions_containing ( addr. into_u64 ( ) ) {
242250 function. set_comment_at (
243- addr,
251+ addr. into_u64 ( ) ,
244252 String :: from_utf8_lossy ( & comments. join ( & b"\n " [ ..] ) ) . to_string ( ) ,
245253 ) ;
246254 }
@@ -265,35 +273,35 @@ fn parse_id0_section_info(
265273 } ) ;
266274
267275 match ( label, & ty, bnty) {
268- ( _ , Some ( ty) , bnty) if matches ! ( & ty. type_variant, TILTypeVariant :: Function ( _) ) => {
276+ ( label , Some ( ty) , bnty) if matches ! ( & ty. type_variant, TILTypeVariant :: Function ( _) ) => {
269277 if bnty. is_none ( ) {
270278 error ! ( "Unable to convert the function type at {addr:#x}" , )
271279 }
272280 if !debug_info. add_function ( DebugFunctionInfo :: new (
273281 None ,
274282 None ,
275- label. map ( str :: to_string) ,
283+ label. map ( |x| x . to_string ( ) ) ,
276284 bnty,
277- Some ( addr) ,
285+ Some ( addr. into_u64 ( ) ) ,
278286 None ,
279287 vec ! [ ] ,
280288 vec ! [ ] ,
281289 ) ) {
282290 error ! ( "Unable to add the function at {addr:#x}" )
283291 }
284292 }
285- ( _ , Some ( _ty) , Some ( bnty) ) => {
286- if !debug_info. add_data_variable ( addr, & bnty, label, & [ ] ) {
293+ ( label , Some ( _ty) , Some ( bnty) ) => {
294+ if !debug_info. add_data_variable ( addr. into_u64 ( ) , & bnty, label, & [ ] ) {
287295 error ! ( "Unable to add the type at {addr:#x}" )
288296 }
289297 }
290- ( _ , Some ( _ty) , None ) => {
298+ ( label , Some ( _ty) , None ) => {
291299 // TODO types come from the TIL sections, can we make all types be just NamedTypes?
292300 error ! ( "Unable to convert type {addr:#x}" ) ;
293301 // TODO how to add a label without a type associacted with it?
294302 if let Some ( name) = label {
295303 if !debug_info. add_data_variable (
296- addr,
304+ addr. into_u64 ( ) ,
297305 & binaryninja:: types:: Type :: void ( ) ,
298306 Some ( name) ,
299307 & [ ] ,
@@ -305,7 +313,7 @@ fn parse_id0_section_info(
305313 ( Some ( name) , None , None ) => {
306314 // TODO how to add a label without a type associacted with it?
307315 if !debug_info. add_data_variable (
308- addr,
316+ addr. into_u64 ( ) ,
309317 & binaryninja:: types:: Type :: void ( ) ,
310318 Some ( name) ,
311319 & [ ] ,
0 commit comments