A configuration management method of a virtual machine, a storage medium and a terminal

By generating a mapping relationship between context structures and function templates, the virtual machine can achieve unified management of the target function without changing the execution logic of the target function. This solves the stability and compatibility problems of virtual machine takeover of functions in the prior art and improves the controllability and security of the system.

CN122152431APending Publication Date: 2026-06-05FUJIAN TQ ONLINE INTERACTIVE INC

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
FUJIAN TQ ONLINE INTERACTIVE INC
Filing Date
2026-02-10
Publication Date
2026-06-05

AI Technical Summary

Technical Problem

In existing technologies, the way virtual machines take over functions can easily disrupt the original execution flow of functions, affecting the stability and compatibility of programs. Furthermore, the maintenance costs are high, and it is difficult to adapt to complex and ever-changing operating environments.

Method used

By obtaining the source code data of the target function in the virtual machine, a context structure is generated, and a mapping relationship with the function template is established. The function template is then used for configuration management during the virtual machine's operation, avoiding direct intervention in the execution logic of the target function.

Benefits of technology

This improves the virtual machine's controllability and security over the target function, reduces maintenance costs caused by changes in function structure, and enhances the system's stability and reliability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122152431A_ABST
    Figure CN122152431A_ABST
Patent Text Reader

Abstract

The application discloses a kind of virtual machine's configuration management method, storage medium and terminal, obtain the source code data of target function needing takeover in virtual machine, according to source code data generation context structure body;Based on context structure body, generate the function template corresponding to target function;Establish the mapping relationship of context structure body and corresponding function template;In the process of virtual machine running, in response to function call request, according to function call request matching corresponding target function function template, and based on the mapping relationship of function template corresponding configuration context structure body, and function call request is completed by the function template of configuration completion.This application target function is concentrated encapsulation to context structure body, and virtual machine only needs to configure context structure body according to mapping relationship in function call stage, and function call can be completed, to avoid direct intervention to original execution logic of target function, improve the security of function takeover process and controllability of overall operation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of virtual machine technology, and in particular to a configurable management method, storage medium, and terminal for virtual machines. Background Technology

[0002] In existing technologies, virtual machines, as a common runtime environment isolation technology, are widely used in application scenarios such as program execution protection, behavior control, and function expansion. In these applications, virtual machines often need to take over some functions running within them to monitor or manage the program's execution process. For example, in scenarios such as program security protection, interface call control, and runtime behavior analysis, virtual machines need to intervene in or manage the execution process of target functions.

[0003] However, existing methods for implementing function takeover often rely on directly intercepting function calls, modifying function execution paths, or obtaining parameter information during function execution. These methods typically require intrusive processing of the original execution logic of the target function, which can easily disrupt the original execution flow and thus affect program stability and compatibility. Furthermore, when the number of target functions is large or their structure changes, these methods also incur high maintenance costs and are difficult to adapt to complex and ever-changing operating environments. Summary of the Invention

[0004] The technical problem to be solved by the present invention is to provide a configurable management method, storage medium and terminal for virtual machines, which can improve the controllability of the virtual machine takeover function execution process.

[0005] To solve the above-mentioned technical problems, the technical solution adopted by the present invention is as follows: A method for configurable management of virtual machines, comprising the following steps: S1. Obtain the source code data of the target function to be taken over in the virtual machine, and generate a context structure based on the source code data; S2. Based on the context structure, generate a function template corresponding to the target function; S3. Establish the mapping relationship between the context structure and the corresponding function template; S4. During the virtual machine's operation, in response to a function call request, the function template of the corresponding target function is matched according to the function call request, and the context structure is configured based on the mapping relationship corresponding to the function template. The function call request is then completed using the configured function template.

[0006] To solve the above-mentioned technical problems, the present invention adopts other technical solutions as follows: A storage medium storing a computer program, which, when executed by a processor, implements the steps of the virtual machine configuration management method.

[0007] A virtual machine configuration management terminal includes a memory, a processor, and a computer program stored in the memory and running on the processor. When the processor executes the computer program, it implements the steps in the virtual machine configuration management method.

