Method for protecting class member functions in so, storage medium, electronic device and system

By splitting and distributing virtual member functions in SO files, setting dependencies and loading initialization, and performing hook modifications, the problem of class member functions being easily cracked in the Linux operating system was solved, and the security of core functions was improved.

CN114238871BActive Publication Date: 2026-02-06武汉斗鱼鱼乐网络科技有限公司
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202111535328.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-15
Publication Date
2026-02-06
Estimated Expiration
2041-12-15

AI Technical Summary

Technical Problem

In existing technologies, class member functions in the SO files of the Linux operating system are easily reverse-engineered and cracked by hackers, making it difficult to guarantee the security of core functions.

Method used

By splitting the virtual member functions in the SO file and distributing them to different target SO files, setting dependencies and loading initialization, using a pre-defined data structure to record the mapping relationship, and performing hook modifications, the virtual member functions of the class can correctly call the code in the target SO file when called.

Benefits of technology

This increases the cost and difficulty of hacker analysis, ensures the security of core functionalities, and prevents individual SO files from being cracked.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114238871B_ABST
    Figure CN114238871B_ABST
Patent Text Reader

Abstract

The application discloses a SO class member function protection method, a storage medium, an electronic device and a system, and relates to the field of Internet application development.The method comprises the following steps: setting the dependency relationship between SO files according to the splitting requirements of virtual member functions in the SO files; setting the virtual member functions and loading initialization of the SO files; recording the splitting mapping relationship of the virtual member functions in the SO files through a preset data structure; performing a splitting operation on the virtual member functions that need to be split, so that the virtual member functions of the class are split into different target SO files according to the splitting mapping relationship; and performing Hook modification on the creation code of the class, so that when the corresponding class calls the virtual member functions thereof after being created, the corresponding virtual member function code in the corresponding target SO file can be called. The application makes the member functions of the class in the SO file not easy to be cracked, effectively improves the security of the core function, and meets the actual application requirements.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of Internet application development, in particular to a class member function protection method in SO, a storage medium, an electronic device and a system. BACKGROUND

[0002] For electronic devices with Linux operating system, many core functions are written in SO files. For example, the algorithm for account login, as a core function for security protection, is not intended to be viewed by the outside world, and therefore a bottom SO file is used to write the algorithm for account login in the SO layer, and interfaces are left for internal and external communication or mutual calling. Further, the SO file is a dynamic link library under Linux, which is equivalent to the.dll file under Windows. In Android, the dynamic library file (*.so) can be called to load the API provided by the SO file through the JNI method.

[0003] In actual applications, the SO file is usually written in C++, and all functions in C++ are encapsulated by classes. The compiler writes the codes of all functions in a class continuously in the SO file. Therefore, once the SO file is obtained, it can be directly used by hackers, and based on the functions of the class, all interfaces of the class can be found, and function reverse analysis and other operations can be easily performed, which leads to the core function being easily reverse-engineered by hackers, and the security is difficult to guarantee.

[0004] Therefore, how to effectively protect the member functions of the class in the SO file and improve the security of the core function is a problem to be solved by those skilled in the art. SUMMARY

[0005] The present application is to overcome the shortcomings of the prior art, and provides a class member function protection method in SO, a storage medium, an electronic device and a system, so that the member functions of the class in the SO file of the electronic device with Linux operating system are not easy to be cracked, the security of the core function is effectively improved, and the actual application requirements are met.

[0006] To achieve the above purpose, in a first aspect, the present application provides a class member function protection method in SO, which comprises:

[0007] According to the splitting requirements of the virtual member functions in each SO file, the dependency relationship between the SO files is set, and the virtual member functions and the loading initialization of the SO files are set;

[0008] The splitting mapping relationship of the virtual member functions in the SO file is recorded by a preset data structure;

[0009] performing a splitting operation on the virtual member function in the SO file that needs to be split, so that the virtual member function of the class is split into different target SO files according to the splitting mapping relationship;

[0010] performing a Hook modification on the creation code of the class of the SO file that has performed the splitting operation, so that the corresponding class, after being created, can call the corresponding virtual member function code in the corresponding target SO file when it calls its virtual member function.

[0011] As a preferred embodiment, the virtual member function of the SO file is set, which specifically includes the following operations:

[0012] The virtual member function of the SO file is set so that it does not call other global variables or global functions;

[0013] The loading initialization of the SO file is set so that the SO file does not perform class creation operation and call the member function of the class that is split when calling the system initialization function for loading initialization; and all SO files with dependency relationship are loaded at the same time.

[0014] As a preferred embodiment, the preset data structure includes the following member variables: the SO file name of the split virtual member function, the class name of the split virtual member function, the offset address of the split virtual member function, the size of the split virtual member function, the target SO file name, and the offset address of the split virtual member function stored in the target SO file.

[0015] As a preferred embodiment, the method further includes: adding a code segment in each target SO file, and the code segment is used to store the code of the split virtual member function.

[0016] As a preferred embodiment, performing a splitting operation on the virtual member function in the SO file that needs to be split, so that the virtual member function of the class is split into different target SO files according to the splitting mapping relationship, specifically includes the following operations:

[0017] Copy the code of the virtual member function that needs to be split in the original SO file to the code segment added in the target SO file; clean up the code of the virtual member function that needs to be split in the original SO file; according to the position of the code of the virtual member function copied to the code segment added in the target SO file, assign the offset address of the split virtual member function stored in the target SO file in the corresponding data structure.

[0018] As a preferred embodiment, copying the code of the virtual member function that needs to be split in the original SO file to the code segment added in the target SO file specifically includes the following operations:

[0019] According to the split mapping relationship, the original SO file name, the target SO file name, the offset address of the split virtual member function, and the size of the split virtual member function are obtained in the corresponding data structure;

[0020] The original SO file and the target SO file are read into memory;

[0021] According to the offset of the split virtual member function, the code of the virtual member function is found;

[0022] A memory space is applied from a code segment added in the target SO file, and the size of the memory space is the size of the split virtual member function;

[0023] The found code of the virtual member function is copied into the applied memory space.

[0024] As a preferred embodiment, the class creation code of the SO file after the split operation is Hook modified, and the Hook modification specifically includes the following operations: the class creation code of the SO file after the split operation is searched; the position of each creation code is Hooked; and the address of the virtual member function in the virtual table is modified to the memory address of the virtual member function code copied in the target SO file.

[0025] In a second aspect, an embodiment of the present application provides an SO class member function protection system, which comprises:

[0026] A setting module is configured to set the dependency relationship between SO files according to the split requirement of the virtual member function in each SO file, and set the virtual member function and loading initialization of the SO file;

[0027] A recording module is configured to record the split mapping relationship of the virtual member function in the SO file through a preset data structure;

[0028] A split module is configured to perform a split operation on the virtual member function in the SO file which needs to be split, so that the virtual member function of the class is split into different target SO files according to the split mapping relationship;

[0029] A Hook module is configured to Hook modify the class creation code of the SO file after the split operation, so that the corresponding class can call the corresponding virtual member function code in the target SO file when calling the virtual member function after being created.

[0030] In a third aspect, an embodiment of the present application further provides a storage medium having a computer program stored thereon, and the computer program is executed by a processor to implement the method in the first aspect.

[0031] Fourthly, embodiments of the present invention also provide an electronic device, including a Linux operating system, a memory, and a processor, wherein the memory stores a computer program that runs on the processor, and the processor executes the computer program to implement the method in the first aspect embodiment.

[0032] The beneficial effects of this invention are as follows:

[0033] This invention can split and break down the virtual member functions of a class, and split the member functions of a class based on multiple SO files. This ensures that a single SO file cannot be used alone, and the virtual member functions of the class will not be distributed continuously in the same SO file due to the splitting. This greatly increases the cost and difficulty of hacker analysis, ensures the security of core functional functions, and meets the needs of practical applications. Attached Figure Description

[0034] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings corresponding to the embodiments are briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0035] Figure 1 This is a flowchart of the method for protecting class member functions in SO in an embodiment of the present invention;

[0036] Figure 2 This is a structural block diagram of the class member function protection system in SO in an embodiment of the present invention.

[0037] In the diagram: 10 - Settings module, 20 - Recording module, 30 - Split module, 40 - Hook module. Detailed Implementation

[0038] In existing technologies, many core functionalities are written in SO files, and all functions in an SO file are encapsulated by classes. All functions of each class are sequentially written into an SO file. Once the SO file is obtained, all interfaces of a class can be found based on its functions, allowing for easy reverse engineering. Therefore, core functionalities are vulnerable to reverse engineering and cracking by hackers, resulting in low security. This invention aims to provide a method, storage medium, electronic device, and system for protecting class member functions in SO files on Linux operating system electronic devices. This method makes it difficult to crack the member functions of classes in SO files, effectively improving the security of core functionalities and meeting practical application needs.

[0039] To achieve the above-mentioned technical effects, the main design concept of this invention is as follows:

[0040] According to the splitting requirement of the virtual member function in each SO file, the dependency relationship between SO files is set; and the virtual member function of the SO file and the loading initialization are set;

[0041] The splitting mapping relationship of the virtual member function in the SO file is recorded through a preset data structure;

[0042] The virtual member function in the SO file which needs to be split is executed to split the operation, so that the virtual member function of the class is split into different target SO files according to the splitting mapping relationship;

[0043] The Hook modification is performed on the creation code of the class of the SO file which has executed the splitting operation, so that the corresponding class can call the corresponding virtual member function code in the corresponding target SO file when it calls its virtual member function after being created.

[0044] In summary, when the protection of the member function of the class in the SO file is implemented, the virtual member function of the class can be split and scattered, and the splitting of the member function of the class is performed based on multiple SO files, so that an independent SO file cannot be used alone, and the virtual member function of the class will not be continuously distributed in the same SO file due to splitting, thereby greatly improving the cost and difficulty of hacker analysis, ensuring the security of the core function, and meeting the actual application requirements.

[0045] In order to make the technical problems, technical solutions and advantages of the present application clearer, the technical solutions of the present application will be described in detail below in combination with the drawings and specific embodiments of the specification.

[0046] However, it should be noted that the examples to be introduced next are only some specific examples, and are not intended to limit the embodiments of the present application to the following specific steps, values, conditions, data, sequences, etc. Those skilled in the art can use the concept of the present application to construct more embodiments not mentioned in the specification by reading the specification.

[0047] Embodiment one

[0048] Referring to Figure 1 The embodiment provides a class member function protection method in an SO, and the method comprises the following steps:

[0049] Step S1, according to the splitting requirement of the virtual member function in each SO file, the dependency relationship between SO files is set; and the virtual member function of the SO file and the loading initialization are set.

[0050] It can be understood that for the program under the Linux operating system, there are multiple SO files, and in the prior art, the SO files do not have a dependency relationship, and all functions of each class are present in one SO file, so the functions of the core function are easy to be reverse-engineered by hackers, and the security is low. In order to solve the above problems, the embodiment needs to scatter and split the member functions of the classes in some SO files, which will be distributed in other SO files, so there is a dependency relationship between the SO files. The dependency relationship depends on the specific splitting requirements, that is, the member functions of the classes in one SO file are split into which SO file or which SO files.

[0051] Further, based on the fact that there may be a circular dependency relationship in the embodiment (assuming that the member functions of the classes in an SO1 file are split into another SO2 file, then SO1 file depends on SO2 file, and when the member functions of the classes in SO2 file are split into SO1, SO2 file depends on SO1 file, which forms a circular dependency relationship), and the dependency is also complex, and there is also a certain SO file depending on other SO files, at this time when loading a certain SO file, the dependent SO file must be loaded first, therefore, due to the fact that the member functions of the classes are split into different SO files, in order to ensure the correctness of the functions, the loading initialization of each SO file needs to be set, so as to ensure that all functions are correctly available. In addition, since the member functions of the classes are divided into three types: one is the static member function of the class, one is the member function of the class, and one is the virtual member function of the class. Among them, for the virtual member function of the class, there is a virtual table of the class, which stores the memory addresses of all member functions, and considering the convenience and complexity of the subsequent function splitting implementation of the scheme, only the virtual member function of the class is split in the embodiment, so that the subsequent operation steps can be simplified, therefore, the virtual member functions of each SO file need to be set.

[0052] For example, as a preferred embodiment, in step S1, the virtual member functions of the SO files and the loading initialization are set, which specifically includes the following operations:

[0053] 1) Set the virtual member function of the SO file, so that it does not call other global variables or global functions. It can be understood that, since the member function of the class may use the global variable or global function in the SO and other information, these global variables or global functions all exist the function associated with the current SO, so they all exist the problem of relocation repair. Considering the complex problem of cross-SO repair relocation, the virtual member function of the SO file is set and limited in this example, so that there is no call to other global variables or global functions in the virtual member function, so there is no relocation repair problem. In this way, the subsequent operation can be simplified.

[0054] 2) Set the loading initialization of the SO file, so that the SO file does not perform class creation operation and call the member function of the class split when calling the system initialization function for loading initialization; and load all SO files with dependency relationship at the same time. It can be understood that, when the SO file is loaded into the memory, it will first call its system initialization function (i.e. initialization function.init and.init_array segment function and JNI_OnLoad function, these three initialization functions are automatically called by the system when loading SO). Based on the splitting of the member function of the class in this embodiment, for each SO file, if the member function of the class is split into other SO files, it cannot create and call the split member function of the class in the above initialization function, otherwise it will cause program crash. Since its use and call are dependent on other SO files, in order to simplify the complexity of splitting, this embodiment makes each SO file not perform class creation operation and call the split member function of the class when calling its system initialization function for loading initialization, and after the execution of the above initialization function is completed, the class creation and use can be performed anywhere in other code execution.

[0055] From the above operation, it can be seen that the loading initialization of the SO file is designed in this embodiment, which ensures that the SO file will not call the corresponding split class member function when it is loaded, so as to avoid the program exception caused by the loading of the SO file. At the same time, this embodiment also loads several SO files with class member function splitting together, and only loads the SO file when loading, without executing the function in the SO. The purpose is to load the required SO file into the memory, so as to facilitate the search and call of the class member function of other SO. This design ensures that all related SO files can be loaded, and the split class can find its member function when searching for its member function, and also does not cause SO circular dependency so as to correctly load the SO in sequence.

[0056] Step S2, record the split mapping relationship of the virtual member function in the SO file through the preset data structure.

[0057] It can be understood that, since the embodiment splits the virtual member function in the SO, a data structure needs to be designed to store the split and mapping relationship, so that it can be executed correctly in subsequent use. Specifically, the preset data structure in the embodiment can include the following member variables: the SO file name in which the virtual member function is split, used to indicate which virtual member function of which class in which SO file is split; the class name in which the virtual member function is split, used to indicate which virtual member function of which class is split; the offset address of the split virtual member function, used to record the module offset address of the SO file corresponding to the split virtual member function; the size of the split virtual member function, used to record the size of the split virtual member function; the target SO file name, used to indicate which target SO file (dependent SO file) the split virtual member function is split into; and the offset address of the split virtual member function in the target SO file, used to record the module offset address of the target SO file in which the split virtual member function is stored.

[0058] For example, in specific implementation, the preset data structure can be designed as follows:

[0059] Struct SOFunc{

[0060] String so1name; / / virtual member function split SO1 file name

[0061] String class; / / virtual member function split class name class

[0062] Uint64_t func; / / split virtual member function offset address func

[0063] Uint64_t size; / / split virtual member function size size

[0064] String so2name; / / target SO2 file name

[0065] Uint64_t func2; / / offset address func2 of split virtual member function stored in target SO2 file

[0066] In addition, in specific implementation, for each split virtual member function of a class, an object of the above-mentioned structure body SOFunc is instantiated to store the mapping relationship of the virtual member function.

[0067] Step S3, split the virtual member function in the SO file that needs to be split, so that the virtual member function of the class is split into different target SO files according to the split mapping relationship.

[0068] It can be understood that after the split mapping relationship of the virtual member functions in each SO file is recorded and stored, the split operation needs to be performed on the virtual member functions in the SO file that needs to be split according to the split mapping relationship, so that the virtual member functions of the class are split into different target SO files according to the split mapping relationship. The essence of the split operation is actually to copy the code of the virtual member functions in the SO file that needs to be split to the target SO file, and to clear the code of the split virtual member functions in the original SO file, so as to realize code replacement. For example, the code of a virtual member function in the class1 class in the SO1 file is stored in the SO1 file. After the above operation, the code of a virtual member function in the class1 class in the SO1 file is modified or deleted, and the corresponding code is copied to the SO2 file, so that the code replacement is completed. According to the above split operation, the virtual member functions of a class can be split into different SO files. Finally, a replacement list represented by an array is formed to store the replacement (split) relationship of all virtual member functions.

[0069] Further, in order to better ensure that the virtual member functions of the class can be successfully split into the target SO file, that is, the code of the virtual member functions in the original SO file can be successfully copied to the target SO file, the embodiment further includes the following operation before step S3: adding a code segment in each target SO file. It can be understood that the target SO file needs to store the code of the virtual member functions of the class in other SO files. Generally, when the SO file compiler is generated, its size is fixed. Therefore, if the code needs to be added in the SO file, other techniques need to be used to add. Therefore, the embodiment adds a code segment in the SO file (for example, at the tail of the SO file) to store the code of the virtual member functions in other SO files, so that the target SO file can have space to store no matter how large the other virtual member functions are, and can be suitable for various situation requirements.

[0070] On this basis, as an optional embodiment, step S3 specifically includes the following operations:

[0071] Step S31, copy the code of the virtual member functions in the original SO file that needs to be split to the code segment added in the target SO file. Specifically, in practical application, the following operations can be included:

[0072] S31-1, according to the split mapping relationship, obtaining the original SO file name (i.e. the SO file name of the split virtual member function) so1name, the target SO file name so2name, the offset address func of the split virtual member function and the size size of the split virtual member function in the corresponding data structure;

[0073] S31-2, reading the original SO file and the target SO file into the memory;

[0074] S31-3, finding the code of the virtual member function according to the offset address func of the split virtual member function;

[0075] S31-4, applying a piece of memory space from the code segment added in the target SO file, and the size is the size size of the split virtual member function;

[0076] S31-5, copying the found code of the virtual member function to the applied piece of memory space.

[0077] Step S32, cleaning the code of the virtual member function which needs to be split in the original SO file. It can be understood that when the code of the virtual member function is copied to the target SO file, the original code can be cleaned up, specifically, it can be cleaned up into invalid instructions or completely emptied.

[0078] Step S33, according to the position of the code of the virtual member function copied to the code segment added in the target SO file, assigning the offset address of the split virtual member function stored in the target SO file in the corresponding data structure.

[0079] Step S4, Hook modifying the creation code of the class of the SO file which has performed the split operation, so that the corresponding class can call the corresponding virtual member function code in the target SO file when it calls its virtual member function after being created.

[0080] It can be understood that for the SO file, if a virtual member function of a class is copied to other SO files, the creation of the existing class needs to be modified, so as to ensure that the class in the original SO file can call the code copied to the target SO file when it calls its virtual member function after being created, and thus ensure that the function of the class is correct. And in the specific execution process, the Hook modification of the creation code of the class of the original SO file needs to be performed immediately after the initialization of the SO file, so as to ensure that the address of the virtual member function of the class is replaced once the class is created.

[0081] Specifically, as an optional embodiment, in step S4, the Hook modification is performed on the class creation code of the SO file which has been subjected to the splitting operation, including the following operations:

[0082] 1) searching the class creation code of the SO file which has been subjected to the splitting operation. In practical application, the code position of the instantiation class code in the SO file can be searched.

