preon

Get size and offset of an object field with Preon


I am developing a shared objects editor/viewer for eclipse using Preon. The editor looks like:

View of the editor

To improve it, I would like to implement a function that, once selected an entry on the top pannel, it would highlight the corresponding bytes on the bottom panel. To do that, whould be of great interest to retireve size and offset of a given field of my object with Preon.

How can I achieve that ? Are there some other alternatives ?


Solution

  • It's a little hard to tell what exactly you are trying to achieve (the screenshot is rather small), but it could be related to this.

    enter image description here

    It's done using the preon-emitter module, emitting meta data on the different snippets of data it decoded, while the decoder is running. As you can see, it allows you to build an HTML page that - while you're hovering over the bytes - gives you the information about the data structure it decoded.

    In this particular case, it's showing the contents of a class file. The bold word at the left is the value decoded, the rest is where that value resides in the class files data structure.