CN117762430A - processing method and device based on application program, computer equipment and storage medium - Google Patents

processing method and device based on application program, computer equipment and storage medium Download PDF

Info

Publication number
CN117762430A
CN117762430A CN202410195070.0A CN202410195070A CN117762430A CN 117762430 A CN117762430 A CN 117762430A CN 202410195070 A CN202410195070 A CN 202410195070A CN 117762430 A CN117762430 A CN 117762430A
Authority
CN
China
Prior art keywords
application program
program
application
resource
resource file
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202410195070.0A
Other languages
Chinese (zh)
Other versions
CN117762430B (en
Inventor
袁正才
龚军
杨帆
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN202410195070.0A priority Critical patent/CN117762430B/en
Priority claimed from CN202410195070.0A external-priority patent/CN117762430B/en
Publication of CN117762430A publication Critical patent/CN117762430A/en
Application granted granted Critical
Publication of CN117762430B publication Critical patent/CN117762430B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Stored Programmes (AREA)

Abstract

The present application relates to a processing method, apparatus, computer device, storage medium and computer program product based on an application program. The method comprises the following steps: if a correction request is received in the running process of the application program, extracting a resource path and a target symbol in the correction request; accessing a resource path to obtain a resource file; loading a resource file and positioning to a target symbol in the resource file; code segments in the resource file related to the target symbol are executed to modify the program behavior of the application program while keeping the application program running. The method aims at the running application program, and can dynamically correct the program behavior in real time without interrupting the application program under the condition of keeping the program body unchanged, thereby improving the usability and flexibility of the application program.

Description

processing method and device based on application program, computer equipment and storage medium
Technical Field
the present application relates to the field of computer technology, and in particular, to an application program-based processing method, an apparatus, a computer device, a storage medium, and a computer program product.
Background
With the development of computer technology, more and more applications such as mail applications, conversation applications, or other business applications, etc., are emerging. As time goes by, the traffic being processed is getting larger and larger, new demands or new defects may be found during the running of the application. In order to meet new requirements or repair new defects, maintenance personnel often update the application program in a version upgrading mode.
However, in the case that the application cannot be upgraded, in the related art, maintenance personnel often hang related execution threads through a debugging tool, and then change the behavior logic of the execution threads to meet the new requirements or repair the defects. This approach often results in a pause in the application, resulting in a disruption to the service of the upper layer service, reducing the availability of the application.
Disclosure of Invention
In view of the foregoing, it is desirable to provide an application-based processing method, apparatus, computer device, computer-readable storage medium, and computer program product that can dynamically modify program behavior in real time without interrupting the application while maintaining the program body unchanged.
In one aspect, the present application provides an application-based processing method, including:
If a correction request is received in the running process of an application program, extracting a resource path and a target symbol in the correction request;
Accessing the resource path to obtain a resource file;
loading the resource file and positioning the resource file to a target symbol in the resource file;
And executing the code segment related to the target symbol in the resource file so as to correct the program behavior of the application program in the process of keeping the application program continuously running.
On the other hand, the application also provides a processing device based on the application program, which comprises:
the extraction module is used for extracting a resource path and a target symbol in the correction request if the correction request is received in the running process of the application program;
the acquisition module is used for accessing the resource path to acquire a resource file;
the positioning module is used for loading the resource file and positioning the target symbol in the resource file;
And the correction module is used for executing the code segment related to the target symbol in the resource file so as to correct the program behavior of the application program in the process of keeping the application program to continue to run.
In another aspect, the present application also provides a computer device, including a memory and a processor, the memory storing a computer program, the processor implementing the following steps when executing the computer program:
If a correction request is received in the running process of an application program, extracting a resource path and a target symbol in the correction request;
Accessing the resource path to obtain a resource file;
loading the resource file and positioning the resource file to a target symbol in the resource file;
And executing the code segment related to the target symbol in the resource file so as to correct the program behavior of the application program in the process of keeping the application program continuously running.
In another aspect, the present application also provides a computer readable storage medium having stored thereon a computer program which when executed by a processor performs the steps of:
If a correction request is received in the running process of an application program, extracting a resource path and a target symbol in the correction request;
Accessing the resource path to obtain a resource file;
loading the resource file and positioning the resource file to a target symbol in the resource file;
And executing the code segment related to the target symbol in the resource file so as to correct the program behavior of the application program in the process of keeping the application program continuously running.
In another aspect, the application also provides a computer program product comprising a computer program which, when executed by a processor, performs the steps of:
If a correction request is received in the running process of an application program, extracting a resource path and a target symbol in the correction request;
Accessing the resource path to obtain a resource file;
loading the resource file and positioning the resource file to a target symbol in the resource file;
And executing the code segment related to the target symbol in the resource file so as to correct the program behavior of the application program in the process of keeping the application program continuously running.
The processing method, the processing device, the computer equipment, the storage medium and the computer program product based on the application program are used for firstly extracting the resource path and the target symbol in the correction request aiming at receiving the correction request in the running process of the application program so as to quickly respond to the correction request and obtain the accurate resource path and the accurate target symbol. And then accessing the resource path to obtain a resource file, loading the resource file and positioning the resource file to a target symbol in the resource file, so that dynamic loading of the external resource file is realized in the running process of the application program. And finally, executing the code segment related to the target symbol in the resource file so as to correct the program behavior of the application program in the process of keeping the application program to continue to run. Therefore, in the whole correction process, the real-time correction of the program behavior can be realized without interrupting the application program under the condition of keeping the running application program unchanged, and the usability of the application program is improved.
Drawings
in order to more clearly illustrate the embodiments of the present application or the technical solutions in the related art, the drawings that are required to be used in the embodiments or the related technical descriptions will be briefly described, and it is apparent that the drawings in the following description are only some embodiments of the present application, and other drawings may be obtained according to the drawings without inventive effort for those skilled in the art.
FIG. 1 is an application environment diagram of an application-based processing method in one embodiment;
FIG. 2 is a flow diagram of an application-based processing method in one embodiment;
FIG. 3 is a flow diagram of a method of establishing a listening port in one embodiment;
FIG. 4 is a flow diagram of a method of extracting information in a correction request according to one embodiment;
FIG. 5 is a flow diagram of a method for obtaining a resource file from a resource path in one embodiment;
FIG. 6 is a flow diagram of a method of implementing behavior modification based on lock protection in one embodiment;
FIG. 7 is a flow diagram of a method of application-based processing in one embodiment;
FIG. 8 is a flow chart of a method for correcting program behavior of a scene for correction of unexpected output in one embodiment;
FIG. 9 is a flow chart of a method for correcting program behavior of a scene for correction of unexpected output in one embodiment;
FIG. 10 is a block diagram of an application processing device in one embodiment;
FIG. 11 is an internal block diagram of a computer device executing application-based processing in one embodiment.
Detailed Description
The present application will be described in further detail with reference to the drawings and examples, in order to make the objects, technical solutions and advantages of the present application more apparent. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the application.
The processing method based on the application program provided by the embodiment of the application can be applied to an application environment shown in fig. 1. In this application environment, the first computer device 102 and the second computer device 104 are two separate computer devices, wherein the first computer device 102 communicates with the second computer device 104 over a network. A listening port conforming to a transmission control protocol is established between the first computer device 102, an application program is run in the first computer device, and a preset tool for packaging the correction request is deployed in the second computer device 104.
In some embodiments, the preset tool deployed by the second computer device 104 encapsulates the resource path and target symbol into a correction request and sends it to the listening port. After the first computer device 102 receives the correction request from the listening port during the running of the application program, first, the resource path and the target symbol in the correction request are extracted, and the resource path is accessed to obtain the resource file. The resource file is then loaded and located to the target symbol in the resource file. And finally, executing the code segments related to the target symbol in the resource file to correct the program behavior of the application program in the process of keeping the application program continuously running. The first computer device 102 or the second computer device 104 may be a terminal or a server, where the terminal includes, but is not limited to, various personal computers, notebook computers, smart phones, tablet computers, internet of things devices and portable wearable devices, and the internet of things devices may be smart speakers, smart televisions, smart air conditioners, smart vehicle devices, and the like. The portable wearable device may be a smart watch, smart bracelet, headset, or the like. The server may be implemented as a stand-alone server or as a server cluster composed of a plurality of servers. The cloud server can also be a cloud server for providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (Content Delivery Network, CDNs), basic cloud computing services such as big data and artificial intelligence platforms, and the like.
In some embodiments, the preset tool and the application may also be co-deployed in the same computer device, which may be the first computer device in fig. 1. The preset tool and the application program establish communication connection in a mode suitable for communication between different processes in the same computer equipment. The operation and maintenance party packages a correction request carrying a resource path and a target symbol through a preset tool and sends the correction request to a interception port, and after the server receives the correction request from the interception port in the running process of an application program, firstly, the resource path and the target symbol in the correction request are extracted, and the resource path is accessed to obtain a resource file. The resource file is then loaded and located to the target symbol in the resource file. And finally, executing the code segments related to the target symbol in the resource file to correct the program behavior of the application program in the process of keeping the application program continuously running.
It should be noted that, the processing method based on the application program provided by the embodiment of the application is realized on the basis that the running system can support dynamic loading (dynamic loading). Dynamic loading means a process of loading external programs and data from external memory or network into memory as required during the running process of an application program.
The processing method based on the application program in the embodiment of the application is essentially aimed at the running application program, extracts the resource path in the correction request after receiving the correction request aiming at the application program, and realizes the loading of the external resource file indicated by the resource path by combining a dynamic loading mode. Then, by calling the code segment in the resource file adapted to the target symbol, a correction operation for the program behavior of the running application program is performed. In the whole program behavior correction process, the original business logic of the running application program itself is kept unchanged, and the program behavior can be dynamically corrected in real time without interrupting the application program.
Based on the above description of dynamic loading, in some embodiments, as shown in fig. 2, an application-based processing method is provided, and the method is applied to a computer device running an application program (such as the first computer device in fig. 1) for example, and includes the following steps 202 to 208. Wherein:
Step 202, if a correction request is received during the running process of the application program, extracting a resource path and a target symbol in the correction request during the process of continuing to run the application program.
The correction request refers to the requirement of real-time correction on the program behavior of the deployed application program in the running process. The correction request carries the resource path and the target symbol. The resource path is a memory address of a resource that can be used to obtain the resource that modifies the program behavior. The resources for correcting the program behavior are correction resources, and the correction resources comprise code segments written by an operation and maintenance party authorized by the application program according to actual correction requirements. The target symbol is a specific function or variable in the code segment. The server finally realizes the behavior modification for the running application program through the target symbol.
In some embodiments, for each of the aforementioned revision scenarios, the authorized operator may send a revision request to the computer device via the listening port that is adapted to the revision scenario for revising program behavior during execution of the application. After receiving the correction request, the computer equipment extracts a resource path and a target symbol carried in the correction request in the process of keeping the application program to continue to run. It should be noted that, due to different running systems of the application programs, the file forms of the correction resources indicated by the resource paths are different. But regardless of the file form in which the revision resource exists, is an executable file that can be loaded and parsed by the computer device by way of dynamic loading. The embodiment of the application does not limit the file form of the correction resource.
In some embodiments, the dynamic link library is used as an executable file capable of realizing dynamic loading, and can be used as a file form of the correction resource in the embodiment of the application, namely the correction resource exists in the dynamic link library. It should be noted that, different operating systems (i.e., running systems of application programs) have different types of files of the dynamic link library. If the operating system is a Linux system, the dynamic link library exists in so (Shared Object) files (such as a dynamic link library test. So), and the so file is in a binary file format for storing executable codes and data of the program. When the operating system is a Windows system, the dynamic link library exists in dll (Dynamic Link Library) files (e.g., dynamic link library test. Dll). When the operating system is an Android system, the dynamic link library may be a dex file (e.g., a dynamic link library test. Dex).
In some embodiments, in order to ensure the security of the information carried by the correction request, the information carried by the correction request may be encrypted by a preset encryption algorithm, where the encryption algorithm may be at least a symmetric encryption algorithm, an asymmetric encryption algorithm, or the like. Illustratively, when a symmetric encryption algorithm is employed, the same key is used by the operator and the running application, and the key may be pre-assigned to the operator.
in some embodiments, the computer device obtains the correction request from the listening port in real time to facilitate timely program behavior correction. The interception port is a port appointed when a communication connection is established between the running application program and the sending program of the correction request. The computer equipment distributes a interception thread for the interception port, the interception port is intercepted in real time by running the interception thread, and the operation and maintenance party sends a correction request aiming at the running application program to the interception port. The running application receives a validated correction request from the listening port.
In some embodiments, the computer device creates a listening port through a preset communication protocol, where the listening port is used to implement communication between processes, and implement communication between an application program in operation and a sending program that sends a correction request. The transmitting program refers to a process corresponding to a preset tool for transmitting the correction request. Meanwhile, the sender is a process trusted by the running application. The running application program creates a interception port through a preset inter-process communication protocol, and allocates an interception thread for the interception port so as to realize real-time interception of the interception port. And the operation and maintenance party authorized by the application program sends a correction request adapted to the program behavior to be corrected to the interception port through a preset tool.
in step 204, the resource path is accessed to obtain a resource file.
In some embodiments, the computer device accesses the resource path in a suitable access manner to obtain the resource file. The access manner for the resource path may be determined according to the running system of the running application program and the file form of the resource file indicated by the resource path. Different running systems and file forms have different access modes for resource paths. Taking the dynamic link library as an example, the file form of the resource file is a library path of the dynamic link library, and the resource path can be an absolute path or a relative path. Specifically, if the running system of the application program is a Linux system, the access mode for the resource path is determined based on the library function dlopen, that is, the resource path is accessed by calling the library function dlopen to obtain the resource file. If the running system of the application program is a Windows system, the access mode for the resource path is determined based on the library function loadLibrary, that is, the resource path is accessed by calling the library function loadLibrary, and the resource file is acquired.
Describing the library function dlopn, the library function dlopn includes two parameters: a resource path and an open mode. The resource path is a library path of a dynamically linked library. The open mode indicates whether the symbols (e.g., variables or functions) contained in the dynamic link library are immediately parsed. If the open mode is rtld_lazy, before dlepen returns, analyzing an undefined symbol (such as a variable or a function) existing in the dynamic link library is not executed, or the address of the symbol is not analyzed; if the open mode is rtld_now, before dlepen returns, the address of each undefined symbol is resolved, and if not, dlepen returns to null.
The description is directed to a library function loadlibrary that is capable of loading a Dynamic Link Library (DLL) and invoking a specified function in the dynamic link library when the program is running. The parameter lpfile name of the loadlibrary function specifies the path of the DLL file to be loaded, i.e., the resource path. The function will return a handle that can be used for subsequent operations on the DLL, such as calling a function therein or unloading the DLL. Before invoking the loadlibrary function, it is first necessary to determine the path of the DLL file to be loaded. The location of the DLL file may be specified using an absolute path or a relative path. The file name may be used directly if the DLL file is located in the system directory or the current working directory.
step 206, loading the resource file and locating the target symbol in the resource file.
Where the target symbol refers to a variable or function in the resource file that is used to modify the behavior of the program.
In some embodiments, the computer device loads the resources in the resource file into the memory space of the running application program through a library function (such as dlopen adapted to the Linux system and loadlibrary adapted to the Windows system) of a loading class (implementing a loading function) adapted to the running system of the application program, so as to ensure the security of the resources. Then, through library functions (such as dlsym in Linux system) adapted to the running system of the application program to realize positioning operation and executing operation, the address of the target symbol in the memory space of the application program is determined based on the address addressing mode, so as to find the start address and end address of the target symbol required to be called.
In some embodiments, the loading and positioning of the computer device for the resource file is related to the file form of the resource file, as well as the running system of the application. In the case where the resource file exists in the form of a dynamic link library, the manner in which different operating systems load and locate the resource file is different. If the running platform of the application program is a Linux system, after the library function dlopen is used to load the resource file into the memory space of the running application program, the starting address and the ending address of the target symbol are determined continuously through the memory space of the running application program for the library function dlsym. If the running system of the application program is a Windows system, after the resource file is loaded into the memory space of the running application program by using the library function loadlibrary realizing loading, the starting address and the ending address of the target symbol are continuously determined in the memory space of the application program by the library function getProcAddress realizing positioning.
and step 208, executing the code segments related to the target symbol in the resource file to correct the program behavior of the application program in the process of keeping the application program running continuously.
In some embodiments, the resource file includes code segments associated with the target symbol. In the running process of the application program, the computer equipment firstly locates the starting address and the ending address of the code segment corresponding to the target symbol in the memory space of the running application program through the corresponding library function. Then, starting from the starting address, code segments related to the target symbol are sequentially executed until the ending address, so that behavior modification for the running application program is realized. In the whole correction process, the program body of the application program is not modified, and the original running logic of the application program is not interrupted, so that the program behavior of the program is corrected only by executing the code fragments indicated by the target coincidence in the external resource file, so as to adapt to the corresponding correction scene.
In the processing method based on the application program, aiming at receiving the correction request in the running process of the application program, the computer equipment running the application program extracts the resource path and the target symbol in the correction request, so that the correction request can be responded quickly and the accurate resource path and the accurate target symbol can be obtained under the condition of not interrupting the application program. Then, the resource path is accessed to obtain a resource file, and the resource file is loaded and positioned to a target symbol in the resource file, so that dynamic loading of the external resource file is realized in the running process of the application program. And finally, executing the code segments related to the target symbol in the resource file in the running process of the application program, and realizing the timely correction of the program behavior of the application program. In the whole correction process, under the condition that the program body of the application program is kept unchanged in operation, the operation of correcting the program behavior of the application program without stopping is realized, and the availability and flexibility of the application program are improved.
In some embodiments, the server may also identify the correction request by: during the running process of the application program, interception is carried out on a pre-established interception port through an interception thread; after listening for a request sent to the listening port, it is identified whether the request is a correction request.
Wherein the snoop thread is a thread created by the computer device in the application. The snoop thread is used to snoop requests from the snoop port in real time. The listening port is a port for data transmission designated by a communication connection between an application program and a transmitting program (a process that transmits a correction request).
In actual implementation, after the computer device detects the request from the interception port in real time through the interception thread, the computer device continues to identify whether the request is a correction request according to the constraint condition. The constraint may be set according to the source of the request on the snoop port. The constraint may also be determined based on the type of request on the listening port. Taking the constraint condition set by the source of the request as an example, if the computer device detects that the source of the request is transmitted by any transmitting program authorized by the application program, the request is identified as a correction request. Taking the constraint condition set by the type of the request as an example, if the computer equipment detects that the type identifier carried by the request on the interception port is matched with the identifier of the preset correction request, the request is identified as the correction request. After identifying the request as a correction request, the computer device performs a subsequent behavior correction operation for the running application in accordance with the correction request. If the request is a non-correction request, the next request is continuously received from the interception port without processing.
In the embodiment, the request from the interception port can be monitored and received in real time, and the application program is ensured to rapidly respond to the external request, so that the correction request can be rapidly identified and processed, the program behavior to be corrected in the application program can be corrected in time, and the stability and the reliability of the running process of the application program are improved.
In some embodiments, the correction request is sent by a default tool, as shown in fig. 3, and the computer device establishes a listening port, including steps 302 to 304. Wherein:
Step 302, determining the deployment mode of the application program and the preset tool.
In some embodiments, the preset tool is a program for sending a correction request. The authorized operator may encapsulate the rework request by a predetermined tool and transmit the rework request to the computer device. The manner in which the correction request is transmitted from the default tool to the application is determined by the communication connection between the default tool and the application. The communication connection between the preset tool and the application program is related to the deployment mode of the preset tool and the application program. Thus, the computer device determines how the application and the preset tool are deployed.
In some embodiments, the deployment may include at least a shared deployment and an independent deployment. The shared deployment refers to that the preset tool and the application program are deployed in the same computer equipment, and the preset tool and the application program share computing resources, storage resources and the like in the computer equipment. The shared deployment in this embodiment specifically refers to that the preset tool and the application program are deployed together in the computer device running the application program. Independent deployment refers to that the preset tool and the application program are deployed in different computer devices, respectively, as shown in fig. 1. Different deployment modes, the communication protocols to be met for establishing the interception port are different. Under the condition that the deployment mode is shared deployment, the application program and the preset tool are deployed in the same computer equipment, and the application program and the preset tool belong to a plurality of processes for communication in the same computer equipment. Under the condition that the deployment mode is independent deployment, the application program and the preset tool are deployed in different computer devices respectively, and the application program and the preset tool belong to a plurality of processes for communication through a network.
step 304, determining a communication protocol adapted to the deployment mode, and establishing a listening port conforming to the communication protocol.
The communication protocol refers to a protocol (i.e., an inter-process communication protocol) that needs to be satisfied for communication between an running application program and a process corresponding to a preset tool. The communication protocols may include at least a transmission control protocol, a socket protocol, and a named pipe (named pipes) protocol.
In some embodiments, the computer device establishes a listening port conforming to a communication protocol for a preset tool and an application program in operation that send a correction request to enable communication therebetween. The communication protocol is matched with the deployment mode, and the communication protocols matched with different deployment modes are different. Specifically, in the case where the deployment mode characterizes that the preset tool and the application program are deployed on different computer devices, the transmission control protocol may be selected as a communication protocol that needs to be met to establish the listening port. Under the condition that the deployment mode characterizes that the preset tool and the application program are deployed on the same computer equipment, a communication protocol is further selected according to an operating system of the computer equipment running the application program, if the operating system is a Windows system, a named pipes protocol is selected as a communication protocol which is required to be met for establishing a interception port. If the operating system is a Linux system, a socket protocol is selected as a communication protocol to be met for establishing the interception port.
The transmission control protocol (TCP, transmission Control Protocol) provides reliable connection-oriented communications suitable for data transfer between different computers. The socket protocol is applied to the Linux system, and can directly access the system resources at the bottom layer, so that the socket protocol is more suitable for communication in the same computer. The named pipes protocol is applied in Windows system and is also suitable for communication inside the same computer. Therefore, under the condition that the deployment mode is shared deployment, the application program and the preset tool run in the same computer equipment, and can be based on a interception port of a socket protocol (applicable to a Linux system) or a named pipe (applicable to a Windows system). Under the condition that the deployment mode is independent deployment, the application program and the preset tool run in different computer equipment, and a interception port conforming to a transmission control protocol can be established.
in this embodiment, an appropriate communication protocol is selected according to a specific running system of an application program and a deployment mode of the application program and a preset tool, so that the efficiency and accuracy of data transmission can be ensured. Meanwhile, the interception port is established based on the communication protocol, so that access to the application program can be effectively controlled, and the safety of the system is improved.
In some embodiments, a computer device running an application may establish a listening port for receiving correction requests by: if the deployment mode is independent deployment, a interception port conforming to a transmission control protocol is established; if the deployment mode is shared deployment, a interception port conforming to a socket protocol is established.
In some embodiments, if an application program and a preset tool are deployed in an independent deployment manner, a specific implementation manner of establishing a listening port according with TCP is as follows in a case that the application program and the preset tool are deployed in different computer devices respectively: first, on the computer device where the running application is located, the TCP port number to be intercepted is determined. Second, an application is written or configured to listen on that port for incoming TCP connections. This typically involves setting up sockets and calling functions such as bind and listen to prepare to receive the connection. The running application program is ensured to have proper network authority, and the correction request can be obtained from the interception port in real time.
again, on the computer device where the preset tool resides, code is written to connect to the TCP port of the application. A socket is created using, for example, a socket function, and then a connect function is used to attempt to establish a connection with a port of the preset tool. Once the connection is established, the application and the preset tool can perform bidirectional data transmission through the TCP protocol.
in addition, because different computers may run different operating systems in a complex network environment, the use of the TCP protocol can ensure that communications between different computer devices are not affected by differences in the operating systems, thereby improving interoperability of the systems.
In some embodiments, if the application and the preset tool are deployed in a shared deployment manner, that is, the application and the preset tool belong to the same computer device, and the running system of the application is a Linux system, the application and the preset tool communicate by creating a Unix domain Socket (Unix domain sockets), that is, a listening port conforming to a Socket protocol is established. Unix domain sockets allow processes to communicate on the same computer device without going through the network protocol stack. This approach, because it does not involve the complexity of running the system network stack, makes inter-process communication lighter and faster than transmission control protocols.
In some embodiments, if the application program and the preset tool are deployed in a shared deployment manner, that is, the application program and the preset tool belong to the same computer device, and the running system of the application program is a Windows system, the communication between processes can also be implemented through a named pipe (naming pipes), which is another method for performing communication between processes on the same machine, and is generally used for simpler communication requirements.
In this embodiment, a suitable communication protocol is selected according to the deployment manner of the application program and the preset tool, and a listening port conforming to the relevant communication protocol is established, so that the high efficiency and the correctness of data transmission can be ensured, the system performance is improved, and the data security is enhanced.
in some embodiments, as shown in FIG. 4, the computer device running the application extracts the resource path and target symbol in the correction request, including steps 402 through 406. Wherein:
Step 402, acquiring verification information carried by the correction request.
The verification information is information required for verifying the correction request.
In actual implementation, the correction request also carries verification information. The computer equipment running the application program verifies the source and the content of the correction request by acquiring verification information carried by the correction request, and ensures that the correction request is initiated by a legal and authorized process, thereby avoiding malicious or erroneous correction operation.
in some embodiments, the verification information may be an authorization code that the application transmits to an authorized correction request sender (i.e., an authorized operator), with different senders obtaining different authorization codes. The authorization code has timeliness, and the state of the expired authorization code is invalid.
And step 404, verifying the validity of the correction request based on the verification information to obtain a verification result.
In some embodiments, the computer device running the application may verify the validity of the correction request by way of information matching. Specifically, a verification information table which is allocated and in a valid state is stored in the computer device, and the verification information table stores verification information (such as authorization codes in a preset format and the like) which is allocated to other programs (generally, correction request sending processes) except the running application program by the computer device and in the valid state. The authentication information is set to an invalid state if it has been used or expired. And periodically cleaning the verification information table to clean the verification information in an invalid state. The computer equipment extracts the verification information in the correction request, searches whether the verification information exists and is in a valid state from the verification information table, and if so, characterizes the correction request as a valid request. If the correction request is not present or is present but in an invalid state, the correction request is an invalid request.
in some embodiments, the computer device may also verify whether the resource path carried in the correction request is wrong, or whether the resource file in the resource path exists, or the like, so as to improve stability and reliability of the application program.
In step 406, if the verification result indicates that the correction request is a valid request, the resource path and the target symbol in the correction request are extracted in the process of continuing to run the application program.
in actual implementation, under the condition that the computer equipment verifies that the correction request is a valid request, in the process of continuing to run the application program, the resource path and the target symbol in the correction request are continuously extracted so as to carry out the subsequent specific correction operation of the program behavior.
in this embodiment, validity verification based on the verification information helps to ensure the integrity and correctness of the correction request. This may prevent invalid or corrupted requests from being performed, reducing adverse effects on running applications.
in some embodiments, as shown in FIG. 5, a computer device running an application accesses a resource path to obtain a resource file, including steps 502 through 504. Wherein:
step 502, determining an access mode for the resource path according to the running system where the application program is located and the file form of the resource file.
In some embodiments, the manner of access to the resource path may be determined based on the operating system of the application and the file form of the resource file indicated by the resource path. Different running systems and file forms have different access modes for resource paths. The resource file is an executable file that can be loaded and executed by a dynamic loading manner.
For example, if the running system of the application program is a Linux system, the access manner for the resource path is determined based on the library function dlopen, that is, the resource path is accessed by calling the library function dlopen to obtain the resource file. If the running system of the application program is a Windows system, the access mode for the resource path is determined based on the library function loadLibrary, that is, the resource path is accessed by calling the library function loadLibrary, and the resource file is acquired.
in step 504, the resource path is accessed to obtain the resource file by access.
In actual implementation, the computer device accesses the resource path by an access manner adapted to the running system to which the running application belongs and the file form of the resource file. It is further possible to detect whether a resource file exists in the resource path, and obtain the resource file in the case that the resource file exists.
In this embodiment, the most appropriate access manner is determined according to the specific system in which the application program operates and the format of the resource file, so that the application program can be ensured to access the resource file normally in various environments, and the efficiency and success rate of resource access are improved.
in some embodiments, the resource file is a dynamic link library file, and the computer device running the application loads the resource file and locates the target symbol in the resource file by: in the process of running the application program, the library function is called to dynamically load the dynamic link library file into the memory space of the application program, and the target symbol in the dynamic link library is positioned in the memory space.
in practical implementation, the dynamic link library has the characteristic of being capable of being loaded by using a dynamic loading mode, so that an operation and maintenance party can compile a resource file into the dynamic link library which is suitable for an operating system of an operating application program. And the library path of the dynamic link library is used as a resource path, and the behavior modification function in the dynamic link library is used as a target symbol to be packaged into a modification request so as to instruct the computer equipment to call the library function matched with the dynamic link library to realize the operation on the dynamic link library in the running process of the application program. It should be noted that, the computer device loads the dynamic link library into the memory space when the application program runs, so that the dynamic link library can be ensured not to be maliciously modified or intercepted by the third party application.
In some embodiments, a library function implementing a load function accesses a library path, loads a dynamically linked library file into a memory space of an operating application, and recalls a library function implementing a locate function to locate a target symbol in the memory space, and executes a code fragment in the target symbol. In the case that the resource file is a dynamic link library file, the computer device running the application program executes a library function adapted to the dynamic link library depending on the programming language and the operating system used, so as to implement an operation for the dynamic link library.
In some embodiments, where the running system of the running application is a Windows system, the computer device may dynamically load the dynamic link library dll file and locate the target symbol during the running of the application by: firstly, dynamically loading dll files by using a library function LoadLibrary for operating a dynamic link library in a Windows system, wherein parameters of the LoadLibrary function at least comprise library paths of the dll files; the LoadLibrary function returns a HINSTANCE type pointer to the location in memory where the dll file is loaded; after dynamically loading the dll file, the pointer of a specific function (namely, the behavior modification function indicated by the target symbol) in the dll file is obtained through the library function GetProcAddress. When the program behavior modification is completed, the loaded dll file is no longer needed, and the server can use the library function FreeLibrary to unload the loaded dll file in the memory space.
in some embodiments, if the running system of the running application is a Linux system, the corresponding library function for the dynamically linked library is dlopen, dlsym, dlcalose, etc.
in this embodiment, the running application program can dynamically load or unload the dynamic link library as required during running, thereby providing greater flexibility and extensibility.
In some embodiments, as shown in FIG. 6, a computer device running an application executes code fragments in a resource file that are associated with a target symbol to modify the program behavior of the application while the application is maintained in continued operation, including steps 602 through 606. Wherein:
Step 602, lock protection is performed on the service thread running the application program.
the lock protection is a thread synchronization mechanism, which can prevent multiple threads from accessing shared resources at the same time, so that thread safety is ensured.
In actual implementation, the computer device uses a preset thread synchronization mechanism to protect the running business thread when performing modification operation on the running application program. The thread synchronization mechanism may be at least a thread Mutex (Mutex), event (Event). In this way, it can be ensured that only one thread can access and modify the shared resource at the same time.
In step 604, during the lock protection process, the code segment related to the target symbol in the resource file is executed, so as to correct the program behavior of the application program under the condition that the program body of the application program is kept unchanged.
In practical implementation, during the lock protection process, the computer device translates the code segments extracted from the resource file into executable machine instructions through a preset translation mode. The predetermined translation may be accomplished by an interpreter, just-in-time compiler (JIT), or other compilation tool. The computer device executes executable machine instructions corresponding to the code segments to modify the behavior of the application while maintaining the program body of the application unchanged. Specific behavior modification operations may include modifying runtime data, invoking other functions, or changing the execution flow of a program.
Step 606, after modifying the program behavior of the application, releases the lock protection.
in actual practice, once the code fragment is executed, the computer device releases the lock previously acquired to secure the business thread. To allow other threads to continue executing or accessing the protected resource.
in this embodiment, lock protection is performed on a service thread that is running on an application program, so that multiple threads are prevented from accessing shared resources at the same time, and thread security problems are prevented from occurring. In addition, by executing the code segments in the resource file, the modification of the application program behavior is realized, the program body is not required to be modified, and the maintenance cost and risk are reduced. Finally, after the behavior is modified, the lock protection is released, so that other threads can continuously access the shared resource, and the running efficiency of the application program is improved.
In some embodiments, after modifying the program behavior of the application, the computer device running the application may also perform the following operations: determining an unloading mode according to an operation platform of an application program and a file form of a resource file; and unloading the resource file from the memory space of the application program based on the unloading mode, and releasing related resources allocated for the resource file.
the uninstalling mode refers to a mode of uninstalling the resource file by using an uninstalling library function which is matched with the running platform of the application program and the file form of the resource file.
In actual implementation, the computer device uses the correction resources in a dynamic loading manner, and after correcting the running application program, the computer device continues to execute the unloading operation for the correction resources in order to reduce the resource consumption for the running application program. The uninstall operation essentially removes the information about the existing revision resource from the memory space of the running application. The computer device performs the corresponding uninstall operation in an uninstall manner that matches the running platform (i.e., running system) of the application and the file form of the resource file.
In some embodiments, if the running system of the application program is Linux and the file form of the resource file is a dynamic link library so file, the computer device loads the dynamic link library corresponding to the correction resource into the memory space of the running application program in a specified mode through the library function dlopen, and returns a handle for indicating the correction resource to the calling process of the library function dlsym, so as to implement the correction operation for the running application program. Finally, the existing dynamic link library in the memory space of the running application program is offloaded by using the offloaded library function dlelose.
In some embodiments, if the running system of the application program is Windows and the file form of the resource file is a dynamic link library dll file, the computer device loads the dynamic link library corresponding to the revised resource into the memory space of the running application program by calling the library function loadlibrary, and returns a handle for indicating the revised resource to the calling process of the library function getprocaddress, so as to implement the revision operation for the running application program. After the corrective action execution is completed, it should be offloaded in time to free up system resources. The computer device invokes the uninstall library function freeligary to uninstall the dynamically linked library loaded in the memory space of the running application.
In this embodiment, by unloading the resource file that is no longer needed, the memory space can be recovered, so as to avoid memory leakage and improve the memory utilization efficiency. Dynamic resource management is supported, so that an application program can load and unload resource files according to needs, and flexibility and expandability of the application program are improved.
In some embodiments, after modifying the program behavior of the application, the computer device running the application may also perform the following operations: acquiring an execution result corresponding to the corrected program behavior; the execution result is used for being called by a function interface in a program body of the application program, or the execution result is used for being called by an external calling party.
in actual implementation, execution results after execution of the modification for the running application may be continuously called by the function interface in the program body of the application, i.e. other parts inside the application may use these results to perform their functions. Therefore, the corrected program behavior can be ensured to be seamlessly integrated into the existing functions of the application program, and the integrity and consistency of the application program are improved.
In some embodiments, the execution result after the correction is executed for the running application may also be used by an external caller, which may include at least other applications different from the running application. The external calling party calls the execution result through a preset calling mode, wherein the preset calling mode at least can be that the server packages the execution result into an application program interface for the external calling party to call, and therefore the external calling party can access the corresponding execution result through the forms of the application program interface (Application Programming Interface, API) and the like. Such as an external caller may need to obtain the behavior results of the modified program to execute its business logic. Thus, the interaction with other systems or services is facilitated, the functions of the application program are expanded, and data sharing and flow integration are realized.
In some embodiments, if the interception port has permission to transmit the execution result, the running application program may transmit the execution result to the interception port, and the external caller obtains the corresponding execution result from the interception port and applies the execution result to its own service logic.
In this embodiment, by providing the execution result to the application itself or other external callers, flexibility and expandability of the application can be increased, so that it can adapt to different service requirements and integration scenarios. By ensuring that the corrected program behavior can provide a correct execution result, the continuity of the service can be maintained, and service interruption caused by abnormal program behavior is reduced.
in some embodiments, the computer device may also perform the following operations: periodically detecting the program behavior of the application program to obtain a detection result; triggering a transmitting program to initiate a correction request under the condition that the detection result represents that the program behavior of the application program accords with the correction condition; the correction request is obtained by packaging the resource path and the target symbol for correcting the program behavior.
In practical implementation, the computer device may also run an automatic detection program, and by periodically detecting the program behavior of the running application program to determine the program behavior to be corrected that meets the correction condition, send alarm information to the outside, where the alarm information is used to prompt that the running program has the program behavior to be corrected, so as to instruct the authorized operation and maintenance party to send a corresponding correction request to the interception port through a preset tool. The computer device obtains a preset detection period, and the detection period can be set according to the importance and stability requirements of the application program. For example, it may be detected every minute, hour or day. And during the set detection period, the computer device collects the program behavior data associated with the running application program, which may include performance indexes, error logs, user feedback, or other relevant detection information. The collected program behavior data is then analyzed to determine whether the behavior of the application is expected. Finally, according to the analysis result, the computer equipment judges whether the behavior of the application program accords with the correction condition. If the detection results indicate that there is a problem or instability in the behavior of the application, then these results will be considered to indicate that a correction is required. If the detection result indicates that the program behavior of the application program accords with the correction condition, the system triggers the sending program to initiate a correction request.
In some embodiments, the computer device runs an automatic detection program and periodically analyzes log information generated by the running program according to a detection period. And then determining the program behavior to be corrected according to the log information. If the log information contains information related to the correction scene, automatically judging the program behavior to be corrected of the currently running application program, and sending alarm information to the interception port to prompt the outside that the program behavior to be corrected exists, so as to instruct authorized maintenance personnel to correct the program behavior.
Taking an example of a correction scenario in which the correction scenario is an unexpected output, the automatic detection program reads log information, if it is detected that a request of a service request is identified as an unexpected value (for example, less than 0, or not increased as expected), it is determined that there is an unexpected program behavior of the output, the computer device generates alarm information through the automatic detection program, and sends the alarm information to a listening port for receiving the correction request, an authorized operator writes a code segment for correcting the program behavior based on the alarm information, compiles the code segment into an executable file capable of being loaded based on a dynamic loading mode, finally, takes a file path of the executable file as a resource path, and a behavior correction function for correcting the program behavior in the executable file is packaged as a correction request and sent to the listening port. The server receives the correction request from the interception port, and corrects the program behavior of the running program based on the resource path and the behavior correction function in the correction request in a dynamic loading mode.
In this embodiment, through periodic detection, unstable or abnormal behavior that may exist in the application program can be found in time, and the program behavior can be corrected in time. And the behavior of the application program can be ensured to be kept in an expected range, and the application program can be corrected in time when a problem occurs, so that the stability and the performance of the application program are maintained.
In some embodiments, the application-based processing method provided by the embodiments of the present application may be applied to a corrected scene of unexpected output. The specific unintended output correction scenario is as follows: the running application program distributes a monotonically increasing request identifier for each received service request, then the service request is downloaded to another functional module of the application program for processing, the processing module compares the request identifier of the current service request with the request identifier of the last processed historical service request after receiving the current service request, if the request identifier type (generally, the numerical value type) overflows, the request identifier distributed for the current service request is smaller than the request identifier of the processed historical service request, namely, the request identifier of the current service request belongs to unexpected output. The running application ignores the current service request, resulting in that this service request is never handled properly.
Aiming at the correction scene of the unexpected output, the authorized operation and maintenance party adopts a proper programming language to write correction resources, and meanwhile compiles the correction resources into a dynamic link library. And packaging the library path of the dynamic link library and the corresponding target symbol into a correction request through a preset tool, and transmitting the correction request through a interception port established between the preset tool and a server running an application program. After receiving the correction request from the interception port, the computer equipment running the application program is adapted to the running system of the application program, and is used for operating the library function of the dynamic link library to execute the operations such as loading, executing and unloading the dynamic link library, so that the correction of the application program for unexpected output is realized for the running application program without modifying the program main body of the application program, and the request identification of the service request can be ensured not to overflow and monotonically increase after the correction.
In some embodiments, the application-based processing method provided by the embodiment of the application can be applied to a correction scene for misoperation of an application program. Illustratively, there are the following corrective scenarios for misoperation of an application: in distributed storage applications, distributed locks are typically employed to ensure data consistency among various clients, which can only modify or read data after the corresponding distributed lock is taken. If the distributed lock is not released all the time due to the defect of the application program itself or the wrong logic of the client, other clients cannot read and write the data protected by the distributed lock.
Aiming at the correction scene of the misoperation, the processing method based on the application program provided by the embodiment of the application is applied to the client side to which the distributed lock to be released belongs, firstly, code fragments for releasing the distributed lock are written and compiled into a dynamic link library, a library path of the dynamic link library and a target symbol (generally referred to as a corresponding behavior correction function) for releasing the distributed lock in the library are packaged into a correction request through a preset tool running on the client side, the correction request is sent to a interception port established between the running application program and the preset tool, the dynamic link library is loaded and executed through the corresponding library function, and the correction processing for the misoperation is executed under the condition of not modifying a program main body of the application program, so that the distributed lock is released, and other client sides are ensured to read and write data protected by the distributed lock.
In some embodiments, the application-based processing method provided by the embodiment of the application can be applied to a modified scene of online upgrade. In the modification scene of online upgrade in the embodiment of the application, under the condition that the program version of the application program is kept unchanged, and the deployed resources in the application program are not deleted, replaced and updated, the online upgrade of the application program is realized by only loading external modification resources (upgrade resources here) in a dynamic loading mode in the running process of the application program. Thus, online upgrades can be implemented even in the face of applications that cannot support online upgrade capabilities. This is essentially different from existing online upgrades of programs implemented based on thermal remediation technology, which are typically implemented based on version management, which modifies or replaces the dependent resources that the application has deployed.
In order to describe the processing method based on the application program in detail, an embodiment is described below, in which the running system of the application program is Linux, the resource file is a dynamic link library, and the file form of the resource file is a so file. The application program and the preset tool are positioned in a computer device, a interception port conforming to a Socket is established between the application program and the preset tool, and particularly, the interception port is established based on the domain Socket. In the Linux system, under the condition that the program body of the running application program is not modified, loading the code segment associated with the target symbol in the dynamic link library through the library function dlopen, dlsym, dlclose and the like, correcting the program behavior of the running application program in the Linux system, and releasing the corresponding memory space after the behavior correction. The method is essentially a method of dynamically changing program behavior in real time.
in some embodiments, the main implementation of dynamically changing program behavior in real time is: and modifying the internal state of the program by loading the dynamic link library and reversing the behavior modification function appointed in the callback library so as to influence the program behavior of the service thread. The whole correction process does not need to pause any business thread of the running application program, and does not need to directly modify the logic of any business thread of the application program, and the internal state of the program is modified according to the normal logic to influence the behavior of the business thread.
For example, as shown in fig. 7, in order to implement a change of program behavior for an application program that is running, a real-time correction processing function module may be included in a program body of the application program, that is, a behavior correction thread is allocated to the real-time correction processing in the program body. The behavior modification thread sequentially realizes the following four functions: 1) interception and acceptance of correction requests, 2) verification of correction request validity, 3) loading of dynamic link libraries, and 4) callback function positioning and execution.
based on the functional modules shown in fig. 7, a specific way of dynamically changing the program behavior in real time is shown in fig. 8.
describing interception and acceptance of the correction request for 1), as shown in fig. 8, number 1, since the running application program and the preset tool for sending the correction request are deployed in the same computer device, an interception port conforming to the domain socket is established, and the correction request from the interception port is received during the running process of the application program. The correction request at least carries the library path of the dynamic link library and the function name of the behavior correction function.
The verification of the validity of the correction request will be described with reference to 2), and as shown in fig. 8, number 2, the validity of the correction request is verified by using a general encryption algorithm. The encryption algorithm is based on the premise that the correction request carries an encryption key distributed by a program main body, and the validity of the correction request is verified through a symmetrical encryption algorithm.
The description is made for 3) loading the dynamic link library, as shown in fig. 8, no. 3, and the dynamic link library indicated by the library path in the correction request is dynamically loaded by using the library function dlopen of the dynamic link library matched with the linux system. The correction request carries a library path of the dynamic link library, and the library path can be an absolute path or a relative path. A handle (handler) for indicating the dynamically linked library is returned by the library function, through which the subsequent library function operates the dynamically linked library.
For 4) callback function locating and executing description, as shown in number 4 of fig. 8, the callback function actually refers to a function indicated by a target symbol in a dynamic link library, and is used for program behavior modification, because the callback function is called by an application program in running and modifies program behavior of the application program in the protection process of a thread lock, and is therefore also called as a callback function. The locate callback function is actually a callback function located in the memory space of the running application by implementing the library function dlsym of the locate function. And executing the code fragments in the callback function after finding the callback function. Finally, in execution completion, the previously loaded dynamically linked library is unloaded by the library function dlelose to free up resources.
Next, the application-based processing method in the present embodiment is described with behavior modification of a modification scene for unexpected output. The correction scenario of the unexpected output may specifically be: the running system deployed by the server running the application program is a Linux system, in the running process of the application program A, a monotonically increasing request identification ID is distributed for each service request, then the service request is downloaded to another module of the application program for processing, the processing module compares the current request with the last processed request ID after receiving the current request, if the new service request with the current ID smaller than the processed ID is ignored due to overflow of the ID type, and the service request can not be processed normally. For the correction scene of the unexpected output, the operation and maintenance party can dynamically modify the generation mode of the request identification ID under the condition of not changing the program main body of the running application program A by using the program behavior correction mode in the example so as to ensure that the request identification ID is strictly monotonically increased and ensure that a new service request can be processed according to expected logic.
As shown in fig. 9, the real-time correction process of the program behavior of the correction scenario for the unexpected output is that, firstly, the authorized operation and maintenance party writes the code segment shown by the number 1 in the graph through the preset programming language, and compiles the code segment through the preset compiling mode to generate the dynamic link library adtinget. The callback function in adtInget.so, which modifies the next service request ID from 0 by calling the setNextID function of the gADTIDDER object present in the running application. In order to ensure thread synchronization of the running program, real-time modification of program behavior is performed under the protection of thread locks. The following operations are then performed:
1) The operation and maintenance party sends a correction request to the running application program through a preset tool adt_control based on the built interception port conforming to the domain socket, wherein the correction request carries an adtInget.so library path of a dynamic link library (shown as a number 1 in the figure) and a callback function ingestFunc (namely a target symbol in the previous description), and the callback function is a function of a callback required by the running application program. At this time, the preset tool and the running application program run together in the same computer device.
2) And after receiving the correction request sent by the authorized operation and maintenance party through the preset tool through the interception port, the running application program acquires verification information carried in the correction request, verifies the correction request, and continuously executes the correction step of the subsequent program behavior under the condition that the verification result represents that the verification source is legal and compliant and the correction request is sent by the authorized operation and maintenance party.
3) If the verification fails, the correction request is determined to be a non-valid correction request, and the next correction request is directly returned and continuously received and processed through the interception port.
4) If the verification is successful, continuing to verify the validity of the dynamic link library adtInget.so in the correction request, including whether the dynamic link library exists or not, and the like.
6) If the verification fails, the next correction request is directly returned and continuously received and processed through the interception port.
7) If the verification is successful, the library function dlopen is called to dynamically load the linked library adtInget.so, and the position of the ingestFunc symbol is located in the memory space of the running application program by calling the library function dlsym.
8) Check if the loading and positioning is successful.
9) If loading or positioning fails, the next correction request is directly returned and continuously received and processed through the interception port.
10 If the loading and positioning are successful, the behavior modification function ingestFun is executed. And after the execution is finished, continuously calling the dynamic library loaded before unloading the library function dlelose to release the corresponding resources.
11 Returns to the interception module and carries the return information of the ingestFunc for other functional interfaces of the running application programs to carry out subsequent processing based on the return information of the ingestFunc.
12 The running application may also send the return result information to the external caller, in this example no post return value.
By loading the behavior modification function of the dynamic link library real-time reverse callback response, the embodiment of the application dynamically modifies the program behavior under the condition that the running program does not need to be stopped or paused, and the abnormal situation is handled by changing the behavior of the real-time program under the condition that the running program main body is unchanged, thereby not only ensuring continuous uninterrupted service to upper-layer business, but also dynamically upgrading to modify the potential problem of the program itself.
It should be understood that, although the steps in the flowcharts related to the embodiments described above are sequentially shown as indicated by arrows, these steps are not necessarily sequentially performed in the order indicated by the arrows. The steps are not strictly limited to the order of execution unless explicitly recited herein, and the steps may be executed in other orders. Moreover, at least some of the steps in the flowcharts described in the above embodiments may include a plurality of steps or a plurality of stages, which are not necessarily performed at the same time, but may be performed at different times, and the order of the steps or stages is not necessarily performed sequentially, but may be performed alternately or alternately with at least some of the other steps or stages.
Based on the same inventive concept, the embodiment of the application also provides an application-based processing device for implementing the above related application-based processing method. The implementation of the solution provided by the device is similar to the implementation described in the above method, so the specific limitation of the embodiment of the application processing device or devices provided below may be referred to the limitation of the application-based processing method hereinabove, and will not be repeated herein.
In some embodiments, as shown in fig. 10, there is provided an application-based processing apparatus 1000 comprising: an extraction module 1010, an acquisition module 1020, a positioning module 1030, and a correction module 1040, wherein:
and the extracting module 1010 is configured to extract the resource path and the target symbol in the correction request if the correction request is received during the running process of the application program.
an acquisition module 1020 for accessing the resource path to obtain a resource file.
And a positioning module 1030, configured to load the resource file and position the target symbol in the resource file.
And the correction module 1040 is used for executing the code segments related to the target symbol in the resource file so as to correct the program behavior of the application program in the process of keeping the application program running continuously.
In some embodiments, the extracting module is further configured to intercept, during the running process of the application program, a pre-established interception port through an interception thread; after listening for a request sent to the listening port, it is identified whether the request is a correction request.
In some embodiments, the correction request is sent by a preset tool, and the extraction module is further configured to determine a deployment manner of the application program and the preset tool; and determining a communication protocol matched with the deployment mode, and establishing a interception port conforming to the communication protocol.
In some embodiments, the extracting module is further configured to obtain verification information carried by the correction request; based on the verification information, carrying out validity verification on the correction request to obtain a verification result; and if the verification result represents that the correction request is a valid request, extracting a resource path and a target symbol in the correction request in the process of continuing to run the application program.
In some embodiments, the obtaining module is further configured to determine an access manner for the resource path according to an operating system in which the application program is located and a file form of the resource file; and accessing the resource path to obtain the resource file in an access mode.
In some embodiments, the resource file is a dynamic link library file, and the positioning module is further configured to call a library function to dynamically load the dynamic link library file into a memory space of the application program in a process of running the application program, and position a target symbol in the dynamic link library in the memory space.
In some embodiments, the correction module is further configured to lock and protect a service thread that is running in the application program; in the lock protection process, code segments related to target symbols in the resource file are executed to correct program behaviors of the application program under the condition that the program body of the application program is kept unchanged.
in some embodiments, the modification module is further configured to release the lock protection after modifying the program behavior of the application.
In some embodiments, the modification module is further configured to determine an uninstalling mode according to an operating platform of the application program and a file form of the resource file; and unloading the resource file from the memory space of the application program based on the unloading mode, and releasing related resources allocated for the resource file.
in some embodiments, the correction module is further configured to obtain, after correcting the program behavior of the application program, an execution result corresponding to the corrected program behavior; the execution result is used for being called by a function interface in a program body of the application program, or the execution result is used for being called by an external calling party.
In some embodiments, the extracting module is further configured to periodically detect a program behavior of the application program, to obtain a detection result; triggering a transmitting program to initiate a correction request under the condition that the detection result represents that the program behavior of the application program accords with the correction condition; the correction request is obtained by packaging the resource path and the target symbol for correcting the program behavior.
The various modules in the application processing apparatus described above may be implemented in whole or in part by software, hardware, or a combination thereof. The above modules may be embedded in hardware or may be independent of a processor in the computer device, or may be stored in software in a memory in the computer device, so that the processor may call and execute operations corresponding to the above modules.
In an exemplary embodiment, a computer device is provided, which may be the first computer device or the second computer device in fig. 1, and the internal structural diagram thereof may be as shown in fig. 11. The computer device includes a processor, a memory, an Input/Output interface (I/O) and a communication interface. The processor, the memory and the input/output interface are connected through a system bus, and the communication interface is connected to the system bus through the input/output interface. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The database of the computer device is for storing resource data of the desktop application. The input/output interface of the computer device is used to exchange information between the processor and the external device. The communication interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement an application-based processing method.
It will be appreciated by those skilled in the art that the structure shown in FIG. 11 is merely a block diagram of some of the structures associated with the present inventive arrangements and is not limiting of the computer device to which the present inventive arrangements may be applied, and that a particular computer device may include more or fewer components than shown, or may combine some of the components, or have a different arrangement of components.
In some embodiments, a computer device is provided, comprising a memory and a processor, the memory having stored therein a computer program, the processor implementing the steps of the method embodiments described above when the computer program is executed.
In some embodiments, a computer-readable storage medium is provided, on which a computer program is stored which, when executed by a processor, carries out the steps of the method embodiments described above.
In some embodiments, a computer program product is provided, comprising a computer program which, when executed by a processor, implements the steps of the method embodiments described above.
It should be noted that, the user information (including but not limited to user equipment information, user personal information, etc.) and the data (including but not limited to data for analysis, stored data, presented data, etc.) related to the present application are both information and data authorized by the user or sufficiently authorized by each party, and the collection, use and processing of the related data are required to meet the related regulations.
Those skilled in the art will appreciate that implementing all or part of the above described methods may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed, may comprise the steps of the embodiments of the methods described above. Any reference to memory, database, or other medium used in embodiments provided herein may include at least one of non-volatile and volatile memory. The nonvolatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical Memory, high density embedded nonvolatile Memory, resistive random access Memory (ReRAM), magnetic random access Memory (Magnetoresistive Random Access Memory, MRAM), ferroelectric Memory (Ferroelectric Random Access Memory, FRAM), phase change Memory (Phase Change Memory, PCM), graphene Memory, and the like. Volatile memory can include random access memory (Random Access Memory, RAM) or external cache memory, and the like. By way of illustration, and not limitation, RAM can be in the form of a variety of forms, such as static random access memory (Static Random Access Memory, SRAM) or dynamic random access memory (Dynamic Random Access Memory, DRAM), and the like. The databases referred to in the embodiments provided herein may include at least one of a relational database and a non-relational database. The non-relational database may include, but is not limited to, a blockchain-based distributed database, and the like. The processor referred to in the embodiments provided in the present application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic unit, a data processing logic unit based on quantum computing, or the like, but is not limited thereto.
The technical features of the above embodiments may be arbitrarily combined, and all possible combinations of the technical features in the above embodiments are not described for brevity of description, however, as long as there is no contradiction between the combinations of the technical features, they should be considered as the scope of the description.
The foregoing examples illustrate only a few embodiments of the application and are described in detail herein without thereby limiting the scope of the application. It should be noted that it will be apparent to those skilled in the art that several variations and modifications can be made without departing from the spirit of the application, which are all within the scope of the application. Accordingly, the scope of the application should be assessed as that of the appended claims.