[0083] 2) Hooking each creation code position. It can be understood that in practical application, the code of each place where the class instance is created needs to be Hooked, wherein the Hook must be after the object is newly created (new) and the constructor of the class is called. In C++ language, an object of a class is instantiated by calling the new function, wherein the constructor of the class is called immediately after the new function is called to initialize the class, and the virtual table of the class is also initialized, wherein the virtual table stores the address of all virtual functions of the class in the memory. Therefore, after the instantiation object constructor of the class is called, the virtual function address of the virtual table has been filled into the virtual table, and the Hook is performed after the assignment is completed.

[0084] 3) modifying the address of the virtual member function in the virtual table to the memory address of the copied virtual member function code in the target SO file. It can be understood that in the embodiment, the address of the virtual member function in the virtual table needs to be modified to the memory address of the copied virtual member function code in the target SO file, which is the new memory address of the virtual member function. Therefore, when the virtual member function is called, the address will be taken out from the virtual table for calling, so as to achieve the purpose of calling the corresponding virtual member function code in the target SO file when the virtual member function is called.

[0085] From the above steps S1-S4, it can be seen that in the implementation of the class member function protection in the SO, the virtual member function of the class can be split and scattered, and the class member function can be split based on multiple SO files. Therefore, an independent SO file cannot be used alone, and the virtual member function of the class will not be continuously distributed in the same SO file due to the splitting, thereby greatly improving the cost and difficulty of hacker analysis, ensuring the security of the core function, and meeting the actual application requirements.

[0086] Embodiment Two

[0087] Based on the same inventive concept, as shown in Figure 2 , the second embodiment of the present application provides a class member function protection system in SO, which comprises:

[0088] A setting module 10 is configured to set the dependency relationship between SO files according to the splitting requirement of the virtual member functions in each SO file, and set the virtual member functions and loading initialization of the SO files;

[0089] A recording module 20 is configured to record the splitting mapping relationship of the virtual member functions in the SO files through a preset data structure;

[0090] A splitting module 30 is configured to perform splitting operation on the virtual member functions in the SO files which need to be split, so that the virtual member functions of the classes are split into different target SO files according to the splitting mapping relationship;

[0091] A Hook module 40 is configured to perform Hook modification on the creation code of the classes of the SO files which have performed the splitting operation, so that the corresponding classes can call the corresponding virtual member function code in the corresponding target SO file when calling the virtual member functions after being created.

[0092] The various changes and specific examples in the foregoing method embodiments are also applicable to the system of the present embodiment. Through the detailed description of the foregoing method, those skilled in the art can clearly understand the implementation method of the system in the present embodiment. Therefore, for the sake of brevity of the specification, the implementation method of the system will not be described in detail here.

[0093] Embodiment Three

[0094] Based on the same inventive concept, the third embodiment of the present application provides a computer readable storage medium having a computer program stored thereon, the program being executed by a processor to implement a SO class member function protection method provided by any embodiment of the present application, the method comprising:

[0095] According to the splitting requirement of the virtual member functions in each SO file, the dependency relationship between the SO files is set, and the virtual member functions and loading initialization of the SO files are set;

[0096] The splitting mapping relationship of the virtual member functions in the SO files is recorded through a preset data structure;

[0097] Splitting operation is performed on the virtual member functions in the SO files which need to be split, so that the virtual member functions of the classes are split into different target SO files according to the splitting mapping relationship;

[0098] The creation code of the classes of the SO files which have performed the splitting operation is Hook modified, so that the corresponding classes can call the corresponding virtual member function code in the corresponding target SO file when calling the virtual member functions after being created.

[0099] The computer storage medium of the embodiments of the present application can adopt any combination of one or more computer-readable media. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium may, for example, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or apparatus, or any combination thereof. More specific examples (non-exhaustive list) of the computer-readable storage medium include an electrical connection having one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this document, the computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in connection with an instruction execution system, apparatus, or device.

[0100] The computer-readable signal medium can include a data signal that is propagated in a baseband or as part of a carrier wave. Such propagated data signals can take a wide variety of forms, including but not limited to electro-magnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media can also be any computer-readable medium that is not a storage medium, that is, that is not a medium of any of the tangible, physical forms of computer-readable storage media. A computer-readable signal medium can be any computer-readable medium that can actually carry or carry away a program for use by or in connection with an instruction execution system, apparatus, or device.

[0101] The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber cable, RF, and the like, or any suitable combination of the above.

[0102] Computer program code for carrying out operations of the present application can be written in any combination of one or more programming languages, including an object-oriented programming language such as Java, Smalltalk, C++, or the like, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code can execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer, or entirely on the remote computer or server. In the latter scenario, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection can be made to an external computer (for example, through the Internet using an Internet Service Provider).

[0103] Embodiment Four

[0104] Based on the same inventive concept, the fourth embodiment of the present application also provides an electronic device comprising a Linux operating system, a memory and a processor, the memory storing a computer program running on the processor, and the processor implementing all the method steps or part of the method steps of the first embodiment when executing the computer program. Exemplarily, the electronic device is a mobile terminal comprising a Linux operating system, a memory and a processor, the memory storing a computer program running on the processor, and the processor implementing all the method steps or part of the method steps of the SO class member function protection method of the first embodiment when executing the computer program.

[0105] The processor can be a central processing unit (CPU), and can also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor and the like, and the processor is a control center of the computer device, and connects all parts of the computer device through various interfaces and lines.

[0106] The memory can be used to store the computer program and / or modules, and the processor realizes various functions of the computer device by running or executing the computer program and / or modules stored in the memory, and calling the data stored in the memory. The memory can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, at least one application program required by a function (such as a sound playing function, an image playing function, etc.), etc.; and the data storage area can store data created according to the use of the mobile phone (such as audio data, video data, etc.), etc. In addition, the memory can include a high-speed random access memory, and can also include a non-volatile memory, for example, a hard disk, a memory, a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, at least one disk storage device, a flash memory device, or other volatile solid-state memory devices.

[0107] Overall, the SO class member function protection method, the storage medium, the electronic device and the system provided by the embodiment of the present application make the member functions of the class of the SO file in the electronic device of the Linux operating system not easy to be cracked, effectively improve the security of the core function, and meet the actual application requirements.

[0108] Those skilled in the art will appreciate that embodiments of the present application can be provided as methods, systems, or computer program products. Accordingly, the present application can be embodied in the form of complete hardware embodiments, complete software embodiments, or embodiments combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including, but not limited to, disk storage and optical storage) containing computer-usable program code.

[0109] The present application is described with reference to flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to embodiments of the present application. It should be understood that each flow and / or block in the flowcharts and / or block diagrams, as well as combinations of flows and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing apparatus to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing apparatus produce a device that implements the functions specified in the flowcharts and / or block diagrams. Figure 1 one or more flows and / or blocks Figure 1 means for performing the functions specified in the flowchart

