CN107391219A - Function Compilation Method and device - Google Patents

Function Compilation Method and device Download PDF

Info

Publication number
CN107391219A
CN107391219A CN201710555363.5A CN201710555363A CN107391219A CN 107391219 A CN107391219 A CN 107391219A CN 201710555363 A CN201710555363 A CN 201710555363A CN 107391219 A CN107391219 A CN 107391219A
Authority
CN
China
Prior art keywords
function
code
call
write
compiled
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201710555363.5A
Other languages
Chinese (zh)
Other versions
CN107391219B (en
Inventor
黄柳优
李源纯
周江
王鹏
魏学峰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN201710555363.5A priority Critical patent/CN107391219B/en
Publication of CN107391219A publication Critical patent/CN107391219A/en
Application granted granted Critical
Publication of CN107391219B publication Critical patent/CN107391219B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/31Programming languages or programming paradigms
    • G06F8/315Object-oriented languages
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements 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/44Arrangements for executing specific programs
    • G06F9/448Execution paradigms, e.g. implementations of programming paradigms
    • G06F9/4488Object-oriented
    • G06F9/449Object-oriented method invocation or resolution

Abstract

The invention discloses a kind of function Compilation Method and device.This method includes:The second function for being compiled to obtain to first function is hooked into self-defined proxy function and obtains function call pointer, first function be using the first programming language write by hooking function, function call pointer is used to call second function;Function call pointer is registered so that it is allowed to the code call write with the first programming language;Referred to using the function call by registration and be compiled to obtain the 4th function for the 3rd function, 3rd function includes being used for the code for calling first function, 3rd function is the self-defined hooking function write using the first programming language, and the code in code and the 4th function in second function allows directly to be performed by CPU.The present invention is solved correlation technique self-defined Hook functions when carrying out Hook to function and must write using C/C++, causes the higher technical problem of the development cost of self-defined Hook functions.

Description

Function Compilation Method and device
Technical field
The present invention relates to computer realm, in particular to a kind of function Compilation Method and device.
Background technology
Hook technologies can refer to the process that some function is replaced using a customized function, wherein, the process can be with It is related to three functions, one is by Hook functions, and one is self-defined Hook functions, and a function can be returned after Hook Pointer, the function pointer can be completed by the function of Hook functions, namely the function pointer can be indicated by the tune of Hook functions With.
Hook technologies can apply to test etc. in field, for example, Fig. 1 is prior art in mobile phone games protocol test work The schematic diagram used in tool, as shown in figure 1, specifically comprising the following steps:
1. registering JIT completes event:The interface mono_profiler_install_jit_end provided with Mono is to Mono The global JIT of registration completes the call back function of event.Wherein, Mono can be an item of increasing income that can run .Net programs Mesh, process when JIT can refer to Mono operations by the on-the-flier compiler of IL codes into Native codes, wherein, IL codes are .Net languages Bytecode after speech compiling, Native codes are the code that directly can be performed by CPU.
2. JIT completion notice events are set:The interface mono_profiler_set_events provided with Mono is to setting There is the call back function that notifies user-defined JIT to complete event when JIT completions.
3. monitor all functions by JIT:Complete to check that all functions are not in event call-back function in customized JIT It is the function for needing Hook now, if it is, implementing Hook, otherwise does nothing.
4. implement HOOK:Hook is carried out to the function for needing Hook.Wherein, Hook functions can be by developer according to reality Border demand is write with C/C++ language.
Prior art has the following disadvantages during above-mentioned use:
First point of deficiency:Login mechanism causes the function with regard to JIT before registration to be never notified that returning for JIT completions Letter of transfer number.
Second point deficiency:Customized Hook functions are write with C/C++.
For first point of deficiency, the premises of JIT once are operationally only understood to same C# functions based on Mono, then Just JIT C# functions before developer registers JIT completion events to Mono, just have no chance by Hook, this is not forever It is the result that developer wants.
It is insufficient for second point, when developer is want to making some modifications in logic by Hook functions, often It is the object for needing to operate C#, if this when goes to operate C# object with C/C++ to write code, this can greatly increase and hold Cost is sent out, this cost is not limited solely to write a few row C/C++ codes more, even more needs very familiar Mono C/C++ and C# Code interactive basis can just be write.And when to wanting to write extremely complex logic, answered with C/C++ to complete script C# The thing of the completion is extremely difficult.
For it is above-mentioned the problem of, not yet propose effective solution at present.
The content of the invention
The embodiments of the invention provide a kind of function Compilation Method and device, entered with least solving correlation technique to function Self-defined Hook functions must be write using C/C++ during row Hook, cause the higher skill of the development cost of self-defined Hook functions Art problem.
One side according to embodiments of the present invention, there is provided a kind of function Compilation Method, including:First function will be entered The second function that row compiling obtains is hooked into self-defined proxy function, obtains function call pointer, wherein, first function is to make With the first programming language write by hooking function, the code in second function allows directly to be performed by CPU, function call pointer For calling second function;Function call pointer is registered, to cause function call pointer to be allowed to call;Utilize process The function call of registration refers to be compiled for the 3rd function, obtains the 4th function, wherein, the 3rd function includes being used to call The code of first function, the 3rd function are the self-defined hooking function write using the first programming language, the generation in the 4th function Code allows directly to be performed by CPU.
Another aspect according to embodiments of the present invention, a kind of function Compilation Method is additionally provided, including:First function is entered Row compiling obtains second function, wherein, first function be using the first programming language write by hooking function, in second function Code allow directly performed by CPU;3rd function is compiled to obtain the 4th function, wherein, the 3rd function includes using In the first code for calling first function, the 3rd function is the self-defined hooking function write using the first programming language, the 4th Code in function allows directly to be performed by CPU;First code is compiled to obtain second code, wherein, second code permits Perhaps directly performed by CPU;Second function is hooked into the 4th function, obtains function call pointer, wherein, function call pointer is used In calling second function;Second code is hooked into the second function indicated by function call pointer.
Another aspect according to embodiments of the present invention, a kind of function compilation device is additionally provided, including:Latch hook unit, use Hooked into by the second function for being compiled to obtain to first function in self-defined proxy function, obtain function call pointer, Wherein, first function be using the first programming language write by hooking function, the code in second function allows directly by CPU Perform, function call pointer is used to call second function;Registering unit, for function call pointer to be registered, to cause Function call pointer is allowed to call;Compilation unit, carried out for being referred to using the function call by registration for the 3rd function Compiling, obtains the 4th function, wherein, the 3rd function includes being used for calling the code of first function, and the 3rd function is uses the The self-defined hooking function that one programming language is write, the code in the 4th function allow directly to be performed by CPU.
Another aspect according to embodiments of the present invention, a kind of function compilation device is additionally provided, including:First compiling is single Member, for being compiled to obtain second function to first function, wherein, first function is the quilt write using the first programming language Hooking function, the code in second function allow directly to be performed by CPU;Second compilation unit, for being compiled to the 3rd function Translate to obtain the 4th function, wherein, the 3rd function includes being used for calling the first code of first function, and the 3rd function is to use the The self-defined hooking function that one programming language is write, the code in the 4th function allow directly to be performed by CPU;3rd compiling is single Member, for first code to be compiled to obtain second code, wherein, second code allows directly to be performed by CPU;First hook Unit, for second function to be hooked into the 4th function, function call pointer is obtained, wherein, function call pointer is used to call Second function;Second latch hook unit, for second code to be hooked into the second function indicated by function call pointer.
In embodiments of the present invention, by being compiled to obtain the second letter to the first function write with C# programming languages Number, wherein, the code in second function is Native codes, and its permission is directly performed by CPU, then hooks into second function To obtain function call pointer in one self-defined proxy function, and the function call pointer is registered, so as to must utilize Function call pointer after registration is by the 3rd function write with C# programming languages is compiled to obtain the 4th function, to reach First function is hooked into the purpose of the 3rd function (self-defined Hook functions) (by Hook functions), and then solves correlation technique When carrying out Hook to function, self-defined Hook functions must be write using C/C++, cause the exploitations of self-defined Hook functions into This higher technical problem, it is achieved thereby that reducing the technique effect of the development cost of self-defined Hook functions.
Brief description of the drawings
Accompanying drawing described herein is used for providing a further understanding of the present invention, forms the part of the application, this hair Bright schematic description and description is used to explain the present invention, does not form inappropriate limitation of the present invention.In the accompanying drawings:
Fig. 1 is the schematic diagram that prior art uses in mobile phone games protocol test instrument;
Fig. 2 is the schematic diagram of the hardware environment of function Compilation Method according to embodiments of the present invention;
Fig. 3 is a kind of flow chart of optional function Compilation Method according to embodiments of the present invention;
Fig. 4 is the flow chart of the optional function Compilation Method of another kind according to embodiments of the present invention;
Fig. 5 is a kind of schematic diagram of optional instrument selection engineering interface according to embodiments of the present invention;
Fig. 6 is a kind of schematic diagram of optional selection one according to embodiments of the present invention existing engineering;
Fig. 7 is the schematic diagram that engineering is opened in a kind of optional selection according to embodiments of the present invention using VS2012;
Fig. 8 is according to embodiments of the present invention a kind of optionally to accelerating function and accelerating to render the real-time Hook of function to show It is intended to;
Fig. 9 is according to embodiments of the present invention a kind of optional self-defined to accelerate button to be pressed the schematic diagram of function;
Figure 10 is a kind of optional self-defined schematic diagram for accelerating to render function according to embodiments of the present invention;
Figure 11 is the schematic diagram that a kind of optional definition according to embodiments of the present invention is called by the original function of Hook functions;
Figure 12 is a kind of schematic diagram of optional increase Hook buttons according to embodiments of the present invention;
Figure 13 is the signal that operation button operation can be clicked on after the completion of a kind of optional compiling according to embodiments of the present invention Figure;
Figure 14 is a kind of schematic diagram of optional runnable interface according to embodiments of the present invention;
Figure 15 is a kind of optional schematic diagram for seeing operational effect in gaming according to embodiments of the present invention;
Figure 16 is a kind of schematic diagram of the operational effect of optional displaying code according to embodiments of the present invention;
Figure 17 is a kind of schematic diagram of optional postrun record data according to embodiments of the present invention;
Figure 18 is a kind of schematic diagram of optional flow for obtaining designation method according to embodiments of the present invention;
Figure 19 is a kind of optional schematic diagram for implementing Hook flows according to embodiments of the present invention;
Figure 20 is a kind of schematic diagram of optional function compilation device according to embodiments of the present invention;
Figure 21 is the schematic diagram of the optional function compilation device of another kind according to embodiments of the present invention;And
Figure 22 is a kind of structured flowchart of terminal according to embodiments of the present invention.
Embodiment
In order that those skilled in the art more fully understand the present invention program, below in conjunction with the embodiment of the present invention Accompanying drawing, the technical scheme in the embodiment of the present invention is clearly and completely described, it is clear that described embodiment is only The embodiment of a part of the invention, rather than whole embodiments.Based on the embodiment in the present invention, ordinary skill people The every other embodiment that member is obtained under the premise of creative work is not made, it should all belong to the model that the present invention protects Enclose.
It should be noted that term " first " in description and claims of this specification and above-mentioned accompanying drawing, " Two " etc. be for distinguishing similar object, without for describing specific order or precedence.It should be appreciated that so use Data can exchange in the appropriate case, so as to embodiments of the invention described herein can with except illustrating herein or Order beyond those of description is implemented.In addition, term " comprising " and " having " and their any deformation, it is intended that cover Cover it is non-exclusive include, be not necessarily limited to for example, containing the process of series of steps or unit, method, system, product or equipment Those steps or unit clearly listed, but may include not list clearly or for these processes, method, product Or the intrinsic other steps of equipment or unit.
First, the part noun or term occurred during the embodiment of the present invention is described is applied to as follows Explain:
C#:C# be Microsoft issue it is a kind of object-oriented, run on .NET Framework or open source projects High-level programming language on Mono.
C/C++:It is the general designation to C language and C Plus Plus in this programme, both language can be realized for C# The function of more bottoms.
IL codes:Refer to the bytecode after .Net language compilations.
Native codes:Refer to the code that directly can be performed by CPU.
Machine code:The code that directly can be performed by CPU is referred to, relative to Native codes, machine code has refered in particular to journey The code of sequence person's manual compiling, and Native codes are generally referred to as by compiler or the machine of some specially programming automatic generations Device code.
Hook:Refer in particular to be replaced the process of some function in this programme with a function oneself write, the process is related to 3 Individual function, one is by Hook function, and one is customized Hook functions, and a function pointer can be returned after Hook, The function pointer can complete the function that can be originally completed by Hook functions, and this function is referred to as " former letter in this programme Number calls ".
Mono:One open source projects that can run .Net programs.
Interface:The function for refering in particular to some functions of some module this being provided when needing to allow other modules call.
TPA:The protocol test instrument used inside Tencent.
Protocol test:Refer to being surveyed in face of the program of client/server type in Web communication layer in this programme Examination.
JIT:Mono is refered in particular in this programme on-the-flier compiler is operationally carried out to IL codes into the process of Native codes.
Apk:The form of the open source operating system Android of Google's issue executable program installation kit.
Visual Studio:The developing instrument that Microsoft delivers, it is a set of IDE.
Render:The process that some specific game process is drawn out on interface is refered in particular in this programme.
Procedure set:Refer in particular to include a series of set of IL codes in this programme, it is exactly a use that concrete expression, which comes out, .Net the EXE that language is write either DLL.
Native Hook:The related Hook processes of CPU are referred to, the CPU of ARM and Intel for current main flow are There are very reliable and stable Hook methods, these Hook methods are referred to as Native Hook.
Embodiment 1
According to embodiments of the present invention, there is provided a kind of embodiment of the method for function Compilation Method.
Alternatively, in the present embodiment, above-mentioned function Compilation Method can apply to as shown in Figure 2 by server 102 In the hardware environment formed with terminal 104.As shown in Fig. 2 server 102 is attached by network and terminal 104, it is above-mentioned Network includes but is not limited to:Wide area network, Metropolitan Area Network (MAN) or LAN, terminal 104 are not limited to PC, mobile phone, tablet personal computer etc..This The function Compilation Method of inventive embodiments can be performed by server 102, can also be performed, can also be by terminal 104 Performed jointly by server 102 and terminal 104.Wherein, the function Compilation Method of the execution of terminal 104 embodiment of the present invention can also It is to be performed by client mounted thereto.
The one of which function Compilation Method that the embodiment of the present invention is provided is explained below.
Fig. 3 is a kind of flow chart of optional function Compilation Method according to embodiments of the present invention, as shown in figure 3, the party Method may comprise steps of:
Step S202, the second function for being compiled to obtain to first function is hooked into self-defined proxy function, obtained To function call pointer, wherein, first function be using the first programming language write by hooking function, the generation in second function Code allows directly to be performed by CPU, and function call pointer is used to call second function;
Step S204, function call pointer is registered, to cause function call pointer to be allowed to the first programming language Say the code call write;
Step S206, referred to using the function call by registration and be compiled for the 3rd function, obtain the 4th function, its In, the 3rd function includes being used for the code for calling first function, and the 3rd function is to be made by oneself using what the first programming language was write Adopted hooking function, the code in the 4th function allow directly to be performed by CPU.
Above-mentioned steps S202 to step S206, by being compiled to obtain to the first function write with C# programming languages Two functions, wherein, the code in second function is Native codes, and its permission is directly performed by CPU, then hangs second function It is hooked in a self-defined proxy function to obtain function call pointer, and the function call pointer is registered, causes The 3rd function write with C# programming languages is compiled to obtain the 4th function using the function call pointer after registration, with up to To first function to be hooked into the purpose of the 3rd function (self-defined Hook functions) (by Hook functions), and then solves related skill Art self-defined Hook functions when carrying out Hook to function must be write using C/C++, cause the exploitation of self-defined Hook functions The higher technical problem of cost, it is achieved thereby that reducing the technique effect of the development cost of self-defined Hook functions.
In the technical scheme that step S202 is provided, first function can be to be linked up with using what the first programming language was write Function, wherein, the first programming language can be C#.The embodiment of the present invention is not specifically limited to the function of first function, and first Function can actual demand is write with C# according to the function with any function.First function, which is compiled, to be obtained Second function, wherein, the code in second function allows directly to be performed by CPU, and alternatively, the code in second function can be Native codes.The function of second function and the function phase of first function are same, differ only in code form difference.Actually should With in scene, the interface mono_compile_method that the embodiment of the present invention can use Mono to provide compiles first function Method pointer obtains the function pointer of second function, and first function is compiled to obtain the purpose of second function to realize.
After being compiled to obtain second function to first function, the embodiment of the present invention can hook into second function In self-defined proxy function, wherein, hook namely Hook in the embodiment of the present invention, wherein, the generation in self-defined proxy function Code also allows directly to be performed by CPU, and alternatively, the code in self-defined proxy function can also be Native codes.By second Function, which hooks into, can use Native Hook modes in self-defined proxy function, second function is hooked into self-defined agency A function call pointer can be obtained in function, wherein, the function call pointer can be used for calling second function, can also Address where the code segment of second function can be pointed to by being interpreted as the function call pointer, pass through the function call pointer Second function is called to realize.
Step S204 provide technical scheme in, obtain for indicate call second function function call pointer it Afterwards, in order that obtaining the function call pointer allows to be called, the embodiment of the present invention needs to be registered on the function call pointer, Specifically, the interface mono_add_internal_call that Mono is provided can be used to note the function call pointer to C# layers Volume, allows it to be called in C# layers, namely the generation that function call pointer is write with the first programming language C# Code calls.
In the technical scheme that step S206 is provided, the 3rd function can be self-defined to be write using the first programming language Hooking function, wherein, the first programming language can be C#.The embodiment of the present invention is not specifically limited to the function of the 3rd function, 3rd function can actual demand is write with C# according to the function with any function.The 3rd letter in the embodiment of the present invention The code for calling first function can be included in number, when being compiled to the 3rd function, if do not known in advance for indicating The pointer of first function address, being compiled when being compiled to the 3rd function to report an error, in order that obtaining the compiling of the 3rd function has Effect, the embodiment of the present invention need to refer to using the function call after registration to be compiled for the 3rd function, wherein, the letter after registration Number calls pointer to allow called and can serve to indicate that calling first function, so ensures that the volume of the 3rd function Translate effectively.
3rd function, which is compiled, can obtain the 4th function, wherein, the code in the 4th function allows directly by CPU Perform, alternatively, the code in the 4th function can also be Native codes.The function of 4th function and the function of the 3rd function It is identical, differ only in code form difference.In practical application scene, the embodiment of the present invention can also use what Mono was provided The method pointer that interface mono_compile_method compiles the 3rd function obtains the function pointer of the 4th function, to realize pair 3rd function compiles to obtain the purpose of the 4th function.
It should be noted that the function call after using registration refer to for the 3rd function compile to obtain the 4th function it Afterwards, first function can be linked up with the 3rd function in C# layers with realizing, namely links up with second function in Native layers In 4th function, so when needing to perform first function, COU can jump to the 4th function, to perform the 4th function.
As a kind of optional embodiment, the second function for being compiled to obtain to first function is linked up with step S202 Before into self-defined proxy function, the embodiment can also include:According to the mark of first function in predetermined procedure set Obtain first function.
It should be noted that predetermined procedure set can be multiple procedure sets, wherein, each procedure set is corresponding with one Unique program set identifier.It can include multiple classes in each procedure set, can include multiple method functions in each class.The reality First function can be got according to the mark of first function from multiple procedure sets by applying example, wherein, the mark of first function can To include but is not limited to the name of first function.
Alternatively, obtaining first function in predetermined procedure set according to the mark of first function can include:To each Procedure set performs following operation, wherein, procedure set is marked as present procedure collection when performing following operate:In present procedure collection Mark and predetermined mark match in the case of, concentrated from present procedure and determine predetermined class, and determined from predetermined class First function.
It should be noted that the embodiment can travel through multiple predetermined procedure sets, and obtain multiple predetermined procedure sets Mark, when mark and the predetermined mark of one of procedure set match, the embodiment can determine from the procedure set Predetermined class, and predetermined method is determined from predetermined class, namely the first function needed.
The embodiment can realize the purpose for obtaining first function in real time by above-mentioned dynamical fashion, can so avoid carrying on the back First point in the prior art that scape technology segment is previously mentioned deficiency, and then improve function Hook coverage and The effect of execution efficiency.
It should also be noted that, above-mentioned dynamical fashion can also be used for self-defined hooking function (namely the 3rd function) Acquire, namely can also be concentrated according to the mark of the 3rd function from preset program and obtain the 3rd function, specifically, can be right Each procedure set performs following operation, wherein, procedure set is marked as present procedure collection when performing following operate:Working as future In the case that the mark of sequence collection matches with predetermined mark, concentrated from present procedure and determine predetermined class, and from predetermined class Determine the 3rd function.Herein it is noted that the mark of the 3rd function can be different from the mark of first function, the 3rd function is obtained When institute preassigned predetermined mark when can also be from obtaining first function the preassigned predetermined mark of institute it is different.
As a kind of alternatively embodiment, it is compiled being referred to using the function call by registration for the 3rd function, After with realization, first function is hooked into the 3rd function, the embodiment can also comprise the following steps:
Step S208, receives operation requests, wherein, operation requests are used to ask to carry out scheduled operation to intended application, Intended application is write to obtain using the first programming language;
Step S210, during response operation requests carry out scheduled operation to intended application, when first function is asked When asking execution, the 4th function is jumped to, to perform the 4th function.
In above-mentioned steps, the intended application in the embodiment can be write to obtain using the first programming language Using, wherein, the first programming language can be C#.The embodiment is not specifically limited to the type of intended application, such as target Using can be game application, browser application, instant messaging application etc..Operation requests in the embodiment can be used for asking Scheduled operation is carried out to intended application, wherein, the type of the scheduled operation embodiment is also not specifically limited, such as scheduled operation Can be that the performance (such as response time) of intended application is tested etc..
After operation requests are received, the embodiment can respond thereto, to carry out predetermined behaviour to intended application Make, it is necessary to explanation, during scheduled operation is carried out to intended application, when needing to perform the in the embodiment of the present invention During one function, because first function has been linked up with the 3rd function, and first function and the 3rd function have also already been volume Translate, CPU can then jump directly to the 4th function, to perform the 4th function.Due to including calling first function in the 3rd function Code, therefore CPU can be realized by the function of hooking function (first function) script when performing four functions.
It should be noted that the concrete application scene of the embodiment can be with specific reference to provided in herein below of the present invention Preferred embodiment, will not specifically describe herein.
The embodiment in intended application by hooking function by will be hooked into self-defined hooking function, and self-defined Other functions are added in hooking function, to cause in intended application running, when needing to perform by hooking function, are passed through Self-defined hooking function is jumped to perform self-defined hooking function, to realize other functions outside intended application, for example (,) it is right Some performance of intended application is tested.It can be reached by the embodiment and the performance of intended application is tested and optimized Purpose.
Another function Compilation Method that the embodiment of the present invention is provided is explained below.
Fig. 4 is the flow chart of the optional function Compilation Method of another kind according to embodiments of the present invention, as shown in figure 4, should Method may comprise steps of:
Step S302, first function is compiled to obtain second function, wherein, first function is to use the first programming language Say write by hooking function, the code in second function allows directly to be performed by CPU;
Step S304, the 3rd function is compiled to obtain the 4th function, wherein, the 3rd function includes being used to call the The first code of one function, the 3rd function are the self-defined hooking function write using the first programming language, in the 4th function Code allows directly to be performed by CPU;
Step S306, first code is compiled to obtain second code, wherein, second code allows directly to be held by CPU OK;
Step S308, second function is hooked into the 4th function, obtains function call pointer, wherein, function call pointer For calling second function;
Step S310, second code is hooked into the second function indicated by function call pointer.
Above-mentioned steps S302 to step S310, by being entered to what is write with C# programming languages by hooking function (first function) Row compiling obtains second function, and to the self-defined hooking function write with C# programming languages, (the 3rd function, the 3rd function include Call the first code of first function) it is compiled to obtain the 4th function, wherein, in the code and the 4th function in second function Code be to allow the Native codes that are directly performed by CPU, then first code is compiled to obtain second code, then pass through The second letter indicated by function call pointer that second code is hooked into obtained by second function is hooked into the 4th function In number, second function can be hooked into the 4th function with realizing, and then first function (by Hook functions) is linked up with To the purpose of the 3rd function (self-defined Hook functions), and then it is self-defined when carrying out Hook to function to solve correlation technique Hook functions must be write using C/C++, cause the higher technical problem of the development cost of self-defined Hook functions, so as to realize The technique effect of the development cost of the self-defined Hook functions of reduction.
It should be noted that the function Compilation Method shown in Fig. 4 is identical with the Compilation Method principle shown in Fig. 3, be for Realize and hook into first function in the 3rd function, it is necessary to be compiled to it, and second function will be called in Native layers Function call pointer notify in the 4th function, with cause need perform first function when, the 4th function can be jumped to, To perform the 4th function, and the function of first function script can be realized.Shown in function Compilation Method and Fig. 3 shown in Fig. 4 Differing only in for Compilation Method notified in the 4th function for calling mode that the function call of second function indicates not Together.
Each step in the function Compilation Method shown in Fig. 4 will be described in detail below, specifically:
In the technical scheme that step S302 is provided, first function can be to be linked up with using what the first programming language was write Function, wherein, the first programming language can be C#.The embodiment of the present invention is not specifically limited to the function of first function, and first Function can actual demand is write with C# according to the function with any function.First function, which is compiled, to be obtained Second function, wherein, the code in second function allows directly to be performed by CPU, and alternatively, the code in second function can be Native codes.The function of second function and the function phase of first function are same, differ only in code form difference.Actually should With in scene, the interface mono_compile_method that the embodiment of the present invention can use Mono to provide compiles first function Method pointer obtains the function pointer of second function, and first function is compiled to obtain the purpose of second function to realize.
In the technical scheme that step S304 is provided, the 3rd function can be self-defined to be write using the first programming language Hooking function, wherein, the first programming language can be C#.The embodiment of the present invention is not specifically limited to the function of the 3rd function, 3rd function can actual demand is write with C# according to the function with any function.The 3rd letter in the embodiment of the present invention The first code for calling first function can be included in number, when going to first code, it is possible to achieve call first function Purpose.3rd function, which is compiled, can obtain the 4th function, wherein, the code in the 4th function allows directly to be held by CPU OK, alternatively, the code in the 4th function can also be Native codes.The function of 4th function and the function phase of the 3rd function Together, code form difference is differed only in.In practical application scene, the embodiment of the present invention can also use connecing for Mono offers The method pointer that mouthful mono_compile_method compiles the 3rd function obtains the function pointer of the 4th function, to realize to the Three functions compile to obtain the purpose of the 4th function.
It should be noted that in order that can then be needed the with normal call second function when performing four functions The function call pointer for calling second function is notified in four functions, can specifically be carried by step S306 to step S310 The scheme of confession, specifically:
In the technical scheme that step S306 provides to step S310, first code is the C# generations for calling first function Code, can obtain second code after being compiled to first code, wherein, second code can be to allow directly to be held by CPU Capable Native codes.It should be noted that the function phase of second code and first code is same, can indicate to call the first letter Number, but both code forms are different.
The embodiment of the present invention is compiling to obtain second function to first function, compiles to obtain the 4th function to the 3rd function Afterwards, second function can be hooked into the 4th function first, to obtain a function call pointer, wherein, the function is adjusted It can be used for calling second function with pointer.However, it is desirable to explanation, due in the 4th function and without proper notice effectively second Function, second function can not be successfully called when performing four functions, therefore, it is necessary to first code will be compiled in step S306 Obtained second code is hooked into second function, namely performs the technical scheme shown in step S310, to cause in the 4th letter The calling pointer of second function is stated in number, and then realizes the mesh that second function can be successfully called when performing four functions , first function is hooked into the 3rd function further to realize.
, should before step S302 is compiled to obtain second function to first function as a kind of optional embodiment Embodiment can also include:First function is obtained in predetermined procedure set according to the mark of first function.
It should be noted that predetermined procedure set can be multiple procedure sets, wherein, each procedure set is corresponding with one Unique program set identifier.It can include multiple classes in each procedure set, can include multiple method functions in each class.The reality First function can be got according to the mark of first function from multiple procedure sets by applying example, wherein, the mark of first function can To include but is not limited to the name of first function.
Alternatively, obtaining first function in predetermined procedure set according to the mark of first function can include:To each Procedure set performs following operation, wherein, procedure set is marked as present procedure collection when performing following operate:In present procedure collection Mark and predetermined mark match in the case of, concentrated from present procedure and determine predetermined class, and determined from predetermined class First function.
It should be noted that the embodiment can travel through multiple predetermined procedure sets, and obtain multiple predetermined procedure sets Mark, when mark and the predetermined mark of one of procedure set match, the embodiment can determine from the procedure set Predetermined class, and predetermined method is determined from predetermined class, namely the first function needed.
The embodiment can realize the purpose for obtaining first function in real time by above-mentioned dynamical fashion, can so avoid carrying on the back First point in the prior art that scape technology segment is previously mentioned deficiency, and then improve function Hook coverage and The effect of execution efficiency.
It should also be noted that, above-mentioned dynamical fashion can also be used for self-defined hooking function (namely the 3rd function) Acquire, namely can also be concentrated according to the mark of the 3rd function from preset program and obtain the 3rd function, specifically, can be right Each procedure set performs following operation, wherein, procedure set is marked as present procedure collection when performing following operate:Working as future In the case that the mark of sequence collection matches with predetermined mark, concentrated from present procedure and determine predetermined class, and from predetermined class Determine the 3rd function.Herein it is noted that the mark of the 3rd function can be different from the mark of first function, the 3rd function is obtained When institute preassigned predetermined mark when can also be from obtaining first function the preassigned predetermined mark of institute it is different.
As a kind of alternatively embodiment, second code is being hooked into the second function indicated by function call pointer, After with realization, first function is hooked into the 3rd function, the embodiment can also comprise the following steps:
Step S312, receives operation requests, wherein, operation requests are used to ask to carry out scheduled operation to intended application, Intended application is write to obtain using the first programming language;
Step S314, during response operation requests carry out scheduled operation to intended application, when first function is asked When asking execution, the 4th function is jumped to, to perform the 4th function.
In above-mentioned steps, the intended application in the embodiment can be write to obtain using the first programming language Using, wherein, the first programming language can be C#.The embodiment is not specifically limited to the type of intended application, such as target Using can be game application, browser application, instant messaging application etc..Operation requests in the embodiment can be used for asking Scheduled operation is carried out to intended application, wherein, the type of the scheduled operation embodiment is also not specifically limited, such as scheduled operation Can be that the performance (such as response time) of intended application is tested etc..
After operation requests are received, the embodiment can respond thereto, to carry out predetermined behaviour to intended application Make, it is necessary to explanation, during scheduled operation is carried out to intended application, when needing to perform the in the embodiment of the present invention During one function, because first function has been linked up with the 3rd function, and first function and the 3rd function have also already been volume Translate, CPU can then jump directly to the 4th function, to perform the 4th function.Due to including calling first function in the 3rd function Code, therefore CPU can be realized by the function of hooking function (first function) script when performing four functions.
It should be noted that the concrete application scene of the embodiment can be with specific reference to provided in herein below of the present invention Preferred embodiment, will not specifically describe herein.
The embodiment in intended application by hooking function by will be hooked into self-defined hooking function, and self-defined Other functions are added in hooking function, to cause in intended application running, when needing to perform by hooking function, are passed through Self-defined hooking function is jumped to perform self-defined hooking function, to realize other functions outside intended application, for example (,) it is right Some performance of intended application is tested.It can be reached by the embodiment and the performance of intended application is tested and optimized Purpose.
It should be noted that the optional function Compilation Method of above two provided in the present invention can be realized and will used The purpose that what C# programming languages were write hooked into by hooking function in the self-defined hooking function write with C# programming languages, and then Solve correlation technique self-defined Hook functions when carrying out Hook to function to write using C/C++, cause self-defined The higher technical problem of the development costs of Hook functions, it is achieved thereby that reducing the technology of the development cost of self-defined Hook functions Effect.
Present invention also offers a kind of preferred embodiment, the preferred embodiment provides a kind of C# functions based on Mono Hook technologies.
This programme realizes the Hook technologies of C# codes, and the technology has a function of being linked up with to function, and can be with Self-defined Hook functions are write using pure C# language, while can be called by Hook functions in self-defined Hook functions to realize By the function of Hook functions, the core technology of the program employs the on-the-flier compiler interfaces of Mono offers by IL codes operationally Native codes are compiled into, then to Native code implementation Hook, so as to reach the function that Hook is carried out to C# codes.
The technology is finally packaged into a C# layer interface by this programme, and the interface is available for developer directly to use, because This programme is all encapsulated the technology of all bottoms, so developer can not have to write C/C++ code cans pair C# functions carry out Hook, in this embodiment it is not even necessary to understand the principle of inside.
The product form of the program is one with the dynamic link library of C/C++ written in code and a source generation write with C# Code file, the program can be applied in " Unity is debugged in real time " instrument, transported to complete to monitor and change Unity game Function during row.Now the instrument process for using is described below:
Fig. 5 is a kind of schematic diagram of optional instrument selection engineering interface according to embodiments of the present invention, as shown in figure 5, Opening instrument, the game for selecting an Apk to be debugged as needs, as shown in figure 5, click can automatically generate after starting Visual Studio engineerings.
Fig. 6 is a kind of schematic diagram of optional selection one according to embodiments of the present invention existing engineering, such as Fig. 6 It is shown, if second uses instrument, then existing engineering can be selected in combobox.
Fig. 7 is that a kind of optional selection according to embodiments of the present invention uses the schematic diagram of VS2012 opening engineerings, such as Fig. 7 It is shown, clicked on after choosing and proceed by exploitation, can selected this when using Visual Studio 2012 (hereinafter Visual Studio abbreviation VS) open engineering developed.
It can give tacit consent in VS engineerings and a CSHook.cs file is provided, this is real using this programme this document gives one Existing interface int cshook.cshook.Hook (string src_file, string src_namespace, string src_class,string src_function,int src_argc,string des_file,string des_ namespace,string des_class,string des_function,int des_argc,string oldname)。
By taking certain game as an example, introduce the technology and apply the application in the game, this example is to test game server The response time for accelerating operation to client is example, and other codes unrelated with this programme are not put up in this example.
Fig. 8 is according to embodiments of the present invention a kind of optionally to accelerating function and accelerating to render the real-time Hook of function to show It is intended to, as shown in figure 8, calling Hook interfaces to press corresponding acceleration function to the acceleration button of game in engineering AccBtn.OnPointerDown and really acceleration accelerate to render function SnakeRenderer.set_IsAcc and enter corresponding to starting Row Hook.
Write by the SQL of Hook functions, performed in gaming by Hook functions to replace, self-defined acceleration Button press minor function as shown in figure 9, self-defined acceleration to render function as shown in Figure 10, wherein, Fig. 9 is according to embodiments of the present invention It is a kind of it is optional it is self-defined accelerate button to be pressed the schematic diagram of function, Figure 10 is according to embodiments of the present invention a kind of optional Self-defined acceleration render the schematic diagram of function.
Figure 11 is the schematic diagram that a kind of optional definition according to embodiments of the present invention is called by the original function of Hook functions, As shown in figure 11, original function can be called in self-defined Hook functions to realize the function of originally being realized by Hook functions, should Function is transmitted to cshook.cshook.Hook as last parameter.
Figure 12 is a kind of schematic diagram of optional increase Hook buttons according to embodiments of the present invention, as shown in figure 12, is This Hook function increases a button, and Hook is performed can click on by hand in gaming.
Figure 13 is the signal that operation button operation can be clicked on after the completion of a kind of optional compiling according to embodiments of the present invention Figure, Figure 14 are a kind of schematic diagrames of optional runnable interface according to embodiments of the present invention, as shown in Figure 13 and Figure 14, are completed simultaneously After compiled, return to the real-time debugging acids of Unity and click on operation button.
Figure 15 is a kind of optional schematic diagram for seeing operational effect in gaming according to embodiments of the present invention, such as Figure 15 It is shown, after instrument operation, one can be had in the upper left corner and is marked on a map as start hook button.
Figure 16 is a kind of schematic diagram of the operational effect of optional displaying code according to embodiments of the present invention, and Figure 17 is root According to a kind of schematic diagram of optional postrun record data of the embodiment of the present invention, above-mentioned code operation result such as Figure 16 institutes Show, final operation result is recorded in a journal file, as shown in figure 17.In fig. 17, the record identifies one with an ID The record of individual delay data, wherein Delay field records are that (My_OnPointerDown2 functions are opened from acceleration button is pressed Begin to perform) time of beginning (My_set_IsAcc2 functions start to perform) is rendered to acceleration, because the preferred embodiment is with one Exemplified by individual online game, game client can't directly carry out acceleration and render when accelerator key is pressed, but go to take Can business device verifies whether to return again to after accelerating gives client one result that accelerate, and client is made whether what is accelerated again Render;RTT field records be client and server delay, the two values, which are subtracted each other, can be obtained by server and is truly delayed Time, server performance optimization of the time to the game have very high directive function.
Figure 18 is a kind of schematic diagram of optional flow for obtaining designation method according to embodiments of the present invention, such as Figure 18 institutes Show, the mode that this programme is taken is that operationally dynamic access is summarized as follows by the address of Hook functions, acquisition modes:
1. the interface mono_assembly_foreach provided with Mono travels through all procedure sets of loading.
2. the interface mono_image_get_name provided with Mono obtains the name for the procedure set being traversed.
3. it is the procedure set name that developer specifies according to name determining program collection.
4. obtained with Mono the interface mono_class_from_name and mono_class_get_method_name provided Needs that originator is specified are taken away by the pointer of Hook functions.
Figure 19 is a kind of optional schematic diagram for implementing Hook flows according to embodiments of the present invention, as shown in figure 19, this The techniqueflow that scheme implements Hook is as follows:
1. the method by Hook functions and self-defined Hook functions of developer's offer is obtained with flow as shown in figure 18 Pointer.
2. the method by Hook functions obtained in the interface mono_compile_method compilings 1 provided with Mono refers to Pin obtains the function pointer of Native codes.
3. Hook is carried out by Hook functions to what is obtained in 2 with Native Hook, by its Hook to self-defined proxy function In.
4. call pointer with the interface mono_add_internal_call that Mono is provided to C# the original function obtained in 3 Layer registration can call in C# layers.
5. the side of the self-defined Hook functions obtained in the interface mono_compile_method compilings 1 provided with Mono Method pointer obtains the function pointer of Native codes.
6. the function pointer of the Native codes obtained in 5 is set in self-defined proxy function.
It should be noted that the proxy_mem_des in this flow is inherently the block number evidence in internal memory, this block Data special service is in some Hook process, since it is desired that will apply for such one piece of internal memory, this block for each Hook processes What is put inside internal memory is machine code, and this part machine code is completed simply to redirect work, and the destination redirected is exactly desptr, this Data configuration inside block internal memory well needs to be called with the system of related platform later is set to executable state by this block internal memory.
The maximum gain effect of this programme is can to use C# written in code by the logic of Hook functions, and can only use C/ in the past C++ writes, and this facility is because the development language that present Unity plays is exactly C#, if writing self-defined Hook with C/C++ On data exchange there is very big difference in C/C++ and C# if function, deal with extremely complex, and this is to development efficiency It is obviously improved.
It should also be noted that, Mono can only be compiled once to some method during once running based on game Premise, it is simple obtain the former Hook is arrived after the Native code pointers of Hook functions and self-defined Hook functions after Person, because the self-defined Hook methods for having used original function to call in self-defined Hook functions and having caused compiling to obtain obtain Native functions have abnormal, and the exception is to can not find original function calling, by the calling of original function to C# after instant Hook Layer registration, in view of self-defined Hook functions have been compiled once, Mono can directly return foregoing compiled Native code pointers.
Special circumstances based on more than, actually have a variety of schemes to bypass this technological difficulties, above-mentioned Figure 19 institutes The scheme shown is efficiency highest scheme, in addition can also have following alternative solution, can specifically be described as:Can be On the basis of technical scheme shown in Figure 19, the function called to the original function that developer provides is compiled to obtain Native generations Code pointer, be designated as old_code_addr, now directly invoke old_code_addr have it is abnormal, it is therefore desirable to by this Gone in technical scheme shown in Hook to the Figure 19 of address in the function pointer for the Native codes that the 5th step obtains.
It should be noted that for foregoing each method embodiment, in order to be briefly described, therefore it is all expressed as a series of Combination of actions, but those skilled in the art should know, the present invention is not limited by described sequence of movement because According to the present invention, some steps can use other orders or carry out simultaneously.Secondly, those skilled in the art should also know Know, embodiment described in this description belongs to preferred embodiment, and involved action and module are not necessarily of the invention It is necessary.
Through the above description of the embodiments, those skilled in the art can be understood that according to above-mentioned implementation The method of example can add the mode of required general hardware platform to realize by software, naturally it is also possible to by hardware, but a lot In the case of the former be more preferably embodiment.Based on such understanding, technical scheme is substantially in other words to existing The part that technology contributes can be embodied in the form of software product, and the computer software product is stored in a storage In medium (such as ROM/RAM, magnetic disc, CD), including some instructions to cause a station terminal equipment (can be mobile phone, calculate Machine, server, or network equipment etc.) perform method described in each embodiment of the present invention.
Embodiment 2
According to embodiments of the present invention, a kind of function compilation device for being used to implement above-mentioned function Compilation Method is additionally provided.
Figure 20 is a kind of schematic diagram of optional function compilation device according to embodiments of the present invention, as shown in figure 20, should Device can include:
Latch hook unit 22, for the second function for being compiled to obtain to first function to be hooked into self-defined proxy function In, obtain function call pointer, wherein, first function be using the first programming language write by hooking function, second function In code allow directly performed by CPU, function call pointer be used for call second function;Registering unit 24, for by function Pointer is called to be registered, the code call write to cause function call pointer to be allowed to the first programming language;Compiling is single Member 26, it is compiled for being referred to using the function call by registration for the 3rd function, obtains the 4th function, wherein, the 3rd Function includes being used for the code for calling first function, and the 3rd function is the self-defined hook letter write using the first programming language Count, the code in the 4th function allows directly to be performed by CPU.
It should be noted that the latch hook unit 22 in the embodiment can be used for performing the step in the embodiment of the present application 1 S202, the registering unit 24 in the embodiment can be used for performing the step S204 in the embodiment of the present application 1, in the embodiment Compilation unit 26 can be used for performing the step S206 in the embodiment of the present application 1.
Herein it should be noted that above-mentioned module is identical with example and application scenarios that corresponding step is realized, but not It is limited to the disclosure of that of above-described embodiment 1.It should be noted that above-mentioned module as a part for device may operate in as It in hardware environment shown in Fig. 2, can be realized, can also be realized by hardware by software.
As a kind of optional embodiment, the function compilation device can also include:Receiving unit, for utilizing process The function call of registration refers to be compiled for the 3rd function after, receive operation requests, wherein, operation requests be used for ask Scheduled operation is carried out to intended application, intended application is write to obtain using the first programming language;Jump-transfer unit, in sound During operation requests are answered to intended application progress scheduled operation, when first function is requested to be performed, the 4th letter is jumped to Number, to perform the 4th function.
As a kind of optional embodiment, the function compilation device can also include:Acquiring unit, for will be to first Before the second function that function is compiled to obtain is hooked into self-defined proxy function, according to the mark of first function predetermined Procedure set in obtain first function.
Alternatively, acquiring unit can include:Execution module, for performing following operation to each procedure set, wherein, journey Sequence collection is marked as present procedure collection when performing following operate:In the feelings that the mark of present procedure collection matches with predetermined mark Under condition, concentrated from present procedure and determine predetermined class, and first function is determined from predetermined class.
As a kind of optional embodiment, the first programming language is C#, in the code and the 4th function in second function Code is Native codes.
By above-mentioned module, can solve correlation technique self-defined Hook functions when carrying out Hook to function must make Write with C/C++, cause the higher technical problem of the development cost of self-defined Hook functions, and then reduce self-defined Hook The technique effect of the development cost of function.
Figure 21 is the schematic diagram of the optional function compilation device of another kind according to embodiments of the present invention, as shown in figure 21, The device can include:
First compilation unit 32, for being compiled to obtain second function to first function, wherein, first function is use First programming language write by hooking function, the code in second function allows directly to be performed by CPU;Second compilation unit 34, for being compiled to obtain the 4th function to the 3rd function, wherein, the 3rd function includes being used to call the of first function One code, the 3rd function are the self-defined hooking function write using the first programming language, and the code in the 4th function allows straight Connect and performed by CPU;3rd compilation unit 36, for first code to be compiled to obtain second code, wherein, second code permits Perhaps directly performed by CPU;First latch hook unit 38, for second function to be hooked into the 4th function, function call pointer is obtained, Wherein, function call pointer is used to call second function;Second latch hook unit 310, adjusted for second code to be hooked into function With the second function indicated by pointer.
It should be noted that the first compilation unit 32 in the embodiment can be used for performing in the embodiment of the present application 1 Step S302, the second compilation unit 34 in the embodiment can be used for performing the step S304 in the embodiment of the present application 1, the reality Apply the 3rd compilation unit 36 in example to can be used for performing the step S306 in the embodiment of the present application 1, first in the embodiment Latch hook unit 38 can be used for performing the step S308 in the embodiment of the present application 1, and the second latch hook unit 310 in the embodiment can For performing the step S310 in the embodiment of the present application 1.
Herein it should be noted that above-mentioned module is identical with example and application scenarios that corresponding step is realized, but not It is limited to the disclosure of that of above-described embodiment 1.It should be noted that above-mentioned module as a part for device may operate in as It in hardware environment shown in Fig. 2, can be realized, can also be realized by hardware by software.
As a kind of optional embodiment, the function compilation device can also include:Receiving unit, for by the second generation Code is hooked into after the second function indicated by function call pointer, receives operation requests, wherein, operation requests are used to ask Scheduled operation is carried out to intended application, intended application is write to obtain using the first programming language;Jump-transfer unit, in sound During operation requests are answered to intended application progress scheduled operation, when first function is requested to be performed, the 4th letter is jumped to Number, to perform the 4th function.
As a kind of optional embodiment, the function compilation device can also include:Acquiring unit, for the first letter Before number is compiled to obtain second function, first function is obtained in predetermined procedure set according to the mark of first function.
Alternatively, acquiring unit can include:Execution module, for performing following operation to each procedure set, wherein, journey Sequence collection is marked as present procedure collection when performing following operate:In the feelings that the mark of present procedure collection matches with predetermined mark Under condition, concentrated from present procedure and determine predetermined class, and first function is determined from predetermined class.
As a kind of optional embodiment, the first programming language is C#, in the code and the 4th function in second function Code is Native codes.
By above-mentioned module, it is necessary can also to solve correlation technique self-defined Hook functions when carrying out Hook to function Write using C/C++, cause the higher technical problem of the development cost of self-defined Hook functions, and then reduce self-defined The technique effect of the development cost of Hook functions.
Embodiment 3
According to embodiments of the present invention, a kind of terminal for being used to implement above-mentioned function Compilation Method is additionally provided.
Figure 22 is a kind of structured flowchart of terminal according to embodiments of the present invention, and as shown in figure 22, the terminal can include: One or more (one is only shown in figure) processor 201, memory 203 and transmitting devices 205, as shown in figure 22, the end End can also include input-output equipment 207.
Wherein, memory 203 can be used for storage software program and module, such as the function compiling side in the embodiment of the present invention Programmed instruction/module corresponding to method and device, processor 201 by operation be stored in software program in memory 203 and Module, so as to perform various function application and data processing, that is, realize above-mentioned function Compilation Method.Memory 203 can wrap Include high speed random access memory, nonvolatile memory can also be included, as one or more magnetic storage device, flash memory or Other non-volatile solid state memories of person.In some instances, memory 203 can further comprise remote relative to processor 201 The memory that journey is set, these remote memories can pass through network connection to terminal.The example of above-mentioned network includes but unlimited In internet, intranet, LAN, mobile radio communication and combinations thereof.
Above-mentioned transmitting device 205 is used to data are received or sent via a network.Above-mentioned network instantiation It may include cable network and wireless network.In an example, transmitting device 205 includes a network adapter (Network Interface Controller, NIC), its can be connected by netting twine with other network equipments with router so as to interconnection Net or LAN are communicated.In an example, transmitting device 205 is radio frequency (Radio Frequency, RF) module, its For wirelessly being communicated with internet.
Wherein, specifically, memory 203 is used to store application program.
Processor 201 can call the application program that memory 203 stores, to perform following step:Will be to first function The second function for being compiled to obtain is hooked into self-defined proxy function, obtains function call pointer, wherein, first function is Using the first programming language write by hooking function, the code in second function allows directly to be performed by CPU, and function call refers to Pin is used to call second function;Function call pointer is registered, to cause function call pointer to be allowed to the first programming The code call that language is write;Referred to using the function call by registration and be compiled for the 3rd function, obtain the 4th function, Wherein, the 3rd function includes being used for calling the code of first function, the 3rd function be using the first programming language write from Hooking function is defined, the code in the 4th function allows directly to be performed by CPU.
Processor 201 is additionally operable to perform following step:Refer to enter for the 3rd function using the function call by registration After row compiling, operation requests are received, wherein, operation requests are used to ask to carry out intended application scheduled operation, and target should Write to obtain with using the first programming language;During response operation requests carry out scheduled operation to intended application, When first function is requested to be performed, the 4th function is jumped to, to perform the 4th function.
Processor 201 is additionally operable to perform following step:Linked up with by the second function for being compiled to obtain to first function Before into self-defined proxy function, first function is obtained in predetermined procedure set according to the mark of first function.
Processor 201 is additionally operable to perform following step:Following operation is performed to each procedure set, wherein, procedure set is being held Present procedure collection is marked as when being operated below row:In the case where the mark of present procedure collection matches with predetermined mark, from Present procedure, which is concentrated, determines predetermined class, and determines first function from predetermined class.
Processor 201 may call upon the application program of the storage of memory 203, to perform following step:To first function Be compiled to obtain second function, wherein, first function be using the first programming language write by hooking function, second function In code allow directly performed by CPU;3rd function is compiled to obtain the 4th function, wherein, the 3rd function includes For calling the first code of first function, the 3rd function is the self-defined hooking function write using the first programming language, the Code in four functions allows directly to be performed by CPU;First code is compiled to obtain second code, wherein, second code Permission is directly performed by CPU;Second function is hooked into the 4th function, obtains function call pointer, wherein, function call pointer For calling second function;Second code is hooked into the second function indicated by function call pointer.
Processor 201 is additionally operable to perform following step:Second code is being hooked into indicated by function call pointer After two functions, operation requests are received, wherein, operation requests are used to ask to carry out intended application scheduled operation, and target should Write to obtain with using the first programming language;During response operation requests carry out scheduled operation to intended application, When first function is requested to be performed, the 4th function is jumped to, to perform the 4th function.
Processor 201 is additionally operable to perform following step:Before being compiled to obtain second function to first function, according to The mark of first function obtains first function in predetermined procedure set.
Processor 201 is additionally operable to perform following step:Following operation is performed to each procedure set, wherein, procedure set is being held Present procedure collection is marked as when being operated below row:In the case where the mark of present procedure collection matches with predetermined mark, from Present procedure, which is concentrated, determines predetermined class, and determines first function from predetermined class.
Using the embodiment of the present invention, there is provided a kind of scheme of function compiling, the program can will use C# programming languages to compile The first function write hooks into the 3rd function (self-defined Hook functions) write with C# programming languages (by Hook functions), and then Solve correlation technique self-defined Hook functions when carrying out Hook to function to write using C/C++, cause self-defined The higher technical problem of the development costs of Hook functions, it is achieved thereby that reducing the technology of the development cost of self-defined Hook functions Effect.
Alternatively, the specific example in the present embodiment may be referred to showing described in above-described embodiment 1 and embodiment 2 Example, the present embodiment will not be repeated here.
It will appreciated by the skilled person that the structure shown in Figure 22 is only to illustrate, terminal can be smart mobile phone (such as Android phone, iOS mobile phones), tablet personal computer, palm PC and mobile internet device (Mobile Internet Devices, MID), the terminal device such as PAD.Figure 22 it does not cause to limit to the structure of above-mentioned electronic installation.For example, terminal is also It may include more either less components (such as network interface, display device etc.) than shown in Figure 22 or have and Figure 22 institutes Show different configurations.
One of ordinary skill in the art will appreciate that all or part of step in the various methods of above-described embodiment is can To be completed by program come command terminal device-dependent hardware, the program can be stored in a computer-readable recording medium In, storage medium can include:Flash disk, read-only storage (Read-Only Memory, ROM), random access device (Random Access Memory, RAM), disk or CD etc..
Embodiment 4
Embodiments of the invention additionally provide a kind of storage medium.Alternatively, in the present embodiment, above-mentioned storage medium can For performing the program code of function Compilation Method.
Alternatively, in the present embodiment, above-mentioned storage medium can be located at multiple in the network shown in above-described embodiment On at least one network equipment in the network equipment.
Alternatively, in the present embodiment, storage medium is arranged to the program code that storage is used to perform following steps:
S1, the second function for being compiled to obtain to first function is hooked into self-defined proxy function, obtains function Call pointer, wherein, first function be using the first programming language write by hooking function, the code in second function allows Directly performed by CPU, function call pointer is used to call second function;
S2, function call pointer is registered, to cause function call pointer to be allowed to be write with the first programming language Code call;
S3, referred to using the function call by registration and be compiled for the 3rd function, obtain the 4th function, wherein, the Three functions include being used for the code for calling first function, and the 3rd function is the self-defined hook write using the first programming language Function, the code in the 4th function allow directly to be performed by CPU.
Alternatively, storage medium is also configured to the program code that storage is used to perform following steps:Using by note After the function call of volume refers to and is compiled for the 3rd function, operation requests are received, wherein, operation requests are used to asking pair Intended application carries out scheduled operation, and intended application is write to obtain using the first programming language;In response operation requests to mesh During mark application carries out scheduled operation, when first function is requested to be performed, the 4th function is jumped to, to perform the 4th letter Number.
Alternatively, storage medium is also configured to the program code that storage is used to perform following steps:Will be to the first letter Before the second function that number is compiled to obtain is hooked into self-defined proxy function, according to the mark of first function predetermined First function is obtained in procedure set.
Alternatively, storage medium is also configured to the program code that storage is used to perform following steps:To each procedure set Following operation is performed, wherein, procedure set is marked as present procedure collection when performing following operate:In the mark of present procedure collection In the case of matching with predetermined mark, concentrated from present procedure and determine predetermined class, and the first letter is determined from predetermined class Number.
Alternatively, in the present embodiment, storage medium is arranged to the program code that storage is used to perform following steps:
S1', first function is compiled to obtain second function, wherein, first function is to be compiled using the first programming language Write by hooking function, the code in second function allows directly to be performed by CPU;
S2', the 3rd function is compiled to obtain the 4th function, wherein, the 3rd function includes being used to call the first letter Several first codes, the 3rd function are the self-defined hooking function write using the first programming language, the code in the 4th function Permission is directly performed by CPU;
S3', first code is compiled to obtain second code, wherein, second code allows directly to be performed by CPU;
S4', second function is hooked into the 4th function, obtains function call pointer, wherein, function call pointer is used to adjust Use second function;
S5', second code is hooked into the second function indicated by function call pointer.
Alternatively, storage medium is also configured to the program code that storage is used to perform following steps:By second code Hook into after the second function indicated by function call pointer, receive operation requests, wherein, operation requests are used for request pair Intended application carries out scheduled operation, and intended application is write to obtain using the first programming language;In response operation requests to mesh During mark application carries out scheduled operation, when first function is requested to be performed, the 4th function is jumped to, to perform the 4th letter Number.
Alternatively, storage medium is also configured to the program code that storage is used to perform following steps:To first function Before being compiled to obtain second function, first function is obtained in predetermined procedure set according to the mark of first function.
Alternatively, storage medium is also configured to the program code that storage is used to perform following steps:To each procedure set Following operation is performed, wherein, procedure set is marked as present procedure collection when performing following operate:In the mark of present procedure collection In the case of matching with predetermined mark, concentrated from present procedure and determine predetermined class, and the first letter is determined from predetermined class Number.
Alternatively, the specific example in the present embodiment may be referred to showing described in above-described embodiment 1 and embodiment 2 Example, the present embodiment will not be repeated here.
Alternatively, in the present embodiment, above-mentioned storage medium can include but is not limited to:USB flash disk, read-only storage (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disc or CD etc. is various can be with the medium of store program codes.
The embodiments of the present invention are for illustration only, do not represent the quality of embodiment.
If the integrated unit in above-described embodiment is realized in the form of SFU software functional unit and is used as independent product Sale or in use, the storage medium that above computer can be read can be stored in.Based on such understanding, skill of the invention The part or all or part of the technical scheme that art scheme substantially contributes to prior art in other words can be with soft The form of part product is embodied, and the computer software product is stored in storage medium, including some instructions are causing one Platform or multiple stage computers equipment (can be personal computer, server or network equipment etc.) perform each embodiment institute of the present invention State all or part of step of method.
In the above embodiment of the present invention, the description to each embodiment all emphasizes particularly on different fields, and does not have in some embodiment The part of detailed description, it may refer to the associated description of other embodiment.
In several embodiments provided herein, it should be understood that disclosed client, can be by others side Formula is realized.Wherein, device embodiment described above is only schematical, such as the division of the unit, and only one Kind of division of logic function, can there is an other dividing mode when actually realizing, for example, multiple units or component can combine or Another system is desirably integrated into, or some features can be ignored, or do not perform.It is another, it is shown or discussed it is mutual it Between coupling or direct-coupling or communication connection can be INDIRECT COUPLING or communication link by some interfaces, unit or module Connect, can be electrical or other forms.
The unit illustrated as separating component can be or may not be physically separate, show as unit The part shown can be or may not be physical location, you can with positioned at a place, or can also be distributed to multiple On NE.Some or all of unit therein can be selected to realize the mesh of this embodiment scheme according to the actual needs 's.
In addition, each functional unit in each embodiment of the present invention can be integrated in a processing unit, can also That unit is individually physically present, can also two or more units it is integrated in a unit.Above-mentioned integrated list Member can both be realized in the form of hardware, can also be realized in the form of SFU software functional unit.
Described above is only the preferred embodiment of the present invention, it is noted that for the ordinary skill people of the art For member, under the premise without departing from the principles of the invention, some improvements and modifications can also be made, these improvements and modifications also should It is considered as protection scope of the present invention.

Claims (12)

  1. A kind of 1. function Compilation Method, it is characterised in that including:
    The second function for being compiled to obtain to first function is hooked into self-defined proxy function, function call is obtained and refers to Pin, wherein, the first function be using the first programming language write by hooking function, the code in the second function is permitted Perhaps directly performed by CPU, the function call pointer is used to call the second function;
    The function call pointer is registered, to cause the function call pointer to be allowed to first programming language The code call write;
    Refer to and is compiled for the 3rd function using the function call by registration, obtain the 4th function, wherein, described the Three functions include being used for the code for calling the first function, and the 3rd function is to be write using first programming language Self-defined hooking function, the code in the 4th function allows directly to be performed by CPU.
  2. 2. according to the method for claim 1, it is characterised in that in the function call pointer using by registration After being compiled to the 3rd function, methods described also includes:
    Operation requests are received, wherein, the operation requests are used to ask to carry out intended application scheduled operation, and the target should Write to obtain with using first programming language;
    During responding the operation requests and carrying out the scheduled operation to the intended application, when the first function quilt When request performs, the 4th function is jumped to, to perform the 4th function.
  3. 3. according to the method for claim 1, it is characterised in that it is described first function will be compiled to obtain second Before function is hooked into self-defined proxy function, methods described also includes:
    The first function is obtained in predetermined procedure set according to the mark of the first function.
  4. 4. according to the method for claim 3, it is characterised in that the mark according to the first function is in predetermined journey Sequence concentrates the acquisition first function to include:
    Following operation is performed to each procedure set, wherein, described program collection is marked as present procedure when performing following operate Collection:In the case where the mark of the present procedure collection matches with predetermined mark, concentrated from the present procedure and determine to make a reservation for Class, and determine the first function from the predetermined class.
  5. 5. method according to any one of claim 1 to 4, it is characterised in that first programming language is C#, described The code in code and the 4th function in second function is Native codes.
  6. A kind of 6. function Compilation Method, it is characterised in that including:
    First function is compiled to obtain second function, wherein, the first function is write using the first programming language By hooking function, the code in the second function allows directly to be performed by CPU;
    3rd function is compiled to obtain the 4th function, wherein, the 3rd function includes being used to call first letter Several first codes, the 3rd function are the self-defined hooking function write using first programming language, the described 4th Code in function allows directly to be performed by CPU;
    The first code is compiled to obtain second code, wherein, the second code allows directly to be performed by CPU;
    The second function is hooked into the 4th function, obtains function call pointer, wherein, the function call pointer is used In the calling second function;
    The second code is hooked into the second function indicated by the function call pointer.
  7. 7. according to the method for claim 6, it is characterised in that the second code is hooked into the function tune described After the second function indicated by pointer, methods described also includes:
    Operation requests are received, wherein, the operation requests are used to ask to carry out intended application scheduled operation, and the target should Write to obtain with using first programming language;
    During responding the operation requests and carrying out the scheduled operation to the intended application, when the first function quilt When request performs, the 4th function is jumped to, to perform the 4th function.
  8. 8. according to the method for claim 6, it is characterised in that first function is compiled to obtain second function described Before, methods described also includes:
    The first function is obtained in predetermined procedure set according to the mark of the first function.
  9. 9. according to the method for claim 8, it is characterised in that the mark according to the first function is in predetermined journey Sequence concentrates the acquisition first function to include:
    Following operation is performed to each procedure set, wherein, described program collection is marked as present procedure when performing following operate Collection:In the case where the mark of the present procedure collection matches with predetermined mark, concentrated from the present procedure and determine to make a reservation for Class, and determine the first function from the predetermined class.
  10. 10. the method according to any one of claim 6 to 9, it is characterised in that first programming language is C#, institute It is Native codes to state the code in code and the 4th function in second function.
  11. A kind of 11. function compilation device, it is characterised in that including:
    Latch hook unit, for the second function for being compiled to obtain to first function to be hooked into self-defined proxy function, obtain To function call pointer, wherein, the first function be using the first programming language write by hooking function, second letter Code in number allows directly to be performed by CPU, and the function call pointer is used to call the second function;
    Registering unit, for the function call pointer to be registered, to cause the function call pointer to be allowed to use institute State the code call that the first programming language is write;
    Compilation unit, it is compiled for being referred to using the function call by registration for the 3rd function, obtains the 4th letter Number, wherein, the 3rd function includes being used for calling the code of the first function, and the 3rd function is use described the The self-defined hooking function that one programming language is write, the code in the 4th function allow directly to be performed by CPU.
  12. A kind of 12. function compilation device, it is characterised in that including:
    First compilation unit, for being compiled to obtain second function to first function, wherein, the first function is to use the One programming language write by hooking function, the code in the second function allows directly to be performed by CPU;
    Second compilation unit, for being compiled to obtain the 4th function to the 3rd function, wherein, the 3rd function includes using In the first code for calling the first function, the 3rd function is the self-defined extension write using first programming language Hook function, the code in the 4th function allow directly to be performed by CPU;
    3rd compilation unit, for the first code to be compiled to obtain second code, wherein, the second code allows Directly performed by CPU;
    First latch hook unit, for the second function to be hooked into the 4th function, function call pointer is obtained, wherein, The function call pointer is used to call the second function;
    Second latch hook unit, for the second code to be hooked into second letter indicated by the function call pointer Number.
CN201710555363.5A 2017-07-07 2017-07-07 Function Compilation Method and device Active CN107391219B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710555363.5A CN107391219B (en) 2017-07-07 2017-07-07 Function Compilation Method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710555363.5A CN107391219B (en) 2017-07-07 2017-07-07 Function Compilation Method and device

Publications (2)

Publication Number Publication Date
CN107391219A true CN107391219A (en) 2017-11-24
CN107391219B CN107391219B (en) 2018-09-18

Family

ID=60335328

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710555363.5A Active CN107391219B (en) 2017-07-07 2017-07-07 Function Compilation Method and device

Country Status (1)

Country Link
CN (1) CN107391219B (en)

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108345458A (en) * 2018-01-25 2018-07-31 微梦创科网络科技(中国)有限公司 A kind of call method and system of static compilation language and script
CN108415739A (en) * 2018-02-28 2018-08-17 腾讯科技(深圳)有限公司 A kind of the hook method, apparatus and storage medium of Dynamic Link Library Function
CN108845841A (en) * 2018-06-15 2018-11-20 广州多益网络股份有限公司 Change the method, apparatus and terminal of terminal applies behavior
CN111124795A (en) * 2018-11-01 2020-05-08 百度在线网络技术(北京)有限公司 Application start monitoring method, device and equipment
CN111240856A (en) * 2020-01-03 2020-06-05 北京小米移动软件有限公司 Message processing method and device and storage medium
CN112416366A (en) * 2019-08-23 2021-02-26 华为技术有限公司 Method, device and equipment for dynamically hooking Java language hooks
CN111240856B (en) * 2020-01-03 2024-04-23 北京小米移动软件有限公司 Message processing method and device and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070113282A1 (en) * 2005-11-17 2007-05-17 Ross Robert F Systems and methods for detecting and disabling malicious script code
US20070261044A1 (en) * 2006-05-04 2007-11-08 Jonathan Clark Chained Hook Function Serving Multiple Versions Of Identically Named Dynamically Loaded Libraries
US20090204980A1 (en) * 2008-02-11 2009-08-13 Blue Coat Systems, Inc. Method for implementing ejection-safe API interception
CN102867142A (en) * 2012-08-22 2013-01-09 四川长虹电器股份有限公司 Android-system-based safety protection method
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

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070113282A1 (en) * 2005-11-17 2007-05-17 Ross Robert F Systems and methods for detecting and disabling malicious script code
US20070261044A1 (en) * 2006-05-04 2007-11-08 Jonathan Clark Chained Hook Function Serving Multiple Versions Of Identically Named Dynamically Loaded Libraries
US20090204980A1 (en) * 2008-02-11 2009-08-13 Blue Coat Systems, Inc. Method for implementing ejection-safe API interception
CN102867142A (en) * 2012-08-22 2013-01-09 四川长虹电器股份有限公司 Android-system-based safety protection method
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

Cited By (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108345458A (en) * 2018-01-25 2018-07-31 微梦创科网络科技(中国)有限公司 A kind of call method and system of static compilation language and script
CN108345458B (en) * 2018-01-25 2021-04-09 微梦创科网络科技(中国)有限公司 Calling method and system for static compiling language and scripting language
CN108415739A (en) * 2018-02-28 2018-08-17 腾讯科技(深圳)有限公司 A kind of the hook method, apparatus and storage medium of Dynamic Link Library Function
CN108415739B (en) * 2018-02-28 2020-04-14 腾讯科技(深圳)有限公司 Hook method and device for dynamic link library function and storage medium
CN108845841A (en) * 2018-06-15 2018-11-20 广州多益网络股份有限公司 Change the method, apparatus and terminal of terminal applies behavior
CN111124795A (en) * 2018-11-01 2020-05-08 百度在线网络技术(北京)有限公司 Application start monitoring method, device and equipment
CN111124795B (en) * 2018-11-01 2024-03-26 百度在线网络技术(北京)有限公司 Application starting monitoring method, device and equipment
CN112416366A (en) * 2019-08-23 2021-02-26 华为技术有限公司 Method, device and equipment for dynamically hooking Java language hooks
CN111240856A (en) * 2020-01-03 2020-06-05 北京小米移动软件有限公司 Message processing method and device and storage medium
CN111240856B (en) * 2020-01-03 2024-04-23 北京小米移动软件有限公司 Message processing method and device and storage medium

Also Published As

Publication number Publication date
CN107391219B (en) 2018-09-18

Similar Documents

Publication Publication Date Title
CN107391219B (en) Function Compilation Method and device
CN103927253B (en) Multiple browser compatibility testing method and system
CN110134386B (en) Program editing method and device
CN109697060B (en) Video special effect system, generation method, device, equipment and storage medium thereof
US8296736B2 (en) Automated business process testing that spans multiple platforms or applications
JP5171790B2 (en) Information processing apparatus, communication system, and program
US20130298110A1 (en) Software Visualization Using Code Coverage Information
US20050188262A1 (en) Simultaneous execution of test suites on different platforms
US11422785B2 (en) Container orchestration framework
CN110362490B (en) Automatic testing method and system for integrating iOS and Android mobile applications
CN109308241A (en) Monitor application program launching flow and method, device, terminal device and storage medium
CN108614767A (en) A kind of remote debugging method and device
CN109800135A (en) A kind of information processing method and terminal
CN107122219A (en) The acquisition methods and device of installation file
CN111444103A (en) Automatic testing method for Web page and related equipment
CN113296758B (en) Front-end component library construction method and device and storage medium
CN112090079B (en) Game task running method and device, computer equipment and storage medium
CN112306471A (en) Task scheduling method and device
US8745587B2 (en) System and method for testing computer programs
JP2018045619A (en) Analysis program, analysis method, and analysis device
EP1027652A1 (en) Apparatus and method for logging information relating to function calls to a function library
CN107193734B (en) Playback method and playback system for mobile Web applications
CN111078209B (en) Development processing method, device and equipment for business page
Weiss et al. Automated integration tests for mobile applications in java 2 micro edition
CN107885659A (en) Method and device, the equipment of request analog response to client

Legal Events

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