[0008] The beneficial effects of this invention are as follows: It provides a configurable management method, storage medium, and terminal for virtual machines. By acquiring the source code data of the target function to be taken over within the virtual machine environment, generating a context structure based on the source code data, and then generating a function template corresponding to the target function and establishing a mapping relationship between the two, the virtual machine can uniformly manage the target function through the function template during operation. Since the input parameters and variable data used during the execution of the target function are centrally encapsulated in the context structure, the virtual machine only needs to configure the context structure according to the mapping relationship to complete the function call during the function call phase. This avoids direct intervention in the original execution logic of the target function, thereby enabling the virtual machine to perform configurable management of different target functions, improving the security of the function takeover process and the overall controllability of operation. Attached Figure Description

[0009] Figure 1 This is a flowchart illustrating a virtual machine configuration management method according to an embodiment of the present invention; Figure 2 This is a schematic diagram of a virtual machine configuration management terminal according to an embodiment of the present invention; Label Explanation: 1. A virtual machine configuration management terminal; 2. Memory; 3. Processor. Detailed Implementation

[0010] To explain in detail the technical content, objectives, and effects of the present invention, the following description is provided in conjunction with the embodiments and accompanying drawings.

[0011] In existing technologies, virtual machines are typically used as isolated runtime environments for scenarios such as program protection, functionality expansion, and runtime behavior monitoring. In these applications, virtual machines often need to take over certain functions or interfaces running within them to manage or control program behavior. However, current technologies for function takeover mostly rely on directly intercepting function calls, modifying function execution logic, or obtaining function parameter information through injection. These methods often require intrusive processing of the original program structure, easily disrupting the original function execution flow. Furthermore, they result in high maintenance costs and poor stability when program versions change or function structures are adjusted.

[0012] On the other hand, as applications become increasingly larger and more complex, the number of functions within a program grows significantly. These functions differ considerably in parameter formats, internal variables, and execution logic, making it difficult for virtual machines to manage them uniformly. In environments with multiple concurrent or frequently invoked functions, existing technologies are prone to issues such as mixed function data and context mismatches, impacting system security and reliability. Therefore, achieving unified management, data isolation, and configurable management of target functions within the virtual machine without altering their original execution logic has become a pressing technical challenge in current technologies.

[0013] To at least solve the above problems, please refer to Figure 1 This invention provides a method for configuring and managing virtual machines, including the following steps: S1. Obtain the source code data of the target function to be taken over in the virtual machine, and generate a context structure based on the source code data; S2. Based on the context structure, generate a function template corresponding to the target function; S3. Establish the mapping relationship between the context structure and the corresponding function template; S4. During the virtual machine's operation, in response to a function call request, the function template of the corresponding target function is matched according to the function call request, and the context structure is configured based on the mapping relationship corresponding to the function template. The function call request is then completed using the configured function template.

[0014] The context structure refers to a data structure generated based on the source code data of the target function. It is used to centrally store the relevant data required by the target function during execution. By encapsulating the parameter and variable data, which were originally scattered within the target function, into the context structure, the execution data environment of the target function becomes visible to the virtual machine in a structured form. This facilitates the virtual machine's configuration, management, and monitoring of the target function's execution data during runtime. The context structure itself does not change the original execution logic of the target function; rather, it serves as the data carrier during the execution of the target function, providing the necessary data support for function calls.

[0015] A function template is a calling format corresponding to a target function, generated based on a context structure. It serves as a unified entry point for target functions during virtual machine execution. The function template uses the context structure as its data entry point, and its execution depends on the data configured within the context structure, thus achieving indirect invocation of the target function. Through function templates, different target functions have a consistent calling method on the virtual machine side, allowing the virtual machine to manage the execution process of target functions without being aware of differences in parameter formats or internal implementations. The introduction of function templates enables the virtual machine to manage target functions through configuration of the context structure, without directly intervening in the execution logic of the target functions.

[0016] The underlying technology is to extract the data environment that the target function depends on during execution from the function body and centrally manage it through a unified data structure (context structure) and a call entry point. Specifically, this invention first generates a corresponding context structure based on the source code data of the target function, and then encapsulates the input parameters and variable data used during execution, which were originally scattered inside the function, into the context structure, thereby making the data environment required for function execution visible to the virtual machine in a structured form.

[0017] Based on this, the present invention does not directly call the target function body by the virtual machine, but generates a function template corresponding to the target function based on the context structure. The function template serves as the unified entry point for the target function on the virtual machine side, and its execution process depends on the data content configured in the context structure. In this way, different target functions have a consistent calling form on the virtual machine side, allowing the virtual machine to manage the function execution process without being aware of the differences in parameter forms or internal implementations of each target function.

[0018] To ensure accurate matching between function templates and their corresponding data environments, this invention further establishes a mapping relationship between context structures and function templates. This mapping relationship identifies the one-to-one correspondence between function templates and context structures, enabling the virtual machine to quickly determine the function template and its context structure corresponding to the target function based on function call requests during runtime. This avoids data mismatch problems caused by similar function structures or identical context structures.

[0019] During virtual machine runtime, when a function call request is received, the virtual machine matches the corresponding function template according to the mapping relationship, configures the context structure corresponding to the function template, and writes the parameter data from the function call request into the context structure. Subsequently, the target function is called using the configured function template. Because the execution of the function template is always based on its corresponding context structure, the execution process of the target function is always within a controlled data environment.

[0020] As described above, the beneficial effects of this invention are as follows: By acquiring the source code data of the target function to be taken over in the virtual machine environment, generating a context structure based on the source code data, generating a function template corresponding to the target function, and establishing a mapping relationship between the two, the virtual machine can uniformly manage the target function through the function template during operation. Since the input parameters and variable data used during execution of the target function are centrally encapsulated in the context structure, the virtual machine only needs to configure the context structure according to the mapping relationship to complete the function call during the function call phase. This avoids direct intervention in the original execution logic of the target function, thereby enabling the virtual machine to have the ability to manage different target functions in a configurable manner, improving the security of the function takeover process and the overall controllability of operation.

[0021] In some implementations, step S40 is included before step S4: During the virtual machine's operation, the number of target functions that need to be taken over is obtained, and a corresponding function pointer is generated for each target function; Using the function pointer as a label, allocate independent memory in the virtual machine for each of the target functions.

[0022] As can be seen from the above description, by obtaining the number of target functions to be taken over before the function call, and generating corresponding function pointers and allocating independent memory for each target function, the virtual machine can complete resource planning in advance during the runtime phase, avoiding the uncertainty brought about by dynamically creating or adjusting the memory structure during the function call process.

[0023] In some implementations, step S40, which involves allocating independent memory in the virtual machine for each target function using the function pointer as a label, specifically includes: Based on the mapping relationship, the memory of the context structure corresponding to each target function is obtained, and the memory is associated with its corresponding function pointer; using the function pointer as a label, independent memory is allocated for each target function in the virtual machine.

[0024] As described above, the specific implementation method of independent memory allocation is defined, namely, obtaining the memory of the context structure corresponding to the target function based on the mapping relationship, and associating this memory with the function pointer. This method ensures that the context structure of each target function has a clear and unique memory space in the virtual machine, thereby preventing different target functions from mistakenly accessing or overwriting each other's context data during execution. This technical solution effectively improves the data isolation capability of the virtual machine in scenarios with multiple concurrent or frequent function calls, enhancing the stability of system operation.

[0025] In some implementations, step S4 further includes: In the memory corresponding to the target function, the function call request is completed using the configured function template.

[0026] As described above, explicit function call requests are executed in the independent memory space corresponding to the target function, using a configured function template. Since the execution of the function template is always confined to the memory space of the context structure corresponding one-to-one with the target function, the function execution process remains consistent with its data environment. This reduces execution exceptions caused by context mismatches, further enhances data security during function execution, and helps the virtual machine maintain a stable and reliable execution state in complex operating environments.

[0027] In some implementations, step S1 specifically includes: Obtain the source code data of the target function in the virtual machine, wherein the source code data includes at least one of input parameters and variable data, and generate a context structure based on the input parameters and / or the variable data.

[0028] As described above, by limiting the context structure to be generated based on the input parameters and variable data of the objective function, the context structure can fully reflect the key data content upon which the execution of the objective function depends. By uniformly incorporating input parameters and variable data during execution into the context structure, the virtual machine can obtain the main information required for function execution without parsing the internal logic of the objective function, thereby improving the virtual machine's ability to perceive the execution state of the objective function.

[0029] In some implementations, step S2 specifically includes: Based on the context structure, a function template corresponding to the target function is generated, and the context structure in the function template is used as the data entry point.

[0030] As described above, by limiting function templates to use a context structure as the data entry point, different objective functions can have a unified data interaction method on the virtual machine side. This approach reduces the complexity of the virtual machine's differentiated processing of different objective functions and facilitates the standardization of interface call formats. With a unified data entry structure, the virtual machine does not need to modify the overall architecture when adding or adjusting objective functions, thereby improving the system's versatility and scalability.

[0031] In some implementations, the mapping relationship is used to represent the correspondence between the function template and the context structure.

[0032] As described above, by explicitly defining the mapping relationship to represent the correspondence between function templates and context structures, the virtual machine can quickly and accurately determine the context structure corresponding to the target function during runtime. This mapping relationship effectively avoids the identification confusion caused by similar function structures or identical context structures, improving the scheduling efficiency and execution accuracy of the virtual machine in a multi-objective function environment.

[0033] In some implementations, step S4 is followed by step S5: During the process of completing the function call request, the target function is monitored through the context structure.

[0034] As described above, by monitoring the target function using a context structure during function calls, the virtual machine can obtain the target function's runtime status information without affecting its normal execution. Since the context structure centrally stores data related to function execution, the virtual machine can continuously monitor the target function's execution process based on this structure. This provides a reliable basis for anomaly analysis, runtime management, and subsequent optimization, further enhancing the overall security and management capabilities of the virtual machine.

[0035] A storage medium storing a computer program, which, when executed by a processor, implements the steps of the virtual machine configuration management method.

[0036] Please refer to Figure 2 A virtual machine configuration management terminal 1 includes a memory 2, a processor 3, and a computer program stored on the memory 2 and running on the processor 3. When the processor 3 executes the computer program, it implements the steps in the virtual machine configuration management method.

[0037] Please refer to Figure 1 Embodiment 1 of the present invention is as follows: A configurable management method for virtual machines is provided. This method is applied in the virtual machine runtime environment and is used to manage the target functions that need to be taken over in a configurable manner.

[0038] In this embodiment, the method includes the following steps.

[0039] First, step S1 is executed to obtain the source code data of the target function to be taken over in the virtual machine, and a context structure is generated based on the source code data. Specifically, during the initialization or runtime phase, the virtual machine parses the pre-configured target function to be taken over, and obtains the source code data of the target function. The source code data includes the input parameter data of the target function and / or the variable data used by the target function during execution. Based on the input parameter data and variable data, a context structure corresponding to the target function is generated to centrally store relevant data involved in the execution of the target function.

[0040] For example, the original function: uintptr_t get_addr(const char name, size_t size) { NTSTATUS status = STATUS_SUCCESS; ULONG neededSize = 0; status = QuerySystemInformation( name, &neededSize ); return status; }; As can be seen from the original function above, the data items of this function include: the input parameters name and size, as well as the local variables status and neededSize defined during the function execution.

[0041] Context structure: uintptr_t get_addr(Context_Get Context) { Context->status = STATUS_SUCCESS; Context->neededSize = 0; Context->status = QuerySystemInformation( Context->name, &Context->neededSize ); return Context->status; } In this way, the objective function no longer directly uses independent input parameters and local variables, but instead accesses and updates relevant data through the context structure. Therefore, the virtual machine can manage and control the execution data of the objective function during runtime by configuring and managing the context structure, without requiring intrusive modifications to the original execution logic of the objective function.

[0042] Subsequently, step S2 is executed, generating a function template corresponding to the target function based on the context structure. In this embodiment, the function template uses the context structure as the data entry point, enabling the target function to be called in a unified data interaction format on the virtual machine side, thereby avoiding the virtual machine from using differentiated calling methods for different target functions.

[0043] Next, step S3 is executed to establish a mapping relationship between the context structure and the corresponding function template. This mapping relationship represents the correspondence between the function template and the context structure, enabling the virtual machine to accurately locate the corresponding context structure based on the function template during subsequent execution.

[0044] Before executing step S4, step S40 is also included. In step S40, the virtual machine obtains the number of target functions to be managed during runtime and generates a corresponding function pointer for each target function. Using the function pointer as a label, an independent memory space is allocated in the virtual machine for each target function. Specifically, the virtual machine obtains the memory required for the context structure corresponding to each target function based on the mapping relationship, and associates the memory with its corresponding function pointer, thereby configuring independent context structure memory for different target functions.

[0045] Then, step S4 is executed. During the virtual machine's operation, in response to a function call request, the virtual machine matches the function template of the corresponding target function according to the function call request, and configures the context structure based on the mapping relationship corresponding to the function template. In this embodiment, after a function call request is triggered, the virtual machine determines the context structure corresponding to the target function according to the mapping relationship, writes the parameter data in the function call request into the context structure, and then completes the function call request through the configured function template.

[0046] In some implementations, step S4 further includes: completing the function call request in the independent memory corresponding to the target function using the configured function template. Since the execution of the function template is confined to the memory space of the context structure corresponding to the target function, the function execution process always remains consistent with its data environment, avoiding execution exceptions caused by context mismatch.

[0047] Furthermore, in some embodiments, step S5 is included after step S4. In step S5, during the completion of the function call request, the target function is monitored through the context structure. Since the context structure centrally stores parameter data and variable data related to the execution of the target function, the virtual machine can continuously monitor the execution status of the target function without affecting its normal execution, thereby obtaining the running status information of the target function.

[0048] Embodiment 2 of the present invention is as follows: A storage medium storing a computer program, which, when executed by a processor, implements the steps of the virtual machine configuration management method.

[0049] Please refer to Figure 2 Embodiment 3 of the present invention is as follows: A virtual machine configuration management terminal 1 includes a memory 2, a processor 3, and a computer program stored on the memory 2 and running on the processor 3. When the processor 3 executes the computer program, it implements the steps in the virtual machine configuration management method.

[0050] The above description is merely an embodiment of the present invention and does not limit the patent scope of the present invention. Any equivalent modifications made based on the content of the present invention specification and drawings, or direct or indirect applications in related technical fields, are similarly included within the patent protection scope of the present invention.

Claims

1. A method for configurable management of virtual machines, characterized in that, Including the following steps: S1. Obtain the source code data of the target function to be taken over in the virtual machine, and generate a context structure based on the source code data; S2. Based on the context structure, generate a function template corresponding to the target function; S3. Establish the mapping relationship between the context structure and the corresponding function template; S4. During the virtual machine's operation, in response to a function call request, the function template of the corresponding target function is matched according to the function call request, and the context structure is configured based on the mapping relationship corresponding to the function template. The function call request is then completed using the configured function template.

2. The virtual machine configuration management method according to claim 1, characterized in that, Step S40 is included before step S4: During the virtual machine's operation, the number of target functions that need to be taken over is obtained, and a corresponding function pointer is generated for each target function; Using the function pointer as a label, allocate independent memory in the virtual machine for each of the target functions.

3. The virtual machine configuration management method according to claim 2, characterized in that, In step S40, allocating independent memory in the virtual machine for each target function using the function pointer as a label specifically includes: Based on the mapping relationship, the memory of the context structure corresponding to each target function is obtained, and the memory is associated with its corresponding function pointer; using the function pointer as a label, independent memory is allocated for each target function in the virtual machine.

4. The virtual machine configuration management method according to claim 3, characterized in that, Step S4 also includes: In the memory corresponding to the target function, the function call request is completed using the configured function template.

5. The virtual machine configuration management method according to claim 1, characterized in that, Step S1 specifically includes: Obtain the source code data of the target function in the virtual machine, wherein the source code data includes at least one of input parameters and variable data, and generate a context structure based on the input parameters and / or the variable data.

6. The virtual machine configuration management method according to claim 1, characterized in that, Step S2 specifically includes: Based on the context structure, a function template corresponding to the target function is generated, and the context structure in the function template is used as the data entry point.

7. The virtual machine configuration management method according to claim 1, characterized in that, The mapping relationship is used to represent the correspondence between the function template and the context structure.

8. The virtual machine configuration management method according to claim 1, characterized in that, Step S4 is followed by step S5: During the process of completing the function call request, the target function is monitored through the context structure.

9. A storage medium, characterized in that, The storage medium stores a computer program, which, when executed by a processor, implements the steps of the virtual machine configuration management method according to any one of claims 1-8.

10. A configurable management terminal for virtual machines, comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that, When the processor executes the computer program, it implements the steps in the virtual machine configuration management method according to any one of claims 1-8.