Jinmo / idapkg

Packages for IDA Pro (written in python but supports all)
MIT License
131 stars 16 forks source link

[Request] Need to provide a way to uninstall idapkg #8

Closed bruce30262 closed 5 years ago

bruce30262 commented 5 years ago

Don't get me wrong ! I've been playing this plugin for a while and it really is an amazing project :) 👍 However when I was testing the plugin, I encountered some problem and have to find a way to re-install idapkg completely.

To be brief, I have two version of IDA in my computer (Windows 10), and when I was testing the plugin, it kind of screwed up the variable in config.json ( I think it's idausr_native_bases ), making me unable to open ida ( it kept crashing ). After I installed idapkg, I first open version A's ida.exe, then open version B's ida64.exe ( both of them worked perfectly ). And then I found I was unable to open version A's ida64.exe and version B's ida.exe ( both of them crashed ). It took me quite a while to find the root cause and have to delete config.json & re-install idapkg to fix the issue.

This make me think that the project should provide a way to uninstall the plugin (and document it in the manual), in case the user have decided not to use the plugin anymore. As far as I understand it has something to do with idapythonrc.py, and it's located in C:\Users\<username>\AppData\Roaming\Hex-Rays\IDA Pro\idapythonrc.py (Windows) , which is not an easy place for user to reach/discover. It would be nice if we can use a single command in IDA's python shell to remove the plugin completely.

Jinmo commented 5 years ago

A completely valid point! I was thinking of it too. To resolve the issue, there are two sub-issues;

1. idausr_native_bases and other version-related issues

A plugin developer may make a plugin that works across IDA >=7.x without difficulties, but of course, it can have some compatibility problems. So I'm thinking of separated directories, like idapkg/7.2(major.minor)/*.

It's not applied immediately but I'll modify idapythonrc.py and related files to make it possible to change the base directory on 0.1.2 version.

Regardless of that, idausr_native_bases will be changed (automatically updated), since it differs between os and micro-version (171130 part of 7.0.171130).

    "idausr_native_bases": {
        "win": {
            "7.0.171130": [
                null, 
                6234328
            ]
        }
    }

2. Uninstallation

The idapkg package itself can be removed by "remove package" command, but it didn't modify idapythonrc.py. I am reading the hook approach from npm, but I'm not sure if it's a good practice because a failing script should trigger a rollback.

Thank you for your careful investigation!

Jinmo commented 5 years ago

Can you check if it's working now in both versions? :smiley:

bruce30262 commented 5 years ago

Can you check if it's working now in both versions? :smiley:

  • [x] Added uninstallers (triggered when remove package from "Packages: Remove Package" or pkg.remove("idapkg")
  • [x] Changed the format of idausr_native_bases.

All good :+1:


However this also remind me that we need a update function to update idapkg to the latest version
pkg.update("idapkg") maybe ?

Jinmo commented 5 years ago

Currently this can be done with pkg.install(..., upgrade=True), but the shortcut seems good (argument order can be sometimes confusing).

In addition, I'm updating some commands e.g. making repo= argument optional, add remote(), pkg << "package". I'll close the issue when the refactoring is done!

Jinmo commented 5 years ago

Done except pkg << "package" since it's impossible in python to override methods in module object without hacking sys.modules... :innocent:

... in de002e3 ! :smiley: