@@ -232,12 +232,22 @@ fn parse_id0_section_info<K: IDAKind>(
232
232
debug_file : & BinaryView ,
233
233
id0 : & ID0Section < K > ,
234
234
) -> Result < ( ) > {
235
- let version = match id0. ida_info ( ) ? {
236
- idb_rs:: id0:: IDBParam :: V1 ( IDBParam1 { version, .. } )
237
- | idb_rs:: id0:: IDBParam :: V2 ( IDBParam2 { version, .. } ) => version,
235
+ let ( version, idb_baseaddr) = match id0. ida_info ( ) ? {
236
+ idb_rs:: id0:: IDBParam :: V1 ( IDBParam1 {
237
+ version, baseaddr, ..
238
+ } )
239
+ | idb_rs:: id0:: IDBParam :: V2 ( IDBParam2 {
240
+ version, baseaddr, ..
241
+ } ) => ( version, baseaddr. into_u64 ( ) ) ,
238
242
} ;
239
243
240
- for ( addr, info) in get_info ( id0, version) ? {
244
+ let bv_baseaddr = bv. start ( ) ;
245
+ // just addr this value to the address to translate from ida to bn
246
+ // NOTE this delta could wrapp here and while using translating
247
+ let addr_delta = bv_baseaddr. wrapping_sub ( idb_baseaddr) ;
248
+
249
+ for ( idb_addr, info) in get_info ( id0, version) ? {
250
+ let addr = addr_delta. wrapping_add ( idb_addr. into_u64 ( ) ) ;
241
251
// just in case we change this struct in the future, this line will for us to review this code
242
252
// TODO merge this data with folder locations
243
253
let AddrInfo {
@@ -246,11 +256,8 @@ fn parse_id0_section_info<K: IDAKind>(
246
256
ty,
247
257
} = info;
248
258
// TODO set comments to address here
249
- for function in & bv. functions_containing ( addr. into_u64 ( ) ) {
250
- function. set_comment_at (
251
- addr. into_u64 ( ) ,
252
- & String :: from_utf8_lossy ( & comments. join ( & b"\n " [ ..] ) ) ,
253
- ) ;
259
+ for function in & bv. functions_containing ( addr) {
260
+ function. set_comment_at ( addr, & String :: from_utf8_lossy ( & comments. join ( & b"\n " [ ..] ) ) ) ;
254
261
}
255
262
256
263
let bnty = ty
@@ -282,7 +289,7 @@ fn parse_id0_section_info<K: IDAKind>(
282
289
None ,
283
290
label. map ( |x| x. to_string ( ) ) ,
284
291
bnty,
285
- Some ( addr. into_u64 ( ) ) ,
292
+ Some ( addr) ,
286
293
None ,
287
294
vec ! [ ] ,
288
295
vec ! [ ] ,
@@ -292,7 +299,7 @@ fn parse_id0_section_info<K: IDAKind>(
292
299
}
293
300
( label, Some ( _ty) , Some ( bnty) ) => {
294
301
let label: Option < & str > = label. as_ref ( ) . map ( |x| x. as_ref ( ) ) ;
295
- if !debug_info. add_data_variable ( addr. into_u64 ( ) , & bnty, label, & [ ] ) {
302
+ if !debug_info. add_data_variable ( addr, & bnty, label, & [ ] ) {
296
303
error ! ( "Unable to add the type at {addr:#x}" )
297
304
}
298
305
}
@@ -302,7 +309,7 @@ fn parse_id0_section_info<K: IDAKind>(
302
309
// TODO how to add a label without a type associacted with it?
303
310
if let Some ( name) = label {
304
311
if !debug_info. add_data_variable (
305
- addr. into_u64 ( ) ,
312
+ addr,
306
313
& binaryninja:: types:: Type :: void ( ) ,
307
314
Some ( & name) ,
308
315
& [ ] ,
@@ -314,7 +321,7 @@ fn parse_id0_section_info<K: IDAKind>(
314
321
( Some ( name) , None , None ) => {
315
322
// TODO how to add a label without a type associacted with it?
316
323
if !debug_info. add_data_variable (
317
- addr. into_u64 ( ) ,
324
+ addr,
318
325
& binaryninja:: types:: Type :: void ( ) ,
319
326
Some ( & name) ,
320
327
& [ ] ,
0 commit comments