Skip to content
/ JBIL Public

A simple, small, lightweight library for instrumenting Java bytecode when retransforming classes with jvmti

License

Notifications You must be signed in to change notification settings

klirii/JBIL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JBIL – Java Bytecode Instrumentation Library

A simple, small, lightweight library for instrumenting Java bytecode when retransforming classes with jvmti.

Library can:

  • Finding entries in the constant pool
  • Add your own entries to the constant pool
  • Finding methods
  • Change methods bytecode

Examples

Before you start working with the library, you must include the "ClassFile.hpp" header and initialize the class you want to work with

image
Further work with the class will be done via cf object

Finding entries in the constant pool

image
All types of constants can be found here

Adding new entries

image

Finding methods and changing bytecode

Note: The "Bytecodes.hpp" header must be included before changing method bytecode

image

Dumping modified class file:

image
or

image

Requirements

x64 Windows 7, 8, 8.1, 10, 11

Including the library in a Visual Studio project

Visual Studio 2022 will be used as an example

  1. Clone the repository to a directory you are comfortable with
  2. Go to releases and download the latest available version of the static libraries
  3. Extract the archive to the directory where you cloned the repository
  4. Open your project in Visual Studio, right-click on the project in the Solution Explorer and select "Properties"
  5. In the "Configuration Properties" section, select "All Configurations" from the "Configuration" dropdown menu
  6. In the "VC++ Directories" section, select "Include Directories", click on the dropdown menu, click "Edit" and add (path to cloned repository)/include there and click "OK"
  7. In the same section, select "Library Directories" and add there the path to the static library folder for the desired configuration
  8. In the "Linker" section, open the "Input" subsection and add JBIL.lib to "Additional Dependencies"
  9. Done!

Notes

You can find more information about classfile structure and bytecode on the Oracle website.

About

A simple, small, lightweight library for instrumenting Java bytecode when retransforming classes with jvmti

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages