WO2025025528A1 - Application program control method and apparatus - Google Patents
Application program control method and apparatus Download PDFInfo
- Publication number
- WO2025025528A1 WO2025025528A1 PCT/CN2024/072324 CN2024072324W WO2025025528A1 WO 2025025528 A1 WO2025025528 A1 WO 2025025528A1 CN 2024072324 W CN2024072324 W CN 2024072324W WO 2025025528 A1 WO2025025528 A1 WO 2025025528A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- dynamic library
- application
- library
- control
- dynamic
- 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.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/445—Program loading or initiating
- G06F9/44521—Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/445—Program loading or initiating
- G06F9/44521—Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading
- G06F9/44526—Plug-ins; Add-ons
Definitions
- the present disclosure relates to the field of computer technology, specifically to the field of application development technology, and more particularly to an application control method and device.
- plug-in extension is usually used to indicate plug-in technology implemented based on dynamic libraries
- dynamic library injection is a technology that uses "hooks" or other similar dynamic code injection technologies in the dynamic library to "hijack” or “overwrite” the original code in the application, or inject new code, to change or expand the original application when loading the dynamic library.
- plug-in extensions can generally only provide corresponding capability extensions based on the agreed interface between them and the application, and cannot go deep into more basic functions; although dynamic library injection can inject code into the application at runtime without being restricted by the plug-in interface, thus going deep into the underlying functions of the application, dynamic library injection is not controlled by the application itself.
- Embodiments of the present disclosure provide an application control method, apparatus, device, and storage medium.
- an application control method comprising: injecting a first dynamic library into the application by loading it at startup; injecting a second dynamic library into the application The dynamic library is loaded into the application in a plug-in manner; in response to determining that the injection of the first dynamic library is completed and the loading of the second dynamic library is completed, based on the second dynamic library, a specified interface provided by the first dynamic library is called to control the function provided by the first dynamic library.
- an application control device which includes: an injection module, configured to inject a first dynamic library into the application by loading it at startup; a loading module, configured to load a second dynamic library into the application as a plug-in; and a control module, configured to, in response to determining that the injection of the first dynamic library is completed and the loading of the second dynamic library is completed, call a specified interface provided by the first dynamic library based on the second dynamic library to control the functions provided by the first dynamic library.
- an electronic device which includes one or more processors; a storage device on which one or more programs are stored, and when the one or more programs are executed by the one or more processors, the one or more processors implement an application control method as in any of the above embodiments.
- a computer-readable medium on which a computer program is stored.
- the program is executed by a processor, the application control method of any of the above embodiments is implemented.
- FIG1 is an exemplary system architecture diagram in which the present disclosure may be applied
- FIG2 is a flow chart of an embodiment of an application control method according to the present disclosure.
- FIG3 is an architecture diagram of an embodiment of an application control method according to the present disclosure.
- FIG4a is a flow chart of an embodiment of an application control method according to the present disclosure.
- FIG4 b is a flow chart of an application scenario of the application control method according to the present disclosure.
- FIG4c is a flow chart of another application scenario of the application control method according to the present disclosure.
- FIG5 is a flow chart of an embodiment of an application control device according to the present disclosure.
- FIG. 6 is a schematic diagram of the structure of a computer system suitable for implementing a server of an embodiment of the present disclosure.
- FIG. 1 shows an exemplary system architecture 100 to which an embodiment of the application control method of the present disclosure can be applied.
- system architecture 100 may include terminal devices 101, 102, 103, network 104 and server 105.
- Network 104 is used to provide a medium for communication links between terminal devices 101, 102, 103 and server 105.
- Network 104 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
- the terminal devices 101, 102, 103 interact with the server 105 via the network 104 to receive or send messages, etc.
- Various communication client applications such as storage applications, communication applications, etc., may be installed on the terminal devices 101, 102, 103.
- Terminal devices 101, 102, 103 can be hardware or software. When terminal devices 101, 102, 103 are hardware, they can be various electronic devices with display screens, including but not limited to mobile phones and laptops. When terminal devices 101, 102, 103 are software, they can be installed in the electronic devices listed above. They can be implemented as multiple software or software modules (for example, to provide application control services), or they can be implemented as a single software or software module. No specific limitation is made here.
- the server 105 may be a server that provides various services, for example, injecting the first dynamic library into the application by loading it at startup; loading the second dynamic library into the application as a plug-in; in response to determining that the injection of the first dynamic library is completed and the injection of the second dynamic library is completed, After the loading is completed, based on the second dynamic library, the specified interface provided by the first dynamic library is called to control the functions provided by the first dynamic library.
- the server 105 can be hardware or software.
- the server 105 can be implemented as a distributed server cluster consisting of multiple servers, or it can be implemented as a single server.
- the server is software, it can be implemented as multiple software or software modules (for example, for providing application control services), or it can be implemented as a single software or software module. No specific limitation is made here.
- the application control method provided in the embodiment of the present disclosure can be executed by the server 105, or by the terminal devices 101, 102, 103, or by the server 105 and the terminal devices 101, 102, 103 cooperating with each other.
- the various parts (such as various units, sub-units, modules, sub-modules) included in the application control device can be all set in the server 105, or all set in the terminal devices 101, 102, 103, or respectively set in the server 105 and the terminal devices 101, 102, 103.
- terminal devices, networks and servers in Figure 1 is only illustrative. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
- FIG2 shows a process 200 of an embodiment of an application control method that can be applied to the present disclosure.
- the application control method includes the following steps:
- Step 201 inject the first dynamic library into the application by loading it at startup.
- the execution entity (such as the server 105 or the terminal devices 101 , 102 , 103 shown in FIG. 1 ) can inject the first dynamic library into the application when the application is started.
- the first dynamic library injected into the application by the execution subject may override the code of the application itself or the code of the dynamic library on which the application depends, which is not limited in the present disclosure.
- the first dynamic library preloaded when starting the application can be set by specifying the environment variable "LD_PRELOAD"; when the application is started, the specified first dynamic library will be loaded into the memory address space of the process before the execution of the application.
- the relevant code is as follows:
- the execution subject may inject the first dynamic library into the application in a variety of specific ways, such as inline injection, overlay injection, etc.
- inline injection is used to indicate that the code is directly injected into the original code location, thereby "hijacking" the original code
- overlay injection is used to indicate that the function pointer in the function jump table or symbol table is overwritten and redirected to the target function.
- the object of overlay injection can be the application itself or a library function that the application depends on.
- the first dynamic library may provide various types of designated interfaces, such as application program interfaces, callback interfaces, etc., for calling.
- Step 202 Load the second dynamic library into the application program in a plug-in manner.
- the execution entity can load the second dynamic into the application in a plug-in manner, that is, load the second dynamic library, namely the plug-in dynamic library, and the plug-in interface function into the application, and the loaded application can call the functions in the second dynamic library through the plug-in interface function.
- the second dynamic library can be loaded through the dl library in glibc.
- the three commonly used library functions are dlopen (open dynamic library), dlclose (close dynamic library) and dlsym (search for famous symbols from the symbol table of the dynamic library).
- the second dynamic library that is, the plug-in dynamic library
- the plug-in dynamic library is loaded through dlopen, and the interface function with the pre-agreed interface name is found from the symbol table of the dynamic library through dlsym.
- the application can call the function in the plug-in dynamic library through the interface function.
- the second dynamic library that is, the plug-in dynamic library
- the second dynamic library can be unloaded through the dlclose function.
- Step 203 in response to the completion of injection of the first dynamic library and loading of the second dynamic library, based on the second dynamic library, calling a specified interface provided by the first dynamic library to control the function provided by the first dynamic library.
- the execution subject can call the first dynamic library through the parameters in the second dynamic library to provide A specified interface, such as an API (Application Program Interface), controls all or part of the functions (for example, functions that are not enabled by default, functions that require calling an API to be triggered, etc.) in the first dynamic library injected into the application, that is, controls the application, that is, combines the underlying functions corresponding to the first dynamic library with the application, and provides the application with controllable underlying function extensions.
- API Application Program Interface
- the functions provided by the first dynamic library are generally functions that the second dynamic library does not have.
- the specified interface provided by the first dynamic library is called to control the function provided by the first dynamic library, including: based on the second dynamic library, the specified interface provided by the first dynamic library is called to perform at least one of the following control operations on the function provided by the first dynamic library: underlying function switch, monitoring, auditing, optimization configuration, and automatic control.
- the execution entity can call the specified interface provided by the first dynamic library through the parameters in the second dynamic library, and perform at least one of the following control operations on the function provided by the first dynamic library, that is, the injection part in the application: underlying function switch, monitoring, auditing, optimization configuration, and automatic control.
- This implementation method calls the specified interface provided by the first dynamic library based on the second dynamic library, and performs at least one of the following control operations on the function provided by the first dynamic library: underlying function switch, monitoring, auditing, optimized configuration, and automatic control, thereby realizing the control of multiple underlying functions and the expansion of application functions.
- the method further includes: in response to determining that the second dynamic library is removed, disabling a new function in the first dynamic library that is opened or enabled by the second dynamic library.
- some functions in the first dynamic library are not enabled by default. After these functions are enabled due to loading the second dynamic library, the execution subject can monitor the status of the second dynamic library in real time or periodically. If the second dynamic library is removed, such as uninstalling the second dynamic library, the new functions in the first dynamic library that are enabled or enabled due to the second dynamic library will be disabled.
- This implementation achieves “pluggability” of the new function by disabling the new function in the first dynamic library that is turned on or enabled by the second dynamic library in response to determining that the second dynamic library is removed.
- the method further includes: in response to determining that the application program injected by the first dynamic library or the library function on which the application program depends has changed, and the changed application program or the library function on which the application program depends is incompatible with the first dynamic library injection mode, only The first dynamic library is re-adapted.
- the code of the application's development library or the application itself changes, it needs to be recompiled, and the changed application's development library or application is incompatible with the injection method of the first dynamic library.
- the code of the first dynamic library must also be changed to adapt. Further, the adapted code is recompiled to ensure that the first dynamic library can still be used when the application itself or the dependent development library changes.
- the first dynamic library used in the original version 1.0 is no longer compatible with version 2.0.
- the source code of the first dynamic library needs to be modified to adapt to version 2.0.
- the modified first dynamic library can be used on version 2.0.
- the plug-in interface of the application and the specified interface provided by the first dynamic library will not change, and the second dynamic library does not need to be re-adapted.
- This implementation method responds to determining that an application injected with the first dynamic library or a library function on which the application depends has changed, and that the changed application or the library function on which the application depends is incompatible with the first dynamic library injection method, and only re-adapts the first dynamic library, thereby achieving timely updating of the first dynamic library, thereby achieving timely and effective control of the first dynamic library, and isolating the impact of the application change on the plug-in.
- the specified interface provided by the first dynamic library is called to control the functions provided by the first dynamic library, including: based on the second dynamic library, the specified interface provided by the first dynamic library and the interface of the application itself are called to control the functions provided by the first dynamic library.
- the execution entity can call the specified interface provided by the first dynamic library through the parameters in the second dynamic library, such as API (Application Program Interface), and the interface of the application itself to control all or part of the functions (for example, functions that are not enabled by default, functions that require calling API to be triggered, etc.) in the first dynamic library injected into the application.
- API Application Program Interface
- This implementation method controls the functions provided by the first dynamic library by calling the specified interface provided by the first dynamic library and the interface of the application itself based on the second dynamic library, that is, combining the underlying capabilities provided by the first dynamic library with the characteristics of the application itself, which helps Implementing advanced capabilities such as operation and maintenance automation will help further expand the underlying capabilities of the application.
- FIG. 3 is an architecture diagram of an application scenario of the application control method according to this embodiment.
- the first dynamic library preloaded when starting the application can be set by specifying the environment variable "LD_PRELOAD"; when the application (such as a.out) is started, the specified first dynamic library (such as injected.so) will be loaded into the memory address space of the process before the execution of the application, so as to realize the injection of the object code in the first dynamic library into the application.
- the first dynamic library can provide a specified interface that can be called, for example, an API interface.
- the second dynamic library (such as plugin.so) is loaded into the application as a plug-in, and the loaded application can call the function in the second dynamic library based on the plug-in interface function.
- the execution subject calls the specified interface provided by the first dynamic library (such as injected.so) based on the second dynamic library (plugin.so) to control the function provided by the first dynamic library, that is, to control the application.
- the specified interface provided by the first dynamic library such as injected.so
- the second dynamic library plugin.so
- FIG4a shows a process 400 of another embodiment of the application control method that can be applied to the present disclosure.
- the application control method includes the following steps:
- Step 401 inject the first dynamic library into the application by loading it at startup.
- step 401 can refer to the description of step 201 and will not be repeated here.
- Step 402 Load the second dynamic library into the application program in a plug-in manner.
- step 402 can refer to the description of step 202 and will not be repeated here.
- Step 403 Based on the plug-in level parameters provided by the second dynamic library, a designated interface provided by the first dynamic library is called to control the functions provided by the first dynamic library.
- the execution subject can call the corresponding designated interface provided by the first dynamic library through the plug-in level parameters provided by the second dynamic library to control the functions provided by the first dynamic library.
- the plug-in level parameters include at least one of the following: configuration parameters and status parameters.
- MySQL supports developers to develop plug-ins through the interface agreed upon by its plug-in system.
- MySQL's own memory management capabilities are relatively weak, and it does not provide an interface for overloading its underlying memory allocator.
- MySQL's memory usage audit can only be tracked through memory-related instruments in performance_schema (PFS for short, used to manage system views related to MySQL performance monitoring), but this relies on the fact that when the MySQL kernel is coded, all codes involving memory allocation and recovery must be explicitly associated with a PFS instrument.
- PFS performance_schema
- MySQL compiled based on the GNU Linux environment uses ptmalloc in the C standard library as the memory allocator by default.
- ptmalloc is relatively slow in recovering and returning memory fragments to the operating system. Therefore, in high-concurrency and high-load scenarios, OOM (Out Of Memory) problems caused by excessive MySQL memory usage often occur.
- the default memory allocator of the FreeBSD system jemalloc
- jemalloc has the characteristics of relatively timely memory fragmentation recovery and return to the operating system.
- the aforementioned "LD_PRELOAD+dynamic library injection” method can be used to overwrite the malloc/free and other library functions of the MySQL memory allocator at startup to take over the memory allocation/recycling operations of MySQL. That is, the first dynamic library (jemalloc) is injected into the application by loading at startup to alleviate the OOM phenomenon of MySQL.
- jemalloc also provides a very rich API interface, which can realize functions such as real-time monitoring of memory allocation status (statistics APIs), auditing of memory allocation behavior (profiling APIs, common scenarios include: memory leak analysis, memory occupancy analysis, etc.), and memory recovery (dirty/muzzy decay APIs).
- these functions are not enabled by default, or require API calls to trigger, and the dynamic library injection method is "transparent" to MySQL itself.
- the MySQL kernel cannot perceive and actively call the jemalloc interface.
- jemalloc has the ability to actively recycle memory and return it to the operating system, the triggering mechanism of memory recovery is still uncontrolled and cannot be managed through the MySQL interface itself. Therefore, even if jemalloc is used, MySQL still has a certain probability of generating OOM due to the untimely triggering of the memory recovery mechanism.
- the my_jemalloc plug-in is developed based on the MySQL plug-in interface (the output is the dynamic library "my_jemalloc.so", that is, the second dynamic library, and the MySQL plug-in is named "jemalloc"), and the second dynamic library and the plug-in interface function are loaded into the application.
- the MySQL plug-in interface a series of plug-in-level parameters are provided, through which the monitoring of the memory allocator and other advanced functions can be realized.
- the MySQL plugin supports two types of parameters. One is called system parameters (i.e. "system variables”), which are named in the format of "plugin name (lowercase)_parameter name”. This type of parameter is a configuration parameter and can be read and written. The other is called status parameters (i.e. "status variables”), which are named in the format of "plugin name (first letter uppercase)_parameter name”. They are status monitoring (i.e. statistics) parameters and are read-only.
- system parameters i.e. "system variables”
- status parameters i.e. "status variables”
- status monitoring i.e. statistics
- the memory allocation status monitoring parameters (status parameters) of Jemalloc are named "Jemalloc_stats_xxx" and display the memory allocation status by calling the statistics APIs of jemalloc.
- the memory recycling trigger parameter (system parameter) is named "jemalloc_manually_reclaim".
- jemalloc_manually_reclaim When reading the parameter, the total amount of reclaimable physical memory is counted by accessing the statistics APIs of jemalloc; when writing any value to this parameter, the aging recycling of free memory pages is realized by calling the dirty/muzzy decay APIs of jemalloc.
- Memory profiling switch parameter system parameter
- jemalloc_active_profiling Memory profiling switch parameter
- Jemalloc supports logging of memory allocation/recycling behavior, but this action has a great impact on performance and will occupy additional memory. Therefore, the my_jemalloc plugin does not enable this function by default. Users can manually enable it when they need to do memory analysis.
- the memory log write parameter (system parameter, write-only) is named "jemalloc_dump_profiling" and is only available when memory profiling is turned on. When the user enters a writable profile file path to this parameter, the entire contents of the current jemalloc memory log can be dumped to this file.
- the background memory reclaim thread switch parameter (system parameter), named "jemalloc_monitor_switch", is used to start or stop the automatic memory reclaim thread.
- the Jemalloc library itself provides the background memory reclaim thread function, but the jemalloc plug-in introduces its own background thread to implement the automatic memory reclaim strategy, and reclaims memory by explicitly calling the dirty/muzzy decay interface.
- the polling interval parameter (system parameter) of the background memory recycling thread is named "jemalloc_monitor_interval”. After the background thread is started, it will poll periodically according to the number of seconds set by this parameter to monitor whether the memory recycling action is automatically performed.
- Memory high water level parameter (system parameter), named "jemalloc_high_water_mark”.
- the memory management capability is controllable and observable.
- users can accurately monitor the memory usage of MySQL by querying parameters such as Jemalloc_stats_xxx in the plug-in; and, by using profiling-related parameters, they can conduct a more accurate analysis of MySQL's memory allocation/recycling behavior.
- the my_jemalloc plug-in has expanded two sets of automatic/manual memory recovery strategies for MySQL, ensuring that the memory occupancy rate always runs below a certain expected water level, completely solving the OOM problem.
- the process of the background memory recovery thread is specifically shown in Figure 4b.
- my_jemalloc plug-in also provides "pluggable" capabilities.
- plug-in uninstalled the advanced functions provided in the plug-in will be automatically disabled.
- the plug-in uninstallation process is shown in Figure 4c.
- the process 400 of the application control method in this embodiment reflects that in response to the completion of the injection of the first dynamic library and the completion of the loading of the second dynamic library, based on the plug-in level parameters provided by the second dynamic library, the specified interface provided by the first dynamic library is called to control the functions provided by the first dynamic library, and the plug-in level parameters include at least one of the following: state parameters, configuration parameters, which further realize the refined control and expansion of the underlying functions of the application.
- the present disclosure provides an embodiment of an application control device, which is similar to the embodiment shown in FIG.
- the device can be specifically applied to various electronic devices.
- the application control device 500 of this embodiment includes: an injection module 501 , a loading module 502 and a control module 503 .
- the injection module 501 may be configured to inject the first dynamic library into the application by loading it at startup.
- the loading module 502 may be configured to load the second dynamic library into the application program in a plug-in manner.
- the control module 503 may be configured to, in response to determining that the injection of the first dynamic library is completed and the loading of the second dynamic library is completed, call a specified interface provided by the first dynamic library based on the second dynamic library to control the function provided by the first dynamic library.
- control module is further configured to call a specified interface provided by the first dynamic library based on the plug-in level parameters provided by the second dynamic library to control the functions provided by the first dynamic library.
- control module is further configured to call a designated interface provided by the first dynamic library and an interface of the application program itself based on the second dynamic library to control the functions provided by the first dynamic library.
- the device further includes: a closing module configured to close a new function in the first dynamic library that is opened or enabled by the second dynamic library in response to determining that the second dynamic library is removed.
- a closing module configured to close a new function in the first dynamic library that is opened or enabled by the second dynamic library in response to determining that the second dynamic library is removed.
- control module is further configured to: based on the second dynamic library, call the specified interface provided by the first dynamic library, and perform at least one of the following control operations on the function provided by the first dynamic library: underlying function switch, monitoring, auditing, optimization configuration, and automatic control.
- the device also includes: a change module, which is configured to respond to determining that the application injected with the first dynamic library or the library function on which the application depends has changed, and the changed application or the library function on which the application depends is incompatible with the first dynamic library injection method, and only re-adapt the first dynamic library.
- a change module which is configured to respond to determining that the application injected with the first dynamic library or the library function on which the application depends has changed, and the changed application or the library function on which the application depends is incompatible with the first dynamic library injection method, and only re-adapt the first dynamic library.
- the present disclosure also provides an electronic device and a readable storage medium.
- FIG6 it is a block diagram of an electronic device according to the application control method of an embodiment of the present disclosure.
- the electronic device 600 is a block diagram of an electronic device according to an application control method of an embodiment of the present disclosure.
- the electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers.
- the electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices.
- the components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and/or required herein.
- the electronic device includes: one or more processors 601, memory 602, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces.
- the various components are connected to each other using different buses, and can be installed on a common mainboard or installed in other ways as needed.
- the processor can process instructions executed in the electronic device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input/output device (such as a display device coupled to the interface).
- an external input/output device such as a display device coupled to the interface.
- multiple processors and/or multiple buses can be used together with multiple memories and multiple memories.
- multiple electronic devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system).
- a processor 601 is taken as an example.
- the memory 602 is a non-transient computer-readable storage medium provided by the present disclosure.
- the memory stores instructions executable by at least one processor to enable the at least one processor to perform the application control method provided by the present disclosure.
- the non-transient computer-readable storage medium of the present disclosure stores computer instructions, which are used to enable a computer to perform the application control method provided by the present disclosure.
- the memory 602 is a non-transient computer-readable storage medium that can be used to store non-transient software programs, non-transient computer executable programs and modules, such as program instructions/modules corresponding to the application control method in the embodiment of the present disclosure (for example, the injection module 501, the loading module 502 and the control module 503 shown in FIG. 5).
- the processor 601 executes the service by running the non-transient software programs, instructions and modules stored in the memory 602.
- the various functional applications and data processing of the device are implemented, that is, the application control method in the above method embodiment is implemented.
- the memory 602 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created by the use of an electronic device controlled by an application, etc.
- the memory 602 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device.
- the memory 602 may optionally include a memory remotely arranged relative to the processor 601, and these remote memories may be connected to the electronic device controlled by the application via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
- the electronic device of the application control method may further include: an input device 603 and an output device 604.
- the processor 601, the memory 602, the input device 603 and the output device 604 may be connected via a bus or other means, and FIG6 takes the bus connection as an example.
- the input device 603 can receive input digital or character information, such as a touch screen, a keypad, a mouse, a track pad, a touch pad, an indicator bar, one or more mouse buttons, a track ball, a joystick, and other input devices.
- the output device 604 may include a display device, an auxiliary lighting device (e.g., an LED), and a tactile feedback device (e.g., a vibration motor).
- the display device may include, but is not limited to, a liquid crystal display (LCD), a light emitting diode (LED) display, and a plasma display. In some embodiments, the display device may be a touch screen.
- Various implementations of the systems and techniques described herein can be realized in digital electronic circuit systems, integrated circuit systems, dedicated ASICs (application specific integrated circuits), computer hardware, firmware, software, and/or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and/or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
- a programmable processor which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
- the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer.
- a display device e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor
- a keyboard and pointing device e.g., a mouse or trackball
- Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
- the systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components.
- the components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
- a computer system may include clients and servers.
- Clients and servers are generally remote from each other and usually interact through a communication network.
- the relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship to each other.
- the first dynamic library is injected into the application by loading at startup; the second dynamic library is loaded into the application in a plug-in manner; in response to determining that the injection of the first dynamic library is completed and the loading of the second dynamic library is completed, based on the first dynamic library, The second dynamic library calls the specified interface provided by the first dynamic library to control the functions provided by the first dynamic library, that is, by simultaneously loading the injected first dynamic library and the plug-in second dynamic library, the control and expansion of the underlying functions of the application are achieved.
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Stored Programmes (AREA)
Abstract
Description
相关申请的交叉引用CROSS-REFERENCE TO RELATED APPLICATIONS
本专利申请要求于2023年07月28日提交的、申请号为202310942825.4、发明名称为“应用程序控制方法、装置”的中国专利申请的优先权,该申请的全文以引用的方式并入本公开中。This patent application claims priority to the Chinese patent application filed on July 28, 2023, with application number 202310942825.4 and invention name “Application Control Method and Device”, the full text of which is incorporated by reference into this disclosure.
本公开涉及计算机技术领域,具体涉及应用开发技术领域,尤其涉及一种应用程序控制方法和装置。The present disclosure relates to the field of computer technology, specifically to the field of application development technology, and more particularly to an application control method and device.
现有技术中,运行时动态扩展应用程序能力的方式,主要包括插件式扩展和动态库注入。其中,插件式扩展通常用于指示基于动态库方式实现的插件技术,动态库注入为在加载动态库时,通过在动态库中以“钩子”或其他类似的动态代码注入技术,“劫持”或“覆盖”应用程序中原有的代码,或注入新代码,以改变或扩展原有应用程序的技术。In the prior art, the methods of dynamically extending the capabilities of applications at runtime mainly include plug-in extension and dynamic library injection. Among them, plug-in extension is usually used to indicate plug-in technology implemented based on dynamic libraries, and dynamic library injection is a technology that uses "hooks" or other similar dynamic code injection technologies in the dynamic library to "hijack" or "overwrite" the original code in the application, or inject new code, to change or expand the original application when loading the dynamic library.
但是,插件式扩展一般只能基于其与应用程序间约定好的接口,提供相应的能力扩展,无法深入到更加底层的功能;动态库注入虽然可以在运行时向应用程序中注入代码,无需受插件接口的限制,从而深入到应用的底层功能,但是,动态库注入不受应用程序本身的控制。However, plug-in extensions can generally only provide corresponding capability extensions based on the agreed interface between them and the application, and cannot go deep into more basic functions; although dynamic library injection can inject code into the application at runtime without being restricted by the plug-in interface, thus going deep into the underlying functions of the application, dynamic library injection is not controlled by the application itself.
发明内容Summary of the invention
本公开实施例提供了一种应用程序控制方法、装置、设备以及存储介质。Embodiments of the present disclosure provide an application control method, apparatus, device, and storage medium.
在一个或多个实施例中,提供了一种应用程序控制方法,该方法包括:将第一动态库通过启动时加载的方式注入到应用程序;将第二 动态库以插件方式加载入应用程序;响应于确定第一动态库注入完成,并且第二动态库加载完成,基于第二动态库,调用第一动态库提供的指定接口,对第一动态库提供的功能进行控制。In one or more embodiments, an application control method is provided, the method comprising: injecting a first dynamic library into the application by loading it at startup; injecting a second dynamic library into the application The dynamic library is loaded into the application in a plug-in manner; in response to determining that the injection of the first dynamic library is completed and the loading of the second dynamic library is completed, based on the second dynamic library, a specified interface provided by the first dynamic library is called to control the function provided by the first dynamic library.
在一个或多个实施例中,提供了一种应用程序控制装置,该装置包括:注入模块,被配置成将第一动态库通过启动时加载的方式注入到应用程序;加载模块,被配置成将第二动态库以插件方式加载入应用程序;控制模块,被配置成响应于确定第一动态库注入完成,并且第二动态库加载完成,基于第二动态库,调用第一动态库提供的指定接口,对第一动态库提供的功能进行控制。In one or more embodiments, an application control device is provided, which includes: an injection module, configured to inject a first dynamic library into the application by loading it at startup; a loading module, configured to load a second dynamic library into the application as a plug-in; and a control module, configured to, in response to determining that the injection of the first dynamic library is completed and the loading of the second dynamic library is completed, call a specified interface provided by the first dynamic library based on the second dynamic library to control the functions provided by the first dynamic library.
在一个或多个实施例中,提供了一种电子设备,该电子设备包括一个或多个处理器;存储装置,其上存储有一个或多个程序,当一个或多个程序被该一个或多个处理器执行,使得一个或多个处理器实现如上述任一实施例的应用程序控制方法。In one or more embodiments, an electronic device is provided, which includes one or more processors; a storage device on which one or more programs are stored, and when the one or more programs are executed by the one or more processors, the one or more processors implement an application control method as in any of the above embodiments.
在一个或多个实施例中,提供了一种计算机可读介质,其上存储有计算机程序,该程序被处理器执行时实现如上述的任一实施例的应用程序控制方法。In one or more embodiments, a computer-readable medium is provided, on which a computer program is stored. When the program is executed by a processor, the application control method of any of the above embodiments is implemented.
应当理解,本部分所描述的内容并非旨在标识本公开的实施例的关键或重要特征,也不用于限制本公开的范围。本公开的其他特征将通过以下的说明书而变得容易理解。It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description.
图1是本公开可以应用于其中的示例性系统架构图;FIG1 is an exemplary system architecture diagram in which the present disclosure may be applied;
图2是根据本公开的应用程序控制方法的一个实施例的流程图;FIG2 is a flow chart of an embodiment of an application control method according to the present disclosure;
图3是根据本公开的应用程序控制方法的一个实施例的架构图;FIG3 is an architecture diagram of an embodiment of an application control method according to the present disclosure;
图4a是根据本公开的应用程序控制方法的一个实施例的流程图;FIG4a is a flow chart of an embodiment of an application control method according to the present disclosure;
图4b是根据本公开的应用程序控制方法的一个应用场景的流程图;FIG4 b is a flow chart of an application scenario of the application control method according to the present disclosure;
图4c是根据本公开的应用程序控制方法的又一个应用场景的流程图;FIG4c is a flow chart of another application scenario of the application control method according to the present disclosure;
图5是根据本公开的应用程序控制装置的一个实施例的流程图; FIG5 is a flow chart of an embodiment of an application control device according to the present disclosure;
图6是适于用来实现本公开实施例的服务器的计算机系统的结构示意图。FIG. 6 is a schematic diagram of the structure of a computer system suitable for implementing a server of an embodiment of the present disclosure.
以下结合附图对本公开的示范性实施例做出说明,其中包括本公开实施例的各种细节以助于理解,应当将它们认为仅仅是示范性的。因此,本领域普通技术人员应当认识到,可以对这里描述的实施例做出各种改变和修改,而不会背离本公开的范围和精神。同样,为了清楚和简明,以下的描述中省略了对公知功能和结构的描述。The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.
需要说明的是,在不冲突的情况下,本公开中的实施例及实施例中的特征可以相互组合。下面将参考附图并结合实施例来详细说明本公开。It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present disclosure may be combined with each other. The present disclosure will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
图1示出了可以应用本公开的应用程序控制方法的实施例的示例性系统架构100。FIG. 1 shows an exemplary system architecture 100 to which an embodiment of the application control method of the present disclosure can be applied.
如图1所示,系统架构100可以包括终端设备101、102、103,网络104和服务器105。网络104用以在终端设备101、102、103和服务器105之间提供通信链路的介质。网络104可以包括各种连接类型,例如有线、无线通信链路或者光纤电缆等等。As shown in Fig. 1, system architecture 100 may include terminal devices 101, 102, 103, network 104 and server 105. Network 104 is used to provide a medium for communication links between terminal devices 101, 102, 103 and server 105. Network 104 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
终端设备101、102、103通过网络104与服务器105交互,以接收或发送消息等。终端设备101、102、103上可以安装有各种通讯客户端应用,例如,存储类应用、通讯类应用等。The terminal devices 101, 102, 103 interact with the server 105 via the network 104 to receive or send messages, etc. Various communication client applications, such as storage applications, communication applications, etc., may be installed on the terminal devices 101, 102, 103.
终端设备101、102、103可以是硬件,也可以是软件。当终端设备101、102、103为硬件时,可以是具有显示屏的各种电子设备,包括但不限于手机和笔记本电脑。当终端设备101、102、103为软件时,可以安装在上述所列举的电子设备中。其可以实现成多个软件或软件模块(例如用来提供应用程序控制服务),也可以实现成单个软件或软件模块。在此不做具体限定。Terminal devices 101, 102, 103 can be hardware or software. When terminal devices 101, 102, 103 are hardware, they can be various electronic devices with display screens, including but not limited to mobile phones and laptops. When terminal devices 101, 102, 103 are software, they can be installed in the electronic devices listed above. They can be implemented as multiple software or software modules (for example, to provide application control services), or they can be implemented as a single software or software module. No specific limitation is made here.
服务器105可以是提供各种服务的服务器,例如,将第一动态库通过启动时加载的方式注入到应用程序;将第二动态库以插件方式加载入应用程序;响应于确定第一动态库注入完成,并且第二动态库加 载完成,基于第二动态库,调用第一动态库提供的指定接口,对第一动态库提供的功能进行控制。The server 105 may be a server that provides various services, for example, injecting the first dynamic library into the application by loading it at startup; loading the second dynamic library into the application as a plug-in; in response to determining that the injection of the first dynamic library is completed and the injection of the second dynamic library is completed, After the loading is completed, based on the second dynamic library, the specified interface provided by the first dynamic library is called to control the functions provided by the first dynamic library.
需要说明的是,服务器105可以是硬件,也可以是软件。当服务器105为硬件时,可以实现成多个服务器组成的分布式服务器集群,也可以实现成单个服务器。当服务器为软件时,可以实现成多个软件或软件模块(例如用来提供应用程序控制服务),也可以实现成单个软件或软件模块。在此不做具体限定。It should be noted that the server 105 can be hardware or software. When the server 105 is hardware, it can be implemented as a distributed server cluster consisting of multiple servers, or it can be implemented as a single server. When the server is software, it can be implemented as multiple software or software modules (for example, for providing application control services), or it can be implemented as a single software or software module. No specific limitation is made here.
需要指出的是,本公开的实施例所提供的应用程序控制方法可以由服务器105执行,也可以由终端设备101、102、103执行,还可以由服务器105和终端设备101、102、103彼此配合执行。相应地,应用程序控制装置包括的各个部分(例如各个单元、子单元、模块、子模块)可以全部设置于服务器105中,也可以全部设置于终端设备101、102、103中,还可以分别设置于服务器105和终端设备101、102、103中。It should be noted that the application control method provided in the embodiment of the present disclosure can be executed by the server 105, or by the terminal devices 101, 102, 103, or by the server 105 and the terminal devices 101, 102, 103 cooperating with each other. Accordingly, the various parts (such as various units, sub-units, modules, sub-modules) included in the application control device can be all set in the server 105, or all set in the terminal devices 101, 102, 103, or respectively set in the server 105 and the terminal devices 101, 102, 103.
应该理解,图1中的终端设备、网络和服务器的数目仅仅是示意性的。根据实现需要,可以具有任意数目的终端设备、网络和服务器。It should be understood that the number of terminal devices, networks and servers in Figure 1 is only illustrative. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
图2示出了可以应用于本公开的应用程序控制方法的实施例的流程200。在本实施例中,应用程序控制方法包括以下步骤:FIG2 shows a process 200 of an embodiment of an application control method that can be applied to the present disclosure. In this embodiment, the application control method includes the following steps:
步骤201,将第一动态库通过启动时加载的方式注入到应用程序。Step 201: inject the first dynamic library into the application by loading it at startup.
在本实施例中,执行主体(如图1中所示的服务器105或终端设备101、102、103)可以在应用程序启动时,将第一动态库注入到应用程序。In this embodiment, the execution entity (such as the server 105 or the terminal devices 101 , 102 , 103 shown in FIG. 1 ) can inject the first dynamic library into the application when the application is started.
这里,执行主体注入到应用程序的第一动态库,既可以override应用程序本身的代码,也可以override应用程序所依赖的动态库的代码,本公开对此不作限定。Here, the first dynamic library injected into the application by the execution subject may override the code of the application itself or the code of the dynamic library on which the application depends, which is not limited in the present disclosure.
具体地,在Linux系统中,可以通过指定环境变量“LD_PRELOAD”来设置启动应用程序时预加载的第一动态库;在应用程序启动时,被指定的第一动态库将先于应用程序的执行被加载至该进程的内存地址空间中,相关代码如下所示: Specifically, in the Linux system, the first dynamic library preloaded when starting the application can be set by specifying the environment variable "LD_PRELOAD"; when the application is started, the specified first dynamic library will be loaded into the memory address space of the process before the execution of the application. The relevant code is as follows:
[Linux]LD_PRELOAD=/my/dir/injected.so./a.out[Linux]LD_PRELOAD=/my/dir/injected.so./a.out
通过上述方式,可以保证在应用程序(a.out)运行前,就完成第一动态库(injected.so)中目标代码向应用程序的注入。Through the above method, it can be ensured that the target code in the first dynamic library (injected.so) is injected into the application before the application (a.out) is run.
这里,执行主体在应用程序启动时,将第一动态库注入到应用程序的具体方式可以包括多种,例如,内联式注入、覆盖式注入等。Here, when the application is started, the execution subject may inject the first dynamic library into the application in a variety of specific ways, such as inline injection, overlay injection, etc.
其中,内联式注入用于指示直接把代码注入到原始代码位置,从而“劫持”原始代码;覆盖式注入用于指示通过覆盖函数跳转表或符号表中的函数指针,将其重定向至目标函数。Among them, inline injection is used to indicate that the code is directly injected into the original code location, thereby "hijacking" the original code; overlay injection is used to indicate that the function pointer in the function jump table or symbol table is overwritten and redirected to the target function.
这里,覆盖式注入的对象可以是应用程序本身,也可以是应用程序依赖的库函数。Here, the object of overlay injection can be the application itself or a library function that the application depends on.
进一步地,第一动态库可提供多种类型的指定接口,例如,应用程序接口、回调接口等等,以供调用。Furthermore, the first dynamic library may provide various types of designated interfaces, such as application program interfaces, callback interfaces, etc., for calling.
步骤202,将第二动态库以插件方式加载入应用程序。Step 202: Load the second dynamic library into the application program in a plug-in manner.
在本实施例中,执行主体可以将第二动态以插件方式加载入应用程序,即将第二动态库,即插件动态库,和插件接口函数加载入应用程序,加载完成的应用程序可通过插件接口函数调用第二动态库中的功能。In this embodiment, the execution entity can load the second dynamic into the application in a plug-in manner, that is, load the second dynamic library, namely the plug-in dynamic library, and the plug-in interface function into the application, and the loaded application can call the functions in the second dynamic library through the plug-in interface function.
具体地,在GNU Linux系统中,可以通过glibc中的dl库加载第二动态库,dl库中,常用的3个库函数为dlopen(打开动态库)、dlclose(关闭动态库)和dlsym(从动态库的符号表中搜索有名符号)。通常通过dlopen加载第二动态库,即插件动态库,并通过dlsym从该动态库的符号表中找到事先约定好接口名字的接口函数。在完成第二动态库以及插件接口函数加载后,应用程序可通过接口函数调用插件动态库中的功能。第二动态库,即插件动态库,使用完毕后,可通过dlclose函数卸载第二动态库。Specifically, in the GNU Linux system, the second dynamic library can be loaded through the dl library in glibc. In the dl library, the three commonly used library functions are dlopen (open dynamic library), dlclose (close dynamic library) and dlsym (search for famous symbols from the symbol table of the dynamic library). Usually, the second dynamic library, that is, the plug-in dynamic library, is loaded through dlopen, and the interface function with the pre-agreed interface name is found from the symbol table of the dynamic library through dlsym. After the second dynamic library and the plug-in interface function are loaded, the application can call the function in the plug-in dynamic library through the interface function. After the second dynamic library, that is, the plug-in dynamic library, is used, the second dynamic library can be unloaded through the dlclose function.
步骤203,响应于第一动态库注入完成,并且第二动态库加载完成,基于第二动态库,调用第一动态库提供的指定接口,对第一动态库提供的功能进行控制。Step 203, in response to the completion of injection of the first dynamic library and loading of the second dynamic library, based on the second dynamic library, calling a specified interface provided by the first dynamic library to control the function provided by the first dynamic library.
在本实施例中,执行主体在确定第一动态库注入完成,并且第二动态库加载完成后,可通过第二动态库中的参数调用第一动态库提供 的指定接口,例如,API(Application Program Interface,应用程序接口),对注入应用程序中的第一动态库中的全部功能或部分功能(例如,默认不开启的功能、需要调用API才能触发的功能等)进行控制,即对应用程序进行控制,也即将第一动态库对应的底层功能与应用程序相结合,向应用程序提供可控的底层功能扩展。In this embodiment, after determining that the injection of the first dynamic library is completed and the loading of the second dynamic library is completed, the execution subject can call the first dynamic library through the parameters in the second dynamic library to provide A specified interface, such as an API (Application Program Interface), controls all or part of the functions (for example, functions that are not enabled by default, functions that require calling an API to be triggered, etc.) in the first dynamic library injected into the application, that is, controls the application, that is, combines the underlying functions corresponding to the first dynamic library with the application, and provides the application with controllable underlying function extensions.
这里,第一动态库提供的功能通常为第二动态库不具备的功能。Here, the functions provided by the first dynamic library are generally functions that the second dynamic library does not have.
在一些可选的方式中,基于第二动态库,调用第一动态库提供的指定接口,对第一动态库提供的功能进行控制,包括:基于第二动态库,调用第一动态库提供的指定接口,对第一动态库提供的功能执行以下至少一项控制操作:底层功能开关、监控、审计、优化配置、自动化控制。In some optional methods, based on the second dynamic library, the specified interface provided by the first dynamic library is called to control the function provided by the first dynamic library, including: based on the second dynamic library, the specified interface provided by the first dynamic library is called to perform at least one of the following control operations on the function provided by the first dynamic library: underlying function switch, monitoring, auditing, optimization configuration, and automatic control.
在本实现方式中,执行主体可以通过第二动态库中的参数调用第一动态库提供的指定接口,对第一动态库,即应用程序中的注入部分,提供的功能执行以下至少一项控制操作:底层功能开关、监控、审计、优化配置、自动化控制。In this implementation, the execution entity can call the specified interface provided by the first dynamic library through the parameters in the second dynamic library, and perform at least one of the following control operations on the function provided by the first dynamic library, that is, the injection part in the application: underlying function switch, monitoring, auditing, optimization configuration, and automatic control.
该实现方式通过基于第二动态库中,调用第一动态库提供的指定接口,对第一动态库提供的功能执行以下至少一项控制操作:底层功能开关、监控、审计、优化配置、自动化控制,实现了对底层多种功能的控制,同时实现了对应用程序功能的扩展。This implementation method calls the specified interface provided by the first dynamic library based on the second dynamic library, and performs at least one of the following control operations on the function provided by the first dynamic library: underlying function switch, monitoring, auditing, optimized configuration, and automatic control, thereby realizing the control of multiple underlying functions and the expansion of application functions.
在一些可选的方式中,该方法还包括:响应于确定第二动态库移除,关闭第一动态库中由第二动态库开启或使能的新功能。In some optional embodiments, the method further includes: in response to determining that the second dynamic library is removed, disabling a new function in the first dynamic library that is opened or enabled by the second dynamic library.
在本实现方式中,第一动态库中部分功能默认不开启,在因加载第二动态库而开启该部分功能后,执行主体可实时或定期监测第二动态库的状态,若第二动态库移除,如卸载第二动态库,则将第一动态库中因第二动态库开启或使能的新功能关闭。In this implementation, some functions in the first dynamic library are not enabled by default. After these functions are enabled due to loading the second dynamic library, the execution subject can monitor the status of the second dynamic library in real time or periodically. If the second dynamic library is removed, such as uninstalling the second dynamic library, the new functions in the first dynamic library that are enabled or enabled due to the second dynamic library will be disabled.
该实现方式通过响应于确定第二动态库移除,关闭第一动态库中由第二动态库开启或使能的新功能,实现了新功能的“可插拔”。This implementation achieves “pluggability” of the new function by disabling the new function in the first dynamic library that is turned on or enabled by the second dynamic library in response to determining that the second dynamic library is removed.
在一些可选的方式中,该方法还包括:响应于确定第一动态库注入的应用程序或应用程序所依赖的库函数发生变更,并且变更后的应用程序或应用程序所依赖的库函数与第一动态库注入方式不兼容,仅 对第一动态库进行重新适配。In some optional embodiments, the method further includes: in response to determining that the application program injected by the first dynamic library or the library function on which the application program depends has changed, and the changed application program or the library function on which the application program depends is incompatible with the first dynamic library injection mode, only The first dynamic library is re-adapted.
在本实现方式中,若应用程序的开发库或者应用程序本身的代码发生改变,需要重新编译,并且变更后的应用程序的开发库或者应用程序与第一动态库的注入方式不兼容,此时也要对第一动态库的代码进行变更,以适配,进一步地,再重新编译适配后的代码,以保障在应用程序本身或者依赖的开发库发生变更的时候,第一动态库还能使用。In this implementation, if the code of the application's development library or the application itself changes, it needs to be recompiled, and the changed application's development library or application is incompatible with the injection method of the first dynamic library. At this time, the code of the first dynamic library must also be changed to adapt. Further, the adapted code is recompiled to ensure that the first dynamic library can still be used when the application itself or the dependent development library changes.
具体地,应用程序从1.0版本更新到2.0版本,此时在原1.0版本上使用的第一动态库已经和2.0版本不兼容了,此时需要修改第一动态库的源码,适配2.0版本,修改后的第一动态库才能在2.0版本上使用。Specifically, when an application is updated from version 1.0 to version 2.0, the first dynamic library used in the original version 1.0 is no longer compatible with version 2.0. At this time, the source code of the first dynamic library needs to be modified to adapt to version 2.0. The modified first dynamic library can be used on version 2.0.
通常,应用程序的插件接口及第一动态库提供的指定接口不会改变,第二动态库不需要重新适配。Usually, the plug-in interface of the application and the specified interface provided by the first dynamic library will not change, and the second dynamic library does not need to be re-adapted.
该实现方式通过响应于确定第一动态库注入的应用程序或应用程序所依赖的库函数发生变更,并且变更后的应用程序或应用程序所依赖的库函数与第一动态库注入方式不兼容,仅对第一动态库进行重新适配,实现了对第一动态库的及时更新,进而实现了对第一动态库及时有效地控制,并且隔离了应用程序变更对插件的影响。This implementation method responds to determining that an application injected with the first dynamic library or a library function on which the application depends has changed, and that the changed application or the library function on which the application depends is incompatible with the first dynamic library injection method, and only re-adapts the first dynamic library, thereby achieving timely updating of the first dynamic library, thereby achieving timely and effective control of the first dynamic library, and isolating the impact of the application change on the plug-in.
在一些可选的方式中,基于第二动态库,调用第一动态库提供的指定接口,对第一动态库提供的功能进行控制,包括:基于第二动态库,调用第一动态库提供的指定接口以及应用程序本身的接口,对第一动态库提供的功能进行控制。In some optional methods, based on the second dynamic library, the specified interface provided by the first dynamic library is called to control the functions provided by the first dynamic library, including: based on the second dynamic library, the specified interface provided by the first dynamic library and the interface of the application itself are called to control the functions provided by the first dynamic library.
在本实现方式中,执行主体可通过第二动态库中的参数调用第一动态库提供的指定接口,例如,API(Application Program Interface,应用程序接口),以及应用程序本身的接口对注入应用程序中的第一动态库中的全部功能或部分功能(例如,默认不开启的功能、需要调用API才能触发的功能等)进行控制。In this implementation, the execution entity can call the specified interface provided by the first dynamic library through the parameters in the second dynamic library, such as API (Application Program Interface), and the interface of the application itself to control all or part of the functions (for example, functions that are not enabled by default, functions that require calling API to be triggered, etc.) in the first dynamic library injected into the application.
该实现方式通过基于第二动态库,调用第一动态库提供的指定接口以及应用程序本身的接口,对第一动态库提供的功能进行控制,即将第一动态库提供的底层能力与应用程序本身的特性相结合,有助于 实现运维自动化等高级能力,即有助于进一步扩展应用程序的底层能力。This implementation method controls the functions provided by the first dynamic library by calling the specified interface provided by the first dynamic library and the interface of the application itself based on the second dynamic library, that is, combining the underlying capabilities provided by the first dynamic library with the characteristics of the application itself, which helps Implementing advanced capabilities such as operation and maintenance automation will help further expand the underlying capabilities of the application.
继续参见图3,图3是根据本实施例的应用程序控制方法的应用场景的一个架构图。Continuing to refer to FIG. 3 , FIG. 3 is an architecture diagram of an application scenario of the application control method according to this embodiment.
在图3的应用场景中,在Linux系统中,可以通过指定环境变量“LD_PRELOAD”来设置启动应用程序时预加载的第一动态库;在应用程序(如a.out)启动时,被指定的第一动态库(如injected.so)将先于应用程序的执行被加载至该进程的内存地址空间中,实现第一动态库中目标代码向应用程序的注入。其中,第一动态库可提供可供调用的指定接口,例如,API接口。进一步地,将第二动态库(如plugin.so)以插件方式加载入应用程序,加载完成的应用程序可基于插件接口函数调用第二动态库中的功能。响应于确定第一动态库注入完成,并且第二动态库加载完成,执行主体基于第二动态库(plugin.so),调用第一动态库(如injected.so)提供的指定接口,对第一动态库提供的功能进行控制,即对应用程序进行控制。In the application scenario of Figure 3, in the Linux system, the first dynamic library preloaded when starting the application can be set by specifying the environment variable "LD_PRELOAD"; when the application (such as a.out) is started, the specified first dynamic library (such as injected.so) will be loaded into the memory address space of the process before the execution of the application, so as to realize the injection of the object code in the first dynamic library into the application. Among them, the first dynamic library can provide a specified interface that can be called, for example, an API interface. Further, the second dynamic library (such as plugin.so) is loaded into the application as a plug-in, and the loaded application can call the function in the second dynamic library based on the plug-in interface function. In response to determining that the injection of the first dynamic library is completed and the loading of the second dynamic library is completed, the execution subject calls the specified interface provided by the first dynamic library (such as injected.so) based on the second dynamic library (plugin.so) to control the function provided by the first dynamic library, that is, to control the application.
图4a示出了可以应用于本公开的应用程序控制方法的另一个实施例的流程400。在本实施例中,应用程序控制方法包括以下步骤:FIG4a shows a process 400 of another embodiment of the application control method that can be applied to the present disclosure. In this embodiment, the application control method includes the following steps:
步骤401,将第一动态库通过启动时加载的方式注入到应用程序。Step 401: inject the first dynamic library into the application by loading it at startup.
在本实施例中,步骤401的实现细节和技术效果,可以参考对步骤201的描述,在此不再赘述。In this embodiment, the implementation details and technical effects of step 401 can refer to the description of step 201 and will not be repeated here.
步骤402,将第二动态库以插件方式加载入应用程序。Step 402: Load the second dynamic library into the application program in a plug-in manner.
在本实施例中,步骤402的实现细节和技术效果,可以参考对步骤202的描述,在此不再赘述。In this embodiment, the implementation details and technical effects of step 402 can refer to the description of step 202 and will not be repeated here.
步骤403,基于第二动态库提供的插件级参数,调用第一动态库提供的指定接口,对第一动态库提供的功能进行控制。Step 403: Based on the plug-in level parameters provided by the second dynamic library, a designated interface provided by the first dynamic library is called to control the functions provided by the first dynamic library.
在本实施例中,执行主体可通过第二动态库提供的插件级参数,调用第一动态库提供的对应的指定接口,对第一动态库提供的功能进行控制。 In this embodiment, the execution subject can call the corresponding designated interface provided by the first dynamic library through the plug-in level parameters provided by the second dynamic library to control the functions provided by the first dynamic library.
其中,插件级参数包括以下至少一项:配置参数、状态参数。The plug-in level parameters include at least one of the following: configuration parameters and status parameters.
具体地,MySQL支持开发者通过其插件系统约定的接口进行插件开发。但是,MySQL本身的内存管理能力偏弱,但又并未提供重载其底层内存分配器的接口。MySQL的内存占用率审计目前只能通过performance_schema(简称“PFS”,用于管理MySQL性能监控相关的系统视图)中内存相关的instruments进行跟踪,但是这依赖于MySQL内核编码时,所有涉及内存分配回收的代码都必须显性的与某个PFS的instrument进行关联。但实际上,MySQL中存在大量的未与PFS关联的内存分配/回收代码,这就造成PFS的内存占用率统计与实际的内存占用率之间存在巨大的偏差。此外,基于GNU Linux环境编译的MySQL,默认采用C标准库中的ptmalloc作为内存分配器。而ptmalloc相对来说内存碎片回收和返还操作系统的实时性并不高,因而在高并发、高负载的场景下,经常出现MySQL内存占用率过高导致的OOM(Out Of Memory,内存溢出)问题。Specifically, MySQL supports developers to develop plug-ins through the interface agreed upon by its plug-in system. However, MySQL's own memory management capabilities are relatively weak, and it does not provide an interface for overloading its underlying memory allocator. Currently, MySQL's memory usage audit can only be tracked through memory-related instruments in performance_schema (PFS for short, used to manage system views related to MySQL performance monitoring), but this relies on the fact that when the MySQL kernel is coded, all codes involving memory allocation and recovery must be explicitly associated with a PFS instrument. But in fact, there are a large number of memory allocation/recycling codes in MySQL that are not associated with PFS, which causes a huge deviation between the memory usage statistics of PFS and the actual memory usage. In addition, MySQL compiled based on the GNU Linux environment uses ptmalloc in the C standard library as the memory allocator by default. However, ptmalloc is relatively slow in recovering and returning memory fragments to the operating system. Therefore, in high-concurrency and high-load scenarios, OOM (Out Of Memory) problems caused by excessive MySQL memory usage often occur.
FreeBSD系统的默认内存分配器jemalloc,具备相对及时的内存碎片回收和返还操作系统的特性,而且可以使用前述“LD_PRELOAD+动态库注入”的方式,通过启动时覆盖MySQL内存分配器的malloc/free等库函数,接管MySQL的内存分配/回收操作,即将第一动态库(jemalloc)通过启动时加载的方式注入到应用程序,以缓解MySQL的OOM现象。The default memory allocator of the FreeBSD system, jemalloc, has the characteristics of relatively timely memory fragmentation recovery and return to the operating system. In addition, the aforementioned "LD_PRELOAD+dynamic library injection" method can be used to overwrite the malloc/free and other library functions of the MySQL memory allocator at startup to take over the memory allocation/recycling operations of MySQL. That is, the first dynamic library (jemalloc) is injected into the application by loading at startup to alleviate the OOM phenomenon of MySQL.
此外,jemalloc还提供了非常丰富的API接口,可以实现诸如:内存分配状态的实时监控(statistics APIs)、内存分配行为审计(profiling APIs,常用场景包括:内存泄漏分析、内存占用率分析等)、以及内存回收(dirty/muzzy decay APIs)等功能。但是,这些功能默认情况下并不开启,或者需要调用API才能触发,而动态库注入方式对MySQL本身而言是“透明的”,MySQL内核无法感知并主动调用jemalloc的接口。此外,虽然jemalloc具备主动内存回收和归还操作系统的能力,但内存回收的触发机制仍不受控,也无法通过MySQL本身的接口进行管理。因而,即使使用了jemalloc,MySQL仍然有一定概率因为内存回收机制触发不及时而产生OOM。 In addition, jemalloc also provides a very rich API interface, which can realize functions such as real-time monitoring of memory allocation status (statistics APIs), auditing of memory allocation behavior (profiling APIs, common scenarios include: memory leak analysis, memory occupancy analysis, etc.), and memory recovery (dirty/muzzy decay APIs). However, these functions are not enabled by default, or require API calls to trigger, and the dynamic library injection method is "transparent" to MySQL itself. The MySQL kernel cannot perceive and actively call the jemalloc interface. In addition, although jemalloc has the ability to actively recycle memory and return it to the operating system, the triggering mechanism of memory recovery is still uncontrolled and cannot be managed through the MySQL interface itself. Therefore, even if jemalloc is used, MySQL still has a certain probability of generating OOM due to the untimely triggering of the memory recovery mechanism.
为解决上述问题,基于MySQL插件接口开发my_jemalloc插件(产出物为动态库“my_jemalloc.so”,即第二动态库,MySQL插件名为“jemalloc”),并将第二动态库和插件接口函数加载入应用程序。利用MySQL的插件接口,提供一系列插件级参数,通过这些参数实现对内存分配器的监控和其他高级功能。To solve the above problems, the my_jemalloc plug-in is developed based on the MySQL plug-in interface (the output is the dynamic library "my_jemalloc.so", that is, the second dynamic library, and the MySQL plug-in is named "jemalloc"), and the second dynamic library and the plug-in interface function are loaded into the application. Using the MySQL plug-in interface, a series of plug-in-level parameters are provided, through which the monitoring of the memory allocator and other advanced functions can be realized.
MySQL插件支持两种参数,一种叫做系统参数(即“system variables”),以“插件名(小写)_参数名”方式命名,这种参数为配置参数,可读写。另一种则叫做状态参数(即“status variables”),以“插件名(首字母大写)_参数名”方式命名,为状态监控(即statistics)参数,只读。插件my_jemalloc提供下列参数:The MySQL plugin supports two types of parameters. One is called system parameters (i.e. "system variables"), which are named in the format of "plugin name (lowercase)_parameter name". This type of parameter is a configuration parameter and can be read and written. The other is called status parameters (i.e. "status variables"), which are named in the format of "plugin name (first letter uppercase)_parameter name". They are status monitoring (i.e. statistics) parameters and are read-only. The plugin my_jemalloc provides the following parameters:
Jemalloc的内存分配状态监控参数(状态参数),命名方式为“Jemalloc_stats_xxx”,通过调用jemalloc的statistics APIs,展现内存分配状态。The memory allocation status monitoring parameters (status parameters) of Jemalloc are named "Jemalloc_stats_xxx" and display the memory allocation status by calling the statistics APIs of jemalloc.
内存回收触发参数(系统参数),名为“jemalloc_manually_reclaim”。参数读取时,通过访问jemalloc的statistics APIs,统计可回收的物理内存总量;向该参数写入任意值时,通过调用jemalloc的dirty/muzzy decay APIs,实现空闲内存页的老化回收。The memory recycling trigger parameter (system parameter) is named "jemalloc_manually_reclaim". When reading the parameter, the total amount of reclaimable physical memory is counted by accessing the statistics APIs of jemalloc; when writing any value to this parameter, the aging recycling of free memory pages is realized by calling the dirty/muzzy decay APIs of jemalloc.
内存profiling开关参数(系统参数),名为“jemalloc_active_profiling”。Jemalloc支持内存分配/回收行为记日志,但此动作对性能影响极大,而且会额外占用内存。因而,my_jemalloc插件默认不开启此功能,用户需要做内存分析时,可以手动打开。Memory profiling switch parameter (system parameter), named "jemalloc_active_profiling". Jemalloc supports logging of memory allocation/recycling behavior, but this action has a great impact on performance and will occupy additional memory. Therefore, the my_jemalloc plugin does not enable this function by default. Users can manually enable it when they need to do memory analysis.
内存日志写出参数(系统参数,只写),名为“jemalloc_dump_profiling”,只在内存profiling开启状态下可用。用户向这个参数输入一个可写入profile文件路径时,即可将当前jemalloc的内存日志的全部内容dump到这个文件中。The memory log write parameter (system parameter, write-only) is named "jemalloc_dump_profiling" and is only available when memory profiling is turned on. When the user enters a writable profile file path to this parameter, the entire contents of the current jemalloc memory log can be dumped to this file.
后台内存回收线程(background memory reclaim thread)开关参数(系统参数),名为“jemalloc_monitor_switch”,用于开启或停止自动化内存回收线程。Jemalloc库本身提供了后台内存回收线程功能,但jemalloc插件为了实现自动化内存回收策略,引入了自己的后台线程,通过显式调用dirty/muzzy decay接口进行内存回收。 The background memory reclaim thread switch parameter (system parameter), named "jemalloc_monitor_switch", is used to start or stop the automatic memory reclaim thread. The Jemalloc library itself provides the background memory reclaim thread function, but the jemalloc plug-in introduces its own background thread to implement the automatic memory reclaim strategy, and reclaims memory by explicitly calling the dirty/muzzy decay interface.
后台内存回收线程轮询时间间隔参数(系统参数),名为“jemalloc_monitor_interval”。后台线程启动后,按照此参数设定的秒数周期性的轮询,监测是否自动执行内存回收动作。The polling interval parameter (system parameter) of the background memory recycling thread is named "jemalloc_monitor_interval". After the background thread is started, it will poll periodically according to the number of seconds set by this parameter to monitor whether the memory recycling action is automatically performed.
内存高水位参数(系统参数),名为“jemalloc_high_water_mark”。后台线程启动后,当监测到当前MySQL实例的内存占用率达到或超过该参数指定值时,自动触发内存回收动作(即,调用dirty/muzzy decay APIs)。Memory high water level parameter (system parameter), named "jemalloc_high_water_mark". After the background thread is started, when the memory usage of the current MySQL instance reaches or exceeds the value specified by this parameter, the memory recycling action is automatically triggered (that is, calling dirty/muzzy decay APIs).
通过上述方式,一方面,实现了内存管理能力的可控、可观测。也就是说,用户可以通过对插件中Jemalloc_stats_xxx这类参数的查询,准确的监控MySQL的内存占用情况;并且,可以通过使用profiling相关的参数,对MySQL的内存分配/回收行为进行更加精准的分析。从而为MySQL扩展了可控的、远胜于其原生PFS能力的内存可观测能力。Through the above methods, on the one hand, the memory management capability is controllable and observable. In other words, users can accurately monitor the memory usage of MySQL by querying parameters such as Jemalloc_stats_xxx in the plug-in; and, by using profiling-related parameters, they can conduct a more accurate analysis of MySQL's memory allocation/recycling behavior. This expands MySQL's controllable memory observability capabilities that are far superior to its native PFS capabilities.
另一方面,通过后台线程管理相关的参数,可以实现内存自动化回收策略的配置和启停。此外,通过内存回收行为触发参数,还能实现人为介入方式驱动的内存回收。也就是说,my_jemalloc插件为MySQL扩展出了自动/手动两套内存回收策略,保证内存占用率始终运行于某个预期的水位以下,彻底解决OOM问题。这里,后台内存回收线程的流程具体如图4b所示。On the other hand, by managing the relevant parameters through the background thread, the configuration and start and stop of the automatic memory recovery strategy can be realized. In addition, by triggering the memory recovery behavior parameters, memory recovery driven by human intervention can also be realized. In other words, the my_jemalloc plug-in has expanded two sets of automatic/manual memory recovery strategies for MySQL, ensuring that the memory occupancy rate always runs below a certain expected water level, completely solving the OOM problem. Here, the process of the background memory recovery thread is specifically shown in Figure 4b.
此外,my_jemalloc插件还提供“可插拔”能力,在卸载插件时,会自动关闭插件中提供的高级功能。插件卸载流程如图4c所示。In addition, the my_jemalloc plug-in also provides "pluggable" capabilities. When the plug-in is uninstalled, the advanced functions provided in the plug-in will be automatically disabled. The plug-in uninstallation process is shown in Figure 4c.
从图4中可以看出,与图2对应的实施例相比,本实施例中的应用程序控制方法的流程400体现了响应于第一动态库注入完成,并且第二动态库加载完成,基于第二动态库提供的插件级参数,调用第一动态库提供的指定接口,对第一动态库提供的功能进行控制,插件级参数包括以下至少一项:状态参数、配置参数,进一步实现了对应用程序底层功能的精细化控制和扩展。As can be seen from Figure 4, compared with the embodiment corresponding to Figure 2, the process 400 of the application control method in this embodiment reflects that in response to the completion of the injection of the first dynamic library and the completion of the loading of the second dynamic library, based on the plug-in level parameters provided by the second dynamic library, the specified interface provided by the first dynamic library is called to control the functions provided by the first dynamic library, and the plug-in level parameters include at least one of the following: state parameters, configuration parameters, which further realize the refined control and expansion of the underlying functions of the application.
进一步参考图5,作为对上述各图所示方法的实现,本公开提供了一种应用程序控制装置的一个实施例,该装置实施例与图2所示的 方法实施例相对应,该装置具体可以应用于各种电子设备中。Further referring to FIG. 5 , as an implementation of the methods shown in the above figures, the present disclosure provides an embodiment of an application control device, which is similar to the embodiment shown in FIG. Corresponding to the method embodiment, the device can be specifically applied to various electronic devices.
如图5所示,本实施例的应用程序控制装置500包括:注入模块501、加载模块502和控制模块503。As shown in FIG. 5 , the application control device 500 of this embodiment includes: an injection module 501 , a loading module 502 and a control module 503 .
其中,注入模块501,可被配置成将第一动态库通过启动时加载的方式注入到应用程序。The injection module 501 may be configured to inject the first dynamic library into the application by loading it at startup.
加载模块502,可被配置成将第二动态库以插件方式加载入应用程序。The loading module 502 may be configured to load the second dynamic library into the application program in a plug-in manner.
控制模块503,可被配置成响应于确定第一动态库注入完成,并且第二动态库加载完成,基于第二动态库,调用第一动态库提供的指定接口,对第一动态库提供的功能进行控制。The control module 503 may be configured to, in response to determining that the injection of the first dynamic library is completed and the loading of the second dynamic library is completed, call a specified interface provided by the first dynamic library based on the second dynamic library to control the function provided by the first dynamic library.
在本实施例的一些可选的方式中,控制模块进一步被配置成基于第二动态库提供的插件级参数,调用第一动态库提供的指定接口,对第一动态库提供的功能进行控制。In some optional aspects of this embodiment, the control module is further configured to call a specified interface provided by the first dynamic library based on the plug-in level parameters provided by the second dynamic library to control the functions provided by the first dynamic library.
在本实施例的一些可选的方式中,控制模块进一步被配置成基于第二动态库,调用第一动态库提供的指定接口以及应用程序本身的接口,对第一动态库提供的功能进行控制。In some optional aspects of this embodiment, the control module is further configured to call a designated interface provided by the first dynamic library and an interface of the application program itself based on the second dynamic library to control the functions provided by the first dynamic library.
在本实施例的一些可选的方式中,该装置还包括:关闭模块,被配置成响应于确定第二动态库移除,关闭第一动态库中由第二动态库开启或使能的新功能。In some optional aspects of this embodiment, the device further includes: a closing module configured to close a new function in the first dynamic library that is opened or enabled by the second dynamic library in response to determining that the second dynamic library is removed.
在本实施例的一些可选的方式中,控制模块进一步被配置成:基于第二动态库,调用第一动态库提供的指定接口,对第一动态库提供的功能执行以下至少一项控制操作:底层功能开关、监控、审计、优化配置、自动化控制。In some optional modes of this embodiment, the control module is further configured to: based on the second dynamic library, call the specified interface provided by the first dynamic library, and perform at least one of the following control operations on the function provided by the first dynamic library: underlying function switch, monitoring, auditing, optimization configuration, and automatic control.
在本实施例的一些可选的方式中,该装置还包括:变更模块,被配置成响应于确定第一动态库注入的应用程序或应用程序所依赖的库函数发生变更,并且变更后的应用程序或应用程序所依赖的库函数与第一动态库注入方式不兼容,仅对第一动态库进行重新适配。In some optional embodiments of this embodiment, the device also includes: a change module, which is configured to respond to determining that the application injected with the first dynamic library or the library function on which the application depends has changed, and the changed application or the library function on which the application depends is incompatible with the first dynamic library injection method, and only re-adapt the first dynamic library.
根据本公开的实施例,本公开还提供了一种电子设备和一种可读存储介质。 According to an embodiment of the present disclosure, the present disclosure also provides an electronic device and a readable storage medium.
如图6所示,是根据本公开实施例的应用程序控制方法的电子设备的框图。As shown in FIG6 , it is a block diagram of an electronic device according to the application control method of an embodiment of the present disclosure.
600是根据本公开实施例的应用程序控制方法的电子设备的框图。电子设备旨在表示各种形式的数字计算机,诸如,膝上型计算机、台式计算机、工作台、个人数字助理、服务器、刀片式服务器、大型计算机、和其它适合的计算机。电子设备还可以表示各种形式的移动装置,诸如,个人数字处理、蜂窝电话、智能电话、可穿戴设备和其它类似的计算装置。本文所示的部件、它们的连接和关系、以及它们的功能仅仅作为示例,并且不意在限制本文中描述的和/或者要求的本公开的实现。600 is a block diagram of an electronic device according to an application control method of an embodiment of the present disclosure. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and/or required herein.
如图6所示,该电子设备包括:一个或多个处理器601、存储器602,以及用于连接各部件的接口,包括高速接口和低速接口。各个部件利用不同的总线互相连接,并且可以被安装在公共主板上或者根据需要以其它方式安装。处理器可以对在电子设备内执行的指令进行处理,包括存储在存储器中或者存储器上以在外部输入/输出装置(诸如,耦合至接口的显示设备)上显示GUI的图形信息的指令。在其它实施方式中,若需要,可以将多个处理器和/或多条总线与多个存储器和多个存储器一起使用。同样,可以连接多个电子设备,各个设备提供部分必要的操作(例如,作为服务器阵列、一组刀片式服务器、或者多处理器系统)。图6中以一个处理器601为例。As shown in Figure 6, the electronic device includes: one or more processors 601, memory 602, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. The various components are connected to each other using different buses, and can be installed on a common mainboard or installed in other ways as needed. The processor can process instructions executed in the electronic device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input/output device (such as a display device coupled to the interface). In other embodiments, if necessary, multiple processors and/or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple electronic devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). In Figure 6, a processor 601 is taken as an example.
存储器602即为本公开所提供的非瞬时计算机可读存储介质。其中,所述存储器存储有可由至少一个处理器执行的指令,以使所述至少一个处理器执行本公开所提供的应用程序控制方法。本公开的非瞬时计算机可读存储介质存储计算机指令,该计算机指令用于使计算机执行本公开所提供的应用程序控制方法。The memory 602 is a non-transient computer-readable storage medium provided by the present disclosure. The memory stores instructions executable by at least one processor to enable the at least one processor to perform the application control method provided by the present disclosure. The non-transient computer-readable storage medium of the present disclosure stores computer instructions, which are used to enable a computer to perform the application control method provided by the present disclosure.
存储器602作为一种非瞬时计算机可读存储介质,可用于存储非瞬时软件程序、非瞬时计算机可执行程序以及模块,如本公开实施例中的应用程序控制方法对应的程序指令/模块(例如,附图5所示的注入模块501、加载模块502和控制模块503)。处理器601通过运行存储在存储器602中的非瞬时软件程序、指令以及模块,从而执行服务 器的各种功能应用以及数据处理,即实现上述方法实施例中的应用程序控制方法。The memory 602 is a non-transient computer-readable storage medium that can be used to store non-transient software programs, non-transient computer executable programs and modules, such as program instructions/modules corresponding to the application control method in the embodiment of the present disclosure (for example, the injection module 501, the loading module 502 and the control module 503 shown in FIG. 5). The processor 601 executes the service by running the non-transient software programs, instructions and modules stored in the memory 602. The various functional applications and data processing of the device are implemented, that is, the application control method in the above method embodiment is implemented.
存储器602可以包括存储程序区和存储数据区,其中,存储程序区可存储操作系统、至少一个功能所需要的应用程序;存储数据区可存储应用程序控制的电子设备的使用所创建的数据等。此外,存储器602可以包括高速随机存取存储器,还可以包括非瞬时存储器,例如至少一个磁盘存储器件、闪存器件、或其他非瞬时固态存储器件。在一些实施例中,存储器602可选包括相对于处理器601远程设置的存储器,这些远程存储器可以通过网络连接至应用程序控制的电子设备。上述网络的实例包括但不限于互联网、企业内部网、局域网、移动通信网及其组合。The memory 602 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created by the use of an electronic device controlled by an application, etc. In addition, the memory 602 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory 602 may optionally include a memory remotely arranged relative to the processor 601, and these remote memories may be connected to the electronic device controlled by the application via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
应用程序控制方法的电子设备还可以包括:输入装置603和输出装置604。处理器601、存储器602、输入装置603和输出装置604可以通过总线或者其他方式连接,图6中以通过总线连接为例。The electronic device of the application control method may further include: an input device 603 and an output device 604. The processor 601, the memory 602, the input device 603 and the output device 604 may be connected via a bus or other means, and FIG6 takes the bus connection as an example.
输入装置603可接收输入的数字或字符信息,例如触摸屏、小键盘、鼠标、轨迹板、触摸板、指示杆、一个或者多个鼠标按钮、轨迹球、操纵杆等输入装置。输出装置604可以包括显示设备、辅助照明装置(例如,LED)和触觉反馈装置(例如,振动电机)等。该显示设备可以包括但不限于,液晶显示器(LCD)、发光二极管(LED)显示器和等离子体显示器。在一些实施方式中,显示设备可以是触摸屏。The input device 603 can receive input digital or character information, such as a touch screen, a keypad, a mouse, a track pad, a touch pad, an indicator bar, one or more mouse buttons, a track ball, a joystick, and other input devices. The output device 604 may include a display device, an auxiliary lighting device (e.g., an LED), and a tactile feedback device (e.g., a vibration motor). The display device may include, but is not limited to, a liquid crystal display (LCD), a light emitting diode (LED) display, and a plasma display. In some embodiments, the display device may be a touch screen.
此处描述的系统和技术的各种实施方式可以在数字电子电路系统、集成电路系统、专用ASIC(专用集成电路)、计算机硬件、固件、软件、和/或它们的组合中实现。这些各种实施方式可以包括:实施在一个或者多个计算机程序中,该一个或者多个计算机程序可在包括至少一个可编程处理器的可编程系统上执行和/或解释,该可编程处理器可以是专用或者通用可编程处理器,可以从存储系统、至少一个输入装置、和至少一个输出装置接收数据和指令,并且将数据和指令传输至该存储系统、该至少一个输入装置、和该至少一个输出装置。Various implementations of the systems and techniques described herein can be realized in digital electronic circuit systems, integrated circuit systems, dedicated ASICs (application specific integrated circuits), computer hardware, firmware, software, and/or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and/or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
这些计算程序(也称作程序、软件、软件应用、或者代码)包括可编程处理器的机器指令,并且可以利用高级过程和/或面向对象的编 程语言、和/或汇编/机器语言来实施这些计算程序。如本文使用的,术语“机器可读介质”和“计算机可读介质”指的是用于将机器指令和/或数据提供给可编程处理器的任何计算机程序产品、设备、和/或装置(例如,磁盘、光盘、存储器、可编程逻辑装置(PLD)),包括,接收作为机器可读信号的机器指令的机器可读介质。术语“机器可读信号”指的是用于将机器指令和/或数据提供给可编程处理器的任何信号。These computer programs (also called programs, software, software applications, or code) include machine instructions for a programmable processor and may be written using high-level procedural and/or object-oriented programming. Programming languages, and/or assembly/machine languages are used to implement these computer programs. As used herein, the terms "machine-readable medium" and "computer-readable medium" refer to any computer program product, device, and/or means (e.g., disk, optical disk, memory, programmable logic device (PLD)) for providing machine instructions and/or data to a programmable processor, including a machine-readable medium that receives machine instructions as a machine-readable signal. The term "machine-readable signal" refers to any signal for providing machine instructions and/or data to a programmable processor.
为了提供与用户的交互,可以在计算机上实施此处描述的系统和技术,该计算机具有:用于向用户显示信息的显示装置(例如,CRT(阴极射线管)或者LCD(液晶显示器)监视器);以及键盘和指向装置(例如,鼠标或者轨迹球),用户可以通过该键盘和该指向装置来将输入提供给计算机。其它种类的装置还可以用于提供与用户的交互;例如,提供给用户的反馈可以是任何形式的传感反馈(例如,视觉反馈、听觉反馈、或者触觉反馈);并且可以用任何形式(包括声输入、语音输入或者、触觉输入)来接收来自用户的输入。To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
可以将此处描述的系统和技术实施在包括后台部件的计算系统(例如,作为数据服务器)、或者包括中间件部件的计算系统(例如,应用服务器)、或者包括前端部件的计算系统(例如,具有图形用户界面或者网络浏览器的用户计算机,用户可以通过该图形用户界面或者该网络浏览器来与此处描述的系统和技术的实施方式交互)、或者包括这种后台部件、中间件部件、或者前端部件的任何组合的计算系统中。可以通过任何形式或者介质的数字数据通信(例如,通信网络)来将系统的部件相互连接。通信网络的示例包括:局域网(LAN)、广域网(WAN)和互联网。The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
计算机系统可以包括客户端和服务器。客户端和服务器一般远离彼此并且通常通过通信网络进行交互。通过在相应的计算机上运行并且彼此具有客户端-服务器关系的计算机程序来产生客户端和服务器的关系。A computer system may include clients and servers. Clients and servers are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship to each other.
根据本公开实施例的技术方案,通过将第一动态库通过启动时加载的方式注入到应用程序;将第二动态库以插件方式加载入应用程序;响应于确定第一动态库注入完成,并且第二动态库加载完成,基于第 二动态库,调用第一动态库提供的指定接口,对第一动态库提供的功能进行控制,即通过同时加载注入式的第一动态库和插件式的第二动态库,实现了对应用程序底层功能的控制和扩展。According to the technical solution of the embodiment of the present disclosure, the first dynamic library is injected into the application by loading at startup; the second dynamic library is loaded into the application in a plug-in manner; in response to determining that the injection of the first dynamic library is completed and the loading of the second dynamic library is completed, based on the first dynamic library, The second dynamic library calls the specified interface provided by the first dynamic library to control the functions provided by the first dynamic library, that is, by simultaneously loading the injected first dynamic library and the plug-in second dynamic library, the control and expansion of the underlying functions of the application are achieved.
应该理解,可以使用上面所示的各种形式的流程,重新排序、增加或删除步骤。例如,本发申请中记载的各步骤可以并行地执行也可以顺序地执行也可以不同的次序执行,只要能够实现本公开公开的技术方案所期望的结果,本文在此不进行限制。It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this application can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution disclosed in this disclosure can be achieved, and this document is not limited here.
上述具体实施方式,并不构成对本公开保护范围的限制。本领域技术人员应该明白的是,根据设计要求和其他因素,可以进行各种修改、组合、子组合和替代。任何在本公开的精神和原则之内所作的修改、等同替换和改进等,均应包含在本公开保护范围之内。 The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.
Claims (14)
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202310942825.4A CN119166227A (en) | 2023-07-28 | 2023-07-28 | Application program control method and device |
| CN202310942825.4 | 2023-07-28 |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2025025528A1 true WO2025025528A1 (en) | 2025-02-06 |
Family
ID=93888412
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2024/072324 Pending WO2025025528A1 (en) | 2023-07-28 | 2024-01-15 | Application program control method and apparatus |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN119166227A (en) |
| WO (1) | WO2025025528A1 (en) |
Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20180316777A1 (en) * | 2017-04-26 | 2018-11-01 | International Business Machines Corporation | Invoking enhanced plug-ins and creating workflows having a series of enhanced plug-ins |
| CN111142972A (en) * | 2019-12-27 | 2020-05-12 | 京东数字科技控股有限公司 | Method, apparatus, system, and medium for extending functions of application program |
| CN113553271A (en) * | 2021-08-06 | 2021-10-26 | 北京自如信息科技有限公司 | Method for generating and testing internal test program of application program |
| CN114237742A (en) * | 2021-12-10 | 2022-03-25 | 北京奇艺世纪科技有限公司 | Loading and compiling method and device of dynamic library, terminal and storage medium |
| CN114327481A (en) * | 2021-12-30 | 2022-04-12 | 北京百度网讯科技有限公司 | Code processing method, device, equipment and storage medium |
| CN115934198A (en) * | 2022-12-16 | 2023-04-07 | 深圳依时货拉拉科技有限公司 | SDK loading method, device, equipment and storage medium |
Family Cites Families (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN102331931B (en) * | 2011-07-25 | 2014-05-14 | 深圳万兴信息科技股份有限公司 | Dynamic library managing method and device |
| CN103019819A (en) * | 2012-12-05 | 2013-04-03 | 上海创图网络科技发展有限公司 | Dynamic link library uniform scheduling method based on plug-in mechanism |
| CN105893094B (en) * | 2016-03-31 | 2019-05-03 | 百度在线网络技术(北京)有限公司 | The implementation method and device of application plug |
| CN110297643B (en) * | 2019-06-04 | 2024-01-30 | 平安科技(深圳)有限公司 | Method, device, equipment and storage medium for injecting application program into dynamic library |
-
2023
- 2023-07-28 CN CN202310942825.4A patent/CN119166227A/en active Pending
-
2024
- 2024-01-15 WO PCT/CN2024/072324 patent/WO2025025528A1/en active Pending
Patent Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20180316777A1 (en) * | 2017-04-26 | 2018-11-01 | International Business Machines Corporation | Invoking enhanced plug-ins and creating workflows having a series of enhanced plug-ins |
| CN111142972A (en) * | 2019-12-27 | 2020-05-12 | 京东数字科技控股有限公司 | Method, apparatus, system, and medium for extending functions of application program |
| CN113553271A (en) * | 2021-08-06 | 2021-10-26 | 北京自如信息科技有限公司 | Method for generating and testing internal test program of application program |
| CN114237742A (en) * | 2021-12-10 | 2022-03-25 | 北京奇艺世纪科技有限公司 | Loading and compiling method and device of dynamic library, terminal and storage medium |
| CN114327481A (en) * | 2021-12-30 | 2022-04-12 | 北京百度网讯科技有限公司 | Code processing method, device, equipment and storage medium |
| CN115934198A (en) * | 2022-12-16 | 2023-04-07 | 深圳依时货拉拉科技有限公司 | SDK loading method, device, equipment and storage medium |
Also Published As
| Publication number | Publication date |
|---|---|
| CN119166227A (en) | 2024-12-20 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US12468552B2 (en) | Execution of sub-application processes within application program | |
| CN108027722B (en) | Dynamically updating applications in compilation and deployment | |
| CN108984225B (en) | Method and device for quickly starting hosted application | |
| EP2950203B1 (en) | Application scenario identification method, power consumption management method and apparatus and terminal device | |
| US11663037B2 (en) | Service information processing method, apparatus, device and computer storage medium | |
| US9256454B2 (en) | Determining optimal methods for creating virtual machines | |
| US20150012732A1 (en) | Method and device for recombining runtime instruction | |
| WO2017087801A1 (en) | Dynamic update of an application in compilation and deployment | |
| US9104567B2 (en) | Memory-leak identification | |
| CN109582382B (en) | Loading method and device of configuration information, storage medium and terminal equipment | |
| CN115705294A (en) | Method, device, electronic equipment and medium for acquiring function call information | |
| US9870400B2 (en) | Managed runtime cache analysis | |
| US20140181502A1 (en) | Dynamically manipulating rules for adding new devices | |
| WO2025025528A1 (en) | Application program control method and apparatus | |
| CN112306413A (en) | Method, device, equipment and storage medium for accessing memory | |
| CN111881212A (en) | Method, device, equipment and storage medium for executing check point operation | |
| CN113110846B (en) | A method and device for obtaining environment variables | |
| US20080154574A1 (en) | Application emulation on a non-production computer system | |
| US12204551B2 (en) | System and method for mining data and storage medium | |
| CN112667327B (en) | Screen rotation display method, device, computer equipment and storage medium | |
| JP6555908B2 (en) | Information processing apparatus, control method therefor, and program | |
| Chen et al. | RCHDroid: Transparent Runtime Change Handling for Android Apps | |
| CN116627527A (en) | Probe injection method, probe injection device, storage medium and electronic equipment | |
| CN121050769A (en) | Alignment method and device between kernel version and eBPF log collection program | |
| CN119597350A (en) | Command execution result acquisition method and device, computer equipment and storage medium |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 24847499 Country of ref document: EP Kind code of ref document: A1 |