JByteMod-Beta icon indicating copy to clipboard operation
JByteMod-Beta copied to clipboard

Attaching doesn't load attach provider

Open Col-E opened this issue 7 years ago • 6 comments

Clicking the "Attach to other process" button prompts the "Couldn't find any VMs" menu, providing PID results unable to attach due to provider not being instantiated.

JByteMod-Beta-master\target>"C:\Program Files\Java\jdk1.8.0_131\bin\java" -jar JByteMod-1.8.0.jar
[03:11:16] [INFO] Reading Language XML..
[03:11:16] [INFO] Successfully loaded 187 local resources and 187 default resources
[03:11:16] [INFO] Unicode check finished!
[03:11:16] [INFO] Loading settings...
[03:11:16] [INFO] Setting default Look and Feel
[03:11:17] [ERROR] No plugin folder found!
java.util.ServiceConfigurationError: com.sun.tools.attach.spi.AttachProvider: Provider sun.tools.attach.WindowsAttachProvider could not be instantiated

The classes are indeed in the classpath: (Picture from an agent looking for attach classes) image

I suspect the reflection-based instantiation of the provider to be the cause. The code for this is around here.

Solution: Modify code to use proper attach API calls

String agentJarPath = "...";
List<VirtualMachineDescriptor> vms = VirtualMachine.list();

// for some value in the list... call method below

void attach(VirtualMachineDescriptor vmDesc) {
    VirtualMachine vm = VirtualMachine.attach(vmDesc);
    vm.loadAgent(agentJarPath);
    vm.detach();
}

Col-E avatar Jun 05 '18 07:06 Col-E

Could you try running it with a JRE instead of JDK?

GraxCode avatar Jun 07 '18 15:06 GraxCode

That wouldnt work, the classes/natives for attach dont exist in the JRE classpath (related)

But since you asked:


JByteMod-Beta-master\target>"C:\Program Files\Java\jre1.8.0_131\bin\java" -jar JByteMod-1.8.0.jar
java.lang.UnsatisfiedLinkError: no attach in java.library.path
        at java.lang.ClassLoader.loadLibrary(Unknown Source)
        at java.lang.Runtime.loadLibrary0(Unknown Source)
        at java.lang.System.loadLibrary(Unknown Source)
        at me.grax.jbytemod.JByteMod.<clinit>(JByteMod.java:86)
[13:50:06] [INFO] Reading Language XML..
[13:50:06] [INFO] Successfully loaded 187 local resources and 187 default resources
[13:50:07] [INFO] Unicode check finished!
[13:50:07] [INFO] Loading settings...
[13:50:07] [INFO] Setting default Look and Feel
[13:50:09] [ERROR] No plugin folder found!
java.util.ServiceConfigurationError: com.sun.tools.attach.spi.AttachProvider: Provider sun.tools.attach.WindowsAttachProvider could not be instantiated

Col-E avatar Jun 07 '18 17:06 Col-E

Which OS and version are you on?

GraxCode avatar Jun 07 '18 20:06 GraxCode

Win 8.1 x64, java version is in the logs.

Col-E avatar Jun 07 '18 20:06 Col-E

Is there a stacktrace in the logs of the injected jvm?

GraxCode avatar Jun 08 '18 14:06 GraxCode

No because the attach process can't start.

Col-E avatar Jun 08 '18 14:06 Col-E