CN109471767A - The method and terminal of a kind of function in hook virtual machine - Google Patents
The method and terminal of a kind of function in hook virtual machine Download PDFInfo
- Publication number
- CN109471767A CN109471767A CN201710803627.4A CN201710803627A CN109471767A CN 109471767 A CN109471767 A CN 109471767A CN 201710803627 A CN201710803627 A CN 201710803627A CN 109471767 A CN109471767 A CN 109471767A
- Authority
- CN
- China
- Prior art keywords
- function
- hook
- virtual machine
- address
- static
- 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; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/30—Monitoring
- G06F11/3003—Monitoring arrangements specially adapted to the computing system or computing system component being monitored
- G06F11/301—Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system is a virtual computing platform, e.g. logically partitioned systems
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR 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/455—Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
- G06F9/45533—Hypervisors; Virtual machine monitors
- G06F9/45558—Hypervisor-specific management and integration aspects
Abstract
The present invention provides the method and terminal of the function in a kind of hook virtual machine, storage address of the function of hook in virtual machine is wanted in acquisition, according to the storage address, the function is compiled as static function, obtain the address of the static function, the address of static function described in hook, to realize the hook to function in virtual machine, dynamic acquisition on-the-flier compiler is realized in memory, it realizes and the dynamic of the function in virtual machine is modified, disk file content will not be changed, so as to the function in correct hook virtual machine, realizes the performance monitoring to system.
Description
Technical field
The present invention relates to the methods and terminal of the function in performance monitoring field more particularly to a kind of hook virtual machine.
Background technique
Hook technology is a kind of technology for changing API implementing result, and hook Chinese can be translated into " hook " or " hook ",
Objective function can be turned in customized function and be handled by hook technology, realize the prison to objective function in system
Control, to realize the analysis to system performance.
Due to the distinctive advantage of virtual machine, present software development is much all based on virtual machine, and if will be to developing
System carry out performance monitoring, then need in virtual machine function carry out hook.But in the prior art, in virtual machine
Function to carry out the mode of hook be static modification virtual machine instructions, i.e. direct modification disk file content, in disk file
Middle insertion self-defined information, the function that this mode can not correctly in hook virtual machine, because after modification file content
Former documentary former data structure can be destroyed, and the operation of main software or game can all use calibration technology, it is former documentary
The destruction meeting of former data structure is so that software or game verification failure, are unable to run so as to cause system.Therefore, existing static state
The hook mode of modification virtual machine instructions can not correctly achieve the purpose that the function in hook virtual machine.
Summary of the invention
The technical problems to be solved by the present invention are: providing the method and terminal of the function in a kind of hook virtual machine, energy
Function in enough correctly hook virtual machines, realizes the performance monitoring to system.
In order to solve the above-mentioned technical problem, a kind of technical solution that the present invention uses are as follows:
A kind of method of function in hook virtual machine, comprising steps of
Storage address of the function of hook in virtual machine is wanted in S1, acquisition;
S2, according to the storage address, the function is compiled as static function, obtains the address of the static function;
The address of static function described in S3, hook.
In order to solve the above-mentioned technical problem, the another technical solution that the present invention uses are as follows:
A kind of terminal of function in hook virtual machine, including memory, processor and storage are on a memory and can be
The computer program run on processor, the processor perform the steps of when executing the computer program
Storage address of the function of hook in virtual machine is wanted in S1, acquisition;
S2, according to the storage address, the function is compiled as static function, obtains the address of the static function;
The address of static function described in S3, hook.
The beneficial effects of the present invention are: according to address of the function of hook in virtual machine is wanted, the function is compiled
For static function, and the address of the static function is obtained, the address of static function described in hook, to realize in virtual machine
The hook of function realizes dynamic acquisition on-the-flier compiler in memory, disk file content will not be changed, so as to correct hook
Function in virtual machine realizes the performance monitoring to system.
Detailed description of the invention
Fig. 1 is the method flow diagram of the function in the hook virtual machine of the embodiment of the present invention;
Fig. 2 is the structural schematic diagram of the terminal of the function in the hook virtual machine of the embodiment of the present invention;
The result schematic diagram of scene switching function in the hook Unity 3D engine of the position Fig. 3 embodiment of the present invention;
Label declaration:
1, the terminal of the function in hook virtual machine;2, memory;3, processor.
Specific embodiment
To explain the technical content, the achieved purpose and the effect of the present invention in detail, below in conjunction with embodiment and cooperate attached
Figure is explained.
The most critical design of the present invention is: the function is compiled according to address of the function of hook in virtual machine is wanted
It is translated into static function, and obtains the address of the static function, the address of static function described in hook, to realize to virtual machine
The correct hook of middle function.
Please refer to Fig. 1, a kind of method of the function in hook virtual machine, comprising steps of
Storage address of the function of hook in virtual machine is wanted in S1, acquisition;
S2, according to the storage address, the function is compiled as static function, obtains the address of the static function;
The address of static function described in S3, hook.
As can be seen from the above description, the beneficial effects of the present invention are: according to wanting address of the function of hook in virtual machine,
The function is compiled as static function, and obtains the address of the static function, the address of static function described in hook, thus
It realizes the hook to function in virtual machine, realizes dynamic acquisition on-the-flier compiler in memory, disk file content will not be changed, from
And can function in correct hook virtual machine, realize the performance monitoring to system.
Further, the step S1 is specifically included:
S11, the memory space for obtaining virtual machine;
The set of S12, the function in opening virtual machine memory space and class;
The set of S13, the traversal function and class, find the function for wanting hook, obtain the storage for wanting the function of hook
Address.
Seen from the above description, storage address of the function of hook in virtual machine is wanted to realize the dynamic to it by acquisition
It obtains and dynamic is modified, do not need to be modified the disk file content where wanting the function of hook.
Further, the step S13 is specifically included:
It wants whether the function of hook is stored in class described in judgement, if it is not, then traversing the function set, finds and want
The function of hook finds the function for wanting hook if it is, traversing the class set;
According to the function for wanting hook found, the storage address for wanting the function of hook is obtained.
Seen from the above description, first judgement wants the function of hook to whether there is in class, is carried out based on judging result corresponding
Traversal search, improve search efficiency.
Further, the function is compiled as static function using JIT technology in the step S2.
Seen from the above description, function is compiled as static function by the JIT technology supported using virtual machine platform, convenient fast
Victory, and solving the problems, such as in the prior art can not direct hook virtual machine instructions.
Further, the step S3 is specifically included:
The address of the static function is turned into customized function.
Seen from the above description, customized function is passed to using the address of static function as parameter, thus realization pair
The hook of objective function haves no need to change the content of objective function, so as to realize the function in correctly hook virtual machine.
Referring to figure 2., the terminal 1 of the function in a kind of hook virtual machine, including memory 2, processor 3 and be stored in
On reservoir 2 and the computer program that can be run on processor 3, the processor 3 realized when executing the computer program with
Lower step:
Storage address of the function of hook in virtual machine is wanted in S1, acquisition;
S2, according to the storage address, the function is compiled as static function, obtains the address of the static function;
The address of static function described in S3, hook.
As can be seen from the above description, the beneficial effects of the present invention are: according to wanting address of the function of hook in virtual machine,
The function is compiled as static function, and obtains the address of the static function, the address of static function described in hook, thus
It realizes the hook to function in virtual machine, realizes dynamic acquisition on-the-flier compiler in memory, disk file content will not be changed, from
And can function in correct hook virtual machine, realize the performance monitoring to system.
Further, the step S1 is specifically included:
S11, the memory space for obtaining virtual machine;
The set of S12, the function in opening virtual machine memory space and class;
The set of S13, the traversal function and class, find the function for wanting hook, obtain the storage for wanting the function of hook
Address.
Seen from the above description, storage address of the function of hook in virtual machine is wanted to realize the dynamic to it by acquisition
It obtains and dynamic is modified, do not need to be modified the disk file content where wanting the function of hook.
Further, the step S13 is specifically included:
It wants whether the function of hook is stored in class described in judgement, if it is not, then traversing the function set, finds and want
The function of hook finds the function for wanting hook if it is, traversing the class set;
According to the function for wanting hook found, the storage address for wanting the function of hook is obtained.
Seen from the above description, first judgement wants the function of hook to whether there is in class, is carried out based on judging result corresponding
Traversal search, improve search efficiency.
Further, the function is compiled as static function using JIT technology in the step S2.
Seen from the above description, function is compiled as static function by the JIT technology supported using virtual machine platform, convenient fast
Victory, and solving the problems, such as in the prior art can not direct hook virtual machine instructions.
Further, the step S3 is specifically included:
The address of the static function is turned into customized function.
Seen from the above description, customized function is passed to using the address of static function as parameter, thus realization pair
The hook of objective function haves no need to change the content of objective function, so as to realize the function in correctly hook virtual machine.
Embodiment one
A kind of method of function in hook virtual machine, comprising steps of
Storage address of the function of hook in virtual machine is wanted in S1, acquisition;
Wherein, step S1 is specifically included:
S11, the memory space for obtaining virtual machine;
The set of S12, the function in opening virtual machine memory space and class;
The set of S13, the traversal function and class, find the function for wanting hook, obtain the storage for wanting the function of hook
Address.
Wherein, step S13 is specifically included:
It wants whether the function of hook is stored in class described in judgement, if it is not, then traversing the function set, finds and want
The function of hook finds the function for wanting hook if it is, traversing the class set;
According to the function for wanting hook found, the storage address for wanting the function of hook is obtained;
S2, according to the storage address, the function is compiled as static function, obtains the address of the static function;
Wherein, the function is compiled as static function using the JIT technology that virtual machine platform is supported;The static function
The function write as by native instruction code is referred specifically to, the function write as by native instruction code can be linked up with by direct hook;
Due to virtual machine be by actual computer the various computer functions of analogue simulation realize there is oneself
Unique instruction system can not directly carry out hook hook to the function write as by its unique instruction, and due to virtual machine
Instruction system need to parse operation, so the speed of service is slower, virtual machine, can be by a part instruction dynamic in order to accelerate speed
It is compiled as static instruction code, to accelerate speed, therefore, this function of virtual machine is can use, the letter of hook will be needed
Number is compiled as static instruction code, then carries out hook.
The address of static function described in S3, hook;
Specifically, the address of the static function is turned into customized function, using the address of static function as parameter
Customized function is passed to, to realize the hook to objective function.
Embodiment two
The method of function in the hook virtual machine is applied in actual scene, to the field in Unity 3D engine
Scape switching function LoadScene () carries out hook, so that output journal when function is called, wherein Unity 3D engine is one
A 3D development of games engine, for framework on the basis of Mono, Mono is the cross-platform dot NET operation of Xamarin company exploitation
Environment, since scene switching function LoadScene () is located in Mono virtual machine, therefore, it is necessary to using described in embodiment one
The mode of dynamic modification carries out hook to it, first finds its address in virtual machine, then according to the address, uses
Scene switching function LoadScene () is compiled as native instruction code by JIT technology, obtains the ground of the native instruction code of its return
The address of native instruction code is turned to customized function by location, to realize the hook to scene switching function LoadScene (),
The customized function enables to the output journal when scene switching function LoadScene () is called.
As shown in figure 3, the log exported when first time calling scene switching function is shown in Fig. 3 (a), Fig. 3 (b) is aobvious
What is shown is the log exported when second calls scene switching function, shown in log scene switching function it is called when
Between and switching scene.It can see by the display result of Fig. 3, by the hook to scene switching function, can count
The runing time of its called number and corresponding different numbers, to realize the monitoring analysis to system performance.
Embodiment three
A kind of terminal 1 of function in hook virtual machine, including memory 2, processor 3 and be stored on memory 2 simultaneously
The computer program that can be run on processor 3, the processor 3 are realized in embodiment one when executing the computer program
Step.
In conclusion the method and terminal of the function in hook virtual machine provided by the invention, according to the function for wanting hook
The function is compiled as static function by the address in virtual machine, and obtains the address of the static function, quiet described in hook
Dynamic acquisition on-the-flier compiler, realization pair are realized in memory to realize the hook to function in virtual machine in the address of state function
The dynamic of function in virtual machine is modified, and disk file content will not be changed, so as to the function in correct hook virtual machine,
Realize the performance monitoring to system.
The above description is only an embodiment of the present invention, is not intended to limit the scope of the invention, all to utilize this hair
Equivalents made by bright specification and accompanying drawing content are applied directly or indirectly in relevant technical field, similarly include
In scope of patent protection of the invention.
Claims (10)
1. a kind of method of the function in hook virtual machine, which is characterized in that comprising steps of
Storage address of the function of hook in virtual machine is wanted in S1, acquisition;
S2, according to the storage address, the function is compiled as static function, obtains the address of the static function;
The address of static function described in S3, hook.
2. the method for the function in hook virtual machine according to claim 1, which is characterized in that
The step S1 is specifically included:
S11, the memory space for obtaining virtual machine;
The set of S12, the function in opening virtual machine memory space and class;
The set of S13, the traversal function and class, find the function for wanting hook, obtain the storage address for wanting the function of hook.
3. the method for the function in hook virtual machine according to claim 2, which is characterized in that
The step S13 is specifically included:
It wants whether the function of hook is stored in class described in judgement, if it is not, then traversing the function set, finds and want hook
Function find the function for wanting hook if it is, traversing the class set;
According to the function for wanting hook found, the storage address for wanting the function of hook is obtained.
4. the method for the function in hook virtual machine according to claim 1, which is characterized in that
The function is compiled as static function using JIT technology in the step S2.
5. the method for the function in hook virtual machine according to claim 1, which is characterized in that
The step S3 is specifically included:
The address of the static function is turned into customized function.
6. a kind of terminal of the function in hook virtual machine, including memory, processor and storage on a memory and can located
The computer program run on reason device, which is characterized in that the processor performs the steps of when executing the computer program
Storage address of the function of hook in virtual machine is wanted in S1, acquisition;
S2, according to the storage address, the function is compiled as static function, obtains the address of the static function;
The address of static function described in S3, hook.
7. the terminal of the function in hook virtual machine according to claim 6, which is characterized in that
The step S1 is specifically included:
S11, the memory space for obtaining virtual machine;
The set of S12, the function in opening virtual machine memory space and class;
The set of S13, the traversal function and class, find the function for wanting hook, obtain the storage address for wanting the function of hook.
8. the terminal of the function in hook virtual machine according to claim 7, which is characterized in that
The step S13 is specifically included:
It wants whether the function of hook is stored in class described in judgement, if it is not, then traversing the function set, finds and want hook
Function find the function for wanting hook if it is, traversing the class set;
According to the function for wanting hook found, the storage address for wanting the function of hook is obtained.
9. the terminal of the function in hook virtual machine according to claim 6, which is characterized in that
The function is compiled as static function using JIT technology in the step S2.
10. the terminal of the function in hook virtual machine according to claim 6, which is characterized in that
The step S3 is specifically included:
The address of the static function is turned into customized function.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710803627.4A CN109471767A (en) | 2017-09-08 | 2017-09-08 | The method and terminal of a kind of function in hook virtual machine |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710803627.4A CN109471767A (en) | 2017-09-08 | 2017-09-08 | The method and terminal of a kind of function in hook virtual machine |
Publications (1)
Publication Number | Publication Date |
---|---|
CN109471767A true CN109471767A (en) | 2019-03-15 |
Family
ID=65657753
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201710803627.4A Pending CN109471767A (en) | 2017-09-08 | 2017-09-08 | The method and terminal of a kind of function in hook virtual machine |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109471767A (en) |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20020144241A1 (en) * | 2001-03-30 | 2002-10-03 | Guei-Yuan Lueh | Debugging support using dynamic re-compilation |
US20120304160A1 (en) * | 2011-05-27 | 2012-11-29 | Ridgeway Internet Security, Llc | Systems and Methods for Run-Time Interception of Software Methods |
CN104598809A (en) * | 2015-02-13 | 2015-05-06 | 北京奇虎科技有限公司 | Program monitoring method and defending method thereof, as well as relevant device |
CN106294166A (en) * | 2016-08-16 | 2017-01-04 | 腾讯科技(深圳)有限公司 | A kind of game data monitoring method and apparatus |
CN106649084A (en) * | 2016-09-14 | 2017-05-10 | 腾讯科技(深圳)有限公司 | Function call information obtaining method and apparatus, and test device |
-
2017
- 2017-09-08 CN CN201710803627.4A patent/CN109471767A/en active Pending
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20020144241A1 (en) * | 2001-03-30 | 2002-10-03 | Guei-Yuan Lueh | Debugging support using dynamic re-compilation |
US20120304160A1 (en) * | 2011-05-27 | 2012-11-29 | Ridgeway Internet Security, Llc | Systems and Methods for Run-Time Interception of Software Methods |
CN104598809A (en) * | 2015-02-13 | 2015-05-06 | 北京奇虎科技有限公司 | Program monitoring method and defending method thereof, as well as relevant device |
CN106294166A (en) * | 2016-08-16 | 2017-01-04 | 腾讯科技(深圳)有限公司 | A kind of game data monitoring method and apparatus |
CN106649084A (en) * | 2016-09-14 | 2017-05-10 | 腾讯科技(深圳)有限公司 | Function call information obtaining method and apparatus, and test device |
Non-Patent Citations (1)
Title |
---|
王保森: "基于Hook技术的Android动态监控系统", 《中国优秀硕士学位论文全文数据库》 * |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109976761B (en) | Software development kit generation method and device and terminal equipment | |
ES2674140T3 (en) | Creation of inferred symbols from the use of code | |
CN107526625B (en) | Java intelligent contract security detection method based on bytecode inspection | |
US10339036B2 (en) | Test automation using multiple programming languages | |
Böhm et al. | Generalized just-in-time trace compilation using a parallel task farm in a dynamic binary translator | |
KR101665219B1 (en) | Nested emulation and dynamic linking environment | |
US9858057B2 (en) | Methods and apparatus to validate translated guest code in a dynamic binary translator | |
US10540262B2 (en) | Using edit and continue to dynamically set and unset optimizations in source code while debugging | |
US10203943B2 (en) | Static analysis and reconstruction of deep link handling in compiled applications | |
US9182953B2 (en) | Hybrid dynamic code compiling device, method, and service system thereof | |
US10417023B2 (en) | GPU simulation method | |
US10466985B2 (en) | Hybrid deoptimization mechanism for class hierarchy analysis | |
US8281296B2 (en) | Cross-ISA inlining in a system virtual machine | |
JP2017508208A (en) | Co-designed dynamic language accelerator for processors | |
CN106055481B (en) | Method and device for testing computer program | |
CN113196243A (en) | Improving simulation and tracking performance using compiler-generated simulation-optimized metadata | |
CN109388435A (en) | Realize app while the repeatedly method and apparatus of opening operation | |
CN111385661B (en) | Method, device, terminal and storage medium for voice control of full screen playing | |
CN109426546B (en) | Application starting method and device, computer storage medium and equipment | |
CN109471767A (en) | The method and terminal of a kind of function in hook virtual machine | |
US9195568B2 (en) | Methods, circuits, apparatus, systems and associated software modules for evaluating code behavior | |
US11429358B2 (en) | Representing asynchronous state machine in intermediate code | |
CN110018953A (en) | Use method, storage medium, equipment and the system of python test JS code | |
US9182990B1 (en) | Method and apparatus for detecting execution of unsupported instructions while testing multiversioned code | |
CN113849397A (en) | Execution engine, virtual machine, related apparatus and related methods |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
WD01 | Invention patent application deemed withdrawn after publication | ||
WD01 | Invention patent application deemed withdrawn after publication |
Application publication date: 20190315 |