Lenni0451 / ClassTransform

A lightweight, easy to use injection library which doesn't require bytecode writing skills
MIT License
74 stars 5 forks source link

Fixed method inlining bug to do with category 2 arg types. #5

Closed notiska closed 1 year ago

notiska commented 1 year ago

Method inlining didn't correctly account for category 2 argument types in the descriptor of the method being inlined.

An example that could cause the problem:

public class Test {
    public void test(double x, int y, float z) {
        System.out.println(x);
        System.out.println(y);
        System.out.println(z);
    }
}

The transformer:

@CTransformer(Test.class)
public class TestTransformer {
    @CInline
    @CInject(method="test(DIF)V", target=@CTarget("HEAD"), cancellable=true)
    public void test(double x, int y, float z, InjectionCallback callback) {
        if (x == 1.0) {
            System.out.println("It's 1.0.");
            callback.setCancelled(true);
        }
    }
}

The InjectionCallback callback parameter, in this case, is incorrectly referenced as local 20 at callback.setCancelled(true), which in turn will cause a verification error.

Also made gradlew executable on *nix systems.

Lenni0451 commented 1 year ago

Thanks, I really missed that