The invention provides a code protecting method and
system based on a hook technology in
JAVA. The code protecting method mainly comprises the steps that a JNI mechanism is mainly used, class calling is changed by modifying class mark information to native, and a nativeFunc is customized in a dynamic link
library; class method codes which are called in the calling process of codes assigned to be protected are added to codes of the customized nativeFunc, and the class method codes which are called in the calling process of the codes assigned to the protected are replaced with arbitrary invalid codes; a class method called in the calling process of the codes assigned to be protected in a program to be protected is replaced with a general interface function exported by the dynamic link
library; finally, the replaced program to be protected is output. The invention further correspondingly provides a corresponding
system structure. By means of the method, calling of the function can be hidden in a dynamic link
library file which is compiled into binary
machine instructions, and thus the difficulty of reversing the calling is greatly increased.