A method and terminal of a function in a hook virtual machine
A virtual machine and function technology, which is applied in the direction of electrical digital data processing, software simulation/interpretation/simulation, program control design, etc., can solve the problem of destroying the original data structure, unable to correctly hook the virtual machine function, and unable to correctly hook the virtual machine Machine functions and other issues to achieve the effect of performance monitoring
- Summary
- Abstract
- Description
- Claims
- Application Information
AI Technical Summary
Problems solved by technology
Method used
Image
Examples
Embodiment 1
[0062] A method for hooking a function in a virtual machine, comprising steps:
[0063] S1. Obtain the storage address of the function to be hooked in the virtual machine;
[0064] Wherein, step S1 specifically includes:
[0065] S11. Obtain the storage space of the virtual machine;
[0066] S12. Open the collection of functions and classes in the storage space of the virtual machine;
[0067] S13. Traverse the set of functions and classes, find the function to be hooked, and acquire the storage address of the function to be hooked.
[0068] Wherein, step S13 specifically includes:
[0069] Judging whether the function to be hooked is stored in the class, if not, traversing the function set to find the function to be hooked, if yes, traversing the class set to find the function to be hooked;
[0070] Obtain the storage address of the function to be hooked according to the found function to be hooked;
[0071] S2. Compile the function into a static function according to th...
Embodiment 2
[0077] Apply the method of the function in the hook virtual machine to the actual scene, hook the scene switching function LoadScene () in the Unity 3D engine, so that the output log is output when the function is called, wherein the Unity 3D engine is a 3D game The development engine is based on Mono, which is a cross-platform dot NET operating environment developed by Xamarin Corporation. Since the scene switching function LoadScene() is located in the Mono virtual machine, the dynamic modification method described in Embodiment 1 needs to be adopted To hook it, first find its address in the virtual machine, then according to the address, use JIT technology to compile the scene switching function LoadScene() into a native instruction code, obtain the address of the native instruction code returned by it, and convert the native instruction code The address of the instruction code is turned to a self-defined function to implement a hook to the scene switching function LoadScene...
Embodiment 3
[0080] A terminal 1 for hooking functions in a virtual machine, including a memory 2, a processor 3, and a computer program stored on the memory 2 and operable on the processor 3, and the processor 3 implements the computer program when executing the computer program Steps in Example 1.
[0081] To sum up, the method and terminal for hooking functions in the virtual machine provided by the present invention compile the function into a static function according to the address of the function to be hooked in the virtual machine, and obtain the address of the static function, Hook the address of the static function, so as to realize the hook of the function in the virtual machine, realize dynamic acquisition and dynamic compilation in the memory, realize the dynamic modification of the function in the virtual machine, and will not change the content of the disk file, so that the virtual machine can be correctly hooked The function in the machine realizes the performance monitorin...
PUM
Login to View More Abstract
Description
Claims
Application Information
Login to View More 


