chcg / NPP_HexEdit

Notepad++ Plugin Hexedit
825 stars 156 forks source link

HexEditor plugin creates an empty folder "plugins\Compare" #10

Closed d0vgan closed 4 years ago

d0vgan commented 5 years ago

Notepad++ 7.6.3, 32-bit. When the "HexEditor.dll" (version 0.9.5.11) is placed under the "plugins\HexEditor" folder, an empty folder "plugins\Compare" is created when Notepad++ starts. If the "HexEditor.dll" is removed, the folder "plugins\Compare" is not created.

d0vgan commented 5 years ago

The same behavior with HexEditor_0.9.5.19_x86.zip

chcg commented 5 years ago

@d0vgan See https://github.com/chcg/NPP_HexEdit/blob/4af4aeaa2ee1a90a924a7f079c265119f34b06ea/HexEditor/src/Hex.cpp#L329-L353

Seems that is expected behaviour. Since 7.6.x it might make sense to use the plugin subdir to create such a dir.

Additional observation: The conf dir from NPPM_GETPLUGINSCONFIGDIR is not called first to retrieve the needed buffer size, but called just with MAX_PATH (see https://docs.microsoft.com/en-us/windows/desktop/fileio/naming-a-file, so maybe 260), so if the path exceed that size NULL is provided from N++. This might be the root cause of remaining #1 issues.

d0vgan commented 5 years ago

Looks like this folder is used by the function DoCompare where temporary files to be compared are created... I would highly recommend to use e.g. $(PLUGINS_CONFIG_DIR)\HexEdit\Compare or %TEMP%\HexEdit\Compare instead. The root issue is that a folder Notepad++\plugins\Compare is created by the plugin. This folder is just not applicable for the task of temporary files comparison.

d0vgan commented 5 years ago

Ah, I forgot I can build the plugin myself :) IMHO, this line in "Hex.cpp" just should not be there: *_tcsrchr(cmparePath, '\\') = NULL; What it does is it jumps one level up from the "Config" folder. Why??? I have no answer for this. I've started to experiment with the code (such as removing the mentioned line). In such case, the "Compare" folder is created under the "Config" folder, but after a few additional actions (when I checked how the comparison works) the plugin just crashed :( That killed my enthusiasm of further experiments.