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

use new IDAPython 9.0 APIs #2339

Merged
merged 3 commits into from
Sep 10, 2024
Merged

use new IDAPython 9.0 APIs #2339

merged 3 commits into from
Sep 10, 2024

Conversation

mr-tz
Copy link
Collaborator

@mr-tz mr-tz commented Aug 27, 2024

closes #2311

WIP as we need to figure out how to use 8.0 and 9.0 APIs

currently this should work just for IDA Pro 9.0 only though

Checklist

  • No CHANGELOG update needed
  • No new tests needed
  • No documentation update needed

@williballenthin
Copy link
Collaborator

what?!? 🏃 so fast nice work

Copy link
Collaborator

@williballenthin williballenthin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like we should introduce some wrappers that can switch on the IDA version. we can maintain those while we want to support 7/8/9 and then maybe deprecate them in a year or so?

i'm pleasantly surprised how small the delta is so this seems maintainable enough. thoughts?

@mike-hunhoff
Copy link
Collaborator

looks like we should introduce some wrappers that can switch on the IDA version. we can maintain those while we want to support 7/8/9 and then maybe deprecate them in a year or so?

i'm pleasantly surprised how small the delta is so this seems maintainable enough. thoughts?

I second this, a few wrappers should enable us to maintain compatibility across supported IDA versions.

@mr-tz
Copy link
Collaborator Author

mr-tz commented Aug 27, 2024

yes, sounds good - luckily here we only use a few affected APIs

@mr-tz
Copy link
Collaborator Author

mr-tz commented Aug 28, 2024

so something along those lines?!

def get_filetype() -> "filetype_t":
    version = float(idaapi.get_kernel_version())
    if version < 9.0:
        file_info = idaapi.get_inf_structure()
        return file_info.filetype
    else:
        import ida_ida
        return ida_ida.inf_get_filetype()

@williballenthin
Copy link
Collaborator

williballenthin commented Aug 28, 2024

I would recommend doing the version check at the top level of the Python module and defining the functions within the if/else blocks, so that the cost of the version check is O(1) at import-time versus O(#api calls) at runtime. Something like:

version = float(idaapi.get_kernel_version())
if version < 9.0:
    def get_filetype() -> "filetype_t":
        file_info = idaapi.get_inf_structure()
        return file_info.filetype

else:
    import ida_ida
    def get_filetype() -> "filetype_t":
        return ida_ida.inf_get_filetype()

Copy link
Collaborator

@mike-hunhoff mike-hunhoff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good 🚀

@mr-tz mr-tz merged commit 9459251 into master Sep 10, 2024
24 checks passed
@mr-tz mr-tz deleted the fix/ida90 branch September 10, 2024 10:55
@h4rdee h4rdee mentioned this pull request Sep 17, 2024
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

Successfully merging this pull request may close these issues.

Failed to load plugin on IDA9.0
3 participants