igogo-x86 / HexRaysPyTools

IDA Pro plugin which improves work with HexRays decompiler and helps in process of reconstruction structures and classes
1.41k stars 224 forks source link

Change config file path #65

Open mrj0n3s opened 4 years ago

mrj0n3s commented 4 years ago

I would recommend changing the default config location in settings.py from

CONFIG_FILE_PATH = os.path.join(idc.idadir(), 'cfg', 'HexRaysPyTools.cfg')

to

CONFIG_FILE_PATH = os.path.join(os.path.dirname(__file__), 'cfg', 'HexRaysPyTools.cfg')

This allows to store the plugin under %APPDATA%\Hex-Rays\IDA Pro\plugins , allowing switching IDA version without having to re-install/moving around files. Note that the change expects a cfg folder to be present inside the HexRaysPyTools folder. This breaks the convention of keeping the cfg inside the cfg folder but makes it easier to copy in between versions, especially with the increase of IDA releases(service packs)

saidelike commented 3 years ago

+1 on this. As if you don't run it in Administrator on Windows, it won't be able to write the config file!

On Windows the following works too:

diff --git a/HexRaysPyTools/settings.py b/HexRaysPyTools/settings.py
index 0b028b2..82dd5cd 100644
--- a/HexRaysPyTools/settings.py
+++ b/HexRaysPyTools/settings.py
@@ -8,7 +8,8 @@ except ImportError:
     # for python 2
     import ConfigParser as configparser

-CONFIG_FILE_PATH = os.path.join(idc.idadir(), 'cfg', 'HexRaysPyTools.cfg')
+CONFIG_FILE_PATH = os.path.join(os.getenv('APPDATA'), 'Hex-Rays', 'IDA Pro', 'cfg', 'HexRaysPyTools.cfg')

 DEBUG_MESSAGE_LEVEL = logging.INFO
 # Whether propagate names (Propagate name feature) through all names or only defaults like v11, a3, this, field_4