A data processing method and device, electronic equipment and storage medium

By creating subclasses and generating overridden function tables in the application development environment, the problem of incorrect function address replacement in virtual function tables is solved, ensuring correct function calls and preventing application runtime errors.

CN113590091BActive Publication Date: 2026-04-17WUBA
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
WUBA
Filing Date
2021-06-30
Publication Date
2026-04-17

AI Technical Summary

Technical Problem

When the application is updated, an error in replacing the function address in the virtual function table causes function calls to fail, resulting in application runtime errors.

Method used

In the application's development environment, create a subclass, set the base class name, the original function, and the address of the target function, generate a rewritten function table, and replace the address of the original function with the address of the target function in the virtual function table.

Benefits of technology

This avoids errors in function address substitution in the virtual function table, ensures correct function calls, and prevents application runtime errors.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113590091B_ABST
    Figure CN113590091B_ABST
Patent Text Reader

Abstract

This invention provides a data processing method, apparatus, electronic device, and storage medium. The method involves obtaining the overridden function table of subclasses in the executable file of an application. The subclasses inherit from a base class in the executable file. The overridden function table includes the addresses of the original functions in the base class that need to be replaced, the class name of the base class, and the address of the target function used to replace the original functions. The method then determines the virtual function table of the base class, which includes the addresses of functions in the base class. The method searches for the address of the original function in the base class's virtual function table. Finally, the address of the target function replaces the address of the original function in the base class's virtual function table. This avoids replacing the address of a function in the virtual function table that should not have been replaced with the address of the target function, thus preventing replacement errors and preventing the application from calling the wrong function, ultimately preventing application runtime errors.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology, and in particular to a data processing method, apparatus, electronic device, and storage medium. Background Technology

[0002] An application may contain multiple functions. Sometimes, for practical needs, it may be necessary to replace one function with another. In this case, the address of the original function in the application's virtual function table can be modified to the address of the other function. This allows the application to obtain the address of the other function when calling a function based on the virtual function table, and then call the other function according to that address.

[0003] In the virtual function table, function addresses are not indexed by function names, but rather by their position within the table. For example, the virtual function table can be understood as an array containing the addresses of multiple functions, each with its own positional order. This positional order allows for indexing of function addresses within the virtual function table. The order of function addresses in the virtual function table corresponds to the order in which function names appear in the application.

[0004] In one example, suppose that by default, the address of the original function (located at position N in the virtual function table) is replaced with the address of the target function. However, sometimes the application may be updated, for example, by inserting a new function. If the new function's name appears before the original function's name in the application, the original function's name will appear in the application in the order N+1, which in turn will cause the address of the original function to appear in the virtual function table in the order N+1.

[0005] In this way, the function name of the function appearing in the application in the order of N becomes the function name of other functions, and the address of the function in the virtual function table in the order of N becomes the address of that other function.

[0006] After the updated application runs, it will still use the address of the target function to replace the address of the function in the virtual function table whose position is N by default. That is, it will replace the address of the other function, but will not replace the address of the original function whose position is N+1. In other words, a replacement error occurs.

[0007] This can lead to a situation where, when another function needs to be called later, the address of that other function cannot be obtained from the virtual function table, thus preventing the function from being called. Furthermore, when the target function needs to be called, the address of the original function is obtained from the virtual function table, preventing the target function from being called, which may cause application runtime errors. Summary of the Invention

[0008] This application discloses a data processing method, apparatus, electronic device, and storage medium.

[0009] In a first aspect, this application discloses a data processing method, the method comprising:

[0010] Create subclasses that inherit from a base class in the application's development environment; the base class is a class that has been developed in the development environment.

[0011] In the subclass, set the class name of the base class, the function name of the original function to be replaced in the base class, and the function address of the target function used to replace the original function;

[0012] In the process of generating the executable file of the application based on the source code of the application already developed in the development environment, the function address of the original function is obtained according to the function name of the original function;

[0013] The executable file generates a table of overridden functions for the subclass, which includes the function address of the original function, the class name of the base class, and the function address of the target function.

[0014] Secondly, this application discloses a data processing method, the method comprising:

[0015] Obtain the overridden function table of subclasses in the executable file of the application. The subclasses inherit from a base class in the executable file. The overridden function table includes the function address of the original function to be replaced in the base class, the class name of the base class, and the function address of the target function used to replace the original function. The overridden function table is generated based on the class name of the base class, the function name of the original function, and the function address of the target function set in the subclass in the application's development environment. The function address of the original function is obtained based on the function name of the original function. The subclass inherits from the base class.

[0016] The virtual function table of the base class is obtained based on the class name of the base class, and the virtual function table includes the function addresses of the functions in the base class;

[0017] The function address of the original function is found in the virtual function table;

[0018] Replace the address of the original function in the virtual function table with the address of the target function.

[0019] In an optional implementation, obtaining the table of overridden functions for subclasses in the application's executable file includes:

