-
Notifications
You must be signed in to change notification settings - Fork 475
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Visualize hex-to-bytecode mapping #244
Comments
This would be a great feature! |
Some thoughts on this, if its ok that the index pointers are not included then just showing the bytecode of instructions' opcodes + argument wildcards could be done. The reason the indices would not be included is because ASM handles rewriting the constant pool, so we don't really know where the things will point to until we save the entire class. And even then ASM doesn't tell us what points where in the constant pool since it abstracts things away. We'd have to use another lower abstraction bytecode library for that. Anyways, an example of what just showing hex for opcode patterns would look like: START:
ALOAD this
INVOKEVIRTUAL com/example/MyApp.doLog()Z
IFEQ END
LOGGING:
GETSTATIC com/example/MyApp.logger Lorg/slf4j/api/Logger;
LDC "Logging message"
INVOKEVIRTUAL org/slf4j/api/Logger.info(Ljava/lang/String;)V
END:
RETURN Would show up as (comments included for clarity): // start
2A // aload_0
B6 ?? // invokevirtual <method-ref>
99 ?? // ifeq <branch-offset>
// logging
B2 ?? // getstatic <field-ref>
12 ?? // ldc <cp-utf8-index>
B6 ?? // invokevirtual <method-ref>
// end
B1 // return Could probably expose some UI bits so you can make a plugin that lets you select the lines you want and export the hex pattern to your clipboard. |
Working on a new hex editor in 3X D2hbhKXXdA.mp4The plan is to make it so you can correlate regions of the class file to the displayed hex. This will still require a bit of extra work, but the design now fully accommodates for this use case :) The next step is to flesh out CAFED00D so that it will optionally let you get back the hex offsets from the data representation. My rough idea for this is to make it so that there is a common class representation over interfaces, but implementations can be provided via an optional factory. One could implement a factory that tacks on the offset information to data that gets parsed. |
Feature
Allow users to see a display similar to this:
Ideally for the entire class file, rather than just the method bytecode. But the method code would be good for now and could be expanded later. This is handy for things such as writing YARA rules where knowing the hex is necessary.
Process
This will likely be implemented using CAFEDOOD once it is fleshed out more, specifically once this issue is completed: Col-E/CAFED00D#1
The text was updated successfully, but these errors were encountered: