最近想加密类文件,防止客户反编译。我知道可以通过JVMTI来创建作为代理dll文件,让代理加密类文件,只要客户不反编译dll文件即可。可是,是否允许多个-agentib参数同时存在?  如果允许,那末就没用了。客户也写个dll代理,我这个dll代理解密类文件载入到虚拟机后,客户自己写的dll文件再把载入的类输出成类文件,那就可以直接反编译了。类似的还有-agentpath , -xrun , -javaagent 这些参数可以同时出现? 那末就是说可以支持多个代理,每个代理都可以监视虚拟机?究竟是否允许多个代理?如果是这样,那我就没必要费力气了。

解决方案 »

  1.   

    刚才实验了下,通过-agentpath和-agentlib成功加载了俩agent,这里边俩agent如果是hook不同的事件是不会互相影响而各自执行的,而如果callback挂接同一个事件只会执行一个,而具体执行哪个我还没找出规律,希望楼下的高手帮忙解答。
      

  2.   

    找到了官方资料:
    JVMTI Environments
    The JVMTI specification supports the use of multiple simultaneous JVMTI agents. Each agent has its own JVMTI environment. That is, the JVMTI state is separate for
    each agent - changes to one environment do not affect the others. The state of a JVMTI environment includes:
     the event callbacks
     the set of events which are enabled
     the capabilities
     the memory allocation/deallocation hooks
    Although their JVMTI state is separate, agents inspect and modify the shared state of the VM, they also share the native environment in which they execute. As such, an agent can perturb the results of other agents or cause them to fail. It is the responsibility of the agent writer to specify the level of compatibility with other agents. JVMTIimplementations are not capable of preventing destructive interactions between agents.也就是说各自JVMTI互不影响(这是能成功挂接多个agent的原因)但是共享VM与Native环境(这是后来多个VM Start事件中我输出多个printf结果只有一个被输出的原因)。处理多个Agent之间互相影响的关系看来比较复杂。
      

  3.   

    Spring的问题怎么解决啊,用了这种方式加密,但spring的就报错...