Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

segment base corruption #52

Open
SpenserStyles opened this issue Nov 8, 2018 · 1 comment
Open

segment base corruption #52

SpenserStyles opened this issue Nov 8, 2018 · 1 comment

Comments

@SpenserStyles
Copy link

I'm attempting to use YaCo v2.6 with IDA 7.0 on a 8051 code base that uses banking for code pages. The segment base is corrupted when opening the _local IDB. This appears to be caused by incorrect use of the ida_segment.get_segm_base() and ida_segment.set_segm_base().

The following steps can be used to replicate the issue:

  • Create dummy binary file of size 0x20000

  • Load into IDA select Intel 8051 leave rest as defaults and click OK until at disassembly view

  • Open Program Segmentation and this is what you see:
    image

  • Modify Program Segmentation to values below
    image

  • Go to File->Script Command

  • Enter following code

import ida_segment
# get segment base linear address
seg = ida_segment.get_segm_by_name("B02")
base = ida_segment.get_segm_base(seg)
print(base)  # this prints 32768 when should be 2048

# now when using set_segm_base(seg) it screws it up the base
ida_segment.set_segm_base(seg, base)

# get segment base linear address
seg = ida_segment.get_segm_by_name("B03")
base = ida_segment.get_segm_base(seg)
print(base)  # this prints 65536 when should be 4096

# now when using set_segm_base(seg) it screws it up the base for segment B03
ida_segment.set_segm_base(seg, base)

image

  • Run script command
  • Close and re-open Program Segmentation view and the BASE value has now been changed to incorrect values
    image

YaCo is currently relying on get_segm_base() to return the value that should be used when calling set_segm_base(). This is incorrect. I believe you must shift the value obtained by calling get_segm_base() right 4 bits for the value to use when calling set_segm_base().

Ultimately I think IDA may have this screwed up because I would have expected these to be complimentary functions. I am unable to test this on IDA 7.1 so it could be possible that it may be corrected.

@bamiaux
Copy link
Contributor

bamiaux commented Nov 14, 2018

Thanks for the bug report, I've reproduced the bug on 7.2 & added the right shift on master.
9b85e6c
Please check if it fixes your issue. Note that IDA does not send any event when changing the segment base leading to potentially missing changes.

@bamiaux bamiaux closed this as completed Nov 14, 2018
@bamiaux bamiaux reopened this Nov 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants