System memory processing method, device, electronic device and storage medium

By obtaining and recording the objective function pointer of memory processing requests in the IOS system, the problem of inability to monitor memory allocation and release in the prior art is solved, effectively monitoring and management of application memory conditions is realized, and the crash rate is reduced.

CN113900798BActive Publication Date: 2025-03-28BEIJING QIYI CENTURY SCI & TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202111045754.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-09-07
Publication Date
2025-03-28
Estimated Expiration
2041-09-07

AI Technical Summary

Technical Problem

The prior art is difficult to effectively record and monitor the memory allocation and release in the IOS system, resulting in the inability to accurately locate and solve the application crash caused by excessive memory usage.

Method used

By obtaining the memory processing request of the target application, querying the target address of the original function pointer, obtaining the target function pointer, and when the system calls the original function, the target function pointer is first called to record the call information for the corresponding target function, and finally, the original function pointed to by the original function pointer allocates memory to the application.

Benefits of technology

It realizes monitoring of all memory allocation and release on the IOS client, helps maintain application stability and reduces application crash rate.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113900798B_ABST
    Figure CN113900798B_ABST
Patent Text Reader

Abstract

The present application discloses a system memory processing method, device, electronic device and storage medium. It includes: obtaining a memory processing request from a target application; in response to the memory processing request, querying the target address of the original function pointer used to allocate memory from the system file, and obtaining the target function pointer from the target address; recording call information based on the target function pointed to by the target function pointer; when the call information is recorded, obtaining the original function pointer from the specified address, and calling the original function pointed to by the original function pointer to allocate memory for the target application. The present application uses the target function pointer to replace the original function pointer. When the system calls the original function, the target function corresponding to the target function pointer is first called to record the call information, so that the memory allocation and release on the IOS client can be obtained, and the memory allocation of the application can be monitored, which is conducive to the subsequent maintenance of the stability of the application.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a system memory processing method, device, electronic device and storage medium. Background Art

[0002] At present, application crashes have a great impact on users. The reasons for application crashes include: insufficient code robustness, excessive application memory usage, or insufficient system memory. In the case of insufficient system memory, the application process will be directly closed to reclaim system memory.

[0003] Therefore, if you want to locate the application crash caused by excessive memory usage, you need to record the memory allocated by the system to the application and the memory released by the application. In the prior art, if you want to record the allocation and release of memory, you generally use the method of hooking the memory allocation and release functions. For the IOS system, you can hook the "Objective-C" function by method swizzling. However, the above method cannot hook the system functions used to implement memory allocation or release (for example: "malloc" function, "calloc" function, "free" function), so that it is impossible to record the calling scenarios and calling information of the above functions, which ultimately leads to the inability to obtain all memory allocation and release situations on the IOS client. Summary of the invention

[0004] In order to solve the above technical problems or at least partially solve the above technical problems, the present application provides a system memory processing method, device, electronic device and storage medium.

[0005] According to one aspect of an embodiment of the present application, a system memory processing method is provided, including:

[0006] Acquire a memory processing request from a target application, wherein the memory processing request is used to request the system to allocate memory for the target application;

[0007] In response to the memory processing request, querying a target address of an original function pointer for allocating memory from a system file, and obtaining a target function pointer from the target address, wherein the target function pointer is obtained by replacing the original function pointer;

[0008] Record call information based on the target function pointed to by the target function pointer;

[0009] When the call information recording is completed, the original function pointer is obtained from the specified address, and the original function pointed to by the original function pointer is called to allocate memory for the target application.

[0010] Furthermore, before obtaining the memory processing request, the method further includes:

[0011] Acquire update information for replacing the original function pointer in the target application, wherein the update information includes: a character string corresponding to the original function, the target function pointer, and the designated address;

[0012] Use the string to query the target address where the original function pointer is currently located;

[0013] The target function pointer is written into the target address, and the address of the original function pointer is changed from the target address to the designated address.

[0014] Further, the using the string to query the target address where the original function pointer is currently located includes:

[0015] Obtain the file header and offset address of the file in the specified format in the target application;

[0016] Using the file header and the offset address to calculate, obtain a table address set;

[0017] Obtain a target data table set corresponding to the table address set;

[0018] The target address currently storing the original function pointer is queried from the target data table set.

[0019] Further, the target data table set includes: a string data table, a symbol data table and a pointer data table;

[0020] The querying the target address of the current storage of the original function pointer from the target data table set includes:

[0021] Determine the string index corresponding to the string of the original function in the string data table as the target string index;

[0022] Determine the symbol index corresponding to the target string index in the symbol data table as the target symbol index;

[0023] The storage address corresponding to the target symbol index is searched in the pointer data table and determined as the target address.

[0024] Furthermore, when the call information is recorded, the original function pointer is obtained from the specified address, and the original function pointed to by the original function pointer is called, and after memory is allocated to the target application, the method further includes:

[0025] Calling the target function pointed to by the target function pointer, monitoring the target application to obtain memory release information;

[0026] Generate a log file based on the memory release information and the call information;

[0027] The log file is stored.

[0028] Furthermore, after storing the log file, the method further includes:

[0029] Receive a memory detection instruction, and call a historical log file set according to the memory instruction;

[0030] Detecting the memory release information in the historical log file set to obtain a detection result;

[0031] When the memory release information in the historical log file set reaches the memory release upper limit, it is determined that there is an application with memory abnormality, and a corresponding processing operation is performed on the application with memory abnormality.

[0032] Furthermore, the performing corresponding processing operations on the application program with the memory exception includes:

[0033] Determine the exception type corresponding to the application program with the memory exception;

[0034] According to the correspondence between the exception type and the processing operation, the target exception processing operation corresponding to the target exception type is executed.

[0035] According to another aspect of an embodiment of the present application, a system memory processing device is further provided, including:

[0036] An acquisition module, used for acquiring a memory processing request from a target application, wherein the memory processing request is used for requesting the system to allocate memory for the target application;

[0037] a query module, configured to query a target address of an original function pointer for allocating memory from a system file in response to the memory processing request, and obtain a target function pointer from the target address, wherein the target function pointer is obtained by replacing the original function pointer;

[0038] A calling module, used for recording calling information based on the target function pointed to by the target function pointer;

[0039] The allocation module is used to obtain the original function pointer from the specified address when the call information recording is completed, and call the original function pointed to by the original function pointer to allocate memory for the target application.

[0040] According to another aspect of an embodiment of the present application, a storage medium is further provided, which includes a stored program, and the above steps are executed when the program is run.

[0041] According to another aspect of an embodiment of the present application, there is also provided an electronic device, including a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; wherein: the memory is used to store computer programs; and the processor is used to execute the steps in the above method by running the program stored in the memory.

[0042] The embodiment of the present application also provides a computer program product including instructions, which, when executed on a computer, enables the computer to execute the steps in the above method.

[0043] The above technical solution provided by the embodiment of the present application has the following advantages over the prior art: the embodiment of the present application uses a target function pointer to replace the original function pointer. When the system calls the original function, it first calls the target function corresponding to the target function pointer to record the call information, thereby being able to obtain all memory allocation and release conditions on the IOS client, and monitor the memory allocation of the application, which is beneficial to the subsequent maintenance of the stability of the application and reduces the crash rate of the application. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0045] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0046] Figure 1 A flowchart of a system memory processing method provided in an embodiment of the present application;

[0047] Figure 2 A flowchart of a system memory processing method provided by another embodiment of the present application;

[0048] Figure 3 A flowchart of a system memory processing method provided by another embodiment of the present application;

[0049] Figure 4 A block diagram of a system memory processing device provided in an embodiment of the present application;

[0050] Figure 5A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0051] In order to make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. The schematic embodiments of the present application and their descriptions are used to explain the present application and do not constitute improper limitations on the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.

[0052] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another similar entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0053] The embodiments of the present application provide a method, device, electronic device and storage medium for storage processing in a system. The method provided by the embodiments of the present invention can be applied to any required electronic device, for example, it can be an electronic device such as a server, a terminal, etc., which is not specifically limited here. For the convenience of description, it is referred to as an electronic device in the following.

[0054] In the prior art, for operating devices of the IOS system, method swizzling is generally used to hook memory allocation and release functions, but this method cannot hook some system functions, such as malloc function, calloc function, free function, etc., which will result in the above functions being unable to be called directly.

[0055] Among them, malloc's full name is memory allocation function, which is called dynamic memory allocation in Chinese. It is used to apply for a continuous memory block area of ​​a specified size and return the allocated memory area address as a void* type. When the specific location of the memory is unknown, if you want to bind the real memory space, you need to use dynamic memory allocation, and the allocated size is the size required by the program.

[0056] Function of calloc: Allocates num continuous spaces of length size in the dynamic storage area of ​​memory. The function returns a pointer to the allocation starting address; if the allocation is unsuccessful, returns NULL.

[0057] In order to solve the above problems, the embodiment of the present application analyzes the file structure of the Mach-O file in the IOS system, obtains the function pointer search and calling process, and replaces the function pointer during the function pointer search process, and finally implements the hook system function.

[0058] Mach-O is the abbreviation of Mach Object file format, which is a file format used for executable files, object code, dynamic libraries, and kernel dumps. As a replacement for the a.out format, Mach-O provides stronger scalability and improves the access speed of information in the symbol table.

[0059] It should be noted that in order to access external functions in Mach-O files, the developer has adopted PIC (position code independence) technology. When the application needs to call the system library function, a pointer will be created in the DATA segment of the Mach-O file. This pointer variable points to the external function, and the dynamic linker will dynamically bind and point the pointer in the DATA segment of the Mach-O file to the external function. Therefore, the embodiment of the present application analyzes the search and call process of the function pointer in the system, finds the original system function pointer, replaces the original function pointer, and rebinds it in the dynamic linker, thereby realizing the replacement of the function pointer. The specific implementation process is as follows:

[0060] Figure 1 A flowchart of a system memory processing method provided in an embodiment of the present application is shown in FIG. Figure 1 As shown, the method includes:

[0061] Step S11, obtaining update information for replacing the original function pointer in the target application, wherein the update information includes: a character string corresponding to the original function, a target function pointer, and a designated address.

[0062] In an embodiment of the present application, the update information may be obtained according to the information input by the user, and the update information includes: a string corresponding to the original function, a target function pointer, and a specified address. As an example, the string corresponding to the original function may be: malloc, the target function pointer may be: my_malloc, and the specified address may be P1.

[0063] Step S12, using the character string to query the target address of the current storage original function pointer;

[0064] In the embodiment of the present application, step S12, using a string to query the target address of the current storage of the original function pointer, includes the following steps A1-A4:

[0065] Step A1, obtaining the file header and offset address of a file in a specified format in a target application.

[0066] Step A2, using the file header and offset address calculation, obtains a table address set.

[0067] In an embodiment of the present application, the file header of the specified format is mach_header, which carries multiple segment addresses, and then the segment address and the offset address are used for calculation to finally obtain a table address set, wherein each table address in the table address set corresponds to a data table.

[0068] As an example, the calculation process of the segment address and the offset address can be:

[0069] Table address = segment address × 10H + offset address, for example, table address = 1000H × 10H + 0001H = 10001H.

[0070] Step A3, obtaining a target data table set corresponding to the table address set.

[0071] In an embodiment of the present application, the target data table set includes: a string data table, a symbol data table and a pointer data table; as an example, the string data table may be: string table, the symbol data table may be: symboltable, and the pointer data table may be: lazy symbol pointer table.

[0072] Step A4, querying the target address where the original function pointer currently resides from the target data table set.

[0073] In the embodiment of the present application, step A4, querying the target address where the original function pointer is currently located from the target data table set, includes the following steps A41-A43:

[0074] Step A41, determining the string index corresponding to the string of the original function in the string data table as the target string index.

[0075] Step A42, determining the symbol index corresponding to the target character string index in the symbol data table as the target symbol index.

[0076] Step A43, query the storage address corresponding to the target symbol index in the pointer data table and determine it as the target address.

[0077] As an example, (1) the string of the original function carried in the update information is searched in the string table, and when a string index matching the string is found, it is recorded as the string index.

[0078] (2) Traverse the symbol table (the first symbol data table). This table contains a series of nlist_tstructs. When n_un.n_strx in a pointer is equal to string index, the position of the symbol index in the symboltable is obtained and recorded as symbol index.

[0079] (3) Traverse the indirect symbol table (the second symbol data table). This table contains a series of numbers. Each number is the index of the nlist_t struct in the symbol table. When the number corresponding to the symbol index is found, the number is recorded as the indirect symbol index.

[0080] (4) Search the lazy symbol pointer table for the indirect symbol index, which is the target address of the original function pointer.

[0081] Step S13, writing the target function pointer into the target address, and changing the storage address of the original function pointer from the target address to the designated address.

[0082] In an embodiment of the present application, after obtaining the target address, the target function pointer is inserted into the target address, and the original function pointer is stored at the specified address, thereby realizing the rebinding of the function pointer. When the original function is subsequently called, the target function pointed to by the target function pointer is first substituted, and the call information is recorded through the target function, thereby finally achieving the system monitoring of the application's memory status.

[0083] According to one aspect of the embodiments of the present application, a method embodiment of a system memory processing method is provided. Figure 2 A flowchart of a system memory processing method provided in an embodiment of the present application is shown in FIG. Figure 2 As shown, the method includes:

[0084] Step S21, obtaining a memory processing request from a target application, wherein the memory processing request is used to request the system to allocate memory to the target application.

[0085] In an embodiment of the present application, when the target application faces insufficient memory, it needs to request memory allocation from the system to avoid the system forcing the application to exit due to excessive memory usage. Therefore, the application will actively send a memory processing request to the system.

[0086] Step S22, in response to the memory processing request, query the target address of the original function pointer used to allocate memory from the system file, and obtain the target function pointer from the target address, wherein the target function pointer is obtained by replacing the original function pointer.

[0087] In an embodiment of the present application, after receiving a memory processing request, the system will obtain the original function pointer used to allocate memory and the target address where the original function pointer is located from the system file. It should be noted that when the system finds the target address where the original function pointer is located, the original function pointer at the target address has been replaced by the target function pointer.

[0088] Therefore, after the system responds to the memory processing request, what it gets from the target address is the target function pointer.

[0089] Step S23, recording call information based on the target function pointed to by the target function pointer.

[0090] In the embodiment of the present application, the target function pointed to by the target function pointer is called, and the target function is used to record the calling information. The calling information includes: a calling stack and calling parameters.

[0091] The embodiment of the present application uses a target function pointer to replace the original function pointer. When the system calls the original function, it first calls the target function corresponding to the target function pointer to record the call information, thereby monitoring the memory allocation of the application, which is beneficial to maintaining the stability of the application and reducing the crash rate of the application.

[0092] Step S24, when the call information recording is completed, obtain the original function pointer from the specified address, call the original function pointed to by the original function pointer, and allocate memory for the target application.

[0093] In an embodiment of the present application, by analyzing the Mach-O file structure, the calling process of the Mach-O file calling the system function can be obtained. By analyzing the calling process, the key position of the calling system library function pointer is dynamically found, the function pointer is retained, replaced with a pre-set function pointer, and the function corresponding to the replaced function pointer is used to record the corresponding calling parameters and call stack, and finally the original function pointer is called, thereby realizing the memory and release function of the hook system.

[0094] The embodiment of the present application uses a target function pointer to replace the original function pointer. When the system calls the original function, it first calls the target function corresponding to the target function pointer to record the calling information, so as to obtain all memory allocation and release conditions on the IOS client and monitor the memory allocation of the application, which is beneficial to the subsequent maintenance of the stability of the application and reduces the crash rate of the application.

[0095] When the call information is recorded, the original function pointer is obtained from the specified address, and the original function pointed to by the original function pointer is called. After the memory is allocated to the target application, a system memory processing method provided by the embodiment of the present application is as follows: Figure 3 As shown, the method includes:

[0096] Step S31, calling the target function using the target function pointer, monitoring the target application to obtain memory release information;

[0097] Step S32, generating a log file based on the memory release information and the call information;

[0098] Step S33, storing the log file.

[0099] In the embodiment of the present application, after allocating memory to the target application, the target function can also be called to monitor the target application's use of the allocated memory, and each use is recorded in the memory release information. At the same time, the memory release information and the call information are generated into a log file and stored, the purpose of which is to perform security detection on the subsequent target application to determine whether the target application has memory risks, and provide a reliable basis for the subsequent maintenance of the stability of the application.

[0100] In the embodiment of the present application, after storing the log file, the method further includes the following steps C1-C3:

[0101] Step C1, receiving a memory detection instruction, and calling a historical log file set according to the memory instruction.

[0102] Step C2, detecting the memory release information in the historical log file set to obtain a detection result.

[0103] Step C3, when the memory release information in the historical log file set reaches the memory release upper limit, it is determined that there is an application with memory abnormality, and corresponding processing operations are performed on the application with memory abnormality.

[0104] In the embodiment of the present application, the memory release information reaching the memory release upper limit at least includes: the memory release frequency is greater than the release frequency upper limit, the memory release capacity is greater than the preset capacity upper limit, and so on.

[0105] In an embodiment of the present application, step C3 performs corresponding processing operations on the application with memory exception, including: determining the exception type corresponding to the application with memory exception and executing the target exception processing operation corresponding to the target exception type according to the correspondence between the exception type and the processing operation.

[0106] In the embodiment of the present application, different exception types correspond to different processing operations. As an example, when the memory release frequency is greater than the upper limit of the release frequency, the target exception processing operation is to limit the frequency of memory allocation of the application. When the memory release capacity is greater than the preset capacity upper limit, the memory release capacity is split and allocated according to the preset frequency.

[0107] In the embodiment of the present application, by recording all memory allocation and release situations on the iOS client, and recovering the relevant logs after a memory problem occurs on the client. By analyzing the logs, the specific location that caused the memory problem can be located, and those locations with hidden memory usage risks can also be found, such as applying for large memory, frequently applying for memory, and the applied memory not being released after the business scenario is exited, etc. Solving these problems can greatly improve the stability of the client, thereby reducing the crash rate and improving the user experience.

[0108] Figure 4 This is a block diagram of a system memory processing device provided in an embodiment of the present application. The device can be implemented as part or all of an electronic device through software, hardware, or a combination of both. Figure 4 As shown, the device comprises:

[0109] An acquisition module 41 is used to acquire a memory processing request, wherein the memory processing request is used to apply for memory for a target application;

[0110] A query module 42 is used to obtain a target function pointer from a system database in response to a memory processing request, wherein the target function pointer includes: a target function pointer and an original function pointer in a target application;

[0111] A calling module 43, used for recording calling information based on the target function pointed to by the target function pointer;

[0112] The allocation module 44 is used to use the original function pointer to call the original function pointed to by the original function pointer to allocate memory for the target application program when it is determined that the call information recording is completed.

[0113] In the embodiment of the present application, the device further includes: a change module, including:

[0114] An acquisition submodule, used to acquire update information for replacing the original function pointer in the target application, wherein the update information includes: a string corresponding to the original function, a target function pointer, and a specified address for storing the original function pointer;

[0115] The query submodule is used to query the target address of the current storage of the original function pointer using a string;

[0116] The execution submodule is used to write the target function pointer to the target address, and change the storage address of the original function pointer from the target address to the specified address.

[0117] In an embodiment of the present application, the device also includes: a query submodule, used to obtain the file header and offset address of a file in a specified format in a target application; use the file header and offset address to calculate and obtain a table address set; obtain a target data table set corresponding to the table address set; and query the target address of the currently stored original function pointer from the target data table set.

[0118] In the embodiment of the present application, the target data table set includes: a string data table, a symbol data table, and a pointer data table;

[0119] The query module is used to determine the string index corresponding to the string of the original function in the string data table as the target string index; determine the symbol index corresponding to the target string index in the symbol data table as the target symbol index; and determine the storage address corresponding to the target symbol index in the pointer data table as the target address.

[0120] In an embodiment of the present application, the device also includes: a monitoring module, which is used to call the target function using the target function pointer, monitor the target application to obtain memory release information; generate a log file based on the memory release information and the call information; and store the log file.

[0121] In an embodiment of the present application, the device also includes: a detection module, which is used to obtain a set of historical log files; detect the set of historical log files to obtain a detection result; when the detection result is used to indicate the existence of an abnormal memory application, execute a target processing operation corresponding to the detection result.

[0122] In an embodiment of the present application, a detection module is used to obtain an abnormal application program having a memory exception and a target exception type of the abnormal application from the detection results; and execute a target exception handling operation corresponding to the target exception type according to a correspondence between the exception type and the handling operation.

[0123] The present application also provides an electronic device, such as Figure 5As shown, the electronic device may include: a processor 1501 , a communication interface 1502 , a memory 1503 and a communication bus 1504 , wherein the processor 1501 , the communication interface 1502 , and the memory 1503 communicate with each other via the communication bus 1504 .

[0124] Memory 1503, used for storing computer programs;

[0125] The processor 1501 is used to implement the steps of the above embodiment when executing the computer program stored in the memory 1503.

[0126] The communication bus mentioned in the above terminal can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.

[0127] The communication interface is used for communication between the above terminal and other devices.

[0128] The memory may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.

[0129] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0130] In another embodiment provided in the present application, a computer-readable storage medium is provided, in which instructions are stored. When the computer-readable storage medium is run on a computer, the computer executes the file detection method described in any one of the above embodiments.

[0131] In another embodiment provided by the present application, a computer program product including instructions is also provided, which, when executed on a computer, enables the computer to execute the file detection method described in any one of the above embodiments.

[0132] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk SolidState Disk), etc.

[0133] The above description is only a preferred embodiment of the present application and is not intended to limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application are included in the protection scope of the present application.

[0134] The above description is only a specific implementation of the present application, so that those skilled in the art can understand or implement the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest range consistent with the principles and novel features applied for herein.

Claims

1. A system memory processing method, characterized in that: include: Obtaining a memory processing request from a target application, wherein the memory processing request is used to request the system to allocate memory for the target application; In response to the memory processing request, querying a target address of an original function pointer used to allocate memory from a system file, and obtaining a target function pointer from the target address, wherein the target function pointer is obtained by replacing the original function pointer; Record call information based on the target function pointed to by the target function pointer; When the call information is recorded, an original function pointer is obtained from a specified address, and an original function pointed to by the original function pointer is called to allocate memory for the target application; The target function pointed to by the target function pointer is called, and the target application is monitored to obtain memory release information; a log file is generated based on the memory release information and the call information; and the log file is stored.

2. The method according to claim 1, characterized in that Before obtaining the memory processing request, the method further includes: Acquire update information for replacing the original function pointer in the target application, wherein the update information includes: a character string corresponding to the original function, the target function pointer, and the designated address; Use the string to query the target address where the original function pointer is currently located; The target function pointer is written into the target address, and the address of the original function pointer is changed from the target address to the designated address.

3. The method according to claim 2, characterized in that The using the string to query the target address where the original function pointer is currently located includes: Obtain the file header and offset address of the file in the specified format in the target application; Using the file header and the offset address to calculate, obtain a table address set; Obtain a target data table set corresponding to the table address set; The target address where the original function pointer currently resides is queried from the target data table set.

4. The method according to claim 3, characterized in that The target data table set includes: a string data table, a symbol data table and a pointer data table; The querying of the target address where the original function pointer is currently located from the target data table set includes: Determine the string index corresponding to the string of the original function in the string data table as the target string index; Determine the symbol index corresponding to the target string index in the symbol data table as the target symbol index; The storage address corresponding to the target symbol index is searched in the pointer data table and determined as the target address.

5. The method according to claim 1, characterized in that After storing the log file, the method further includes: Receive a memory detection instruction, and call a historical log file set according to the memory detection instruction; Detecting the memory release information in the historical log file set to obtain a detection result; When the memory release information in the historical log file set reaches the memory release upper limit, it is determined that there is an application with memory abnormality, and a corresponding processing operation is performed on the application with memory abnormality.

6. The method according to claim 5, characterized in that The performing corresponding processing operations on the application program with the memory exception includes: Determine a target exception type corresponding to the application program having the memory exception; According to the correspondence between the exception type and the processing operation, the target exception processing operation corresponding to the target exception type is executed.

7. A system memory processing device, characterized in that: include: An acquisition module, used for acquiring a memory processing request from a target application, wherein the memory processing request is used for requesting the system to allocate memory for the target application; a query module, configured to query a target address of an original function pointer for allocating memory from a system file in response to the memory processing request, and obtain a target function pointer from the target address, wherein the target function pointer is obtained by replacing the original function pointer; A calling module, used for recording calling information based on the target function pointed to by the target function pointer; an allocation module, configured to obtain an original function pointer from a specified address and call an original function pointed to by the original function pointer to allocate memory for the target application program when the call information recording is completed; The monitoring module is used to call the target function pointed to by the target function pointer, monitor the target application to obtain memory release information; generate a log file based on the memory release information and the call information; and store the log file.

8. A storage medium, characterized in that: The storage medium includes a stored program, wherein the program executes the method steps of any one of claims 1 to 6 when running.

9. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; wherein: Memory, used to store computer programs; A processor, configured to execute the method steps of any one of claims 1 to 6 by running a program stored in a memory.

Citation Information

Patent Citations

  • Attack detection method and device

    CN110059477A