- 博客(0)
- 资源 (5)
- 问答 (1)
- 收藏
- 关注
完全替代本地360各种软件管家
完全替代本地360各种软件管家,拜托全家桶各种依赖。总有你喜欢的。希望来下载。包含系统瘦身,大文件管理,无需安装,系统优化,性能监视,能随时保护你电脑,不占用内存。直接关闭即可
2020-06-02
jclasslib 工具修改.class文件,同时需要jad.exe做辅助
修改jar包中变量 或者长量
步骤如下:
1.用jd-gui打开该jar 怎么打开不用我说了吧?
打开之后找到 要修改提示信息 的class文件 这里找到的是GenEntity
找到对应需要修改的代码所在的方法名
我这里包含提示信息的这段代码在方法 getAllDataBase() 如下图:
2.用jd-gui或者winrar把GenEntity.class 解压出来到C盘 (目录无所谓)
3.双击桌面上安装好了的 jc
lasslib bytecode viewer ,点击软件的 File -- Open Class File 打开你刚解压出来的class文件
4.点击methods--getAllDataBase--Code
methods是表示方法不用说吧
getAllDataBase是刚在jd-gui里面找到的方法名
Code包含了getAllDataBase方法里所有的信息
找到"不能打开数据库连接,请检查!"
这里这个工具没有提供搜索功能
如果这里很多内容 那么你可以点击 copy to clipboard把这里的内容复制到一个文本文件里面然后再搜索
这里找到的是第82行
5.点击第 82行后面的 #34 会跳转到Constant Pool常量池的第34个常量
6.再点右边的 cp info #362 会跳转到第362个常量
这里能看到String: 不能打开数据库连接,请检查! 也就是最后输出的信息
7.找到GenEntity.class的关键常量了现在就该修改它了
在eclipse里面新建一个Test来处理GenEntity.class
[java] view plain copy
import java.io.*;
import org.gjt.jclasslib.io.ClassFileWriter;
import org.gjt.jclasslib.structures.CPInfo;
import org.gjt.jclasslib.structures.ClassFile;
import org.gjt.jclasslib.structures.constants.ConstantUtf8Info;
public class Test {
public static void main(String[] args) throws Exception {
String filePath = "C:\\GenEntity.class";
FileInputStream fis = new FileInputStream(filePath);
DataInput di = new DataInputStream(fis);
ClassFile cf = new ClassFile();
cf.read(di);
CPInfo[] infos = cf.getConstantPool();
int count = infos.length;
for (int i = 0; i < count; i++) {
if (infos[i] != null) {
System.out.print(i);
System.out.print(" = ");
System.out.print(infos[i].getVerbose());
System.out.print(" = ");
System.out.println(infos[i].getTagVerbose());
if(i == 362){
ConstantUtf8Info uInfo = (ConstantUtf8Info)infos[i];
uInfo.setBytes("芝麻不开门!".getBytes());
infos[i]=uInfo;
}
}
}
cf.setConstantPool(infos);
fis.close();
File f = new File(filePath);
ClassFileWriter.writeToFile(f, cf);
}
}
这里需要注意"C:\\GenEntity.class"是我存放class的目录
if(i == 362) 这里是刚我在第七步找到的常量序号
"芝麻不开门!"这里是我想修改的文字信息!
运行Test.java 会有如下提示信息 没有报错就证明正常的 如果报错那么就有问题
9.把C盘刚修改后的GenEntity.class替换掉原来的GenEntity.class
怎么替换不用我说了吧..
用winrar打开.jar 然后把GenEntity.class拖进去覆盖就行了
10.运行效果..
2018-02-27
myeclipse建类包的路径默认为空
2016-05-24
TA创建的收藏夹 TA关注的收藏夹
TA关注的人