Yao Yiu asked for help today.
The software he's using now has a bug, because it's a foreign developer, so asking for a change is a hassle. The thing to change is simply to modify the return value of the error in a function.
A jar package that can be run directly by the software.
The first idea is simple, you want to directly decompile the code, and then modify and repackage, using the Jd-gui has been a favorite.
But later found not so simple, because this software features more, code is more cumbersome, anti-compilation code after the dependency of a large number of errors, want to make all the errors are modified and re-packaging is almost impossible, can only give up.
Yao Yao told me that he had previously fixed a bug, as long as the return value of a method can be modified.
According to his position, I found the method, and it was just a return value to be modified.
I started looking for ways to modify class files online, and in many articles we found ways to use Jclasslib to see where variables are located within class and then modify bytecode.
Open the file you want to modify, and navigate to that method:
To change the return value of Bipush from 17 to 18.
But the trouble is, the article is to modify the variables, such as 1 lines of #131, and this position is the method of directly return int value, need to directly modify the definition of the method
After looking at the Org.gjt.jclasslib API without a result (most likely I didn't find it myself), I started looking for the class file structure and wanted to navigate to the location of the corresponding method definition.
Finally, the corresponding position is found by searching the 16 binary value of the return value "17" and the corresponding ID of the Bipush opcode. Modify "11" to "12".
The corresponding value of the Bipush is the corresponding value of 0x10,ireturn is 0xAC, and then continue to compare the location code can correspond to, so the 10 after 11 modified to 12, save.
(Is the modified file)
After saving, the class is overwritten back to the jar package and the double-click cannot run.
Run Java-jar Xxx.jar on the command line, find the error "java.lang.securityexception", continue to the online search solution, need to remove Meta-inf, in addition to MANIFEST.MF and SERVER.RSA content.
Open MANIFEST.MF found inside is all classes of SHA-256 encrypted string, because the class file was modified by me to cause the string will not be error.
Delete the contents of MANIFEST.MF inside Main-class:xxx.xxx.xxx.main (leave a blank line, otherwise you will be prompted "No Master manifest attribute! ”)。
Run the jar package again, success!
Send jar package to Yao Yao, get feedback is can run, bug changed, complete!
"Java" Modify Jar Package class file small note