[0020] Obtain the memory address of the subclass in the executable file;

[0021] Obtain the offset of the overridden function table of the subclass in the memory address;

[0022] The rewrite function table is obtained based on the offset.

[0023] In an optional implementation, obtaining the offset of the overridden function table of the subclass in the memory address includes:

[0024] Get the value of a specific flag bit in the subclass;

[0025] The structure of the subclass is determined based on the value of the specific flag bit;

[0026] The offset is determined based on the structure of the subclass.

[0027] Thirdly, this application discloses a data processing apparatus, the apparatus comprising:

[0028] Create a module for creating subclasses that inherit from a base class, which is a class that has been developed in the application's development environment;

[0029] The configuration module is used to set the class name of the base class, the function name of the original function to be replaced in the base class, and the function address of the target function used to replace the original function in the subclass.

[0030] The first acquisition module is used to obtain the function address of the original function based on the function name of the original function during the process of generating the executable file of the application based on the source code of the application developed in the development environment.

[0031] A generation module is used to generate a rewritten function table of the subclass in the executable file. The rewritten function table includes the function address of the original function, the class name of the base class, and the function address of the target function.

[0032] Fourthly, this application discloses a data processing apparatus, the apparatus comprising:

[0033] The second acquisition module is used to acquire the overridden function table of subclasses in the executable file of the application. The subclasses inherit from the base class in the executable file. The overridden function table includes the function address of the original function to be replaced in the base class, the class name of the base class, and the function address of the target function used to replace the original function. The overridden function table is generated based on the class name of the base class, the function name of the original function, and the function address of the target function set in the subclass in the application's development environment. The function address of the original function is obtained based on the function name of the original function. The subclass inherits from the base class.

[0034] The third acquisition module is used to obtain the virtual function table of the base class according to the class name of the base class, wherein the virtual function table includes the function addresses of the functions in the base class;

[0035] The lookup module is used to find the function address of the original function in the virtual function table;

[0036] The replacement module is used to replace the function address of the original function in the virtual function table with the function address of the target function.

[0037] In one optional implementation, the second acquisition module includes:

[0038] The first acquisition unit is used to acquire the memory address of the subclass in the executable file;

[0039] The second acquisition unit is used to acquire the offset of the overridden function table of the subclass in the memory address;

[0040] The third acquisition unit is used to acquire the rewrite function table based on the offset.

[0041] In one optional implementation, the second acquisition unit includes:

[0042] Obtain a sub-unit, used to obtain the value of a specific flag bit in the subclass;

[0043] The first determining subunit is used to determine the structure of the subclass based on the value of the specific flag bit;

[0044] The second determining subunit is used to determine the offset based on the structure of the subclass.

[0045] Fifthly, this application discloses an electronic device comprising:

[0046] processor;

[0047] Memory used to store processor-executable instructions;

[0048] The processor is configured to perform the data processing method as described in the first aspect.

[0049] In a sixth aspect, this application discloses a non-transitory computer-readable storage medium in which, when the instructions in the storage medium are executed by a processor of an electronic device, enable the electronic device to perform the data processing method as described in the first aspect.

[0050] In a seventh aspect, this application discloses a computer program product in which, when the instructions in the computer program product are executed by a processor of an electronic device, the electronic device is enabled to perform the data processing method as described in the first aspect.

[0051] Eighthly, this application discloses an electronic device comprising:

[0052] processor;

[0053] Memory used to store processor-executable instructions;

[0054] The processor is configured to perform the data processing method as described in the second aspect.

[0055] In a ninth aspect, this application discloses a non-transitory computer-readable storage medium in which, when instructions in the storage medium are executed by a processor of an electronic device, enable the electronic device to perform the data processing method as described in the second aspect.

[0056] In a tenth aspect, this application discloses a computer program product in which, when the instructions in the computer program product are executed by a processor of an electronic device, the electronic device is enabled to perform the data processing method as described in the second aspect.

[0057] The technical solution provided in this application may include the following beneficial effects:

[0058] In this application, during application development, subclasses that inherit from a base class are created within the application's development environment. The base class is a class already developed in the development environment. The subclass sets the base class name, the name of the original function to be replaced, and the address of the target function used to replace the original function. During the process of generating the application's executable file from the application's source code developed in the development environment, the address of the original function is obtained based on its name. An overridden function table for the subclass is generated within the executable file, including the addresses of the original functions, the base class name, and the address of the target function.

[0059] This application enables the acquisition of the overridden function table of subclasses in the application's executable file during hooking of the original function. This allows for the determination of the virtual function table of the base class inherited by the subclass, which includes the function addresses of functions in the base class. The address of the original function is then searched within the base class's virtual function table. Finally, the address of the target function replaces the address of the original function in the base class's virtual function table.

[0060] This application allows binding the address of a target function to the address of the original function that needs to be replaced. When replacing the address of the original function in the virtual function table of the base class with the address of the target function, the search for the original function's address in the virtual function table can be performed directly based on the original function's address, rather than according to the order of the original function's name in the base class. This ensures that the address found in the virtual function table of the base class is always the address of the original function. Replacing the found address with the address of the target function in the virtual function table achieves the goal of replacing the original function's address with the address of the target function, avoiding the replacement of function addresses in the virtual function table that should not be replaced. This prevents replacement errors and avoids the application calling the wrong function, thus preventing application runtime errors. Attached Figure Description

[0061] Figure 1 This is a flowchart illustrating the steps of a data processing method shown in this application.

[0062] Figure 2 This is a flowchart illustrating the steps of a data processing method shown in this application.

[0063] Figure 3 This is a structural block diagram of a data processing apparatus shown in this application.

[0064] Figure 4 This is a structural block diagram of a data processing apparatus shown in this application.

[0065] Figure 5 This is a block diagram of an electronic device shown in this application.

[0066] Figure 6 This is a block diagram of an electronic device shown in this application. Detailed Implementation

[0067] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0068] Reference Figure 1 The diagram illustrates a flowchart of a data processing method according to this application, applied to an electronic device. The method may specifically include the following steps:

[0069] In step S101, a subclass is created in the application's development environment to inherit from a base class, which is a class that has been developed in the development environment.

[0070] Developers can launch a development environment on an electronic device and develop the application's source code within that environment.

[0071] In one embodiment, a portion of the application's source code has been developed in the development environment. The developed source code includes at least a base class, which may include at least one function.

[0072] In this application, there may be a situation where it is necessary to call another function instead of a certain function in the base class when calling the base class later. In this case, it is necessary to hook the certain function in the base class, for example, to replace the certain function with the other function, and it is necessary not to modify the code of the base class.

[0073] In this scenario, during the development phase, developers can enter a creation request in the application's development environment to create a subclass that inherits from a base class, which is one of the classes already developed in the development environment. The electronic device can receive this creation request and then create the subclass that inherits from the base class in the application's development environment based on it.

[0074] In step S102, the class name of the base class, the function name of the original function to be replaced in the base class, and the function address of the target function used to replace the original function are set in the subclass.

[0075] In this application, since it is necessary to call another function instead of a certain function in the base class when calling the base class later, after the developer controls the electronic device to create a subclass for inheriting the base class in the application's development environment, the class name of the base class, the name of the original function in the base class that needs to be replaced, and the function address of the target function used to replace the original function can be set in the subclass in the development environment.

[0076] The electronic device receives the base class name, the original function name, and the target function address in the subclass.

[0077] The original function can be one of the functions included in the base class, or more than two functions included in the base class. This application uses the example of the original function being one of the functions included in the base class for illustration, but this is not intended to limit the scope of protection of this application.

[0078] In step S103, during the process of generating the executable file of the application based on the source code of the application already developed in the development environment, the function address of the original function is obtained based on the function name of the original function.

[0079] The source code of an application developed in the development environment includes at least a base class and subclasses that inherit from the base class, as well as the class name of the base class, the function name of the original function, and the function address of the target function set in the subclass. Of course, it may also include the code of other functions of the application, which will not be detailed here.

[0080] In this application, after the developer has finished writing the application's source code in the development environment, the developer can input a compilation request into the electronic device to compile the source code of the application that has been developed in the development environment. The electronic device can receive the compilation request and compile the source code of the application that has been developed in the development environment according to the compilation request to obtain the executable file of the application.

[0081] In the subclass within the development environment, there is a first string indicating the inheritance relationship between the subclass and the base class, and a second string indicating that the address of the original function corresponding to the function name of the original function in the base class should be replaced with the address of the target function.

[0082] Thus, during the process of compiling the source code of an application developed in the development environment, the electronic device can identify the first string and the second string in the subclass. Based on the first string, it can determine that there is an inheritance relationship between the subclass and the base class. Based on the second string, it can determine that the function address of the target function needs to be replaced with the function address of the original function in the base class.

[0083] Under the condition that the above two conditions are met, during the process of compiling the code in the development environment, for the subclass, the overridden function table of the subclass will be generated. For example, the function address of the original function can be found in the virtual function table according to the function name of the original function. For example, the order in which the original function appears in all functions in the base class can be determined according to the function name of the original function. Then, the function address located in that order can be found in the virtual function table of the base class and used as the function address of the original function. Then, step S104 is executed.

[0084] In step S104, a rewritten function table for the subclass is generated in the executable file. The rewritten function table includes the function address of the original function, the class name of the base class, and the function address of the target function.

[0085] In this way, the executable file contains a table of overridden functions for the subclass. This ensures that when a function in the base class needs to be called later, the function will be invoked based on the address of the target function, rather than the address of the original function. This achieves the goal of using the target function to hook the original function.

[0086] For specific calling methods, please refer to Figure 2 The embodiments shown are not described in detail here.

[0087] In this application, during application development, subclasses that inherit from a base class are created within the application's development environment. The base class is a class already developed in the development environment. The subclass sets the base class name, the name of the original function to be replaced, and the address of the target function used to replace the original function. During the process of generating the application's executable file from the application's source code developed in the development environment, the address of the original function is obtained based on its name. An overridden function table for the subclass is generated within the executable file, including the addresses of the original functions, the base class name, and the address of the target function.

[0088] This application enables the acquisition of the overridden function table of subclasses in the application's executable file during hooking of the original function. This allows for the determination of the virtual function table of the base class inherited by the subclass, which includes the function addresses of functions in the base class. The address of the original function is then searched within the base class's virtual function table. Finally, the address of the target function replaces the address of the original function in the base class's virtual function table.

[0089] This application allows binding the address of a target function to the address of the original function that needs to be replaced. When replacing the address of the original function in the virtual function table of the base class with the address of the target function, the search for the original function's address in the virtual function table can be performed directly based on the original function's address, rather than according to the order of the original function's name in the base class. This ensures that the address found in the virtual function table of the base class is always the address of the original function. Replacing the found address with the address of the target function in the virtual function table achieves the goal of replacing the original function's address with the address of the target function, avoiding the replacement of function addresses in the virtual function table that should not be replaced. This prevents replacement errors and avoids the application calling the wrong function, thus preventing application runtime errors.

[0090] Reference Figure 2 The diagram illustrates a flowchart of a data processing method according to this application, applied to an electronic device. The method may specifically include the following steps:

[0091] In step S201, the overridden function table of the subclasses in the executable file of the application is obtained. The subclasses inherit from the base class in the executable file. The overridden function table includes the function address of the original function to be replaced in the base class, the class name of the base class, and the function address of the target function used to replace the original function.

[0092] The overridden function table is generated based on the base class name, the original function name, and the target function address set in the subclass in the application's development environment; the original function address is obtained based on the original function name; the subclass is used to inherit from the base class.

[0093] In this application, after the executable file is run in the electronic device, the electronic device can initialize each class of the executable file separately. When initializing the subclass, the overridden function table in the subclass can be obtained. The specific method of obtaining the table can be found in the following process.

[0094] This step can be implemented through the following process:

[0095] 2011. Obtain the memory address of a subclass in the executable file.

[0096] In this application, the execution of an executable file by an electronic device involves loading the executable file into the memory of the electronic device, thus giving the executable file a memory address in the memory of the electronic device.

[0097] In this step, the memory address of a subclass in the executable file can be obtained using methods such as `class.self`. Of course, other methods can also be used to obtain the memory address of a subclass in the executable file; this application does not limit the specific method used.

[0098] 2012. Get the offset of the overridden function table of the subclass in the subclass's memory address.

[0099] This step can be achieved through the following process:

[0100] 11) Get the value of a specific flag in a subclass.

[0101] In this application, subclasses often contain multiple elements, such as Flag, Parent, Name, AccessFunction, and an OverrideTableList table of overridden functions. The elements contained in a subclass may differ under different circumstances; that is, the subclass structure may vary. The specific elements contained in a subclass can be distinguished by the value of a specific flag, i.e., the subclass structure is differentiated by the value of that specific flag. In other words, different values ​​of a specific flag correspond to different subclass structures.

[0102] 12) Determine the structure of the subclass based on the value of a specific flag bit.

[0103] 13) Determine the offset of the rewritten function table in memory address based on the subclass's structure.

[0104] In this application, the subclass has a memory address in memory, and the offset of the overridden function table in the subclass's memory address can be understood as the distance between the starting address of the overridden function table in memory and the starting address of the subclass's memory address.

[0105] Once the structure of a subclass is determined, the order in which it includes content is determined, and the size of each content in the subclass is also determined.

[0106] Once the subclass structure is determined, the position and order of the overridden function table in the subclass can be determined, as can the contents preceding the overridden function table and the size of each of these contents. Therefore, based on the contents preceding the overridden function table in the subclass and the size of each of these contents, the offset of the overridden function table in the subclass structure can be determined, which can be used as the offset in memory address.

[0107] 2013. Obtain the overridden function table of the subclass based on the offset.

[0108] In this application, the structure of the rewritten function table is predetermined and fixed. For example, the order of the function address of the original function, the class name of the base class, and the function address of the target function in the rewritten function table is also predetermined and fixed. The space size (e.g., bytes) occupied by the function address of the original function, the class name of the base class, and the function address of the target function in the rewritten function table is also predetermined and fixed.

[0109] Based on this, the electronic device can parse the function address of the primitive function, the class name of the base class, and the function address of the target function in the rewrite function table according to the above-mentioned pre-set rules.

[0110] For example, starting from the offset, read the contents of three adjacent spaces of a specific size in sequence, and parse out the function address of the original function, the class name of the base class, and the function address of the target function in a specific order.

[0111] In step S202, the virtual function table of the base class inherited by the subclass is obtained according to the class name of the base class. The virtual function table includes the function addresses of the functions in the base class.

[0112] In this application, the base class inherited by the subclass can be found in the executable file based on the class name of the base class in the overridden function table (the specific search method can be found in the existing methods, which will not be detailed here), and then the virtual function table of the base class can be searched in the base class.

[0113] In step S203, the function address of the original function is searched in the virtual function table of the base class.

[0114] In this application, the virtual function table of the base class stores the function addresses of each function in the base class, one of which is the function address of the original function. The function address of the original function can be found in the virtual function table of the base class, and then step S204 is executed.

[0115] In step S204, the function address of the original function in the virtual function table of the base class is replaced with the function address of the target function.

[0116] Thus, the virtual function table of the base class no longer contains the function address of the original function, but contains the function address of the target function. Furthermore, the order of the function address of the original function in the virtual function table of the base class before the replacement is the same as the order of the function address of the target function in the virtual function table of the base class after the replacement.

[0117] In this way, when a function in the base class needs to be called later, when the function is called based on the storage address of the function in the virtual function table of the base class, the original function will not be called based on its address. Instead, the target function will be called based on its address, thus achieving the purpose of using the target function to hook the original function.

[0118] In this application, the overridden function table of subclasses in the executable file of the application is obtained. The subclasses inherit from the base class in the executable file. The overridden function table includes the function address of the original function to be replaced in the base class, the class name of the base class, and the function address of the target function used to replace the original function. The virtual function table of the base class inherited by the subclass is determined, and this virtual function table includes the function addresses of the functions in the base class. The function address of the original function is found in the virtual function table of the base class. The function address of the target function is used to replace the function address of the original function in the virtual function table of the base class.

[0119] This application allows binding the address of a target function to the address of the original function that needs to be replaced. When replacing the address of the original function in the virtual function table of the base class with the address of the target function, the search for the original function's address in the virtual function table can be performed directly based on the original function's address, rather than according to the order of the original function's name in the base class. This ensures that the address found in the virtual function table of the base class is always the address of the original function. Replacing the found address with the address of the target function in the virtual function table achieves the goal of replacing the original function's address with the address of the target function, avoiding the replacement of function addresses in the virtual function table that should not be replaced. This prevents replacement errors and avoids the application calling the wrong function, thus preventing application runtime errors.

[0120] It should be noted that, for the sake of simplicity, the method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, because according to this application, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also understand that the embodiments described in the specification are all optional embodiments, and the actions involved are not necessarily required by this application.

[0121] Reference Figure 3 The diagram shows a structural block diagram of a data processing apparatus according to this application, which is applied to an electronic device. The apparatus may specifically include the following modules:

[0122] Module 11 is created to create subclasses that inherit from a base class in the application's development environment, where the base class is a class that has been developed in the development environment.

[0123] Setting module 12 is used to set the class name of the base class, the function name of the original function to be replaced in the base class, and the function address of the target function used to replace the original function in the subclass;

[0124] The first acquisition module 13 is used to obtain the function address of the original function based on the function name of the original function during the process of generating the executable file of the application based on the source code of the application developed in the development environment.

[0125] The generation module 14 is used to generate a rewritten function table of the subclass in the executable file. The rewritten function table includes the function address of the original function, the class name of the base class, and the function address of the target function.

[0126] In this application, during application development, subclasses that inherit from a base class are created within the application's development environment. The base class is a class already developed in the development environment. The subclass sets the base class name, the name of the original function to be replaced, and the address of the target function used to replace the original function. During the process of generating the application's executable file from the application's source code developed in the development environment, the address of the original function is obtained based on its name. An overridden function table for the subclass is generated within the executable file, including the addresses of the original functions, the base class name, and the address of the target function.

[0127] This application enables the acquisition of the overridden function table of subclasses in the application's executable file during hooking of the original function. This allows for the determination of the virtual function table of the base class inherited by the subclass, which includes the function addresses of functions in the base class. The address of the original function is then searched within the base class's virtual function table. Finally, the address of the target function replaces the address of the original function in the base class's virtual function table.

[0128] This application allows binding the address of a target function to the address of the original function that needs to be replaced. When replacing the address of the original function in the virtual function table of the base class with the address of the target function, the search for the original function's address in the virtual function table can be performed directly based on the original function's address, rather than according to the order of the original function's name in the base class. This ensures that the address found in the virtual function table of the base class is always the address of the original function. Replacing the found address with the address of the target function in the virtual function table achieves the goal of replacing the original function's address with the address of the target function, avoiding the replacement of function addresses in the virtual function table that should not be replaced. This prevents replacement errors and avoids the application calling the wrong function, thus preventing application runtime errors.

[0129] Reference Figure 4The diagram shows a structural block diagram of a data processing apparatus according to this application, which is applied to an electronic device. The apparatus may specifically include the following modules:

[0130] The second acquisition module 21 is used to acquire the overridden function table of a subclass in the executable file of an application. The subclass inherits from the base class in the executable file. The overridden function table includes the function address of the original function to be replaced in the base class, the class name of the base class, and the function address of the target function used to replace the original function. The overridden function table is generated based on the class name of the base class, the function name of the original function, and the function address of the target function set in the subclass in the development environment of the application. The function address of the original function is obtained based on the function name of the original function. The subclass inherits from the base class.

[0131] The third acquisition module 22 is used to acquire the virtual function table of the base class according to the class name of the base class, wherein the virtual function table includes the function addresses of the functions in the base class;

[0132] The lookup module 23 is used to look up the function address of the original function in the virtual function table;

[0133] Replacement module 24 is used to replace the function address of the original function in the virtual function table with the function address of the target function.

[0134] In one optional implementation, the second acquisition module includes:

[0135] The first acquisition unit is used to acquire the memory address of the subclass in the executable file;

[0136] The second acquisition unit is used to acquire the offset of the overridden function table of the subclass in the memory address;

[0137] The third acquisition unit is used to acquire the rewrite function table based on the offset.

[0138] In one optional implementation, the second acquisition unit includes:

[0139] Obtain a sub-unit, used to obtain the value of a specific flag bit in the subclass;

[0140] The first determining subunit is used to determine the structure of the subclass based on the value of the specific flag bit;

[0141] The second determining subunit is used to determine the offset based on the structure of the subclass.

[0142] In this application, the overridden function table of subclasses in the executable file of the application is obtained. The subclasses inherit from the base class in the executable file. The overridden function table includes the function address of the original function to be replaced in the base class, the class name of the base class, and the function address of the target function used to replace the original function. The virtual function table of the base class inherited by the subclass is determined, and this virtual function table includes the function addresses of the functions in the base class. The function address of the original function is found in the virtual function table of the base class. The function address of the target function is used to replace the function address of the original function in the virtual function table of the base class.

[0143] This application allows binding the address of a target function to the address of the original function that needs to be replaced. When replacing the address of the original function in the virtual function table of the base class with the address of the target function, the search for the original function's address in the virtual function table can be performed directly based on the original function's address, rather than according to the order of the original function's name in the base class. This ensures that the address found in the virtual function table of the base class is always the address of the original function. Replacing the found address with the address of the target function in the virtual function table achieves the goal of replacing the original function's address with the address of the target function, avoiding the replacement of function addresses in the virtual function table that should not be replaced. This prevents replacement errors and avoids the application calling the wrong function, thus preventing application runtime errors.

[0144] As the device embodiment is basically similar to the method embodiment, the description is relatively simple, and relevant parts can be found in the description of the method embodiment.

[0145] Optionally, embodiments of the present invention also provide an electronic device, including: a processor, a memory, and a computer program stored in the memory and executable on the processor. When the computer program is executed by the processor, it implements the various processes of the above-described data processing method embodiments and achieves the same technical effect. To avoid repetition, it will not be described again here.

[0146] This invention also provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, it implements the various processes of the above-described data processing method embodiments and achieves the same technical effects. To avoid repetition, it will not be described again here. The computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.

[0147] Figure 5This is a block diagram illustrating an electronic device 800. For example, the electronic device 800 may be a mobile phone, computer, digital broadcasting terminal, messaging device, game console, tablet device, medical device, fitness equipment, personal digital assistant, etc.

[0148] Reference Figure 5 The electronic device 800 may include one or more of the following components: a processing component 802, a memory 804, a power component 806, a multimedia component 808, an audio component 810, an input / output (I / O) interface 812, a sensor component 814, and a communication component 816.

[0149] Processing component 802 typically controls the overall operation of electronic device 800, such as operations associated with display, telephone calls, data communication, camera operation, and recording operations. Processing component 802 may include one or more processors 820 to execute instructions to complete all or part of the steps of the methods described above. Furthermore, processing component 802 may include one or more modules to facilitate interaction between processing component 802 and other components. For example, processing component 802 may include a multimedia module to facilitate interaction between multimedia component 808 and processing component 802.

[0150] Memory 804 is configured to store various types of data to support the operation of device 800. Examples of this data include instructions for any application or method operating on electronic device 800, contact data, phonebook data, messages, images, videos, etc. Memory 804 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk.

[0151] Power supply component 806 provides power to various components of electronic device 800. Power supply component 806 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to electronic device 800.

[0152] Multimedia component 808 includes a screen that provides an output interface between the electronic device 800 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touchscreen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensors may sense not only the boundaries of the touch or swipe action but also the duration and pressure associated with the touch or swipe operation. In some embodiments, multimedia component 808 includes a front-facing camera and / or a rear-facing camera. When the device 800 is in an operating mode, such as a shooting mode or a video mode, the front-facing camera and / or the rear-facing camera may receive external multimedia data. Each front-facing camera and rear-facing camera may be a fixed optical lens system or have focal length and optical zoom capabilities.

[0153] Audio component 810 is configured to output and / or input audio signals. For example, audio component 810 includes a microphone (MIC) configured to receive external audio signals when electronic device 800 is in an operating mode, such as call mode, recording mode, and voice recognition mode. The received audio signals may be further stored in memory 804 or transmitted via communication component 816. In some embodiments, audio component 810 also includes a speaker for outputting audio signals.

[0154] I / O interface 812 provides an interface between processing component 802 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to, home buttons, volume buttons, power buttons, and lock buttons.

[0155] Sensor assembly 814 includes one or more sensors for providing state assessments of various aspects of electronic device 800. For example, sensor assembly 814 may detect the on / off state of device 800, the relative positioning of components such as the display and keypad of electronic device 800, changes in position of electronic device 800 or a component of electronic device 800, the presence or absence of user contact with electronic device 800, orientation or acceleration / deceleration of electronic device 800, and temperature changes of electronic device 800. Sensor assembly 814 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. Sensor assembly 814 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, sensor assembly 814 may also include an accelerometer, gyroscope, magnetometer, pressure sensor, or temperature sensor.

[0156] Communication component 816 is configured to facilitate wired or wireless communication between electronic device 800 and other devices. Electronic device 800 can access wireless networks based on communication standards, such as WiFi, carrier networks (such as 2G, 3G, 4G, or 5G), or combinations thereof. In one exemplary embodiment, communication component 816 receives broadcast signals or broadcast operation information from an external broadcast management system via a broadcast channel. In one exemplary embodiment, communication component 816 also includes a near-field communication (NFC) module to facilitate short-range communication. For example, the NFC module may be implemented based on radio frequency identification (RFID) technology, Infrared Data Association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.

[0157] In an exemplary embodiment, the electronic device 800 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the methods described above.

[0158] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 804 including instructions, which can be executed by a processor 820 of an electronic device 800 to perform the above-described method. For example, the non-transitory computer-readable storage medium may be a ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, and optical data storage device, etc.

[0159] Figure 6 This is a block diagram of an electronic device 1900 shown in this application. For example, the electronic device 1900 can be provided as a server.

[0160] Reference Figure 6 The electronic device 1900 includes a processing component 1922, which further includes one or more processors, and memory resources represented by memory 1932 for storing instructions, such as application programs, that can be executed by the processing component 1922. The application programs stored in memory 1932 may include one or more modules, each corresponding to a set of instructions. Furthermore, the processing component 1922 is configured to execute instructions to perform the methods described above.

[0161] Electronic device 1900 may also include a power supply component 1926 configured to perform power management of electronic device 1900, a wired or wireless network interface 1950 configured to connect electronic device 1900 to a network, and an input / output (I / O) interface 1958. Electronic device 1900 can operate on an operating system stored in memory 1932, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, or similar.

[0162] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.

[0163] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of the present invention.

[0164] The embodiments of the present invention have been described above with reference to the accompanying drawings. However, the present invention is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of the present invention without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of the present invention.

[0165] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed in this invention can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.

[0166] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0167] In the embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.

[0168] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0169] In addition, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.

[0170] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, essentially, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, ROM, RAM, magnetic disks, or optical disks.

[0171] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.

Claims

1. A data processing method, characterized by, The method includes: Create subclasses that inherit from a base class in the application's development environment; the base class is a class that has been developed in the development environment. In the subclass, set the class name of the base class, the function name of the original function to be replaced in the base class, and the function address of the target function used to replace the original function; In the process of generating the executable file of the application based on the source code of the application already developed in the development environment, the function address of the original function is obtained according to the function name of the original function; The executable file generates a table of overridden functions for the subclass, the table of overridden functions including the function address of the original function, the class name of the base class, and the function address of the target function; Obtain the overridden function table of the subclass in the executable file of the application; In the subclass in the development environment, there is a first string indicating the inheritance relationship between the subclass and the base class, and a second string indicating that the function address of the original function corresponding to the function name of the original function in the base class is replaced with the function address of the target function. The step of obtaining the function address of the original function based on its function name includes: Identify the first string and the second string in the subclass; Based on the first string, it is determined that there is an inheritance relationship between the subclass and the base class; and based on the second string, it is determined that the function address of the original function in the base class needs to be replaced by the function address of the target function. The step of obtaining the overridden function table of the subclass in the executable file of the application includes: Obtain the memory address of the subclass in the executable file; Obtain the offset of the overridden function table of the subclass in the memory address; The rewrite function table is obtained based on the offset.

2. A data processing method, characterized by, The method includes: Obtain the overridden function table of subclasses in the executable file of the application. The subclasses inherit from a base class in the executable file. The overridden function table includes the function address of the original function to be replaced in the base class, the class name of the base class, and the function address of the target function used to replace the original function. The overridden function table is generated based on the class name of the base class, the function name of the original function, and the function address of the target function set in the subclass in the application's development environment. The function address of the original function is obtained based on the function name of the original function. The subclass inherits from the base class. The virtual function table of the base class is obtained based on the class name of the base class, and the virtual function table includes the function addresses of the functions in the base class; The function address of the original function is found in the virtual function table; Replace the address of the original function in the virtual function table with the address of the target function; In the subclass in the development environment, there is a first string indicating the inheritance relationship between the subclass and the base class, and a second string indicating that the function address of the original function corresponding to the function name of the original function in the base class is replaced with the function address of the target function. Obtaining the function address of the original function based on its function name includes: Identify the first string and the second string in the subclass; Based on the first string, it is determined that there is an inheritance relationship between the subclass and the base class; and based on the second string, it is determined that the function address of the original function in the base class needs to be replaced by the function address of the target function. The step of obtaining the table of overridden functions for subclasses in the executable file of the application includes: Obtain the memory address of the subclass in the executable file; Obtain the offset of the overridden function table of the subclass in the memory address; The rewrite function table is obtained based on the offset.

3. The method of claim 2, wherein, The step of obtaining the offset of the overridden function table of the subclass in the memory address includes: Get the value of a specific flag bit in the subclass; The structure of the subclass is determined based on the value of the specific flag bit; The offset is determined based on the structure of the subclass.

4. A data processing apparatus, characterized in that, The device includes: Create a module for creating subclasses that inherit from a base class, which is a class that has been developed in the application's development environment; The configuration module is used to set the class name of the base class, the function name of the original function to be replaced in the base class, and the function address of the target function used to replace the original function in the subclass. The first acquisition module is used to obtain the function address of the original function based on the function name of the original function during the process of generating the executable file of the application based on the source code of the application developed in the development environment. A generation module is used to generate a rewritten function table of the subclass in the executable file. The rewritten function table includes the function address of the original function, the class name of the base class, and the function address of the target function. The second acquisition module is used to acquire the overridden function table of the subclass in the executable file of the application. In the subclass in the development environment, there is a first string indicating the inheritance relationship between the subclass and the base class, and a second string indicating that the function address of the original function corresponding to the function name of the original function in the base class is replaced with the function address of the target function. The first acquisition module is further configured to identify the first string and the second string in the subclass; determine that there is an inheritance relationship between the subclass and the base class based on the first string; and determine that the function address of the original function in the base class needs to be replaced by the function address of the target function based on the second string. The second acquisition module includes: The first acquisition unit is used to acquire the memory address of the subclass in the executable file; The second acquisition unit is used to acquire the offset of the overridden function table of the subclass in the memory address; The third acquisition unit is used to acquire the rewrite function table based on the offset.

5. A data processing apparatus, characterized in that, The device includes: The second acquisition module is used to acquire the overridden function table of subclasses in the executable file of the application. The subclasses inherit from the base class in the executable file. The overridden function table includes the function address of the original function to be replaced in the base class, the class name of the base class, and the function address of the target function used to replace the original function. The overridden function table is generated based on the class name of the base class, the function name of the original function, and the function address of the target function set in the subclass in the application's development environment. The function address of the original function is obtained based on the function name of the original function. The subclass inherits from the base class. The third acquisition module is used to obtain the virtual function table of the base class according to the class name of the base class, wherein the virtual function table includes the function addresses of the functions in the base class; The lookup module is used to find the function address of the original function in the virtual function table; A replacement module is used to replace the function address of the original function in the virtual function table with the function address of the target function; In the subclass in the development environment, there is a first string indicating the inheritance relationship between the subclass and the base class, and a second string indicating that the function address of the original function corresponding to the function name of the original function in the base class is replaced with the function address of the target function. Obtaining the function address of the original function based on its function name includes: Identify the first string and the second string in the subclass; Based on the first string, it is determined that there is an inheritance relationship between the subclass and the base class; and based on the second string, it is determined that the function address of the original function in the base class needs to be replaced by the function address of the target function. The second acquisition module includes: The first acquisition unit is used to acquire the memory address of the subclass in the executable file; The second acquisition unit is used to acquire the offset of the overridden function table of the subclass in the memory address; The third acquisition unit is used to acquire the rewrite function table based on the offset.

6. The apparatus according to claim 5, characterized in that, The second acquisition unit includes: Obtain a sub-unit, used to obtain the value of a specific flag bit in the subclass; The first determining subunit is used to determine the structure of the subclass based on the value of the specific flag bit; The second determining subunit is used to determine the offset based on the structure of the subclass.

7. An electronic device, characterized in that, include: A processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the data processing method as described in any one of claims 1 to 3.

8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the data processing method as described in any one of claims 1 to 3.