CN110780949A - Method for acquiring NPAPI interface list capable of being called by outside - Google Patents
Method for acquiring NPAPI interface list capable of being called by outside Download PDFInfo
- Publication number
- CN110780949A CN110780949A CN201911014948.1A CN201911014948A CN110780949A CN 110780949 A CN110780949 A CN 110780949A CN 201911014948 A CN201911014948 A CN 201911014948A CN 110780949 A CN110780949 A CN 110780949A
- Authority
- CN
- China
- Prior art keywords
- npobject
- called
- npp
- browser
- identifier
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 105
- 230000003993 interaction Effects 0.000 claims description 4
- 230000008569 process Effects 0.000 abstract description 10
- 238000012360 testing method Methods 0.000 abstract description 2
- 230000006978 adaptation Effects 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 238000012546 transfer Methods 0.000 description 2
- 241000238582 Artemia Species 0.000 description 1
- VYZAMTAEIAYCRO-UHFFFAOYSA-N Chromium Chemical compound [Cr] VYZAMTAEIAYCRO-UHFFFAOYSA-N 0.000 description 1
- 230000007547 defect Effects 0.000 description 1
- 238000010586 diagram Methods 0.000 description 1
- 238000002474 experimental method Methods 0.000 description 1
- 230000007774 longterm Effects 0.000 description 1
- 230000007246 mechanism Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/448—Execution paradigms, e.g. implementations of programming paradigms
- G06F9/4488—Object-oriented
- G06F9/449—Object-oriented method invocation or resolution
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/448—Execution paradigms, e.g. implementations of programming paradigms
- G06F9/4488—Object-oriented
- G06F9/4492—Inheritance
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Stored Programmes (AREA)
Abstract
The invention discloses a method for acquiring an NPAPI interface list which can be called by the outside, which provides a method for an NPAPI plug-in to call a function externally from the aspects of the operation principle of the NPAPI, the execution process of a browser, the loading flow of the plug-in and the like. Therefore, the tester can quickly select the available plug-in interface for testing, thereby greatly saving the working time and improving the working efficiency.
Description
Technical Field
The invention relates to the technical field of plug-ins, in particular to a method for acquiring an NPAPI interface list which can be called by the outside.
Background
Netscape plug-in application Programming Interface (NPAPI) is a plug-in Interface similar to ActiveX used by Gecko engine browsers such as Netscape Navigator, Mozilla Suite, Mozilla SeaMonkey, and Mozilla Firefox, and by webkit engine browsers such as Apple Safari and Google Chrome.
The NPAPI usually has three functions which can be directly called by a browser, NP _ GetEntryPoints, which is usually used for filling a plug-in basic function table for the browser to use; NP _ Initialize, which is typically used to populate the browser base functions table for use by plug-ins; NP _ Shutdown, end of work.
The user can call the plug-in interface externally, but due to the mechanism problem of the NPAPI, the user cannot intuitively acquire the interface list which can be called externally.
Disclosure of Invention
In order to overcome the defects, the inventor of the invention provides a method for acquiring an NPAPI interface list which can be called by the outside world from the aspects of the operation principle of the NPAPI, the execution process of a browser, the loading flow of a plug-in and the like through long-term exploration attempts and multiple experiments and efforts, continuous innovation and innovation.
In order to achieve the purpose, the invention adopts the technical scheme that: a method for obtaining an NPAPI interface list that can be called by an external entity, the method comprising the following operations:
the browser calls an NPP _ GetValue method to obtain an NPObject object, and the NPObject object is used as a bridge for interaction of JS and the plug-in;
when a JS method is called, NPObject is called firstly, and HasMethod is called to inquire whether the method exists or not; if yes, then calling NPObject, invoking to actually execute the corresponding method and transmitting the corresponding parameters;
when the browser calls the NPP _ GetValue method, returning an NPObject object;
registering a JS callable method, setting a method name, returning an identifier as an identifier of the character string, and using the identifier as an operation object when other methods are needed;
JS interface lookup for np. The registration of all JS-callable method names generates a character string identifier, the character string identifier is filled in a global variable, the callable positions of the JS-callable method names can be tracked in a cross-reference mode, and relevant attributes or method names are seen;
the JS method number to call is determined by the NPObject: HasMethod method,
the parameter list is determined from the implementation seen by the Invoke method in NPObject.
According to the method for acquiring the NPAPI interface list which can be called by the outside, a further preferable technical scheme is that three parameters are introduced when the browser calls the NPP _ GetValue method, wherein the three parameters are an NPP instance plugin instance, an NPPVPluginScriptablNPObject (a structure body used for describing plugin information) and an NPObject pointer (pointing to the structure body for storing the plugin information) as a return result.
According to the method for acquiring the NPAPI interface list that can be called by the outside, a further preferred technical solution is that when the browser calls the NPP _ GetValue method, an NPObject object is returned, the NPObject is created by an NPN _ CreateObject, and the NPObject is defined as: NPObject NPN _ createoobject (nppnp, NPClass aClass); among them, NPClass is a subclass inherited to scriptableplugingobjectbase, which provides the necessary basic methods.
According to the method for acquiring the NPAPI interface list capable of being called by the outside, the further preferable technical scheme is that a distributor is adopted to implement the JS method, and the distributor executes the NPIdentifier method.
According to the method for acquiring the NPAPI interface list capable of being called by the outside, a further preferable technical scheme is that a character string identifier is generated by registering all JS calling method names, an NPN _ GetStringIdentifier function is used for generating a character string identifier during specific registration, and the function is provided by a browser.
According to the method for acquiring the NPAPI interface list capable of being called by the outside, the further preferable technical scheme is that the NP _ Initialize function is filled into the global variable, then the calling position can be tracked in a cross-reference mode, and the related attribute or method name can be seen.
Compared with the prior art, the invention has the following advantages:
the method solves the problem that no relevant technical analysis aiming at the externally-called interface of the NPAPI plug-in is available, and provides a method aiming at obtaining the NPAPI interface list which can be called by the outside from the aspects of the operation principle of the NPAPI, the execution process of a browser, the loading flow of the plug-in and the like, so that a tester can quickly screen out the available plug-in interface for testing, thereby greatly saving the working time and improving the working efficiency.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings that are required to be used in the embodiments will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present invention and therefore should not be considered as limiting the scope, and for those skilled in the art, other related drawings can be obtained according to the drawings without inventive efforts.
FIG. 1 is a block flow diagram of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the technical solutions in the embodiments of the present invention are clearly and completely described below, and it is obvious that the described embodiments are a part of the embodiments of the present invention, not all of the embodiments of the present invention. All other embodiments, which can be obtained by a person skilled in the art without any inventive step based on the embodiments of the present invention, are within the scope of the present invention. Thus, the detailed description of the embodiments of the present invention provided below is not intended to limit the scope of the invention as claimed, but is merely representative of selected embodiments of the invention.
Examples
As shown in fig. 1: a method for acquiring an NPAPI interface list which can be called by the outside world comprises a calling process of a browser to a plug-in and a calling process of the browser to the plug-in. The calling process of the browser to the plug-in is as follows:
1. and calling the NPP _ GetValue method by the browser to acquire the NPObject object, wherein the NPObject object is used as a bridge for interaction of JavaScript and the plug-in. When the browser calls the NPP _ GetValue method, 3 parameters are introduced, which are NPP instance, nppvplugscriptable NPObject, and NPObject pointer as a return result.
2. When a JS method is called, NPObject is called firstly, and HasMethod is called to inquire whether the method exists or not; if yes, then call NPObject, Invoke to actually execute the corresponding method and transfer the corresponding parameters.
The calling process of the browser to the plug-in is as follows:
1. and calling the NPP _ GetValue method by the browser to acquire the NPObject object, wherein the NPObject object is used as a bridge for interaction of JavaScript and the plug-in. When the browser calls the NPP _ GetValue method, 3 parameters are introduced, which are NPP instance, nppvplugscriptable NPObject, and NPObject pointer as a return result.
2. When a JS method is called, NPObject is called firstly, and HasMethod is called to inquire whether the method exists or not; if yes, then call NPObject, Invoke to actually execute the corresponding method and transfer the corresponding parameters.
The plug-in function implementation process comprises the following steps:
1. when the browser calls the NPP _ GetValue method, an NPObject object needs to be returned. NPObject is created by NPN _ CreateObject, which is defined as:
NPObject*NPN_CreateObject(NPP npp,NPClass*aClass);
among them, NPClass is a subclass inherited to scriptableplugingobjectbase, which provides the necessary basic methods.
2. Registering a JS callable requires setting the method name via the NPN _ GetStringIdentifier function, which returns an NPIdentifier as an identifier for the string. When other methods need to be used, the NPIdentifier is used as an operation object instead of directly using a character string.
3. The method is realized in a NPObject-Invoke function, wherein the parameter 1 of the function is an NPIdentifier, so the function is essentially a distributor which executes the specific realization of the method corresponding to the NPIdentifier.
The JS interface searching method for the np.dll file comprises the following steps:
the NPN _ GetStringIdentifier function is used for generating a character string identifier for registering all JS-callable method names, the function is provided by a browser, namely the NPN _ GetStringIdentifier function is filled in a global variable, the calling of the NPN _ GetStringIdentifier function can be tracked by means of cross reference, and the related attribute or the method name can be seen.
Determining the number of JS methods to call according to the NPObject, namely determining the number of JS methods to call according to the HasMethod method; the Invoke method may see the implementation from NPObject to guess the parameter list. Both methods can be found by finding a similar virtual function table named scriptable PluginObject through the script.
The implementation process of the technical solution is specifically described below by taking npqqmailwebkit.
The rdata section of the program can first find the following virtual function table as shown in table one:
watch 1
From the function table, we can locate the position of the HasNethod function, and then compare the parameter 1 twice in the HasMethod method, so that only two methods for JS call can be known; the implementation code is shown in table two:
watch two
Table two shows that only two methods can be called externally by JS, and then the global variable assignment location is found by cross-reference, so that they are the string identifiers generated by the NPN _ GetStringIdentifier, and therefore, the methods are the callable method names, namely createscreen capture and CreateUploader, and the specific operation code is shown in table three.
Watch III
In the code of table three, the generation process of the string identifier that can call the method name can be seen.
The above is only a preferred embodiment of the present invention, and it should be noted that the above preferred embodiment should not be considered as limiting the present invention, and the protection scope of the present invention should be subject to the scope defined by the claims. It will be apparent to those skilled in the art that various modifications and adaptations can be made without departing from the spirit and scope of the invention, and these modifications and adaptations should be considered within the scope of the invention.
Claims (6)
1. A method for obtaining an NPAPI interface list that can be called by an external entity, the method comprising:
the browser calls an NPP _ GetValue method to obtain an NPObject object, and the NPObject object is used as a bridge for interaction of JS and the plug-in;
when a JS method is called, NPObject is called firstly, and HasMethod is called to inquire whether the method exists or not; if yes, then calling NPObject, invoking to actually execute the corresponding method and transmitting the corresponding parameters;
when the browser calls the NPP _ GetValue method, returning an NPObject object;
registering a JS callable method, setting a method name, returning an identifier as an identifier of the character string, and using the identifier as an operation object when other methods are needed;
JS interface lookup for np. The registration of all JS-callable method names generates a character string identifier, the character string identifier is filled in a global variable, the callable positions of the JS-callable method names can be tracked in a cross-reference mode, and relevant attributes or method names are seen;
the JS method number to call is determined by the NPObject: HasMethod method,
the parameter list is determined from the implementation seen by the Invoke method in NPObject.
2. The method of claim 1, wherein the browser calls the NPP _ GetValue method and introduces three parameters, which are an NPP instance plugin instance, a structure for describing plugin information, and an NPObject pointer as a return result.
3. The method of claim 2, wherein the browser returns an NPObject when calling the NPP _ GetValue method, the NPObject is created by an NPN _ CreateObject, and the NPObject is defined as: NPObject NPN _ createoobject; among them, NPClass is a subclass inherited to scriptableplugingobjectbase, which provides the necessary basic methods.
4. The method of claim 1, wherein the JS method is implemented by a dispatcher that executes the corresponding NPIdentifier method.
5. The method of claim 1, wherein the registration of all JS callable method names generates a string identifier, and the specific registration is performed by using an NPN _ GetStringIdentifier function provided by the browser.
6. The method of claim 5, wherein the global variable is filled in an NP _ Initialize function, and then the calling site can be traced by means of cross-reference, and the related attribute or method name can be seen.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201911014948.1A CN110780949A (en) | 2019-10-24 | 2019-10-24 | Method for acquiring NPAPI interface list capable of being called by outside |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201911014948.1A CN110780949A (en) | 2019-10-24 | 2019-10-24 | Method for acquiring NPAPI interface list capable of being called by outside |
Publications (1)
Publication Number | Publication Date |
---|---|
CN110780949A true CN110780949A (en) | 2020-02-11 |
Family
ID=69387062
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201911014948.1A Pending CN110780949A (en) | 2019-10-24 | 2019-10-24 | Method for acquiring NPAPI interface list capable of being called by outside |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110780949A (en) |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20030056204A1 (en) * | 2001-06-21 | 2003-03-20 | Broussard Scott J. | Java classes comprising an application program interface for platform integration derived from a common codebase |
CN102938036A (en) * | 2011-11-29 | 2013-02-20 | Ut斯达康通讯有限公司 | Section double encryption and safe loading method of Windows dynamic link library |
CN106648627A (en) * | 2016-11-30 | 2017-05-10 | 武汉斗鱼网络科技有限公司 | Method and device for migrating live-streaming application software to mozilla firefox browser |
-
2019
- 2019-10-24 CN CN201911014948.1A patent/CN110780949A/en active Pending
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20030056204A1 (en) * | 2001-06-21 | 2003-03-20 | Broussard Scott J. | Java classes comprising an application program interface for platform integration derived from a common codebase |
CN102938036A (en) * | 2011-11-29 | 2013-02-20 | Ut斯达康通讯有限公司 | Section double encryption and safe loading method of Windows dynamic link library |
CN106648627A (en) * | 2016-11-30 | 2017-05-10 | 武汉斗鱼网络科技有限公司 | Method and device for migrating live-streaming application software to mozilla firefox browser |
Non-Patent Citations (4)
Title |
---|
19ENGLISH: "DLL接口的实现(虚函数)", 《HTTPS://BLOG.CSDN.NET/U011599942/ARTICLE/DETAILS/11195667》 * |
吴伟峰 等: "反编译中用户函数与库函数同名的区分技术研究", 《计算机学报》 * |
灬鬼谷灬: "深入理解虚函数表", 《HTTPS://BLOG.CSDN.NET/YO746862873/ARTICLE/DETAILS/51635503》 * |
聆听的风声: "火狐插件开发教程", 《HTTPS://WWW.CNBLOGS.COM/WANGJUNQIAO/P/4689035.HTML》 * |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US8286142B2 (en) | Method and system for providing a visual debugger for an interpreted statistical language | |
CN107908541B (en) | Interface testing method and device, computer equipment and storage medium | |
US8196108B2 (en) | Breakpoint management and reconciliation for embedded scripts in a business integration language specified program process | |
US20050015752A1 (en) | Static analysis based error reduction for software applications | |
GB2454263A (en) | Generating debug information from low level program code | |
US11113050B2 (en) | Application architecture generation | |
CN110650091B (en) | Routing configuration information processing method and device, computer equipment and storage medium | |
CN111026645A (en) | User interface automatic testing method and device, storage medium and electronic equipment | |
EP3447635A1 (en) | Application architecture generation | |
CN105630674A (en) | Test method and device capable of aiming at interface | |
CN111045941B (en) | Positioning method and device for user interface control and storage medium | |
CN110968296B (en) | Data acquisition method, device, equipment and readable storage medium | |
CN112100078A (en) | Method, device and equipment for generating interface test case | |
CN116302930A (en) | Application testing method and device | |
CN108595162B (en) | Code generation method and device | |
CN108319548A (en) | A kind of program code adjustment method and device | |
CN110780949A (en) | Method for acquiring NPAPI interface list capable of being called by outside | |
CN110457013B (en) | Program component configuration device and method | |
CN112416762A (en) | API test method and device, equipment and computer readable storage medium | |
US11954014B2 (en) | Automated unit testing in a mainframe CICS environment | |
CN114218072A (en) | Test script generation method and device, storage medium and computer equipment | |
CN107168870B (en) | Method for acquiring program information during operation | |
CN112073462B (en) | Positioning method and device | |
CN110297647B (en) | Method and terminal for updating npm packet by front-end engineering | |
CN111401020A (en) | Interface loading method and system and computing equipment |
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 | ||
RJ01 | Rejection of invention patent application after publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20200211 |