Remember Hexer? It's back. In Java form. For those who don't remember, back in 2005 I posted the
of Hexer, a hex editor written in C#. Like most of my projects, Hexer was abandoned for lack of time. However, the basic idea of an easily extensible hex editor still appeals to me and so I decided to bring it back.
The new version of Hexer is not written in C# anymore. I ditched C# for Java for practical reasons. The primary reason is that I'm using Java at
which means I'm doing nearly all of my development these days in Java. The second reason is that we've had lots of code that's necessary for Hexer in our company's internal Java library already and I only had to combine our Java library with some new code. That way I managed to implement the first Java version of Hexer in a very short amount of time.
Alright, if everything works out smoothly the first version of Hexer 1.0.0 will be released next week (depending on how fast I can write the remaining unit tests, the documentation, and how quickly I can get someone to update the company website where Hexer will be available as a free download). So let's have a sneak preview of Hexer 1.0.0.
The underlying principle of Hexer is complete extensibility (think of Hexer as the Eclipse of hex editors). Whenever some kind of functionality is missing from the basic Hexer package it should be possible to add the missing functionality in as few lines of code as possible using plugins or scripts. This principle lead to a very powerful plugin API that makes it possible to extend nearly all parts of Hexer. In fact, the plugin API is so powerful that most of the functionality of the basic Hexer package is not part of Hexer itself but in a package called Standard Plugins. Hexer itself only guarantees the existence of a main window, the existence of hex windows, and some very simple standard functionality like copy/paste or undo/redo. The Standard Plugins on the other hand provide things like standard dialogs (Goto, Search, Replace, ...) or standard algorithms for comparing files or converting the binary data into printable text.
In the next few days I'll try to write some updates on how Hexer works and how it can be extended. Let's start with the basic plugin functionality right now. All plugins that Hexer should use must implement the IPlugin interface, which is the base interface for more specific plugin interfaces. As you can see below, the IPlugin interface defines four methods.
public interface IPlugin
{
String getDescription();
long getGuid();
String getName();
void init(PluginInterface pluginInterface);
}
Each plugin is identified by a GUID. This GUID must be unique and it is used by Hexer to manage plugins (whether they are loaded or disabled, configuration issues, ...). Furthermore plugins should provide a name and a description that tells the user of Hexer what the plugin does. The last method is the init method that is called when the plugin is loaded for the first time. The PluginInterface object passed to the function can be used by the plugin to interact with Hexer.
When a user wants to add a new plugin he has several options. If the plugin is rather simple, he could implement the IPlugin interface in a simple Java file, compile his plugin and put the class file into the plugins directory. When Hexer is started the next time, the plugin is loaded and integrated into Hexer. If the plugin is more complicated or if the user wants to provide his own plugin library, he can put all his plugins into a single JAR file and put the JAR file into the plugins directory. All he has to do is to add a class called PluginServer to the JAR file which returns a list of plugins generated by the JAR file (the Standard Plugins package is implemented this way). The third and sweetest option is the possibility to extend Hexer using languages other than Java. In theory, Hexer plugins can be written in any of the languages mentioned on
this site (scroll down), so if you think that the perfect language to extend a hex editor is AWK or Haskell, have fun with that. In practice not all languages mentioned there can be used because some of the scripting support packages from that site still have issues. Example scripts that implement Hexer plugins have been written in Python/Jython, Groovy and ECMAScript. These example scripts will be distributed in the final Hexer package. Trying to extend Hexer using Ruby/JRuby failed because - if I understood the problem correctly - JRuby broke for JSR scripting last December or something.
Alright, so much for a first explanation. In my next update I'll give some examples on how to concretely extend Hexer using some sample plugins. Let's end this post with a few screenshots of the new Hexer.
The first screenshot shows a typical Hexer window with one open file. The color map dialog (a Standard Plugin) is used to emphasize the printable ASCII characters. The entries in the list of the color map dialog are themselves plugins. Two of the color maps are from the Standard Plugins package while the third is an example scripting plugin written in Groovy.

The second screenshot shows the File Statistics dialog (a Standard Plugin), more specifically the byte distribution page (another Standard Plugin) that counts how often each byte value appears in a file. In the lower right corner the Export dialog (a Standard Plugin) is shown. Using this dialog, the user can convert selected byte ranges into printable text (like a C++ array). Of course the export options are plugins too, so they can be extended easily.

The third screenshot shows the Structure Viewer dialog (a Standard Plugin). It is used to display pre-defined structures in a more readable way. The screenshot shows the PE header of an EXE file. All the entries in the Structure Viewer dialog are obviously generated by plugins so that users can easily extend the dialog for their own needs.

The fourth and last screenshot shows the Scripting dialog (a Standard Plugin). In this dialog the user can write simple scripts in the same languages that are supported to develop scripted plugins (Jython, Groovy, ECMAScript for now). It is even possible to write plugins in this dialog and have them added to Hexer during runtime. That's not really recommended though. The scripting dialog is for smaller scripts like the one in the screenshot that displays name and file size of all loaded files.