Claims (15)

1. A method of application-based processing, the method comprising:
If a correction request is received in the running process of an application program, extracting a resource path and a target symbol in the correction request;
Accessing the resource path to obtain a resource file;
loading the resource file and positioning the resource file to a target symbol in the resource file;
And executing the code segment related to the target symbol in the resource file so as to correct the program behavior of the application program in the process of keeping the application program continuously running.
2. the method according to claim 1, characterized in that the method comprises:
during the running process of the application program, interception is carried out on a pre-established interception port through an interception thread;
after a request sent to the interception port is intercepted, whether the request is a correction request is identified.
3. the method of claim 2, wherein the correction request is sent by a preset tool, the method further comprising:
determining deployment modes of the application program and the preset tool;
and determining a communication protocol matched with the deployment mode, and establishing a interception port conforming to the communication protocol.
4. the method of claim 1, wherein the extracting the resource path and the target symbol in the correction request comprises:
Acquiring verification information carried by the correction request;
based on the verification information, carrying out validity verification on the correction request to obtain a verification result;
and if the verification result represents that the correction request is a valid request, extracting a resource path and a target symbol in the correction request in the process of continuing to run the application program.
5. The method of claim 1, wherein said accessing the resource path to obtain a resource file comprises:
Determining an access mode aiming at the resource path according to an operating system where the application program is located and a file form of the resource file;
And accessing the resource path to obtain the resource file through the access mode.
6. The method of claim 1, wherein the resource file is a dynamic link library file, and the loading the resource file and locating the target symbol in the resource file comprises:
and in the process of running the application program, calling a library function to dynamically load the dynamic link library file into a memory space of the application program, and positioning a target symbol in the dynamic link library in the memory space.
7. The method of claim 1, wherein the executing the code segment in the resource file associated with the target symbol to modify the program behavior of the application while maintaining the program ontology of the application unchanged comprises:
Performing lock protection on the service thread in which the application program is running;
executing the code segments related to the target symbol in the resource file in the lock protection process, so as to correct the program behavior of the application program under the condition that the program body of the application program is kept unchanged;
the method further comprises the steps of:
And after the program behavior of the application program is corrected, releasing the lock protection.
8. The method of claim 1, wherein after modifying the program behavior of the application, the method further comprises:
determining an unloading mode according to the operation platform of the application program and the file form of the resource file;
And unloading the resource file from the memory space of the application program based on the unloading mode, and releasing related resources allocated for the resource file.
9. The method according to claim 1, wherein the method further comprises:
After the program behavior of the application program is corrected, an execution result corresponding to the corrected program behavior is obtained; the execution result is used for being called by a function interface in a program body of the application program, or is used for being called by an external calling party.
10. The method according to any one of claims 1 to 9, further comprising:
periodically detecting the program behavior of the application program to obtain a detection result;
Triggering a transmitting program to initiate a correction request under the condition that the detection result represents that the program behavior of the application program accords with the correction condition; the correction request is obtained by packaging a resource path and a target symbol for correcting the program behavior.
11. An application-based processing apparatus, the apparatus comprising:
the extraction module is used for extracting a resource path and a target symbol in the correction request if the correction request is received in the running process of the application program;
the acquisition module is used for accessing the resource path to acquire a resource file;
the positioning module is used for loading the resource file and positioning the target symbol in the resource file;
And the correction module is used for executing the code segment related to the target symbol in the resource file so as to correct the program behavior of the application program in the process of keeping the application program to continue to run.
12. the apparatus of claim 11, wherein the extraction module is further configured to, during running of the application, snoop a pre-established snoop port by a snoop thread; after a request sent to the interception port is intercepted, whether the request is a correction request is identified.
13. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor implements the steps of the method of any one of claims 1 to 10 when the computer program is executed.
14. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 10.
15. a computer program product comprising a computer program, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any one of claims 1 to 10.
CN202410195070.0A 2024-02-22 Processing method and device based on application program, computer equipment and storage medium Active CN117762430B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410195070.0A CN117762430B (en) 2024-02-22 Processing method and device based on application program, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410195070.0A CN117762430B (en) 2024-02-22 Processing method and device based on application program, computer equipment and storage medium

Publications (2)

Publication Number Publication Date
CN117762430A true CN117762430A (en) 2024-03-26
CN117762430B CN117762430B (en) 2024-07-09

Family

ID=

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107305495A (en) * 2016-04-19 2017-10-31 华为技术有限公司 Realize the method and terminal of software installation packet function modification
CN107506221A (en) * 2017-09-28 2017-12-22 阿里巴巴集团控股有限公司 Application program updating method, apparatus and equipment
CN110471690A (en) * 2019-06-25 2019-11-19 珠海格力电器股份有限公司 Loading method, device and the storage medium of dynamic link library SO file
CN112486547A (en) * 2021-02-03 2021-03-12 苏州达家迎信息技术有限公司 Application program updating method and device under multi-tenant scene and electronic equipment
WO2022083316A1 (en) * 2020-10-21 2022-04-28 北京字节跳动网络技术有限公司 Application running method and apparatus, and computer storage medium
CN116991434A (en) * 2023-05-19 2023-11-03 厦门铠甲网络股份有限公司 Packet reorganization method, system and storage medium for android APP

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107305495A (en) * 2016-04-19 2017-10-31 华为技术有限公司 Realize the method and terminal of software installation packet function modification
CN107506221A (en) * 2017-09-28 2017-12-22 阿里巴巴集团控股有限公司 Application program updating method, apparatus and equipment
CN110471690A (en) * 2019-06-25 2019-11-19 珠海格力电器股份有限公司 Loading method, device and the storage medium of dynamic link library SO file
WO2022083316A1 (en) * 2020-10-21 2022-04-28 北京字节跳动网络技术有限公司 Application running method and apparatus, and computer storage medium
CN112486547A (en) * 2021-02-03 2021-03-12 苏州达家迎信息技术有限公司 Application program updating method and device under multi-tenant scene and electronic equipment
CN116991434A (en) * 2023-05-19 2023-11-03 厦门铠甲网络股份有限公司 Packet reorganization method, system and storage medium for android APP

Similar Documents

Publication Publication Date Title
US11762986B2 (en) System for securing software containers with embedded agent
CN109739573B (en) Processing method and device for realizing API (application program interface) call and system for realizing API
CN107562513B (en) Intelligent contract life cycle management method based on JAVA
CN110825420B (en) Method, device, equipment and storage medium for updating configuration parameters of distributed cluster
CN107038045B (en) Method and device for loading library file
US20230259386A1 (en) Data processing method based on container engine and related device
US20230036357A1 (en) Method and apparatus for authority control, computer device and storage medium
CN110166459B (en) Protection method, device and equipment for deserialization loophole and readable storage medium
EP3451221B1 (en) Binary suppression and modification for software upgrades
CN113569285A (en) Identity authentication and authorization method, device, system, equipment and storage medium
CN112699034B (en) Virtual login user construction method, device, equipment and storage medium
CN111327680B (en) Authentication data synchronization method, device, system, computer equipment and storage medium
CN117762430B (en) Processing method and device based on application program, computer equipment and storage medium
CN112199441A (en) Data synchronization processing method, device, equipment and medium based on big data platform
WO2023125755A1 (en) Service request processing method and apparatus based on large-scale cluster, and device and medium
CN117762430A (en) processing method and device based on application program, computer equipment and storage medium
CN112559248B (en) Preprocessing service recovery method, device, equipment and storage medium
CN113938527B (en) Extension processing method of API gateway, computing device and storage medium
US7305554B2 (en) Dynamic acquisition of state during security system reconfiguration
CN114385503A (en) Interface test method, device, equipment and storage medium
CN114386047A (en) Application vulnerability detection method and device, electronic equipment and storage medium
CN100555237C (en) Be used to detect and prevent the method and system of replay attack
CN112988353A (en) Operation control method and device for application program
CN114692145A (en) Rear door detection method and system
CN112464225A (en) Request processing method, request processing device and computer readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant