CN107391219B - Function Compilation Method and device - Google Patents

Function Compilation Method and device Download PDF

Info

Publication number
CN107391219B
CN107391219B CN201710555363.5A CN201710555363A CN107391219B CN 107391219 B CN107391219 B CN 107391219B CN 201710555363 A CN201710555363 A CN 201710555363A CN 107391219 B CN107391219 B CN 107391219B
Authority
CN
China
Prior art keywords
function
code
write
compiled
programming language
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.)
Active
Application number
CN201710555363.5A
Other languages
Chinese (zh)
Other versions
CN107391219A (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

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Devices For Executing Special Programs (AREA)
  • Stored Programmes (AREA)

Abstract

The invention discloses a kind of function Compilation Method and devices.This method includes:Obtain function call pointer by being hooked into self-defined proxy function to the second function that first function is compiled, first function be using the first programming language write by hooking function, function call pointer is for calling 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 is compiled to obtain the 4th function for third function, third function includes the code for calling first function, third function is the self-defined hooking function write using the first programming language, and the code permission in the code and the 4th function in second function is directly executed by CPU.The present invention is solved the relevant technologies self-defined Hook functions when carrying out Hook to function and must be write using C/C++, and the higher technical problem of development cost of self-defined Hook functions is caused.

Description

Function Compilation Method and device
Technical field
The present invention relates to computer realms, 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 be indicated by the tune of Hook functions by the function of Hook functions namely the function pointer With.
Hook technologies can be applied to test etc. in fields, for example, Fig. 1 is the 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 at Native codes, wherein IL codes are .Net languages Bytecode after speech compiling, Native codes are the code that can be directly executed by CPU.
2. JIT completion notice events are arranged:The interface mono_profiler_set_events provided with Mono is to setting There is the call back function for notifying that user-defined JIT completes event when JIT completions.
3. monitoring all functions by JIT:It completes 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. implementing 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 insufficient:Login mechanism leads to time that the function before registration with regard to JIT is never notified that JIT is completed Letter of transfer number.
Second point is insufficient:Customized Hook functions are write with C/C++.
For first point of deficiency, the primary premises of JIT are only understood to the same C# functions based on Mono at runtime, then The just C# functions of JIT 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.
For second point deficiency, when developer wants to making some modifications in logic by Hook functions, often It is the object for needing to operate C#, if this when writes the object that code removes operation C# with C/C++, 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 the C/C++ and C# of very familiar Mono Code interactive basis can just be write.And when to wanting to write extremely complex logic, it is answered with C/C++ to complete script C# The thing of the completion is very difficult.
For above-mentioned problem, currently no effective solution has been proposed.
Invention content
An embodiment of the present invention provides a kind of function Compilation Method and device, at least solve the relevant technologies to function into Self-defined Hook functions must be write using C/C++ when row Hook, lead to the higher skill of development cost of self-defined Hook functions Art problem.
One side according to the ... of the embodiment of the present invention provides a kind of function Compilation Method, including:Will to first function into The second function that row compiling obtains hooks 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 permission in second function is directly executed by CPU, function call pointer For calling second function;Function call pointer is registered, so that function call pointer is allowed to call;Utilize process The function call of registration refers to be compiled for third function, obtains the 4th function, wherein third function includes for calling The code of first function, third function are the self-defined hooking function write using the first programming language, the generation in the 4th function Code allows directly to be executed by CPU.
Another aspect according to the ... of the embodiment of the present invention additionally provides a kind of function Compilation Method, including:To first function into Row compiling obtains second function, wherein first function be using the first programming language write by hooking function, in second function Code permission directly executed by CPU;Third function is compiled to obtain the 4th function, wherein third function includes using In the first code for calling first function, third function is the self-defined hooking function write using the first programming language, the 4th Code permission in function is directly executed by CPU;First code is compiled to obtain second code, wherein second code permits Perhaps it is directly executed 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 the ... of the embodiment of the present invention additionally provides a kind of function compilation device, including:Latch hook unit is used In will be hooked into self-defined proxy function to the second function that first function is compiled, function call pointer is obtained, Wherein, first function be using the first programming language write by hooking function, the code in second function allows directly by CPU It executes, function call pointer is for calling second function;Registering unit, for function call pointer to be registered, so that Function call pointer is allowed to call;Compilation unit is carried out for being referred to using the function call by registration for third function Compiling, obtains the 4th function, wherein third function includes the code for calling first function, and third function is to use the The self-defined hooking function that one programming language is write, the code permission in the 4th function are directly executed by CPU.
Another aspect according to the ... of the embodiment of the present invention additionally provides a kind of function compilation device, including:First compiling is single Member obtains second function for being compiled to first function, wherein first function is the quilt write using the first programming language Hooking function, the code permission in second function are directly executed by CPU;Second compilation unit, for being compiled to third function It translates to obtain the 4th function, wherein third function includes the first code for calling first function, and third function is to use the The self-defined hooking function that one programming language is write, the code permission in the 4th function are directly executed by CPU;Third compiling is single Member obtains second code for first code to be compiled, wherein second code permission is directly executed by CPU;First hook Unit obtains function call pointer for second function to be hooked into the 4th function, wherein function call pointer is for calling 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 permission is directly executed 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 that utilizing Function call pointer after registration is by the third function write with C# programming languages is compiled to obtain the 4th function, to reach First function is hooked into the purpose of third function (self-defined Hook functions) (by Hook functions), and then solves the relevant technologies When carrying out Hook to function, self-defined Hook functions must be write using C/C++, cause the exploitations of self-defined Hook functions at This higher technical problem, to realize the technique effect for the development cost for reducing self-defined Hook functions.
Description of the drawings
Attached drawing described herein is used to provide further understanding of the present invention, and is constituted part of this application, this hair Bright illustrative embodiments and their description are not constituted improper limitations of the present invention for explaining the present invention.In the accompanying drawings:
Fig. 1 is the schematic diagram that the prior art uses in mobile phone games protocol test tool;
Fig. 2 is the schematic diagram of the hardware environment of function Compilation Method according to the ... of the embodiment of the present invention;
Fig. 3 is a kind of flow chart of optional function Compilation Method according to the ... of the embodiment of the present invention;
Fig. 4 is the flow chart of another optional function Compilation Method according to the ... of the embodiment of the present invention;
Fig. 5 is a kind of schematic diagram of optional tool selection engineering interface according to the ... of the embodiment of the present invention;
Fig. 6 is a kind of schematic diagram of one already existing engineering of optional selection according to the ... of the embodiment of the present invention;
Fig. 7 is the schematic diagram that engineering is opened in a kind of optional selection according to the ... of the embodiment of the present invention using VS2012;
Fig. 8 is according to the ... of the embodiment of the present invention a kind of optionally to accelerating function and the rendering real-time Hook of function being accelerated to show It is intended to;
Fig. 9 is according to the ... of the embodiment of the present invention a kind of optional self-defined button to be accelerated 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 the ... of the embodiment of the present invention;
Figure 11 is the schematic diagram that a kind of optional definition according to the ... of the embodiment of the present invention is called by the original function of Hook functions;
Figure 12 is a kind of optional schematic diagram for increasing Hook buttons according to the ... of the embodiment of the present invention;
Figure 13 is the signal that a kind of optional compiling according to the ... of the embodiment of the present invention can click operation button operation after the completion Figure;
Figure 14 is a kind of schematic diagram of optional runnable interface according to the ... of the embodiment of the present invention;
Figure 15 is a kind of optional schematic diagram for seeing operational effect in gaming according to the ... of the embodiment of the present invention;
Figure 16 is a kind of schematic diagram of the operational effect of optional displaying code according to the ... of the embodiment of the present invention;
Figure 17 is a kind of schematic diagram of optional postrun record data according to the ... of the embodiment of the present invention;
Figure 18 is a kind of schematic diagram of optional flow for obtaining designation method according to the ... of the embodiment of the present invention;
Figure 19 is a kind of optional schematic diagram for implementing Hook flows according to the ... of the embodiment of the present invention;
Figure 20 is a kind of schematic diagram of optional function compilation device according to the ... of the embodiment of the present invention;
Figure 21 is the schematic diagram of another optional function compilation device according to the ... of the embodiment of the present invention;And
Figure 22 is a kind of structure diagram of terminal according to the ... of the embodiment of the present invention.
Specific implementation mode
In order to enable those skilled in the art to better understand the solution of the present invention, below in conjunction in the embodiment of the present invention Attached drawing, technical scheme in the embodiment of the invention is clearly and completely described, it is clear that described embodiment is only The embodiment of a part of the invention, instead of all the embodiments.Based on the embodiments of the present invention, ordinary skill people The every other embodiment that member is obtained without making creative work should all belong to the model that the present invention protects It encloses.
It should be noted that term " first " in description and claims of this specification and above-mentioned attached drawing, " Two " etc. be for distinguishing similar object, without being used to describe specific sequence or precedence.It should be appreciated that using in this way Data can be interchanged in the appropriate case, so as to the embodiment of the present invention described herein can in addition to illustrating herein or Sequence other than those of description is implemented.In addition, term " comprising " and " having " and their any deformation, it is intended that cover It includes to be not necessarily limited to for example, containing the process of series of steps or unit, method, system, product or equipment to cover non-exclusive Those of clearly list step or unit, but may include not listing clearly or for these processes, method, product Or the other steps or unit that equipment is intrinsic.
First, the part noun or term occurred during the embodiment of the present invention is described is suitable for as follows It explains:
C#:C# be Microsoft publication 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 can be directly executed by CPU.
Machine code:Refer to the code that can be directly executed by CPU, 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 certain specially programming automatic generations Device code.
Hook:The function for refering in particular to oneself be write with one in this programme replaces the process of some function, which is related to 3 A function, one is by the function of Hook, 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, 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 provided when certain functions of some module need to allow other modules to call is provided.
TPA:The protocol test tool used inside Tencent.
Protocol test:It refers to being surveyed in face of the program of client/server type in Web communication layer in this programme Examination.
JIT:The process that Mono carries out on-the-flier compiler into Native codes to IL codes at runtime is refered in particular in this programme.
Apk:The format of the executable program installation kit of the open source operating system Android of Google's publication.
Visual Studio:The developing instrument that Microsoft delivers is a set of Integrated Development Environment.
It renders: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:Refer to the relevant Hook processes of CPU, the CPU of ARM and Intel for current mainstream 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, a kind of embodiment of the method for function Compilation Method is provided.
Optionally, in the present embodiment, above-mentioned function Compilation Method can be applied to as shown in Figure 2 by server 102 In the hardware environment constituted with terminal 104.As shown in Fig. 2, server 102 is attached by network and terminal 104, it is above-mentioned Network includes but not limited to:Wide area network, Metropolitan Area Network (MAN) or LAN, terminal 104 are not limited to PC, mobile phone, tablet computer etc..This The function Compilation Method of inventive embodiments can be executed by server 102, can also be executed, be can also be by terminal 104 It is executed 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 executed 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 the ... of the embodiment of the present invention, as shown in figure 3, the party Method may comprise steps of:
Step S202 will hook into self-defined proxy function the second function that first function is compiled, obtain 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 executed by CPU, and function call pointer is for calling second function;
Step S204 registers function call pointer, so that function call pointer is allowed to the first programming language Say the code call write;
Step S206 is referred to using the function call by registration and is compiled for third function, obtains the 4th function, In, third function includes the code for calling first function, and third function is to be made by oneself using what the first programming language was write Adopted hooking function, the code permission in the 4th function are directly executed by CPU.
Above-mentioned steps S202 to step S206 obtains by being compiled to the first function write with C# programming languages Two functions, wherein the code in second function is Native codes, and permission is directly executed 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, so that It is compiled the third function write with C# programming languages to obtain the 4th function using the function call pointer after registration, to reach To first function to be hooked into the purpose of third 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++, lead to the exploitation of self-defined Hook functions The higher technical problem of cost, to realize the technique effect for the development cost for reducing self-defined Hook functions.
In the technical solution 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 the function of first function, and first Function can actual demand is write with C# according to the function with arbitrary function.Being compiled to first function can obtain Second function, wherein the code permission in second function is directly executed by CPU, and optionally, the code in second function can be Native codes.The function of second function is identical as the function of first function, and it is different to differ only in code form.Actually answering With in scene, the interface mono_compile_method compiling first functions of Mono offers may be used in the embodiment of the present invention Method pointer obtains the function pointer of second function, compiles to obtain the purpose of second function to first 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 the hook in the embodiment of the present invention namely Hook, wherein the generation in self-defined proxy function Code also allows directly to be executed by CPU, and optionally, the code in self-defined proxy function may be Native codes.By second Function, which hooks into self-defined proxy function, may be used Native Hook modes, and 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 It is interpreted as the address that the function call pointer can be directed toward where the code segment of second function, passing through the function call pointer Second function is called to realize.
In the technical solution that step S204 is provided, obtain being used to indicate the function call pointer for calling second function it Afterwards, in order to enable the function call pointer allows to be called, the embodiment of the present invention needs to register on the function call pointer, Specifically, the interface mono_add_internal_call that Mono offers may be used notes the function call pointer to C# layers Volume allows it to be called at C# layers, namely the generation that function call pointer is write with the first programming language C# Code calls.
In the technical solution that step S206 is provided, third 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 the function of third function, Third function can actual demand is write with C# according to the function with arbitrary function.Third letter in the embodiment of the present invention It may include the code for calling first function in number, when being compiled to third function, be used to indicate if do not known in advance The pointer of first function address, being compiled when being compiled to third function will report an error, in order to enable the compiling of third function has Effect, needs of the embodiment of the present invention are referred to using the function call after registration to be compiled for third function, wherein the letter after registration Number calls pointer that can allow called and can serve to indicate that calling first function, ensures that the volume of third function in this way It translates effectively.
The 4th function can be obtained by being compiled to third function, wherein the code in the 4th function allows directly by CPU It executes, optionally, the code in the 4th function may be Native codes.The function of the function and third function of 4th function It is identical, it is different to differ only in code form.In practical application scene, the embodiment of the present invention can also use Mono to provide The method pointer of interface mono_compile_method compiling third function obtains the function pointer of the 4th function, to realize pair Third function compiles to obtain the purpose of the 4th function.
It should be noted that using the function call after registration refer to for third function compile to obtain the 4th function it Afterwards, it can realize and second function is linked up with to first function hook in third function, namely at Native layers at C# layers In 4th function, in this way when needing to execute first function, COU can jump to the 4th function, to execute the 4th function.
As a kind of optional embodiment, the second function being compiled to first function is linked up in step S202 To before in self-defined proxy function, which can also include:According to the mark of first function in scheduled procedure set Obtain first function.
It should be noted that scheduled procedure set can be multiple procedure sets, wherein there are one each procedure set corresponds to Unique program set identifier.It may include multiple classes in each procedure set, may 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.
Optionally, first function is obtained in scheduled procedure set according to the mark of first function may include:To each Procedure set executes following operation, wherein procedure set is marked as present procedure collection when executing following operation:In present procedure collection Mark match with predetermined mark in the case of, concentrated from present procedure and determine scheduled class, and determined from scheduled class First function.
It should be noted that the embodiment can traverse multiple scheduled procedure sets, and obtain multiple scheduled procedure sets Mark, when the mark of one of procedure set matches with predetermined mark, which can determine from the procedure set Scheduled class, and scheduled method is determined from scheduled class, namely the first function that needs.
The embodiment may be implemented to obtain the purpose of first function in real time by above-mentioned dynamical fashion, can avoid carrying on the back in this way First point in the prior art that scape technology segment is previously mentioned is insufficient, so reach the coverage area for improving function Hook 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 third function) It acquires, namely can also concentrate acquisition third function specifically can be right from preset program according to the mark of third function Each procedure set executes following operation, wherein procedure set is marked as present procedure collection when executing following operation:Working as future In the case that the mark of sequence collection matches with predetermined mark, is concentrated from present procedure and determine scheduled class, and from scheduled class Determine third function.Herein it is noted that the mark of third function can be different from the mark of first function, third function is obtained When institute preassigned predetermined mark can also be different from institute's preassigned predetermined mark when obtaining first function.
As a kind of optionally embodiment, it is compiled for third function being referred to using the function call by registration, After being hooked into first function in third function with realization, which can also include the following steps:
Step S208, receives operation requests, wherein and operation requests carry out predetermined operation for asking to intended application, Intended application is write to obtain using the first programming language;
Step S210, during responding operation requests to intended application progress predetermined operation, when first function is asked When asking execution, the 4th function is jumped to, to execute 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 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 Predetermined operation is carried out to intended application, wherein the type of the predetermined operation embodiment is also not specifically limited, such as predetermined operation Can test etc. the performance (such as response time) of intended application.
After receiving operation requests, which can respond thereto, to carry out predetermined behaviour to intended application Make, it should be noted that during carrying out predetermined operation to intended application, when needing to execute the in the embodiment of the present invention When one function, since first function has been linked up in third function, and volume also has been carried out in first function and third function It translates, CPU can then jump directly to the 4th function, to execute the 4th function.Due to including calling first function in third function Code, therefore CPU may be implemented when executing four functions by the function of hooking function (first function) script.
It should be noted that the concrete application scene of the embodiment can be with specific reference to provided in the following contents 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, so that in intended application operational process, when needing to execute by hooking function, are passed through Self-defined hooking function is jumped to execute self-defined hooking function, to realize other functions except 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 another optional function Compilation Method according to the ... of the embodiment of the present invention, as shown in figure 4, should Method may comprise steps of:
Step S302 is compiled first function to obtain second function, wherein first function is to use the first programming language Say write by hooking function, the code permission in second function is directly executed by CPU;
Step S304 is compiled third function to obtain the 4th function, wherein third function includes for calling the The first code of one function, third function are the self-defined hooking function write using the first programming language, in the 4th function Code permission is directly executed by CPU;
First code is compiled to obtain second code by step S306, wherein second code permission is directly held by CPU Row;
Second function is hooked into the 4th function, obtains function call pointer, wherein function call pointer by step S308 For calling second function;
Second code is hooked into the second function indicated by function call pointer by step S310.
Above-mentioned steps S302 to step S310, by with C# programming languages write by hooking function (first function) into Row compiling obtains second function, and to the self-defined hooking function write with C# programming languages, (third function, third 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 executed by CPU, then first code is compiled to obtain second code, then pass through Second code is hooked into the second letter hooked into second function in the 4th function indicated by obtained function call pointer In number, it can realize and hook into second function in the 4th function, and then reach and link up with first function (by Hook functions) To the purpose of third function (self-defined Hook functions), and then it is self-defined when carrying out Hook to function to solve the relevant technologies Hook functions must be write using C/C++, lead to the higher technical problem of development cost of self-defined Hook functions, to realize The technique effect of the development cost of the self-defined Hook functions of reduction.
It should be noted that function Compilation Method shown in Fig. 4 is identical with Compilation Method principle shown in Fig. 3, be for It realizes and hooks into first function in third function, need to be compiled it, and second function will be called at Native layers Function call pointer notify in the 4th function so that need execute first function when, the 4th function can be jumped to, To execute the 4th function, and it can realize the function of first function script.Shown in function Compilation Method shown in Fig. 4 and Fig. 3 Compilation Method differ only in the 4th function notice for calling mode that the function call of second function indicates not Together.
It will describe in detail below to each step in function Compilation Method shown in Fig. 4, specifically:
In the technical solution 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 the function of first function, and first Function can actual demand is write with C# according to the function with arbitrary function.Being compiled to first function can obtain Second function, wherein the code permission in second function is directly executed by CPU, and optionally, the code in second function can be Native codes.The function of second function is identical as the function of first function, and it is different to differ only in code form.Actually answering With in scene, the interface mono_compile_method compiling first functions of Mono offers may be used in the embodiment of the present invention Method pointer obtains the function pointer of second function, compiles to obtain the purpose of second function to first function to realize.
In the technical solution that step S304 is provided, third 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 the function of third function, Third function can actual demand is write with C# according to the function with arbitrary function.Third letter in the embodiment of the present invention It may include the first code for calling first function in number, when going to first code, may be implemented to call first function Purpose.The 4th function can be obtained by being compiled to third function, wherein the code permission in the 4th function is directly held by CPU Row, optionally, the code in the 4th function may be Native codes.The function of 4th function and the function phase of third function Together, it is different to differ only in code form.In practical application scene, the embodiment of the present invention can also use connecing for Mono offers The method pointer of mouthful mono_compile_method compiling third 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 to enable can then be needed with normal call second function when executing four functions Function call pointer of the notice for calling second function, can specifically be carried by step S306 to step S310 in four functions The scheme of confession, specifically:
In the technical solution that step S306 is provided 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 second code is identical with the function of first code, can indicate to call the first letter Number, but the code form of the two is different.
The embodiment of the present invention is compiling first function to obtain second function, is compiling to obtain the 4th function to third function Later, second function can be hooked into the 4th function first, to obtain a function call pointer, wherein the function tune 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 can not successfully call second function when executing four functions, and therefore, it is necessary to will be compiled to first code in step S306 Obtained second code hooks into second function, namely executes technical solution shown in step S310, to make 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 executing four functions , first function is hooked into third function to further realize.
It, should before step S302 is compiled to obtain second function to first function as a kind of optional embodiment Embodiment can also include:According to the mark of first function first function is obtained in scheduled procedure set.
It should be noted that scheduled procedure set can be multiple procedure sets, wherein there are one each procedure set corresponds to Unique program set identifier.It may include multiple classes in each procedure set, may 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.
Optionally, first function is obtained in scheduled procedure set according to the mark of first function may include:To each Procedure set executes following operation, wherein procedure set is marked as present procedure collection when executing following operation:In present procedure collection Mark match with predetermined mark in the case of, concentrated from present procedure and determine scheduled class, and determined from scheduled class First function.
It should be noted that the embodiment can traverse multiple scheduled procedure sets, and obtain multiple scheduled procedure sets Mark, when the mark of one of procedure set matches with predetermined mark, which can determine from the procedure set Scheduled class, and scheduled method is determined from scheduled class, namely the first function that needs.
The embodiment may be implemented to obtain the purpose of first function in real time by above-mentioned dynamical fashion, can avoid carrying on the back in this way First point in the prior art that scape technology segment is previously mentioned is insufficient, so reach the coverage area for improving function Hook 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 third function) It acquires, namely can also concentrate acquisition third function specifically can be right from preset program according to the mark of third function Each procedure set executes following operation, wherein procedure set is marked as present procedure collection when executing following operation:Working as future In the case that the mark of sequence collection matches with predetermined mark, is concentrated from present procedure and determine scheduled class, and from scheduled class Determine third function.Herein it is noted that the mark of third function can be different from the mark of first function, third function is obtained When institute preassigned predetermined mark can also be different from institute's preassigned predetermined mark when obtaining first function.
As a kind of optionally embodiment, second code is being hooked into the second function indicated by function call pointer, After being hooked into first function in third function with realization, which can also include the following steps:
Step S312, receives operation requests, wherein and operation requests carry out predetermined operation for asking to intended application, Intended application is write to obtain using the first programming language;
Step S314, during responding operation requests to intended application progress predetermined operation, when first function is asked When asking execution, the 4th function is jumped to, to execute 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 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 Predetermined operation is carried out to intended application, wherein the type of the predetermined operation embodiment is also not specifically limited, such as predetermined operation Can test etc. the performance (such as response time) of intended application.
After receiving operation requests, which can respond thereto, to carry out predetermined behaviour to intended application Make, it should be noted that during carrying out predetermined operation to intended application, when needing to execute the in the embodiment of the present invention When one function, since first function has been linked up in third function, and volume also has been carried out in first function and third function It translates, CPU can then jump directly to the 4th function, to execute the 4th function.Due to including calling first function in third function Code, therefore CPU may be implemented when executing four functions by the function of hooking function (first function) script.
It should be noted that the concrete application scene of the embodiment can be with specific reference to provided in the following contents 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, so that in intended application operational process, when needing to execute by hooking function, are passed through Self-defined hooking function is jumped to execute self-defined hooking function, to realize other functions except 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 may be implemented to use What C# programming languages were write is hooked into the purpose in the self-defined hooking function write with C# programming languages by hooking function, in turn It solves the relevant technologies self-defined Hook functions when carrying out Hook to function to write using C/C++, cause self-defined The higher technical problem of development cost of Hook functions, to realize the technology for the development cost for reducing self-defined Hook functions Effect.
The present invention also provides 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, which 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 call in self-defined Hook functions and be realized by Hook functions By the function of Hook functions, the core technology of the program uses the on-the-flier compiler interfaces of Mono offers by IL codes at runtime Native codes are compiled into, then to Native code implementation Hook, to reach the function of carrying out Hook to C# codes.
By the technology final encapsulation at a C# layer interface, which directly uses this programme for developer, because This programme is all encapsulated the technology of all bottoms, thus developer can not have to write C/C++ codes can be right C# functions carry out Hook, in this embodiment it is not even necessary to understand internal principle.
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 " tool, transported to complete to monitor and change Unity game Function when row.Now the tool process for using is described below:
Fig. 5 is a kind of schematic diagram of optional tool selection engineering interface according to the ... of the embodiment of the present invention, as shown in figure 5, Opening tool selects an Apk as the game debugged, as shown in figure 5, click can automatically generate after starting Visual Studio engineerings.
Fig. 6 is a kind of schematic diagram of one already existing engineering of optional selection according to the ... of the embodiment of the present invention, such as Fig. 6 It is shown, tool is used if it is second, then already existing engineering can be selected in combobox.
Fig. 7 is the schematic diagram that engineering is opened in a kind of optional selection according to the ... of the embodiment of the present invention using VS2012, such as Fig. 7 It is shown, it is clicked after choosing and proceeds 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, introduces the technology and apply the application in the game, this example is to test game server It is example to accelerate the response time of operation to client, other codes unrelated with this programme are not put up in this example.
Fig. 8 is according to the ... of the embodiment of the present invention a kind of optionally to accelerating function and the rendering real-time Hook of function being accelerated 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 accelerating start corresponding accelerations rendering function SnakeRenderer.set_IsAcc into Row Hook.
It writes by the custom function of Hook functions, is executed in gaming by Hook functions to replace, self-defined acceleration Button presses minor function as shown in figure 9, self-defined acceleration rendering function is 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 that one kind according to the ... of the embodiment of the present invention is optional Self-defined acceleration render function schematic diagram.
Figure 11 is the schematic diagram that a kind of optional definition according to the ... of the embodiment 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, be somebody's turn to do Function is transmitted to cshook.cshook.Hook as the last one parameter.
Figure 12 is that a kind of optional schematic diagram for increasing Hook buttons according to the ... of the embodiment of the present invention is as shown in figure 12 This Hook function increases a button, and Hook is executed can click by hand in gaming.
Figure 13 is the signal that a kind of optional compiling according to the ... of the embodiment of the present invention can click operation button operation after the completion Figure, Figure 14 is a kind of schematic diagram of optional runnable interface according to the ... of the embodiment of the present invention, as shown in Figure 13 and Figure 14, is completed simultaneously After compiled, return to the real-time debugging acids of Unity and click operation button.
Figure 15 is a kind of optional schematic diagram for seeing operational effect in gaming according to the ... of the embodiment of the present invention, such as Figure 15 It is shown, it, can be in upper left corner meeting there are one marking on a map as the button of start hook after tool operation.
Figure 16 is a kind of schematic diagram of the operational effect of optional displaying code according to the ... of the embodiment 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, which identifies one with an ID The record of a delay data, wherein Delay field records is that (My_OnPointerDown2 functions are opened from acceleration button is pressed Begin to execute) to the time for accelerating rendering to start (My_set_IsAcc2 functions start to execute), because the preferred embodiment is with one For a online game, game client can't directly carry out acceleration rendering when pressing accelerator key, but go to take Business device verify whether to accelerate it is later return again to client one can accelerate as a result, client is made whether acceleration again It renders;RTT field records be client and server delay, the two values, which are subtracted each other, can be obtained by server and is really delayed There are very high directive function in time, the time to the server performance optimization of the game.
Figure 18 is a kind of schematic diagram of optional flow for obtaining designation method according to the ... of the embodiment of the present invention, such as Figure 18 institutes Show, the mode that this programme is taken is that dynamic access is summarized as follows by the address of Hook functions, acquisition modes at runtime:
1. with all procedure sets of the Mono interface mono_assembly_foreach traversal loads provided.
2. the interface mono_image_get_name provided with Mono obtains the name for the procedure set being traversed.
3. being the procedure set name that developer specifies according to name determining program collection.
4. being obtained with Mono the interface mono_class_from_name and mono_class_get_method_name provided The specified needs of originator are taken away by the pointer of Hook functions.
Figure 19 is a kind of optional schematic diagram for implementing Hook flows according to the ... of the embodiment of the present invention, as shown in figure 19, this The techniqueflow that scheme implements Hook is as follows:
1. obtaining the method by Hook functions and self-defined Hook functions that developer provides 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 Needle obtains the function pointer of Native codes.
3. with obtaining carrying out Hook by Hook functions in Native Hook couple 2, by its Hook to self-defined proxy function In.
4. calling the interface mono_add_internal_call that pointer is provided with Mono to C# the original function obtained in 3 Layer registration can be called at 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 setting 5 in self-defined proxy function.
It should be noted that the proxy_mem_des in this flow is inherently the block number evidence in memory, this block Data special service is in some Hook process, since it is desired that will apply for such one piece of memory, this block for each Hook processes What is put inside memory is machine code, this part machine code completion simply redirects work, and the destination redirected is exactly desptr, this It needs to be called with the system of related platform after data configuration inside block memory is good and this block memory is set to executable state.
The maximum gain effect of this programme is C# written in code can be used by the logic of Hook functions, and can only use C/ in the past C++ writes, this facility is because the development language that present Unity plays is exactly C#, if writing self-defined Hook with C/C++ C/C++ and C# deals with extremely complex there are prodigious difference on data exchange if function, this is to development efficiency It is obviously improved.
It should also be noted that, Mono can only compile some method once during primary operation 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, since the self-defined Hook methods for having used original function to call in self-defined Hook functions and compiling being caused to obtain obtain Native functions have abnormal, which is that can not find original function calling, by the calling of original function to C# after instant Hook Layer registration, has been compiled once, Mono can directly return aforementioned compiled in view of self-defined Hook functions Native code pointers.
Based on above special circumstances, actually there are many kinds of schemes can bypass this technological difficulties, above-mentioned Figure 19 institutes The scheme shown is the highest scheme of efficiency, in addition to this can also have following alternative solution, can specifically be described as:It can be On the basis of technical solution shown in Figure 19, the function called to the original function that developer provides is compiled to obtain Native generations Code pointer, be denoted as old_code_addr, directly invoke at this time old_code_addr have it is abnormal, it is therefore desirable to by this It is gone in the function pointer for the Native codes that the 5th step obtains in technical solution shown in Hook to the Figure 19 of address.
It should be noted that for each method embodiment above-mentioned, for simple description, therefore it is all expressed as a series of Combination of actions, but those skilled in the art should understand that, the present invention is not limited by the described action sequence because According to the present invention, certain steps can be performed in other orders or simultaneously.Secondly, those skilled in the art should also know It knows, 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 it is very much In the case of the former be more preferably embodiment.Based on this understanding, technical scheme of the present invention is substantially in other words to existing The part that technology contributes can be expressed in the form of software products, which is stored in a storage In medium (such as ROM/RAM, magnetic disc, CD), including some instructions are used so that a station terminal equipment (can be mobile phone, calculate Machine, server or network equipment etc.) execute 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 implementing above-mentioned function Compilation Method is additionally provided.
Figure 20 is a kind of schematic diagram of optional function compilation device according to the ... of the embodiment of the present invention, as shown in figure 20, should Device may include:
Latch hook unit 22, for self-defined proxy function will to be hooked into the second function that first function is compiled In, obtain function call pointer, wherein first function be using the first programming language write by hooking function, second function In code permission directly executed by CPU, function call pointer is for calling second function;Registering unit 24 is used for function Pointer is called to be registered, so that function call pointer is allowed to the code call write with the first programming language;Compiling is single Member 26 is compiled for third function for being referred to using the function call by registration, obtains the 4th function, wherein third Function includes the code for calling first function, and third function is the self-defined hook letter write using the first programming language It counts, the code permission in the 4th function is directly executed by CPU.
It should be noted that the latch hook unit 22 in the embodiment can be used for executing the step in the embodiment of the present application 1 S202, the registering unit 24 in the embodiment can be used for executing the step S204 in the embodiment of the present application 1, in the embodiment Compilation unit 26 can be used for executing the step S206 in the embodiment of the present application 1.
Herein it should be noted that above-mentioned module is identical as example and application scenarios that corresponding step is realized, but not It is limited to 1 disclosure of that of above-described embodiment.It should be noted that above-mentioned module as a part for device may operate in as In hardware environment shown in Fig. 2, it can also pass through hardware realization by software realization.
As a kind of optional embodiment, which can also include:Receiving unit, for utilizing process The function call of registration refers to be compiled for third function after, receive operation requests, wherein operation requests are for asking Predetermined operation is carried out to intended application, intended application is write to obtain using the first programming language;Jump-transfer unit, in sound During answering operation requests to carry out predetermined operation to intended application, when first function is requested to be executed, the 4th letter is jumped to Number, to execute the 4th function.
As a kind of optional embodiment, which can also include:Acquiring unit, for will be to first Before the second function that function is compiled hooks into self-defined proxy function, according to the mark of first function predetermined Procedure set in obtain first function.
Optionally, acquiring unit may include:Execution module, for executing following operation to each procedure set, wherein journey Sequence collection is marked as present procedure collection when executing following operation:In the feelings that the mark of present procedure collection matches with predetermined mark Under condition, is concentrated from present procedure and determine scheduled class, and determine first function from scheduled 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 the relevant technologies self-defined Hook functions when carrying out Hook to function must make It is write with C/C++, leads to the higher technical problem of development cost of self-defined Hook functions, and then reach the self-defined Hook of reduction The technique effect of the development cost of function.
Figure 21 is the schematic diagram of another optional function compilation device according to the ... of the embodiment of the present invention, as shown in figure 21, The device may include:
First compilation unit 32 obtains second function for being compiled to first function, wherein first function is to use First programming language write by hooking function, the code permission in second function is directly executed by CPU;Second compilation unit 34, obtain the 4th function for being compiled to third function, wherein third function includes for calling first function One code, third function are the self-defined hooking function write using the first programming language, and the code in the 4th function allows straight It connects and is executed by CPU;Third compilation unit 36 obtains second code for first code to be compiled, wherein second code permits Perhaps it is directly executed by CPU;First latch hook unit 38 obtains function call pointer for second function to be hooked into the 4th function, Wherein, function call pointer is for calling second function;Second latch hook unit 310, for second code to be hooked into function tune With the second function indicated by pointer.
It should be noted that the first compilation unit 32 in the embodiment can be used for executing in the embodiment of the present application 1 Step S302, the second compilation unit 34 in the embodiment can be used for executing the step S304 in the embodiment of the present application 1, the reality It applies the third compilation unit 36 in example to can be used for executing the step S306 in the embodiment of the present application 1, first in the embodiment Latch hook unit 38 can be used for executing the step S308 in the embodiment of the present application 1, and the second latch hook unit 310 in the embodiment can For executing the step S310 in the embodiment of the present application 1.
Herein it should be noted that above-mentioned module is identical as example and application scenarios that corresponding step is realized, but not It is limited to 1 disclosure of that of above-described embodiment.It should be noted that above-mentioned module as a part for device may operate in as In hardware environment shown in Fig. 2, it can also pass through hardware realization by software realization.
As a kind of optional embodiment, which can also include:Receiving unit, for by the second generation Code hooks into after the second function indicated by function call pointer, receives operation requests, wherein operation requests are for asking Predetermined operation is carried out to intended application, intended application is write to obtain using the first programming language;Jump-transfer unit, in sound During answering operation requests to carry out predetermined operation to intended application, when first function is requested to be executed, the 4th letter is jumped to Number, to execute the 4th function.
As a kind of optional embodiment, which can also include:Acquiring unit, for the first letter Before number is compiled to obtain second function, first function is obtained in scheduled procedure set according to the mark of first function.
Optionally, acquiring unit may include:Execution module, for executing following operation to each procedure set, wherein journey Sequence collection is marked as present procedure collection when executing following operation:In the feelings that the mark of present procedure collection matches with predetermined mark Under condition, is concentrated from present procedure and determine scheduled class, and determine first function from scheduled 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 the relevant technologies self-defined Hook functions when carrying out Hook to function It is write using C/C++, leads to the higher technical problem of development cost of self-defined Hook functions, and then it is self-defined to reach reduction The technique effect of the development cost of Hook functions.
Embodiment 3
According to embodiments of the present invention, a kind of terminal for implementing above-mentioned function Compilation Method is additionally provided.
Figure 22 is a kind of structure diagram of terminal according to the ... of the embodiment of the present invention, and as shown in figure 22, which may include: One or more (one is only shown in figure) processors 201, memory 203 and transmitting device 205, as shown in figure 22, the end End can also include input-output equipment 207.
Wherein, memory 203 can be used for storing software program and module, such as the function compiling side in the embodiment of the present invention Method and the corresponding program instruction/module of device, processor 201 by operation be stored in software program in memory 203 and Module realizes above-mentioned function Compilation Method to perform various functions application and data processing.Memory 203 can wrap Include high speed random access memory, can also include nonvolatile memory, 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 of journey setting, 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 receive via a network or transmission data.Above-mentioned network specific example It may include cable network and wireless network.In an example, transmitting device 205 includes a network adapter (Network Interface Controller, NIC), can be connected with other network equipments with router by cable so as to interconnection Net or LAN are communicated.In an example, transmitting device 205 is radio frequency (Radio Frequency, RF) module, For wirelessly being communicated with internet.
Wherein, specifically, memory 203 is for storing application program.
Processor 201 can call the application program that memory 203 stores, to execute following step:It will be to first function The second function being compiled hooks into self-defined proxy function, obtains function call pointer, wherein first function is Using the first programming language write by hooking function, the code permission in second function is directly executed by CPU, and function call refers to Needle is for calling second function;Function call pointer is registered, so that function call pointer is allowed to the first programming The code call that language is write;Referred to using the function call by registration and be compiled for third function, obtains the 4th function, Wherein, third function includes the code for calling first function, and third function is oneself write using the first programming language Hooking function is defined, the code permission in the 4th function is directly executed by CPU.
Processor 201 is additionally operable to execute following step:Using by registration function call refer to for third function into After row compiling, operation requests are received, wherein operation requests carry out predetermined operation for asking to intended application, and target is answered It is write to obtain with the first programming language is used;During responding operation requests to intended application progress predetermined operation, When first function is requested to be executed, the 4th function is jumped to, to execute the 4th function.
Processor 201 is additionally operable to execute following step:The second function that first function is compiled will linked up with To before in self-defined proxy function, first function is obtained in scheduled procedure set according to the mark of first function.
Processor 201 is additionally operable to execute following step:Following operation is executed to each procedure set, wherein procedure set is being held Below row present procedure collection is marked as when operation:In the case where the mark of present procedure collection matches with predetermined mark, from Present procedure, which is concentrated, determines scheduled class, and first function is determined from scheduled class.
Processor 201 may call upon the application program of the storage of memory 203, to execute 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 permission directly executed by CPU;Third function is compiled to obtain the 4th function, wherein third function includes First code for calling first function, third function are the self-defined hooking function write using the first programming language, the Code permission in four functions is directly executed by CPU;First code is compiled to obtain second code, wherein second code Permission is directly executed 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 execute following step:Second code is being hooked into indicated by function call pointer After two functions, operation requests are received, wherein operation requests carry out predetermined operation for asking to intended application, and target is answered It is write to obtain with the first programming language is used;During responding operation requests to intended application progress predetermined operation, When first function is requested to be executed, the 4th function is jumped to, to execute the 4th function.
Processor 201 is additionally operable to execute following step:Before being compiled to obtain second function to first function, according to The mark of first function obtains first function in scheduled procedure set.
Processor 201 is additionally operable to execute following step:Following operation is executed to each procedure set, wherein procedure set is being held Below row present procedure collection is marked as when operation:In the case where the mark of present procedure collection matches with predetermined mark, from Present procedure, which is concentrated, determines scheduled class, and first function is determined from scheduled class.
Using the embodiment of the present invention, a kind of scheme of function compiling is provided, the program can will use C# programming languages to compile The first function write hooks into the third function (self-defined Hook functions) write with C# programming languages (by Hook functions), in turn It solves the relevant technologies self-defined Hook functions when carrying out Hook to function to write using C/C++, cause self-defined The higher technical problem of development cost of Hook functions, to realize the technology for the development cost for reducing self-defined Hook functions Effect.
Optionally, the specific example in the present embodiment can refer to showing described in above-described embodiment 1 and embodiment 2 Example, details are not described herein for the present embodiment.
It will appreciated by the skilled person that structure shown in Figure 22 is only to illustrate, terminal can be smart mobile phone (such as Android phone, iOS mobile phones), tablet computer, palm PC and mobile internet device (Mobile Internet Devices, MID), the terminal devices such as PAD.Figure 22 it does not cause to limit to the structure of above-mentioned electronic device.For example, terminal is also It may include more either less components (such as network interface, display device) 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 come command terminal device-dependent hardware by program, which can be stored in a computer readable storage medium In, storage medium may include:Flash disk, read-only memory (Read-Only Memory, ROM), random access device (Random Access Memory, RAM), disk or CD etc..
Embodiment 4
The embodiments of the present invention also provide a kind of storage mediums.Optionally, in the present embodiment, above-mentioned storage medium can For executing the program code of function Compilation Method.
Optionally, in the present embodiment, above-mentioned storage medium can be located at multiple in network shown in above-described embodiment On at least one of network equipment network equipment.
Optionally, in the present embodiment, storage medium is arranged to store the program code for executing following steps:
S1 will hook into self-defined proxy function the second function that first function is compiled, obtain function Call pointer, wherein first function be using the first programming language write by hooking function, the code in second function allows It is directly executed by CPU, function call pointer is for calling second function;
S2 registers function call pointer, so that function call pointer is allowed to be write with the first programming language Code call;
S3 is referred to using the function call by registration and is compiled for third function, obtains the 4th function, wherein the Three functions include the code for calling first function, and third function is the self-defined hook write using the first programming language Function, the code permission in the 4th function are directly executed by CPU.
Optionally, storage medium is also configured to store the program code for executing following steps:Using by note After the function call of volume refers to and is compiled for third function, operation requests are received, wherein operation requests are for asking pair Intended application carries out predetermined operation, and intended application is write to obtain using the first programming language;In response operation requests to mesh During mark application carries out predetermined operation, when first function is requested to be executed, the 4th function is jumped to, to execute the 4th letter Number.
Optionally, storage medium is also configured to store the program code for executing following steps:Will be to the first letter Before the second function that number is compiled hooks into self-defined proxy function, according to the mark of first function scheduled First function is obtained in procedure set.
Optionally, storage medium is also configured to store the program code for executing following steps:To each procedure set Execute following operation, wherein procedure set is marked as present procedure collection when executing following operation:In the mark of present procedure collection In the case of matching with predetermined mark, is concentrated from present procedure and determine scheduled class, and determine the first letter from scheduled class Number.
Optionally, in the present embodiment, storage medium is arranged to store the program code for executing following steps:
S1' is compiled first function to obtain second function, wherein first function is to be compiled using the first programming language Write by hooking function, the code permission in second function is directly executed by CPU;
S2' is compiled third function to obtain the 4th function, wherein third function includes for calling the first letter Several first codes, third function are the self-defined hooking function write using the first programming language, the code in the 4th function Permission is directly executed by CPU;
First code is compiled to obtain second code by S3', wherein second code permission is directly executed by CPU;
Second function is hooked into the 4th function, obtains function call pointer by S4', wherein function call pointer is for adjusting Use second function;
Second code is hooked into the second function indicated by function call pointer by S5'.
Optionally, storage medium is also configured to store the program code for executing following steps:By second code It hooks into after the second function indicated by function call pointer, receives operation requests, wherein operation requests are for request pair Intended application carries out predetermined operation, and intended application is write to obtain using the first programming language;In response operation requests to mesh During mark application carries out predetermined operation, when first function is requested to be executed, the 4th function is jumped to, to execute the 4th letter Number.
Optionally, storage medium is also configured to store the program code for executing following steps:To first function Before being compiled to obtain second function, first function is obtained in scheduled procedure set according to the mark of first function.
Optionally, storage medium is also configured to store the program code for executing following steps:To each procedure set Execute following operation, wherein procedure set is marked as present procedure collection when executing following operation:In the mark of present procedure collection In the case of matching with predetermined mark, is concentrated from present procedure and determine scheduled class, and determine the first letter from scheduled class Number.
Optionally, the specific example in the present embodiment can refer to showing described in above-described embodiment 1 and embodiment 2 Example, details are not described herein for the present embodiment.
Optionally, in the present embodiment, above-mentioned storage medium can include but is not limited to:USB flash disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disc or The various media that can store program code such as CD.
The embodiments of the present invention are for illustration only, can 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 as independent product Sale in use, can be stored in the storage medium that above computer can be read.Based on this understanding, skill of the invention Substantially all or part of the part that contributes to existing technology or the technical solution can be with soft in other words for art scheme The form of part product embodies, which is stored in a storage medium, including some instructions are used so that one Platform or multiple stage computers equipment (can be personal computer, server or network equipment etc.) execute each embodiment institute of the present invention State all or part of step of method.
In the above embodiment of the present invention, all emphasizes particularly on different fields to the description of each embodiment, do not have in some embodiment The part of detailed description may refer to the associated description of other embodiment.
In several embodiments provided herein, it should be understood that disclosed client, it can be by others side Formula is realized.Wherein, the apparatus embodiments described above are merely exemplary, for example, the unit division, only one Kind of division of logic function, formula that in actual implementation, there may be another division manner, such as multiple units or component can combine or It is desirably integrated into another system, or some features can be ignored or not executed.Another point, it is shown or discussed it is mutual it Between coupling, direct-coupling or communication connection can be INDIRECT COUPLING or communication link by some interfaces, unit or module It connects, can be electrical or other forms.
The unit illustrated as separating component may or may not be physically separated, aobvious as unit The component shown may or may not be physical unit, you can be located at a place, or may be distributed over multiple In network element.Some or all of unit therein can be selected according to the actual needs to realize the mesh of this embodiment scheme 's.
In addition, each functional unit in each embodiment of the present invention can be integrated in a processing unit, it can also It is that each unit physically exists alone, it can also be during two or more units be integrated in one unit.Above-mentioned integrated list The form that hardware had both may be used in member is realized, can also be realized in the form of SFU software functional unit.
The above is only a preferred embodiment of the present invention, it is noted that for the ordinary skill people of the art For member, various improvements and modifications may be made without departing from the principle of the present invention, these improvements and modifications are also answered It is considered as protection scope of the present invention.

Claims (12)

1. a kind of function Compilation Method, which is characterized in that including:
The second function that first function is compiled will be hooked into self-defined proxy function, obtains function call and refer to Needle, wherein the first function be using the first programming language write by hooking function, the code in the second function is permitted Perhaps it is directly executed by CPU, the function call pointer is for calling the second function;
The function call pointer is registered, so that the function call pointer is allowed to first programming language The code call write;
Refer to and is compiled for third function using the function call by registration, obtain the 4th function, wherein described the Three functions include the code for calling the first function, and the third function is to be write using first programming language Self-defined hooking function, the code permission in the 4th function directly executes by CPU.
2. according to the method described in claim 1, it is characterized in that, in the function call pointer using by registration After being compiled to third function, the method further includes:
Receive operation requests, wherein the operation requests carry out predetermined operation for asking to intended application, and the target is answered It is write to obtain with first programming language is used;
During responding the operation requests to the intended application progress predetermined operation, when the first function quilt When request executes, the 4th function is jumped to, to execute the 4th function.
3. according to the method described in claim 1, it is characterized in that, in second will be compiled to first function Before function hooks into self-defined proxy function, the method further includes:
The first function is obtained in scheduled procedure set according to the mark of the first function.
4. according to the method described in claim 3, it is characterized in that, the mark according to the first function is in scheduled journey Sequence concentration obtains the first function:
Following operation is executed to each procedure set, wherein described program collection is marked as present procedure when executing following operation Collection:In the case where the mark of the present procedure collection matches with predetermined mark, concentrated from the present procedure determining predetermined Class, and the first function is determined from the scheduled class.
5. method according to claim 1 to 4, which is characterized 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 function Compilation Method, which is characterized 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 permission in the second function is directly executed by CPU;
Third function is compiled to obtain the 4th function, wherein the third function includes for calling first letter Several first codes, the third function are the self-defined hooking function write using first programming language, the described 4th Code permission in function is directly executed by CPU;
It is compiled the first code to obtain second code, wherein the second code permission is directly executed 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. according to the method described in claim 6, it is characterized in that, the second code is hooked into the function tune described After the second function indicated by pointer, the method further includes:
Receive operation requests, wherein the operation requests carry out predetermined operation for asking to intended application, and the target is answered It is write to obtain with first programming language is used;
During responding the operation requests to the intended application progress predetermined operation, when the first function quilt When request executes, the 4th function is jumped to, to execute the 4th function.
8. according to the method described in claim 6, it is characterized in that, being compiled to obtain second function to first function described Before, the method further includes:
The first function is obtained in scheduled procedure set according to the mark of the first function.
9. according to the method described in claim 8, it is characterized in that, the mark according to the first function is in scheduled journey Sequence concentration obtains the first function:
Following operation is executed to each procedure set, wherein described program collection is marked as present procedure when executing following operation Collection:In the case where the mark of the present procedure collection matches with predetermined mark, concentrated from the present procedure determining predetermined Class, and the first function is determined from the scheduled class.
10. the method according to any one of claim 6 to 9, which is characterized in that first programming language is C#, institute It is Native codes to state the code in the code and the 4th function in second function.
11. a kind of function compilation device, which is characterized in that including:
Latch hook unit is obtained for will be hooked into self-defined proxy function to the second function that first function is compiled To function call pointer, wherein the first function be using the first programming language write by hooking function, second letter Code permission in number is directly executed by CPU, and the function call pointer is for calling the second function;
Registering unit, for registering the function call pointer, so that the function call pointer is allowed to use institute State the code call that the first programming language is write;
Compilation unit is compiled for third function for being referred to using the function call by registration, obtains the 4th letter Number, wherein the third function includes the code for calling the first function, and the third function is using described the The self-defined hooking function that one programming language is write, the code permission in the 4th function are directly executed by CPU.
12. a kind of function compilation device, which is characterized in that including:
First compilation unit obtains second function for being compiled to first function, wherein the first function is to use the One programming language write by hooking function, the code permission in the second function is directly executed by CPU;
Second compilation unit obtains the 4th function for being compiled to third function, wherein the third function includes using In the first code for calling the first function, the third function is the self-defined extension write using first programming language Hook function, the code permission in the 4th function are directly executed by CPU;
Third compilation unit, for being compiled the first code to obtain second code, wherein the second code allows Directly executed by CPU;
First latch hook unit obtains function call pointer for the second function to be hooked into the 4th function, wherein The function call pointer is for calling 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 CN107391219A (en) 2017-11-24
CN107391219B true 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)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108345458B (en) * 2018-01-25 2021-04-09 微梦创科网络科技(中国)有限公司 Calling method and system for static compiling language and scripting language
CN108415739B (en) * 2018-02-28 2020-04-14 腾讯科技(深圳)有限公司 Hook method and device for dynamic link library function and storage medium
CN108845841B (en) * 2018-06-15 2021-10-01 广州多益网络股份有限公司 Method and device for changing terminal application behaviors and terminal
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
CN111240856B (en) * 2020-01-03 2024-04-23 北京小米移动软件有限公司 Message processing method and device and storage medium

