Skip to content

snowf14k3/lightweight-instrumentation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Simple-Instrumentation


features

  • classTransform
  • redefineClass
  • retransformClass

Usage

@Test
public void test(){
    SClassTransformer.list.add(new CustomTransfomer());
}

package com.utils;

import com.utils.Transformer;

public class SClassTransformer {
    /* add your custom Transfomer here*/
    public static ArrayList<Transformer> list = new ArrayList();

    public native static void redefineClass(Class<?> clazz,byte[] bytes);
    
    public native static void retransformClass(Class<?> clazz); 

    public static byte[] tansform(String name,byte[] orignalBytes){
       for(Transformer transfomer : SClassTransformer.list)
       {
           return transfomer.tansform(name,orignalBytes);
       } 
       return orignalBytes;
    }

    static{
        // ur lib load
        System.load("path/library.dll");
    }

}

package com.utils;

public abstract class Transformer {
    public abstract byte[] tansform(String name,byte[] orignalBytes);
}

About

a lightweight java bytecode instrumentation (not safe)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published