CN106708516A - Method and device for SO files to call external functions - Google Patents

Method and device for SO files to call external functions Download PDF

Info

Publication number
CN106708516A
CN106708516A CN201611131096.0A CN201611131096A CN106708516A CN 106708516 A CN106708516 A CN 106708516A CN 201611131096 A CN201611131096 A CN 201611131096A CN 106708516 A CN106708516 A CN 106708516A
Authority
CN
China
Prior art keywords
memory address
specified function
function
files
external file
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201611131096.0A
Other languages
Chinese (zh)
Other versions
CN106708516B (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.)
360 Digital Security Technology Group Co Ltd
Original Assignee
Beijing Qihoo Technology 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 Beijing Qihoo Technology Co Ltd filed Critical Beijing Qihoo Technology Co Ltd
Priority to CN201611131096.0A priority Critical patent/CN106708516B/en
Publication of CN106708516A publication Critical patent/CN106708516A/en
Application granted granted Critical
Publication of CN106708516B publication Critical patent/CN106708516B/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/70Software maintenance or management
    • G06F8/73Program documentation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/44Encoding
    • G06F8/441Register allocation; Assignment of physical memory space to logical memory space

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Library & Information Science (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a method and a device for SO files to call external functions. The method comprises the steps of getting memory addresses of the external functions which are needed to be called by the SO files, establishing mapping relations between specified functions and the obtained memory addresses, calling the specified functions from the corresponding memory addresses according to the mapping relations when the SO files need to call the specified functions. According to the technical scheme, when the SO files call the specified external functions, the calling process no longer depends on the memory addresses of the specified external functions provided by a system. The method and device are suitable for the SO files wrapped in a shell and meet the requirement of reinforcing the SO files.

Description

It is a kind of to realize the method and apparatus that SO files call external function
Technical field
The present invention relates to field of computer technology, and in particular to a kind of to realize that SO files call the method and dress of external function Put.
Background technology
Developer needs the function of considering to be realized using code when code is write, and business demand is often have overlap , the function for commonly using develops the code for obtaining can generally be compiled as a library file, be carried out for other codes Call, for example, the dynamic link library SO files of Android are just frequently necessary to call the function in other system SO files.These are non- The all of function of this SO files is exactly external function, in the prior art, this SO files when these external functions are called, it is necessary to by System helps find the memory address of these external functions, in particular it is required that stating in this SO files need to call outer File where portion's function, such system will be searched when this SO files are loaded from the file where these external functions Go out the memory address of external function, then pass to this SO files.
But the consideration to security is in order at, many SO files are, by increasing the consolidation process such as shell, so to reinforce SO files be not equivalent to former SO files, specifically, former SO files are loaded often by the SO files reinforced, this Sample results in system and is no longer provided for original SO files the memory address of the external function called required for it, also allows for former SO texts Part cannot call external function.
The content of the invention
In view of the above problems, it is proposed that the present invention so as to provide one kind overcome above mentioned problem or at least in part solve on State the method and apparatus that SO files call external function of realizing of problem.
According to one aspect of the present invention, there is provided a kind of to realize the method that SO files call external function, including:
Obtain the memory address of the specified function that SO files needs are called;
The mapping relations set up between the specified function and accessed memory address;
When the SO files need to call the specified function, adjusted from corresponding memory address according to the mapping relations Use the specified function.
Alternatively, the memory address of the specified function that the acquisition SO files needs are called includes:
According to the attribute information of the specified function, memory address search strategy corresponding with its attribute information is selected;
With the memory address search strategy selected, the memory address of the specified function is found out from external file.
Alternatively, the attribute information includes:
STB_WEAK attributes.
Alternatively, wherein, it is described with selected when the specified function is the function not comprising STB_WEAK attributes Address search strategy is deposited, the memory address that the specified function is found out from external file includes:
One external file is loaded with dlopen functions, the corresponding handle of the external file is obtained;
According to the handle and the title of specified function, the memory address of specified function is searched in the external file.
Alternatively, the method also includes:
If not finding, another external file is loaded with dlopen functions, repeated the above steps.
Alternatively, it is described according to the handle and the title of specified function, find out function from the external file Memory address include:
Dlsym functions are called, the memory address of function is searched in the external file.
Alternatively, when the specified function is the function comprising STB_WEAK attributes, the memory address to select Search strategy, the memory address that the specified function is found out from external file includes:
The mirror image of an external file is searched in internal memory;
The table comprising function information is found out in the mirror image;
Whether the information of the specified function is included in table comprising function information described in judging;
If comprising information corresponding with the specified function being extracted from the table comprising function information, according to extraction Information calculate specified function memory address.
Alternatively, the method also includes:
If not including, the mirror image of another external file is searched in internal memory, repeated the above steps.
Alternatively, the mirror image that external file is searched in internal memory includes:
Specified file to calling the process of the application of current file is scanned, and obtains at least one external file Loading plot;A loading plot is therefrom selected, the mirror image of corresponding external file is obtained.
Alternatively, at least one during the table comprising function information is included as follows:
String table, symbol table, Hash table.
Alternatively, other SO files that the external file is relied on by the SO files.
Alternatively, the method also includes:
Mapping relations between the specified function and accessed memory address are preserved into relocation table.
According to another aspect of the present invention, there is provided a kind of to realize that SO files call the device of external function, including:
Memory address acquiring unit, is suitable to obtain the memory address of the specified function that SO file needs are called;
Mapping relations set up unit, and the mapping being adapted to set up between the specified function and accessed memory address is closed System;
Function calling cell, is suitable to when the SO files need to call the specified function, according to the mapping relations The specified function is called from corresponding memory address.
Alternatively, the memory address acquiring unit, is suitable to the attribute information according to the specified function, and selection belongs to it The property corresponding memory address search strategy of information;With the memory address search strategy selected, from external file finding out this refers to Determine the memory address of function.
Alternatively, the attribute information includes:
STB_WEAK attributes.
Alternatively, the memory address acquiring unit, it is not comprising STB_WEAK attributes to be suitable in the specified function During function, an external file is loaded with dlopen functions, obtain the corresponding handle of the external file;According to the handle and specify The title of function, searches the memory address of specified function in the external file.
Alternatively, the memory address acquiring unit, is further adapted for when not finding, another outer with the loading of dlopen functions Portion's file, obtains the corresponding handle of the external file;According to the handle and the title of specified function, in the external file Search the memory address of specified function.
Alternatively, the memory address acquiring unit, is suitable to call dlsym functions, and letter is searched in the external file Several memory address.
Alternatively, the memory address acquiring unit, it is the letter comprising STB_WEAK attributes to be suitable in the specified function During number, the mirror image of an external file is searched in internal memory, the table comprising function information is found out in the mirror image, judge described Whether the information of the specified function is included in table comprising function information;If comprising from the table comprising function information Information corresponding with the specified function is extracted, the memory address of specified function is calculated according to the information extracted.
Alternatively, the memory address acquiring unit, is further adapted in the table comprising function information not comprising described During the information of specified function, the mirror image of another external file is searched in internal memory, found out in the mirror image comprising function letter Whether the table of breath, include the information of the specified function in the judgement table comprising function information;If comprising being included from described Information corresponding with the specified function is extracted in the table of function information, the internal memory ground of specified function is calculated according to the information extracted Location.
Alternatively, the memory address acquiring unit, is suitable to the specified file of the process of application to calling current file It is scanned, obtains the loading plot of at least one external file;A loading plot is therefrom selected, obtains corresponding outer The mirror image of portion's file.
Alternatively, at least one during the table comprising function information is included as follows:
String table, symbol table, Hash table.
Alternatively, other SO files that the external file is relied on by the SO files.
Alternatively, the mapping relations set up unit, are further adapted for the specified function and accessed memory address Between mapping relations preserve into relocation table.
From the foregoing, technical scheme, by the specified function that active obtaining SO files needs are called Address, and the mapping relations set up between specified function and accessed memory address are deposited, so needs to call in SO files During the specified function, the specified function can be called from corresponding memory address according to the mapping relations.The technical scheme So that SO files are when the specified function of outside is called, the memory address of the outside specified function of system offer is no longer dependent on, It is suitable for the SO files being wrapped in shell, meets the reinforcing demand to SO files.
Described above is only the general introduction of technical solution of the present invention, in order to better understand technological means of the invention, And can be practiced according to the content of specification, and in order to allow the above and other objects of the present invention, feature and advantage can Become apparent, below especially exemplified by specific embodiment of the invention.
Brief description of the drawings
By reading the detailed description of hereafter preferred embodiment, various other advantages and benefit is common for this area Technical staff will be clear understanding.Accompanying drawing is only used for showing the purpose of preferred embodiment, and is not considered as to the present invention Limitation.And in whole accompanying drawing, identical part is denoted by the same reference numerals.In the accompanying drawings:
Fig. 1 shows and according to an embodiment of the invention a kind of realizes that SO files call the flow of the method for external function Schematic diagram;
Fig. 2 shows and according to an embodiment of the invention a kind of realizes that SO files call the structure of the device of external function Schematic diagram.
Specific embodiment
The exemplary embodiment of the disclosure is more fully described below with reference to accompanying drawings.Although showing the disclosure in accompanying drawing Exemplary embodiment, it being understood, however, that may be realized in various forms the disclosure without should be by embodiments set forth here Limited.Conversely, there is provided these embodiments are able to be best understood from the disclosure, and can be by the scope of the present disclosure Complete conveys to those skilled in the art.
Fig. 1 shows and according to an embodiment of the invention a kind of realizes that SO files call the flow of the method for external function Schematic diagram, as shown in figure 1, the method includes:
Step S110, obtains the memory address of the specified function that SO files needs are called.
Step S120, the mapping relations set up between specified function and accessed memory address.
Step S130, when SO files need to call specified function, calls according to mapping relations from corresponding memory address The specified function.
It can be seen that, the method shown in Fig. 1, the memory address of the specified function for needing to call by active obtaining SO files, and The mapping relations set up between specified function and accessed memory address, so need to call the specified letter in SO files During number, the specified function can be called from corresponding memory address according to the mapping relations.The technical scheme causes SO files When the specified function of outside is called, the memory address of the outside specified function of system offer is no longer dependent on, is suitable for parcel SO files in shell, meet the reinforcing demand to SO files.
In one embodiment of the invention, in the method shown in Fig. 1, the specified function that SO files needs are called is obtained Memory address includes:According to the attribute information of specified function, memory address search strategy corresponding with its attribute information is selected;With Selected memory address search strategy, finds out the memory address of the specified function from external file.
In the prior art, the memory address of external function can be provided by system, then how realize active obtaining The memory address of external function is the problem for needing to solve.In view of Android system when SO files are loaded, one can be generated Solist a --- chained list comprising multiple soinfo structures.For an application program, system is each of its loading SO files correspond to a soinfo structure all in the chained list.The general structure of soinfo is as follows:
And specified letter can just be calculated according to the function structure recorded in function name, the symbol table recorded in string table Several memory address (Hash table can help the content in quick positioning words symbol string list and symbol table).
A kind of so acquisition SO files need the method for the memory address of the specified function called to be:
1) whole solist is scanned, if it find that the corresponding SO files of one of soinfo are that this SO files are relied on (wherein containing this SO files needs the function that calls), then just record this soinfo;
2) for each soinfo of 1) middle record, string table therein, symbol table and Hash table are read, using these The data message stored in table calculates the memory address of one or more specified functions.
But the problem of this method is:Not all soinfo is unified normalized form, and this is with regard to table It is bright, it is impossible to which that a kind of general method that string table, symbol table and Hash table are read from soinfo is provided, therefore in each system Soinfo structures be probably different.Therefore, the present embodiment proposes the attribute information according to specified function, and selection belongs to it The method of the property corresponding memory address search strategy of information.Specifically, attribute information includes:STB_WEAK attributes.
So, for the function not comprising STB_WEAK attributes, following method can be taken:
By taking function " abc " as an example, the function is included in certain SO file.Due to the SO files where not knowing the function Specifically which, therefore, it can take the mode of circulation, and a SO files are loaded with dlopen functions, obtain the external file pair The handle (handle) for answering;, recycle dlsym (handle, " abc ") attempt therefrom searching the address of function " abc ".If Do not find, if not finding, another SO files are loaded with dlopen functions, repeat the above steps.
And during for function comprising STB_WEAK attributes, call dlysm functions to be found in it from SO files Address is deposited, therefore following method can be taken:
In view of SO files when being loaded into internal memory, corresponding one piece of region of memory can be taken, can be described as image (mirrors Picture), therefore, the mirror image of a SO files is searched in internal memory first;Then the file format to mirror image is analyzed, in mirror image The table comprising function information is found out, for example, string table, symbol table and Hash table.Then can just be searched from table and specified The information of function, finds the memory address that can just calculate specified function;If searched less than illustrating in the SO files not Comprising specified function.The mirror image of another SO files is so just searched in internal memory, is repeated the above steps.SO files therein are exactly A kind of external file relied on by SO files, it is the file of the extended formattings such as DLL to be likely to according to the actual requirements.
In one embodiment of the invention, in the above method, the mirror image that external file is searched in internal memory includes:Exchange It is scanned with the specified file of the process of the application of current file, obtains the loading plot of at least one external file;Therefrom One loading plot of selection, obtains the mirror image of corresponding external file.For example, the maps files of scanning current process, therefrom The loading plot of other SO files relied on to current SO files, and then realize the method in above-described embodiment.
In one embodiment of the invention, the above method also includes:By specified function and accessed memory address Between mapping relations preserve into relocation table.So when specified function is called, can by search relocation table come from Memory address calls corresponding specified function, and cause the reorientation and function of memory address actually call separation, reduction In same time to the demand of calculation resources.
Fig. 2 shows and according to an embodiment of the invention a kind of realizes that SO files call the structure of the device of external function Schematic diagram, as shown in Fig. 2 realizing that SO files call the device 200 of external function to include:
Memory address acquiring unit 210, is suitable to obtain the memory address of the specified function that SO file needs are called.
Mapping relations set up unit 220, and the mapping being adapted to set up between specified function and accessed memory address is closed System.
Function calling cell 230, is suitable to when SO files need to call specified function, according to mapping relations from accordingly Deposit the call by location specified function.
It can be seen that, the device shown in Fig. 2, the memory address of the specified function for needing to call by active obtaining SO files, and The mapping relations set up between specified function and accessed memory address, so need to call the specified letter in SO files During number, the specified function can be called from corresponding memory address according to the mapping relations.The technical scheme causes SO files When the specified function of outside is called, the memory address of the outside specified function of system offer is no longer dependent on, is suitable for parcel SO files in shell, meet the reinforcing demand to SO files.
In one embodiment of the invention, in said apparatus, memory address acquiring unit 210 is suitable to according to specified letter Several attribute informations, selects memory address search strategy corresponding with its attribute information;With the memory address search strategy selected, The memory address of the specified function is found out from external file.
In one embodiment of the invention, in said apparatus, attribute information includes:STB_WEAK attributes.
In one embodiment of the invention, in said apparatus, memory address acquiring unit 210 is suitable in specified function When being the function not comprising STB_WEAK attributes, an external file is loaded with dlopen functions, obtain the external file corresponding Handle;According to handle and the title of specified function, the memory address of specified function is searched in external file.
In one embodiment of the invention, in said apparatus, memory address acquiring unit 210 is further adapted for not searching Then, another external file is loaded with dlopen functions, repeats the step in above-described embodiment.
In one embodiment of the invention, in said apparatus, memory address acquiring unit 210 is suitable to call dlsym letters Number, searches the memory address of function in external file.
In one embodiment of the invention, in said apparatus, memory address acquiring unit 210 is suitable in specified function When being the function comprising STB_WEAK attributes, the mirror image of an external file is searched in internal memory, found out comprising letter in mirror image Whether the table of number information, include the information of specified function in table of the judgement comprising function information;If comprising from comprising function information Table in extract corresponding with specified function information, according to the memory address of the information calculating specified function extracted.
In one embodiment of the invention, in said apparatus, memory address acquiring unit 210 is further adapted for comprising letter When not including the information of specified function in the table of number information, the mirror image of another external file is searched in internal memory, repeated State the step in embodiment.
In one embodiment of the invention, in said apparatus, memory address acquiring unit 210 is suitable to current to calling The specified file of the process of the application of file is scanned, and obtains the loading plot of at least one external file;Therefrom select one Individual loading plot, obtains the mirror image of corresponding external file.
In one embodiment of the invention, in said apparatus, the table comprising function information include it is following at least one Kind:String table, symbol table, Hash table.
In one embodiment of the invention, in said apparatus, other SO files that external file is relied on by SO files.
In one embodiment of the invention, in said apparatus, mapping relations set up unit 220, are further adapted for specified letter Mapping relations between several and accessed memory address are preserved into relocation table.
It should be noted that the specific embodiment of above-mentioned each device embodiment is specific with foregoing corresponding method embodiment Implementation method is identical, will not be repeated here.
In sum, technical scheme, the internal memory of the specified function for needing to call by active obtaining SO files Address, and the mapping relations set up between specified function and accessed memory address, so need to call institute in SO files When stating specified function, the specified function can be called from corresponding memory address according to the mapping relations.The technical scheme makes SO files are obtained when the specified function of outside is called, the memory address of the outside specified function of system offer is provided, fitted Together in the SO files being wrapped in shell, the reinforcing demand to SO files is met.
It should be noted that:
Algorithm and display be not inherently related to any certain computer, virtual bench or miscellaneous equipment provided herein. Various fexible units can also be used together with based on teaching in this.As described above, construct required by this kind of device Structure be obvious.Additionally, the present invention is not also directed to any certain programmed language.It is understood that, it is possible to use it is various Programming language realizes the content of invention described herein, and the description done to language-specific above is to disclose this hair Bright preferred forms.
In specification mentioned herein, numerous specific details are set forth.It is to be appreciated, however, that implementation of the invention Example can be put into practice in the case of without these details.In some instances, known method, structure is not been shown in detail And technology, so as not to obscure the understanding of this description.
Similarly, it will be appreciated that in order to simplify one or more that the disclosure and helping understands in each inventive aspect, exist Above to the description of exemplary embodiment of the invention in, each feature of the invention is grouped together into single implementation sometimes In example, figure or descriptions thereof.However, the method for the disclosure should be construed to reflect following intention:I.e. required guarantor The application claims of shield features more more than the feature being expressly recited in each claim.More precisely, such as following Claims reflect as, inventive aspect is all features less than single embodiment disclosed above.Therefore, Thus the claims for following specific embodiment are expressly incorporated in the specific embodiment, and wherein each claim is in itself All as separate embodiments of the invention.
Those skilled in the art are appreciated that can be carried out adaptively to the module in the equipment in embodiment Change and they are arranged in one or more equipment different from the embodiment.Can be the module or list in embodiment Unit or component be combined into a module or unit or component, and can be divided into addition multiple submodule or subelement or Sub-component.In addition at least some in such feature and/or process or unit exclude each other, can use any Combine to all features disclosed in this specification (including adjoint claim, summary and accompanying drawing) and so disclosed appoint Where all processes or unit of method or equipment are combined.Unless expressly stated otherwise, this specification (including adjoint power Profit is required, summary and accompanying drawing) disclosed in each feature can the alternative features of or similar purpose identical, equivalent by offer carry out generation Replace.
Although additionally, it will be appreciated by those of skill in the art that some embodiments described herein include other embodiments In included some features rather than further feature, but the combination of the feature of different embodiments means in of the invention Within the scope of and form different embodiments.For example, in the following claims, embodiment required for protection is appointed One of meaning mode can be used in any combination.
All parts embodiment of the invention can be realized with hardware, or be run with one or more processor Software module realize, or with combinations thereof realize.It will be understood by those of skill in the art that can use in practice Microprocessor or digital signal processor (DSP) are realized according to embodiments of the present invention realizing that SO files call external function Device in some or all parts some or all functions.The present invention is also implemented as performing institute here Some or all equipment or program of device of the method for description are (for example, computer program and computer program are produced Product).It is such to realize that program of the invention be stored on a computer-readable medium, or can have one or more The form of signal.Such signal can be downloaded from internet website and obtained, or be provided on carrier signal, or to appoint What other forms is provided.
It should be noted that above-described embodiment the present invention will be described rather than limiting the invention, and ability Field technique personnel can design alternative embodiment without departing from the scope of the appended claims.In the claims, Any reference symbol being located between bracket should not be configured to limitations on claims.Word "comprising" is not excluded the presence of not Element listed in the claims or step.Word "a" or "an" before element is not excluded the presence of as multiple Element.The present invention can come real by means of the hardware for including some different elements and by means of properly programmed computer It is existing.If in the unit claim for listing equipment for drying, several in these devices can be by same hardware branch To embody.The use of word first, second, and third does not indicate that any order.These words can be explained and run after fame Claim.
Embodiment of the invention discloses that A1, it is a kind of realize the method that SO files call external function, wherein, the method bag Include:
Obtain the memory address of the specified function that SO files needs are called;
The mapping relations set up between the specified function and accessed memory address;
When the SO files need to call the specified function, adjusted from corresponding memory address according to the mapping relations Use the specified function.
A2, the method as described in A1, wherein, the acquisition SO files need the memory address bag of the specified function called Include:
According to the attribute information of the specified function, memory address search strategy corresponding with its attribute information is selected;
With the memory address search strategy selected, the memory address of the specified function is found out from external file.
A3, the method as described in A2, wherein, the attribute information includes:
STB_WEAK attributes.
A4, the method as described in A3, wherein, when the specified function is the function not comprising STB_WEAK attributes, institute The memory address search strategy to select is stated, the memory address that the specified function is found out from external file includes:
One external file is loaded with dlopen functions, the corresponding handle of the external file is obtained;
According to the handle and the title of specified function, the memory address of specified function is searched in the external file.
A5, the method as described in A4, wherein, the method also includes:
If not finding, another external file is loaded with dlopen functions, repeat the step in A4.
A6, the method as described in A4, wherein, it is described according to the handle and the title of specified function, from the outside The memory address that function is found out in file includes:
Dlsym functions are called, the memory address of function is searched in the external file.
A7, the method as described in A3, wherein, it is described when the specified function is the function comprising STB_WEAK attributes With the memory address search strategy selected, the memory address that the specified function is found out from external file includes:
The mirror image of an external file is searched in internal memory;
The table comprising function information is found out in the mirror image;
Whether the information of the specified function is included in table comprising function information described in judging;
If comprising information corresponding with the specified function being extracted from the table comprising function information, according to extraction Information calculate specified function memory address.
A8, the method as described in A7, wherein, the method also includes:
If not including, the mirror image of another external file is searched in internal memory, repeat the step in A7.
A9, the method as described in A7, wherein, the mirror image that external file is searched in internal memory includes:
Specified file to calling the process of the application of current file is scanned, and obtains at least one external file Loading plot;A loading plot is therefrom selected, the mirror image of corresponding external file is obtained.
A10, the method as described in A7, wherein, the table comprising function information include it is following at least one:
String table, symbol table, Hash table.
A11, the method as any one of A4-A10, wherein, the external file SO files are relied on Other SO files.
A12, the method as described in A1, wherein, the method also includes:
Mapping relations between the specified function and accessed memory address are preserved into relocation table.
Embodiments of the invention also disclose B13, it is a kind of realize that SO files call the device of external function, wherein, the dress Put including:
Memory address acquiring unit, is suitable to obtain the memory address of the specified function that SO file needs are called;
Mapping relations set up unit, and the mapping being adapted to set up between the specified function and accessed memory address is closed System;
Function calling cell, is suitable to when the SO files need to call the specified function, according to the mapping relations The specified function is called from corresponding memory address.
B14, the device as described in B12, wherein,
The memory address acquiring unit, is suitable to the attribute information according to the specified function, selection and its attribute information Corresponding memory address search strategy;With the memory address search strategy selected, the specified function is found out from external file Memory address.
B15, the device as described in B14, wherein, the attribute information includes:
STB_WEAK attributes.
B16, the device as described in B15, wherein,
The memory address acquiring unit, is suitable to when the specified function is the function not comprising STB_WEAK attributes, One external file is loaded with dlopen functions, the corresponding handle of the external file is obtained;According to the handle and specified function Title, searches the memory address of specified function in the external file.
B17, the device as described in B16, wherein,
The memory address acquiring unit, is further adapted for, when not finding, another external file being loaded with dlopen functions, Repeat the step in B16.
B18, the device as described in B16, wherein,
The memory address acquiring unit, is suitable to call dlsym functions, and the internal memory of function is searched in the external file Address.
B19, the device as described in B15, wherein,
The memory address acquiring unit, is suitable to when the specified function is the function comprising STB_WEAK attributes, The mirror image of an external file is searched in internal memory, the table comprising function information is found out in the mirror image, judge described comprising letter Whether the information of the specified function is included in the table of number information;If comprising, from the table comprising function information extract with The corresponding information of the specified function, the memory address of specified function is calculated according to the information extracted.
B20, the device as described in B18, wherein,
The memory address acquiring unit, is further adapted for not including the specified function in the table comprising function information Information when, the mirror image of another external file is searched in internal memory, repeat the step in B18.
B21, the device as described in B18, wherein,
The memory address acquiring unit, is suitable to sweep the specified file for calling the process of the application of current file Retouch, obtain the loading plot of at least one external file;A loading plot is therefrom selected, corresponding external file is obtained Mirror image.
B22, the device as described in B18, wherein, the table comprising function information include it is following at least one:
String table, symbol table, Hash table.
B23, the device as any one of B16-B22, wherein, the external file SO files are relied on Other SO files.
B24, the device as described in B12, wherein,
The mapping relations set up unit, are further adapted for reflecting between the specified function and accessed memory address The relation of penetrating is preserved into relocation table.

Claims (10)

1. it is a kind of to realize the method that SO files call external function, wherein, the method includes:
Obtain the memory address of the specified function that SO files needs are called;
The mapping relations set up between the specified function and accessed memory address;
When the SO files need to call the specified function, this is called from corresponding memory address according to the mapping relations Specified function.
2. the method for claim 1, wherein the acquisition SO files need the memory address bag of the specified function called Include:
According to the attribute information of the specified function, memory address search strategy corresponding with its attribute information is selected;
With the memory address search strategy selected, the memory address of the specified function is found out from external file.
3. method as claimed in claim 2, wherein, the attribute information includes:
STB_WEAK attributes.
4. method as claimed in claim 3, wherein, when the specified function is the function not comprising STB_WEAK attributes, The memory address search strategy to select, the memory address that the specified function is found out from external file includes:
One external file is loaded with dlopen functions, the corresponding handle of the external file is obtained;
According to the handle and the title of specified function, the memory address of specified function is searched in the external file.
5. method as claimed in claim 4, wherein, the method also includes:
If not finding, another external file is loaded with dlopen functions, repeat the step in claim 4.
6. it is a kind of to realize that SO files call the device of external function, wherein, the device includes:
Memory address acquiring unit, is suitable to obtain the memory address of the specified function that SO file needs are called;
Mapping relations set up unit, are adapted to set up the mapping relations between the specified function and accessed memory address;
Function calling cell, is suitable to when the SO files need to call the specified function, according to the mapping relations slave phase The memory address answered calls the specified function.
7. device as claimed in claim 6, wherein,
The memory address acquiring unit, is suitable to the attribute information according to the specified function, selects corresponding with its attribute information Memory address search strategy;With the memory address search strategy selected, found out from external file in the specified function Deposit address.
8. device as claimed in claim 7, wherein, the attribute information includes:
STB_WEAK attributes.
9. device as claimed in claim 8, wherein,
The memory address acquiring unit, is suitable to when the specified function is the function not comprising STB_WEAK attributes, with Dlopen functions load an external file, obtain the corresponding handle of the external file;According to the handle and the name of specified function Claim, the memory address of specified function is searched in the external file.
10. device as claimed in claim 9, wherein,
The memory address acquiring unit, is further adapted for, when not finding, another external file being loaded with dlopen functions, repeats Step in perform claim requirement 9.
CN201611131096.0A 2016-12-09 2016-12-09 Method and device for calling external function by SO file Active CN106708516B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201611131096.0A CN106708516B (en) 2016-12-09 2016-12-09 Method and device for calling external function by SO file

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201611131096.0A CN106708516B (en) 2016-12-09 2016-12-09 Method and device for calling external function by SO file

Publications (2)

Publication Number Publication Date
CN106708516A true CN106708516A (en) 2017-05-24
CN106708516B CN106708516B (en) 2020-02-28

Family

ID=58936693

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201611131096.0A Active CN106708516B (en) 2016-12-09 2016-12-09 Method and device for calling external function by SO file

Country Status (1)

Country Link
CN (1) CN106708516B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107943544A (en) * 2017-12-11 2018-04-20 北京奇虎科技有限公司 The loading method and device of a kind of kernel patch
CN111506301A (en) * 2020-04-24 2020-08-07 同盾(广州)科技有限公司 Method for bypassing system restriction reflection call and related equipment

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107943544A (en) * 2017-12-11 2018-04-20 北京奇虎科技有限公司 The loading method and device of a kind of kernel patch
CN107943544B (en) * 2017-12-11 2021-10-08 北京奇虎科技有限公司 Kernel patch loading method and device
CN111506301A (en) * 2020-04-24 2020-08-07 同盾(广州)科技有限公司 Method for bypassing system restriction reflection call and related equipment
CN111506301B (en) * 2020-04-24 2022-11-11 同盾(广州)科技有限公司 Method for bypassing system restriction reflection call and related equipment

Also Published As

Publication number Publication date
CN106708516B (en) 2020-02-28