Family Cites Families (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
US8255931B2 (en) * 2008-02-11 2012-08-28 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
CN104598809B (en) * 2015-02-13 2017-04-19 北京奇虎科技有限公司 Program monitoring method and defending method thereof, as well as relevant device
CN106294166B (en) * 2016-08-16 2018-07-06 腾讯科技(深圳)有限公司 A kind of game data monitoring method and device

Also Published As

Publication number Publication date
CN107391219A (en) 2017-11-24

Similar Documents

Publication Publication Date Title
CN107391219B (en) Function Compilation Method and device
CN109933522B (en) Test method, test system and storage medium for automatic case
CN103927253B (en) Multiple browser compatibility testing method and system
CN110134386B (en) Program editing method and device
US7287190B2 (en) Simultaneous execution of test suites on different platforms
CN103336724B (en) System and method for the integrated hardware platform with distributed objects of Flash application program
JP5171790B2 (en) Information processing apparatus, communication system, and program
US20120284696A1 (en) Method, Apparatuses and a System for Compilation
US20130298110A1 (en) Software Visualization Using Code Coverage Information
US20080209405A1 (en) Distributed debugging for a visual programming language
WO2009014981A2 (en) Extensible execution language
CN109800135A (en) A kind of information processing method and terminal
CN111444103B (en) Web page automatic testing method and related equipment
CN108614767A (en) A kind of remote debugging method and device
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
CN115658529A (en) Automatic testing method for user page and related equipment
CN114328217A (en) Application testing method, device, equipment, medium and computer program product
CN112988588B (en) Client software debugging method and device, storage medium and electronic equipment
CN113296758A (en) Front-end component library construction method and device and storage medium
US20070006121A1 (en) Development activity recipe
CN106842969A (en) Apparatus control method and device
CN113282332A (en) Operation and maintenance processing method and device
JP2018045619A (en) Analysis program, analysis method, and analysis device
CN111078209B (en) Development processing method, device and equipment for business page

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