[0110] These computer program instructions can also be stored in a computer-readable memory that can direct the computer or other programmable data processing apparatus to work in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including instruction means, which implements the functions specified in the flowcharts and / or block diagrams. Figure 1 one or more flows and / or blocks Figure 1 one or more blocks

[0111] These computer program instructions can also be loaded onto a computer or other programmable data processing apparatus, so that a series of operation steps are performed on the computer or other programmable data processing apparatus to produce a computer-implemented process, so that the instructions executed on the computer or other programmable data processing apparatus provide a process for implementing the functions specified in the flowcharts and / or block diagrams. Figure 1 one or more flows and / or blocks Figure 1 one or more blocks

[0112] Note: the above specific examples are only examples and not limitations, and those skilled in the art can combine and combine some steps and devices from the above separately described various embodiments according to the concept of the present application to achieve the effect of the present application, and such combined and combined embodiments are also included in the present application, and such combined and combined embodiments are not described here.

[0113] The advantages, advantages, effects and the like mentioned in the embodiments of the present application are only examples and not limitations, and these advantages, advantages, effects and the like cannot be considered as the various embodiments of the present application must have. In addition, the above specific details disclosed in the embodiments of the present application are only for the purpose of example and for the purpose of understanding, and are not limited to the specific details disclosed in the embodiments of the present application.

[0114] The block diagrams of the devices, apparatuses, equipment, systems involved in the embodiments of the present application are only illustrative examples, and are not intended to require or imply the connection, arrangement, configuration shown in the block diagram. As those skilled in the art will recognize, these devices, apparatuses, equipment, systems can be connected, arranged, configured in any manner. Words such as "include", "contain", "have" and the like are open-ended words, which mean "including but not limited to", and can be used interchangeably. The words "or" and "and" used in the embodiments of the present application mean the word "and / or", and can be used interchangeably unless the context clearly indicates otherwise. The word "such as" used in the embodiments of the present application means the phrase "such as but not limited to", and can be used interchangeably.

[0115] The step flowchart and the above method description in the embodiments of the present application are only illustrative examples, and are not intended to require or imply the order of the steps of the various embodiments. As those skilled in the art will recognize, the order of the steps in the above embodiments can be performed in any order. Words such as "after", "then", "next" and the like are not intended to limit the order of the steps; these words are only used to guide the reader to read through the description of these methods. In addition, any reference to singular elements using articles "a", "an" or "the" is not interpreted as limiting the element to singular.

[0116] In addition, the steps and devices in various embodiments of the present application are not limited to only performing in a certain embodiment, in fact, according to the concept of the present application, relevant parts of the steps and part of the devices in various embodiments herein can be combined to conceive new embodiments, and these new embodiments are also included in the scope of the present application.

[0117] Each operation in the embodiments of the present application can be performed by any appropriate means capable of performing the corresponding function. The means can include various hardware and / or software components and / or modules, including but not limited to hardware circuit or processor.

[0118] The methods of embodiments of the application include one or more acts for implementing the methods described above. The methods and / or acts can be interchanged with one another without departing from the scope of the claims. In other words, unless a specific order is specified, the order and / or use of terms can be modified without departing from the scope of the claims.

[0119] Those skilled in the art will appreciate that various changes, modifications, substitutions, reversals, and alterations can be made to the techniques described herein without departing from the teachings of the disclosure as defined by the appended claims. Further, the scope of the claims of the present disclosure is not limited to the specific aspects described herein. Embodiments of the present disclosure can utilize existing or later-developed processes, machines, manufacture, compositions of matter, means, methods, and / or result substantially similar to those described herein. Accordingly, the appended claims include within their scope such processes, machines, manufacture, compositions of matter, means, methods, and / or result.

[0120] The above description of the disclosed aspects is given for illustrative purposes and is not intended to limit the scope of the application. Various modifications to these aspects will be readily apparent to those skilled in the art, and the generic principles defined herein can be applied to other aspects without departing from the scope of the application. Thus, the present application is not intended to be limited to the aspects shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

[0121] The above description has been presented for the purpose of illustration and description. Furthermore, the description is not intended to limit the embodiments of the application to the form disclosed herein. Although various example aspects and embodiments have been discussed above, those of skill in the art will recognize that certain variations, modifications, alterations, additions, and sub-combinations can be made to the aspects and embodiments discussed above without departing from the scope of the application. The description in this specification has not set forth in detail the specific details of the application in order to avoid obscuring the application.

Claims

1. A method for protecting class member functions in SO, characterized in that, The method includes the following steps: Based on the requirements for splitting virtual member functions in each SO file, set the dependencies between SO files; and configure the virtual member functions and loading initialization of SO files. The splitting and mapping relationships of virtual member functions in the SO file are recorded using a pre-defined data structure; Perform a splitting operation on the virtual member functions in the SO files that need to be split, so that the virtual member functions of the class are split into different target SO files according to the splitting mapping relationship; Hook the creation code of classes in SO files that have already undergone splitting, so that when the corresponding class is created, it can call the corresponding virtual member function code in the target SO file when it calls its virtual member function; Specifically, the virtual member functions and loading initialization of the SO file are set, including the following operations: Configure the virtual member functions in the SO file so that they do not call other global variables or global functions; Configure the loading and initialization of SO files so that when the SO file is loaded and initialized by calling the system initialization function, no class creation operation or member function call of its split class is performed; and load all SO files with dependencies at the same time.

2. The method for protecting class member functions in SO as described in claim 1, characterized in that, The preset data structure includes the following member variables: the SO file name where the virtual member function is split, the class name where the virtual member function is split, the offset address of the split virtual member function, the size of the split virtual member function, the target SO file name, and the offset address where the split virtual member function is stored in the target SO file.

3. The method for protecting class member functions in SO as described in claim 2, characterized in that, The method also includes adding a code segment to each target SO file, the code segment being used to store the code of the split virtual member functions.

4. The method for protecting class member functions in SO as described in claim 3, characterized in that, Perform a splitting operation on the virtual member functions in the SO files that need to be split, so that the virtual member functions of the class are split into different target SO files according to the splitting mapping relationship. Specifically, this includes the following operations: Copy the code of the virtual member functions that need to be split from the original SO file to the code segment added to the target SO file; Clean up the code of virtual member functions in the original SO file that needs to be split; The code of the virtual member function is copied to the location in the code segment added to the target SO file, and the offset address of the split virtual member function stored in the target SO file is assigned to the corresponding data structure.

5. The method for protecting class member functions in SO as described in claim 4, characterized in that, Copy the code of the virtual member functions that need to be split from the original SO file to the newly added code segment in the target SO file. This includes the following operations: Based on the splitting mapping relationship, the original SO file name, the target SO file name, the offset address of the split virtual member function, and the size of the split virtual member function are obtained from the corresponding data structure. Read the original SO file and the target SO file into memory; The code of the virtual member function is found based on the offset of the split virtual member function; Allocate a memory space from the code segment added to the target SO file, the size of which is the size of the split virtual member functions; Copy the code of the found virtual member function into the allocated memory space.

6. The method for protecting class member functions in SO as described in claim 1, characterized in that, Hook and modify the creation code of classes in SO files that have already undergone splitting operations, specifically including the following operations: Search for the class creation code in the SO file that has already undergone the splitting operation; Hook the location where each piece of code is created; Modify the address of the virtual member function in the virtual table to the memory address of the copied virtual member function code in the target SO file.

7. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, it implements the method described in any one of claims 1 to 6.

8. An electronic device comprising a Linux operating system, a memory, and a processor, wherein the memory stores a computer program that runs on the processor, characterized in that: When the processor executes the computer program, it implements the method according to any one of claims 1 to 6.

9. A class member function protection system in SO, characterized in that, include: The configuration module is used to set the dependencies between SO files according to the splitting requirements of virtual member functions in each SO file; and to configure the virtual member functions and loading initialization of SO files. The recording module is used to record the splitting and mapping relationships of virtual member functions in the SO file through a preset data structure; The splitting module is used to perform splitting operations on the virtual member functions in the SO files that need to be split, so that the virtual member functions of the class are split into different target SO files according to the splitting mapping relationship; The Hook module is used to hook and modify the creation code of classes in SO files that have undergone splitting operations, so that when the corresponding class is created, it can call the corresponding virtual member function code in the target SO file when it calls its virtual member function. The setting module configures the virtual member functions and loading initialization of SO files, including the following operations: configuring the virtual member functions of SO files so that they do not call other global variables or global functions; configuring the loading initialization of SO files so that when the SO file calls the system initialization function for loading initialization, it does not perform class creation operations or call the member functions of its split classes; and loading all SO files with dependencies simultaneously.

Citation Information

Patent Citations

  • Method and device for preventing reverse cracking of shared object file for Android system

    CN105227565A

  • Data table storage method, data table modification method, data table query method and data table statistical method

    CN105279198A

  • A plug-in-based iOS security compiler and a security compiling method

    CN109711118A