Method and device for hooking function

A technology of functions and original functions, which is applied in the direction of program control devices, program loading/starting, etc., can solve the problem of code increase and other problems, and achieve the effect of reducing the amount of code and saving space

Active Publication Date: 2017-03-29
TENCENT TECH (SHENZHEN) CO LTD
View PDF11 Cites 14 Cited by
  • Summary
  • Abstract
  • Description
  • Claims
  • Application Information

AI Technical Summary

Problems solved by technology

[0004] Based on this, it is necessary to provide a method of hooking functions, which can reduce the amount of code and save space, in order to solve the problem of code increase when many functions are traditionally hooked.

Method used

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
View more

Image

Smart Image Click on the blue labels to locate them in the text.
Viewing Examples
Smart Image
  • Method and device for hooking function
  • Method and device for hooking function
  • Method and device for hooking function

Examples

Experimental program
Comparison scheme
Effect test

Embodiment Construction

[0025] In order to make the object, technical solution and advantages of the present invention clearer, the present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described here are only used to explain the present invention, not to limit the present invention.

[0026] It can be understood that the terms "first", "second" and the like used in the present invention can be used to describe various elements herein, but these elements are not limited by these terms. These terms are only used to distinguish one element from another element. For example, a first client could be termed a second client, and, similarly, a second client could be termed a first client, without departing from the scope of the present invention. Both the first client and the second client are clients, but they are not the same client.

[0027] figure 1 It is a schematic diagram of a...

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to view more

PUM

No PUM Login to view more

Abstract

The invention relates to a method and device for hooking a function. The method comprises the following steps: acquiring a to-be-hooked original function; judging a returned value type of the original function; configuring a corresponding substitution function containing a pre-callback function and a post-callback function according to the returned value type of the original function; and substituting the original function with the substitution function to realize the hooking of the original function. By use of the method and device disclosed by the invention, the returned value type of the original function is judged after the original function is acquired, the corresponding substitution function containing the pre-callback function and the post-callback function is configured according to the returned value type, and the original function is substituted by the substitution function to realize the hooking of the original function. One kind of returned value types are corresponding to the same substitution function by use of the returned value type to configure the substitution function, the corresponding between each function and one substitution function is unnecessary, the code quantity is reduced, and the space is saved. Whether the original function parameter and the returned need to be modified is judged through the pre-callback function and the post-callback function, and the control to the original function is realized.

Description

technical field [0001] The invention relates to the field of data processing, in particular to a method and device for hooking functions. Background technique [0002] The hook technology used in iOS development is implemented through the system function class_replaceMethod. For example, function A has three parameters p1, p2, and p3. The return type is r. If you want to implement a hook for this function, you must write a function parameter with A For the same function as the return value, the traditional object-C syntax is used to describe the function A: -(r)FUN_A:(id)p1 p2:(id)p2 p3:(id)p3; the replacement function should be written as follows, The function name can be arbitrary: -(r)FAKE_FUN_A:(id)p1 p2:(id)p2p3:(id)p3. [0003] However, when the above method needs to hook many functions, it is necessary to write a corresponding replacement function for each function. Each function has different return values ​​and different parameters, which cannot be processed togeth...

Claims

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to view more

Application Information

Patent Timeline
no application Login to view more
Patent Type & Authority Applications(China)
IPC IPC(8): G06F9/445
Inventor 俞骁李伟
Owner TENCENT TECH (SHENZHEN) CO LTD
Who we serve
  • R&D Engineer
  • R&D Manager
  • IP Professional
Why Eureka
  • Industry Leading Data Capabilities
  • Powerful AI technology
  • Patent DNA Extraction
Social media
Try Eureka
PatSnap group products