Similar Documents

Publication Publication Date Title
JP6198939B2 (en) Method for loading driver and embedded device
CN106598667B (en) Method and apparatus for repairing kernel loophole
CN103473367B (en) Method for using local application program in browser and web browser
US20160086054A1 (en) Storing Information For Access Using A Captured Image
CN105893085A (en) Method and device for loading kernel module
CN106354536A (en) Method and device of loading ELF file of Linux system in Windows system
CN105095525A (en) Method and device for acquiring web page data
CN111143739A (en) Page jump method, computing device and computer storage medium
CN105117499A (en) File display method and device based on cloud disk
CN106708516A (en) Method and device for SO files to call external functions
CN107341100A (en) The collocation method and device of camera parameter
CN105868639A (en) Kernel vulnerability repair method and device
CN109445770B (en) Error code processing method, device, medium and equipment
CN107632986A (en) Searching method and device
US9466003B2 (en) System and method for using an image to provide search results
CN105183887A (en) Data processing method based on browser and browser device
CN105989075A (en) Method, device and system for displaying image by browser
CN105095416B (en) A kind of method and apparatus realizing content in the search and promoting
CN107402749A (en) Realize the method and device in picture loading storehouse
CN105117498A (en) Webpage data processing method and device
CN112988810A (en) Information searching method, device and equipment
CN105389351A (en) Account number upgrading method and apparatus for specified platform
US20080112701A1 (en) Information presenting device and information presenting terminal
CN107491460A (en) The data mapping method and device of adaption system
CN108228795A (en) Add the method and device of business object

Legal Events

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

Effective date of registration: 20220325

Address after: 100020 1773, 15 / F, 17 / F, building 3, No.10, Jiuxianqiao Road, Chaoyang District, Beijing

Patentee after: Sanliu0 Digital Security Technology Group Co.,Ltd.

Address before: 100088 room 112, block D, 28 new street, new street, Xicheng District, Beijing (Desheng Park)

Patentee before: BEIJING QIHOO TECHNOLOGY Co.,Ltd.