CN106909430A - A kind of compatible interface creation method and system - Google Patents

A kind of compatible interface creation method and system Download PDF

Info

Publication number
CN106909430A
CN106909430A CN201510971806.XA CN201510971806A CN106909430A CN 106909430 A CN106909430 A CN 106909430A CN 201510971806 A CN201510971806 A CN 201510971806A CN 106909430 A CN106909430 A CN 106909430A
Authority
CN
China
Prior art keywords
interface
function
state
kernel
pointer variable
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
Application number
CN201510971806.XA
Other languages
Chinese (zh)
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.)
Beijing Qihoo Technology Co Ltd
Qizhi Software Beijing Co Ltd
Original Assignee
Beijing Qihoo Technology Co Ltd
Qizhi Software Beijing 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, Qizhi Software Beijing Co Ltd filed Critical Beijing Qihoo Technology Co Ltd
Priority to CN201510971806.XA priority Critical patent/CN106909430A/en
Publication of CN106909430A publication Critical patent/CN106909430A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The interface creation method and a kind of compatible interface that the embodiment of the invention provides a kind of compatibility create system, it is related to field of computer technology, the interface function of the kernel state of identical parameters is will be provided with according to the present invention and state interface function is applied, corresponding common interface function is created in common interface storehouse, it is the first object of global function pointer variable loading correspondence kernel state interface function during compiling;It is the first object of the global function pointer variable loading correspondence application state interface function in application state example;Common interface storehouse is according to the function pointer variable, for common interface function generates calling interface, supply common code part is compatible to lower floor's kernel state, User space, the calling interface then can be as compatible system interface, thus User space is solved mutually incompatible with kernel state interface function, the low problem of development efficiency, achieves the compiling for making user that User space and kernel state code can be completed using compatibility interface, improves the beneficial effect of development efficiency.

Description

A kind of compatible interface creation method and system
Technical field
The present invention relates to field of computer technology, more particularly to a kind of compatible interface creation method and A kind of compatible interface creates system.
Background technology
Kernel state and two kinds of runtime classes that User space (User space can be understood as applying state) is operating system Not, the device driver of Windows is exactly to operate under kernel state, and user application is all transported Row is under User space.The program of User space is operated on non-privileged PRM processor mode, some other to be protected The subsystem code of shield is also operated in the pattern.The program of User space can not obtain depositing for system data Weighting, unless called Win32API, (Application Programming Interface, application program is compiled Journey interface) or system service.The driver of kernel state as operating system a part quilt Perform --- support the operating system bottom component of one or more shielded subsystems.
There is a kind of exploitation demand on the kernel development of windows platform, such as same set of logic, Need the code of kernel state and the code of User space simultaneously.But in practical application, for same work( Can, to should function kernel state interface function with application state interface function it is different.Therefore, open Hair personnel need to record the interface function of the interface function of kernel state form and application state form respectively, Using the interface function of application state, otherwise the generation of application state can not compiled when compiling the code of kernel state The interface function of kernel state can not be used during code.So for developer, for identical function There is the interface function of different forms, its exploitation is more complicated, and to develop respectively completely, develop Efficiency is low.
The content of the invention
In view of the above problems, it is proposed that the present invention overcomes above mentioned problem or at least portion to provide one kind The compatible interface creation method for solving the above problems with dividing and corresponding compatible interface creating device.
According to one aspect of the present invention, there is provided a kind of compatible interface creates system, including:
Kernel state interface creation module, using state interface creation module, common interface storehouse;
Kernel state interface creation module, is suitable in kernel state example, is global function pointer variable First object of loading correspondence kernel state interface function;The function pointer variable is directed to a pair of kernel states Interface function and application state interface function;The pair of kernel state interface function and application state interface function With identical parameter;
Using state interface creation module, it is suitable in application state example, is the global function pointer First object of variable loading correspondence application state interface function;
Common interface storehouse, is suitable to according to the function pointer variable, is that the generation of common interface function is called Interface;The common interface function has the kernel state interface function identical with application state interface function Parameter.
Preferably, in kernel state interface creation module and using state interface creation module before also include:
Global pointer definition module, is suitable for each pair kernel state interface function and application state interface function is determined The same global function pointer variable of justice.
Preferably, the kernel state interface creation module includes:
Kernel execution instance creation module, is suitable to create kernel state example;
Kernel state initialization module, is suitable in kernel state example, obtains the function pointer variable, And be the symbol of function pointer variable loading correspondence kernel state interface function.
Preferably, the application state interface creation module includes:
Application example creation module, is suitable to create and applies state example;
Using state initialization module, it is suitable in application state example, obtains the function pointer variable, And be the symbol of function pointer variable loading correspondence application state interface function.
Preferably, kernel state interface creation module also includes:
Kernel interface function export module, is suitable to obtain the calling interface of the common interface function, and Calling interface according to the common interface function derives kernel interface function file;
The application state interface creation module also includes:
Application interface function export module, is suitable to obtain the calling interface of the common interface function, and Calling interface according to the common interface function derives application interface function file.
Preferably, also include:
Using state program debugging module, be suitable to by application state routine interface select file and/or, standard Input and output debud mode, and/or debugging output debud mode;The application state program debugging interface mould Intend kernel state program debugging interface.
According to another aspect of the present invention, there is provided a kind of compatible interface creation method, including:
It is global function pointer variable loading correspondence kernel state interface function in kernel state example First object;The function pointer variable is for a pair of kernel state interface functions and applies state interface letter Number;The pair of kernel state interface function and there is identical parameter using state interface function
It is the global function pointer variable loading correspondence application state interface letter in application state example The first several objects;
It is common interface function generation calling interface according to the function pointer variable;It is described public to connect Mouth function has the kernel state interface function and applies state interface function identical parameter.
Preferably, it is that global function pointer variable loading correspondence kernel state connects in kernel state example First object of mouthful function and in application state example, is that the global function pointer variable loading is right Before the first object of state interface function should be applied, also include:
It is that each pair kernel state interface function and application state interface function define same global function pointer Variable.
Preferably, it is described in kernel state example, it is global function pointer variable loading correspondence kernel First object of state interface function includes:
Create kernel state example;
In kernel state example, the function pointer variable is obtained, and for the loading of function pointer variable is right Answer the symbol of kernel state interface function.
Preferably, it is described in application state example, it is the global function pointer variable loading correspondence The first object using state interface function includes:
Create and apply state example;
In application state example, the function pointer variable is obtained, and for the loading of function pointer variable is right The symbol of state interface function should be applied.
Preferably, also include:
Obtain the calling interface of the common interface function, and calling according to the common interface function Interface derives kernel interface function file;
With the calling interface for obtaining the common interface function, and according to the tune of the common interface function Application interface function file is derived with interface.
Preferably, also include:
By application state routine interface select file and/or, standard input and output debud mode, and/or tune Examination output debud mode;The application state program debugging interface simulates kernel state program debugging interface.
According to another aspect of the present invention, there is provided a kind of compatible interface creates equipment, including:
Memory, is loaded with a plurality of executable instruction;
Processor, performs a plurality of executable instruction;The a plurality of executable instruction include perform with The method of lower step:
It is global function pointer variable loading correspondence kernel state interface function in kernel state example First object;The function pointer variable is for a pair of kernel state interface functions and applies state interface letter Number;The pair of kernel state interface function and there is identical parameter using state interface function
It is the global function pointer variable loading correspondence application state interface letter in application state example The first several objects;
It is common interface function generation calling interface according to the function pointer variable;It is described public to connect Mouth function has the kernel state interface function and applies state interface function identical parameter.
Compatible interface of the invention creates system and method, includes common interface storehouse, kernel State interface creation module, using state interface creation module, will be provided with the interface of the kernel state of identical parameters Function and application state interface function, create corresponding common interface function, the institute in common interface storehouse Stating common interface function has the kernel state interface function and applies state interface function identical parameter. It is global function pointer variable loading correspondence kernel state interface in kernel state example when then compiling First object of function;It is the global function pointer variable loading in addition in application state example First object of correspondence application state interface function;Then common interface storehouse becomes according to the function pointer Amount, is common interface function generation calling interface, and supply common code part is to lower floor's kernel state, use Family state is compatible, the calling interface then can as compatible system interface, thus solve User space and Kernel state interface function is mutually incompatible, causes exploitation complicated, and the low problem of development efficiency is achieved Compatibility interface can be provided to user on upper strata, and user is completed user using compatibility interface The compiling of state and kernel state code, improves the beneficial effect of development efficiency.
Described above is only the general introduction of technical solution of the present invention, of the invention in order to better understand Technological means, and being practiced according to the content of specification, and in order to allow it is of the invention above-mentioned and Other objects, features and advantages can become apparent, below especially exemplified by specific embodiment party of the invention Formula.
Brief description of the drawings
By reading the detailed description of hereafter preferred embodiment, various other advantage and benefit for Those of ordinary skill in the art will be clear understanding.Accompanying drawing is only used for showing the mesh of preferred embodiment , and it is not considered as limitation of the present invention.And in whole accompanying drawing, with identical with reference to symbol Number represent identical part.In the accompanying drawings:
Fig. 1 shows that a kind of compatible interface according to an embodiment of the invention creates system embodiment Structured flowchart;
Fig. 2 shows that a kind of compatible interface according to an embodiment of the invention creates system embodiment Structured flowchart;
Fig. 2A shows that a kind of compatible interface according to an embodiment of the invention creates system embodiment Logical architecture figure;
Fig. 3 shows a kind of compatible interface creation method embodiment according to an embodiment of the invention Flow chart of steps;
Fig. 4 shows a kind of compatible interface creation method embodiment according to an embodiment of the invention Flow chart of steps.
Specific embodiment
The exemplary embodiment of the disclosure is more fully described below with reference to accompanying drawings.Although showing in accompanying drawing The exemplary embodiment of the disclosure is shown, it being understood, however, that may be realized in various forms the disclosure Without that should be limited by embodiments set forth here.Conversely, there is provided these embodiments are able to more Thoroughly understand the disclosure, and can be by the complete technology for conveying to this area of the scope of the present disclosure Personnel.
Reference picture 1, shows that a kind of compatible interface according to an embodiment of the invention creates system reality The structured flowchart of example is applied, can specifically include such as lower module:
Kernel state interface creation module 110, using state interface creation module 120, common interface storehouse 130;
Kernel state interface creation module 110, is suitable in kernel state example, is that global function pointer becomes First object of amount loading correspondence kernel state interface function;The function pointer variable is directed to a pair of kernels State interface function and application state interface function;The pair of kernel state interface function and application state interface letter Number has identical parameter;
Such as table 1- tables 3, it illustrates in the different operating under the difference in functionality classification of Windows systems Core state interface function and application state interface function, two function pairs often gone answer same operation.Such as ZwOpenFile is the function and NtOpenFile for opening file of kernel state to answer in table 1- tables 3 With the function for opening file of state, both parameters are consistent.
Other functions are similar to, and as shown in table 1- tables 3, most kernel state interface function and apply state Interface function be different from.
Table 1
Table 2
Table 3
And the embodiment of the present invention, for each pair kernel state interface function in table 1- tables 3 and using state interface Function is provided with a common interface function all in common interface storehouse, and its parameter connects with this pair of kernel state Mouthful function is consistent with application state interface function, is kernel state for beating such as foregoing ZwOpenFile The function and NtOpenFile of open file are using the function for opening file of state, there is provided public Interface function FRMBASE_OpenFile, its parameter is as described above.
In embodiments of the present invention, due to constructing above-mentioned common interface storehouse, in order to common interface The function in storehouse is corresponding with the kernel state interface function of reality to be used, then complete firstly the need of predefined one The function pointer variable of office, then in kernel state example, obtains the global function pointer variable, Then it is the first object of global function pointer variable loading correspondence kernel state interface function.It is actual On, it is by the ground of common interface function for the function pointer variable loads kernel the first object of state function Point to the address of the kernel state function in location.
In C language, a function always takes one section of continuous memory field, and function name is exactly this The first address of memory field shared by function.We can assign this first address (or entry address) of function A pointer variable is given, the pointer variable is pointed to the function.Then can just be looked for by pointer variable To and call this function.Therefore, this pointer variable for pointing to function is referred to as " function pointer change Amount ".The general type of function pointer variable-definition is:
Type specifier (* pointer variables name) ();
Preferably, before kernel state interface creation module 110 and application state interface creation module 120, Also include:
Global pointer definition module 100, is suitable for each pair kernel state interface function and applies state interface function Define same global function pointer variable.
In embodiments of the present invention, in order that in kernel state example and application state example, can distinguish Function pointer variable is obtained, the embodiment of the present invention is provided with the function pointer variable of the overall situation.So kernel State interface creation module is in its kernel state example, you can obtain the function pointer variable, is its loading First object of correspondence kernel state interface function.Using state interface creation module state example is applied at it In, you can the function pointer variable is obtained, is the first couple of its loading correspondence application state interface function As.
For foregoing " (* pointer variables name) () " in the embodiment of the present invention, the overall situation is defined as Function pointer variable.
Using state interface creation module 120, it is suitable in application state example, is that the global function refers to First object of pin variable loading correspondence application state interface function;
In embodiments of the present invention, for foregoing global function pointer variable, then in application state reality In example, the global function pointer variable is obtained, then for global function pointer variable loads correspondence Using the first object of state interface function.In fact, for state function is applied in function pointer variable loading First object, is that the address of common interface function is pointed into the address using state function.
Common interface storehouse 130, is suitable to according to the function pointer variable, is that the generation of common interface function is adjusted Use interface;The common interface function has the kernel state interface function and applies state interface function phase Same parameter.
In actual applications, it is being the overall situation that kernel state interface creation module or application state interface are created Function pointer variable load corresponding first object after, common interface storehouse can be respectively called, by public Interface library is that the function pointer variable and common interface function encapsulate a calling interface.Then this is adjusted Respective example is returned to interface.
In this way, can pass through same calling interface realize to the kernel state of bottom, User space it is same The compatibility of the interface function of operation.
When certain process calls the calling interface, then the kernel state that the calling interface can be according to belonging to it Still state is applied, the first of corresponding corresponding kernel state or application state is oriented to by function pointer variable Object, then will perform in the incoming corresponding function of parameter.It is achieved thereby that kernel state and application state The unification of interface.
The embodiment of the present invention includes common interface storehouse, kernel state interface creation module, using state interface Creation module, will be provided with the interface function of the kernel state of identical parameters and applies state interface function, in public affairs With corresponding common interface function is created in interface library, this states common interface function has the kernel state Interface function and application state interface function identical parameter.When then compiling, it is in kernel state example First object of global function pointer variable loading correspondence kernel state interface function;In addition in application state It is the first couple of the global function pointer variable loading correspondence application state interface function in example As;Then common interface storehouse is according to the function pointer variable, is that the generation of common interface function is called and connect Mouthful, supply common code part is compatible to lower floor's kernel state, User space, and the calling interface can then be made It is compatible system interface, it is mutually incompatible with kernel state interface function thus to solve User space, leads Cause exploitation complicated, the low problem of development efficiency, achieve can upper strata provide compatibility interface to Family, and allow user that the compiling of User space and kernel state code is completed using compatibility interface, improve The beneficial effect of development efficiency.
Embodiment two
Reference picture 2, shows that a kind of compatible interface according to an embodiment of the invention creates system reality The structured flowchart of example is applied, can specifically include such as lower module:
Global pointer definition module 210, kernel state interface creation module 220, using state interface create mould Block 230, common interface storehouse 240;The embodiment of the present invention is described with reference to Fig. 2A.Fig. 2A Show that the optimal compatible interface of the present invention creates system architecture logic chart.
The embodiment of the present invention is built using WDK, and WDK is the kernel development compiling set of Microsoft's issue Part, itself not only supports compiling generation kernel sys modules, also supports compiling user state executable program Exe and dynamic link library dll.The embodiment of the present invention is using two WDK Makefile Development Engineerings difference Build kernel state interface creation module 220 and application state interface creation module 230.I.e. as in Fig. 2A DLL Makefile correspondence application state interfaces creation module 230, SYS Makefile correspondence kernel state interfaces Creation module 220.
Wherein, global pointer definition module 210, is suitable for each pair kernel state interface function and is connect using state Mouth function defines same global function pointer variable.
In embodiments of the present invention public header file Common FRMBase.h (do not show in Fig. 2A Go out) defined in global function pointer variable.The Common after FRMBase.h loadings correspondence it is global Pointer definition module 210.
In actual applications, the interface function for being operated if necessary to which or which, then can determine The global function pointer variable of adopted these operations, than if desired for ZwOpenFile's and NtOpenFile Operation, then can define global function pointer variable is:
typedef NTSTATUS(NTAPI*FN_NtOpenFile)(
OUT PHANDLE FileHandle,
N ACCESS_MASK DesiredAccess,
IN POBJECT_ATTRIBUTES ObjectAttributes,
OUT PIO_STATUS_BLOCK IoStatusBlock,
IN ULONG ShareAccess,
IN ULONG OpenOptions);
Wherein FN_NtOpenFile is function pointer type of variables, and its function pointer variable is fn_NtOpenFile.Certainly, function pointer variable name can be named by the way of any custom, this Inventive embodiments are not any limitation as to it.
Certainly, it is similar to definition for other functions for operating.
Kernel state interface creation module 220, is suitable in kernel state example, is that global function pointer becomes First object of amount loading correspondence kernel state interface function;The function pointer variable is directed to a pair of kernels State interface function and application state interface function;The pair of kernel state interface function and application state interface letter Number has identical parameter;Specifically include:
Kernel execution instance creation module 221, is suitable to create kernel state example;
In embodiments of the present invention such as Fig. 2A, Drv therein correspondence kernel in part where Drv Main.C Example creation module 221.Drv Drv Main.C start after, load kernel state example, in the kernel Other parts are loaded in state example.Drv Drv Main.C realize the base of kernel state interface creation module 220 Plinth framework, for the treatment of kernel state interface provides running environment.
Kernel state initialization module 222, is suitable in kernel state example, obtains the function pointer and becomes Amount, and be the symbol of function pointer variable loading correspondence kernel state interface function.
Such as Fig. 2A, Drv XxxBaseInit.c correspondence kernel states initialization module 222.Of the invention real In applying example, can in advance Drv write each kernel state interface function in XxxBaseInit.c, it is and right The dynamic load logic of function pointer variable.
In embodiments of the present invention, kernel state example establishment after, then can load Drv XxxBaseInit.c carries out the process of kernel interface function initialization, and it can be from global pointer definition module The function pointer variable of the overall situation is obtained in 210, then analyzes which kernel the function pointer variable is directed to Interface function, such as by function pointer variable and the corresponding relation of kernel interface function name, it is determined that should Function pointer variable correspondence is which kernel interface function.Then the kernel is loaded to the function pointer variable The symbol of interface function.Such as foregoing typedef NTSTATUS (NTAPI * FN_NtOpenFile) (), function pointer types of variables FN_NtOpenFile is extracted, with structure in advance FN_NtOpenFile and ZwOpenFile functions corresponding relation, identified according to certain kernel state The corresponding relation of FN_NtOpenFile and ZwOpenFile functions is searched, to determine that the function pointer becomes Corresponding kernel state interface function is measured for ZwOpenFile functions, then can be by ZwOpenFile functions Symbol load and give the function pointer variable.Its loading procedure can be as follows:
1st, the function name of kernel state interface function is generated into a unicode character string;
Such as RtlInitUnicodeString (s &usNtOpenFile, WSTR_FUNC_OPENFILE);
By taking foregoing fn_NtOpenFile as an example, WSTR_FUNC_OPENFILE correspondences ZwOpenFile The function name of function, i.e. ZwOpenFile.Will by RtlInitUnicodeString functions The function name of ZwOpenFile functions generates a unicode character string.
2nd, function pointer variable is obtained, the address of kernel state interface function is searched from kernel, and should Address assigns the function pointer variable.
Such as function pointer variable fn_NtOpenFile, its code is such as:
Fn_NtOpenFile=MmGetSystemRoutineAddress (&usNtOpenFile);
Wherein, by MmGetSystemRoutineAddress functions, using foregoing ZwOpenFile The unicode character strings of function, search the address of ZwOpenFile functions from kernel.
Using state interface creation module 230, it is suitable in application state example, is that the global function refers to First object of pin variable loading correspondence application state interface function;Specifically include:
Application example creation module 231, is suitable to create and applies state example;
In embodiments of the present invention such as Fig. 2A, Dll therein part correspondence application where Dll Main.C it is real Example creation module 231.Dll Dll Main.C start after, loading apply state example, apply state at this Other parts are loaded in example.Dll Dll Main.C realize the basis of application state interface creation module 230 Framework, to provide running environment using the treatment of state interface.
Using state initialization module 232, it is suitable in application state example, obtains the function pointer and become Amount, and be the symbol of function pointer variable loading correspondence application state interface function.
Such as Fig. 2A, Dll XxxBaseInit.c correspondence application states initialization module 232.Of the invention real In applying example, can in advance Dll write each application state interface function in XxxBaseInit.c, it is and right The dynamic load logic of function pointer variable.
In embodiments of the present invention, application state example establishment after, then can load Dll XxxBaseInit.c carries out the process of application interface function initialization, and it can be from global pointer definition module The function pointer variable of the overall situation is obtained in 210, then analyzes which application the function pointer variable is directed to Interface function, such as by function pointer variable and the corresponding relation of application interface function name, it is determined that should Function pointer variable correspondence is which application interface function.Then the application is loaded to the function pointer variable The symbol of interface function.Such as foregoing typedef NTSTATUS (NTAPI * FN_NtOpenFile) (), function pointer types of variables FN_NtOpenFile is extracted, with structure in advance FN_NtOpenFile and NtOpenFile functions corresponding relation, looked into according to certain application state mark The corresponding relation of FN_NtOpenFile and NtOpenFile functions is looked for, to determine the function pointer variable pair The application state interface function answered is NtOpenFile, then can be added the symbol of ZwOpenFile functions Carry and give the function pointer variable.Its loading procedure can be as follows:
1st, the dynamic link library ntdll.dll handles of application state kernel interface function are obtained;
Such as hDllModule=GetModuleHandle (TSTR_DLL_NTDLL);
Wherein, by GetModuleHandle functions, the handle of dynamic link library ntdll.dll is obtained.
2nd, the handle according to the dynamic link library ntdll.dll searches corresponding dynamic link library, then The address of the application state interface function is searched from the dynamic link library and the letter is assigned by the address Number pointer variable.
Such as function pointer variable fn_NtOpenFile, its code is such as:
Fn_NtOpenFile= (FN_NtOpenFile)GetProcAddress(hDllModule,ASTR_FUNC_OPENFILE);
Wherein, the function name of WSTR_FUNC_OPENFILE correspondences NtOpenFile functions, passes through From the handle corresponding ntdll.dll of lookup of dynamic link library ntdll.dll by GetProcAddress, and from The address of NtOpenFile functions is searched in the ntdll.dll.
Common interface storehouse 240, is suitable to according to the function pointer variable, is that the generation of common interface function is adjusted Use interface;The common interface function has the kernel state interface function and applies state interface function phase Same parameter.
As Fig. 2A common interfaces storehouse 240 include Common Xxxbase.c and Common Xxx.C. In embodiments of the present invention, for the kernel state interface function with identical parameters and using state interface letter Number, encapsulates common interface function in common interface storehouse.It is with NtOpenFile and ZwOpenFile Example, Common in Xxxbase.c packaged type it is as follows:
Due to foregoing kernel state interface creation module 220 and each leisure of application state interface creation module 230 certainly Global function pointer variable is imparted the symbol of corresponding demand in oneself example, and in order that each Caller when common interface function is called, can be by the kernel state interface function of the incoming bottom of parameter Or state interface function is applied, the embodiment of the present invention is also to the function pointer variable and public function interface It is packaged, is encapsulated as a calling interface, then kernel state is called public using state caller During interface function, the function just can by the calling interface by parameter be delivered to corresponding kernel state or Person is using in the interface function of state.In embodiments of the present invention, the high level for common interface is encapsulated in Common perform in Xxx.C.
Such as foregoing fn_NtOpenFile, it is as follows that it encapsulates example code:
In this way, if the caller of kernel state calls FRMBASE_OpenFile functions, basis is interior The identity of core state, by the calling interface, by each parameter by function pointer variable, is passed to ZwOpenFile.Then bottom is the logic of executable kernel state interface function.
If calling FRMBASE_OpenFile functions using the caller of state, according to application state Identity, by the calling interface, by each parameter by function pointer variable, is passed to NtOpenFile.Then bottom is the logic of executable application state interface function.
In actual applications, also including internal memory declaration module, it includes Common MemManage.h, three functions have been further stated that wherein:
#define__MM__TEXT("MemoryManagement:")
EXTERN_C PVOID
MM_MemAlloc(IN SIZE_T stByteCount);Define memory allocation function;
EXTERN_C PVOID
MM_MemReAlloc(IN PVOID lpMem,IN SIZE_T stByteCount);In defining Deposit reassignment function;
EXTERN_C VOID
MM_MemFree(IN PVOID lpMem);Define internal memory release function.
Can so be called in kernel state memory management module and using state memory management module above-mentioned several Function carries out memory management.
Preferably, in kernel state interface creation module 220, also include:
Kernel interface function export module 223, is suitable to obtain the calling interface of the common interface function, And kernel interface function file is derived according to the calling interface of the common interface function;
In embodiments of the present invention, as the Drv in Fig. 2A correspondence kernel interface after Drv_Xxx.h loadings Function export module 223.Kernel interface function export module 223 connects in calling for common interface storehouse 240 After mouth encapsulation is finished, common interface function and calling interface can be obtained, and impart kernel interface The codes such as the function pointer variable of the symbol of function, derive kernel interface function file, such as Sys files.
Certainly, in actual applications, in kernel state interface creation module 220, also include:
Kernel state memory management module, is suitable to be managed the corresponding internal memory of kernel state example.
Such as Fig. 2A, its Drv correspondence kernel state memory management module after MemManage.c loadings. Drv realize unified dynamic memory management calling interface in MemManage.c.Kernel state interface is created Other modules of module 220 can call the calling interface of kernel state memory management module in oneself distribution Deposit.
Preferably, in application state interface creation module 230, also include:
Application interface function export module 233, is suitable to obtain the calling interface of the common interface function, And application interface function file is derived according to the calling interface of the common interface function.
In embodiments of the present invention, as the DLL in Fig. 2A after DLL_Xxx.h loadings correspondence application connect Mouth function export module 233.The calling in common interface storehouse 240 of application interface function export module 233 After interface encapsulation is finished, common interface function and calling interface can be obtained, and imparts kernel and connect The codes such as the function pointer variable of symbol of mouth function, derive application interface function file, such as dll texts Part.
Certainly, in actual applications, in application state interface creation module 230, also include:
Using state memory management module, it is suitable to be managed the corresponding internal memory of application state example.
Such as Fig. 2A, its Dll correspondence application state memory management module after MemManage.c loadings. Dll realize unified dynamic memory management calling interface in MemManage.c.Mould is created using state interface Other modules of block 230 can be called using the calling interface of state memory management module as in oneself distribution Deposit.
Preferably, in application state interface creation module 230, also include:
Using state program debugging module 234, be suitable to by application state routine interface select file and/or, Standard input and output debud mode, and/or debugging output debud mode;The application state program debugging connects Mouth mold intends kernel state program debugging interface.
In embodiments of the present invention, such as Fig. 2A, Dll after DbgTrace.c loadings correspondence application state program remove Mismatch block 234, application layer is connect by DbgTrace.c simulated implementation kernel states program debugging (Debug) Mouthful, not only unify with kernel tailoring information interface but also can be accustomed in the application layer tune according to application layer programming Try in mouthful simulated implementation alternatively from file, standard input and output and the various debugging sides of debugging output Formula.So as to user can be selected in application state program debugging module 234 by application state routine interface File and/or, standard input and output debud mode, and/or debugging output debud mode.By this kind of side Formula makes to can be used to verifying and aiding in kernel development, lifting exploitation and test using state program debugging module 234 Efficiency.
Only calling DbgPrint interfaces or DbgPrintEx interfaces in kernel in actual applications is carried out Debug is exported.And in order that can be right using the custom of Application of composite layer using the DLL Makefile of state Program verified, the embodiment of the present invention application state program debugging module 234 provide file printout, Standard output, Debug export three kinds of interfaces.In actual applications, can select out according to actual needs Which kind of interface closed.In embodiments of the present invention, the above three in application state program debugging module 234 Interface is derived the interface of the same name with kernel state, and oneself need can be encapsulated in the interface using state The logic asked.
The embodiment of the present invention includes common interface storehouse, kernel state interface creation module, using state interface Creation module, will be provided with the interface function of the kernel state of identical parameters and applies state interface function, in public affairs With corresponding common interface function is created in interface library, this states common interface function has the kernel state Interface function and application state interface function identical parameter.When then compiling, it is in kernel state example First object of global function pointer variable loading correspondence kernel state interface function;In addition in application state It is the first couple of the global function pointer variable loading correspondence application state interface function in example As;Then common interface storehouse is according to the function pointer variable, is that the generation of common interface function is called and connect Mouthful, supply common code part is compatible to lower floor's kernel state, User space, and the calling interface can then be made It is compatible system interface, it is mutually incompatible with kernel state interface function thus to solve User space, leads Cause exploitation complicated, the low problem of development efficiency, achieve can upper strata provide compatibility interface to Family, and allow user that the compiling of User space and kernel state code is completed using compatibility interface, improve The beneficial effect of development efficiency.And can provide makes using state program debugging module, for verifying and Auxiliary kernel development, lifts testing efficiency.
Embodiment three
Reference picture 3, shows a kind of compatible interface creation method reality according to an embodiment of the invention The step of applying flow chart, specifically may include steps of:
Step 310, is that global function pointer variable loading correspondence kernel state connects in kernel state example First object of mouth function;The function pointer variable is for a pair of kernel state interface functions and applies state Interface function;The pair of kernel state interface function and there is identical parameter using state interface function.
Step 320, is the global function pointer variable loading correspondence application in application state example First object of state interface function;
Step 310 and step 320 can be with executed in parallel in embodiments of the present invention.
Step 330, is common interface function generation calling interface according to the function pointer variable;Institute Stating common interface function has the kernel state interface function and applies state interface function identical parameter.
Preferably, also included before step 310 and step 320:
Step 300, is that each pair kernel state interface function and application state interface function define the same overall situation Function pointer variable.
The embodiment of the invention provides common interface storehouse, will be provided with identical parameters kernel state interface letter State interface function is counted and applied, corresponding common interface function is created in common interface storehouse, this is described Common interface function has the kernel state interface function and applies state interface function identical parameter.So After when compiling, be global function pointer variable loading correspondence kernel state interface letter in kernel state example The first several objects;It is that the global function pointer variable loading is right in addition in application state example The first object of state interface function should be applied;Then common interface storehouse is according to the function pointer variable, For common interface function generates calling interface, supply common code part is to lower floor's kernel state, User space Thus compatibility, the calling interface then can solve User space and kernel as compatible system interface State interface function is mutually incompatible, causes exploitation complicated, the low problem of development efficiency, and achieving can be with Upper strata provide compatibility interface to user, and allow user using compatibility interface complete User space and The compiling of kernel state code, improves the beneficial effect of development efficiency.
Example IV
Reference picture 4, shows a kind of compatible interface creation method reality according to an embodiment of the invention The step of applying flow chart, specifically may include steps of:
Step 410, is that each pair kernel state interface function and application state interface function define the same overall situation Function pointer variable.The function pointer variable is for a pair of kernel state interface functions and applies state interface Function;The pair of kernel state interface function and there is identical parameter using state interface function.
Step 412, creates kernel state example;
Step 414, in kernel state example, obtains the function pointer variable, and for function pointer becomes The symbol of amount loading correspondence kernel state interface function.
Step 416, creates and applies state example;
Step 418, in application state example, obtains the function pointer variable, and for function pointer becomes The symbol of amount loading correspondence application state interface function.
Step 420, is common interface function generation calling interface according to the function pointer variable;Institute Stating common interface function has the kernel state interface function and applies state interface function identical parameter.
Step 422, obtains the calling interface of the common interface function, and according to the common interface letter Several calling interfaces derives application interface function file.
Step 424, obtains the calling interface of the common interface function, and according to the common interface letter Several calling interfaces derives kernel interface function file;
In embodiments of the present invention, step 412,414,422 only can hold in SYS Makefile OK.Step 416,418,424 only can perform in Dll Makefile.
Preferably, also included before step 310 and step 320:
Step A11, by application state routine interface select file and/or, standard input and output debugging side Formula, and/or debugging output debud mode;The application state program debugging interface simulation kernel state program is removed Misconnection mouthful.
For embodiment of the method, in order to be briefly described, therefore it is all expressed as a series of action group Close, but those skilled in the art should know, and the embodiment of the present invention is not suitable by described action The limitation of sequence, because according to the embodiment of the present invention, some steps can using other orders or simultaneously Carry out.Secondly, those skilled in the art should also know, embodiment described in this description belongs to Necessary to preferred embodiment, the involved action not necessarily embodiment of the present invention.
Provided herein algorithm and display not with any certain computer, virtual system or miscellaneous equipment It is intrinsic related.Various general-purpose systems can also be used together with based on teaching in this.According to above Description, the structure constructed required by this kind of system is obvious.Additionally, the present invention is not also directed to Any certain programmed language.It is understood that, it is possible to use various programming languages realize described here The content of invention, and the description done to language-specific above is to disclose optimal reality of the invention Apply mode.
In specification mentioned herein, numerous specific details are set forth.It is to be appreciated, however, that Embodiments of the invention can be put into practice in the case of without these details.In some instances, Known method, structure and technology is not been shown in detail, so as not to obscure the understanding of this description.
Similarly, it will be appreciated that in order to simplify the disclosure and helping understand in each inventive aspect one Individual or multiple, in above to the description of exemplary embodiment of the invention, each feature of the invention Sometimes it is grouped together into single embodiment, figure or descriptions thereof.However, should be by The method of the disclosure is construed to reflect following intention:I.e. the present invention for required protection requirement ratio is at each The more features of feature being expressly recited in claim.More precisely, as following right will As asking book to reflect, inventive aspect is all spies less than single embodiment disclosed above Levy.Therefore, it then follows thus claims of specific embodiment are expressly incorporated in the specific embodiment party Formula, wherein each claim are in itself as separate embodiments of the invention.
Those skilled in the art are appreciated that can be carried out to the module in the equipment in embodiment Adaptively change and they are arranged in one or more equipment different from the embodiment. Module or unit or component in embodiment can be combined into a module or unit or component, and In addition multiple submodule or subelement or sub-component can be divided into.Except such feature and/or Outside at least some in process or unit exclude each other, can be using any combinations to this explanation All features disclosed in book (including adjoint claim, summary and accompanying drawing) and so disclosed All processes or unit of any method or equipment are combined.Unless expressly stated otherwise, this theory Each feature disclosed in bright book (including adjoint claim, summary and accompanying drawing) can be by offer phase The alternative features of same, equivalent or similar purpose replace.
Although additionally, it will be appreciated by those of skill in the art that some embodiments described herein include Some included features are rather than further feature, but the feature of different embodiments in other embodiments Combination mean to be within the scope of the present invention and formed different embodiments.For example, under In the claims in face, the one of any of embodiment required for protection can be in any combination Mode is used.
All parts embodiment of the invention can realize with hardware, or with one or more The software module run on reason device is realized, or is realized with combinations thereof.Those skilled in the art It should be appreciated that can be realized using microprocessor or digital signal processor (DSP) in practice Some or all parts in compatible interface establishment equipment according to embodiments of the present invention some or Person's repertoire.The present invention be also implemented as a part for performing method as described herein or Person whole equipment or program of device (for example, computer program and computer program product).So Realize that program of the invention can be stored on a computer-readable medium, or can have one or The form of person's multiple signal.Such signal can be downloaded from internet website and obtained, or carried There is provided on body signal, or provided in any other form.
It should be noted that above-described embodiment the present invention will be described is limited rather than to the present invention Make, and those skilled in the art can design without departing from the scope of the appended claims Alternative embodiment.In the claims, any reference symbol being located between bracket should not be configured to Limitations on claims.Word "comprising" do not exclude the presence of element not listed in the claims or Step.Word "a" or "an" before element does not exclude the presence of unit as multiple Part.The present invention can be by means of the hardware for including some different elements and by means of properly programmed Computer is realized.If some in these devices in the unit claim for listing equipment for drying Individual can be embodied by same hardware branch.Word first, second, and third Using not indicating that any order.These words can be construed to title.
System is created the invention discloses A1, a kind of compatible interface, including:
Kernel state interface creation module, using state interface creation module, common interface storehouse;
Kernel state interface creation module, is suitable in kernel state example, is global function pointer variable First object of loading correspondence kernel state interface function;The function pointer variable is directed to a pair of kernel states Interface function and application state interface function;The pair of kernel state interface function and application state interface function With identical parameter;
Using state interface creation module, it is suitable in application state example, is the global function pointer First object of variable loading correspondence application state interface function;
Common interface storehouse, is suitable to according to the function pointer variable, is that the generation of common interface function is called Interface;The common interface function has the kernel state interface function identical with application state interface function Parameter.
A2, the method according to claim A1, it is characterised in that create mould in kernel state interface Block and using also including before state interface creation module:
Global pointer definition module, is suitable for each pair kernel state interface function and application state interface function is determined The same global function pointer variable of justice.
A3, the method according to claim A1 or A2, it is characterised in that the kernel state connects Mouth creation module includes:
Kernel execution instance creation module, is suitable to create kernel state example;
Kernel state initialization module, is suitable in kernel state example, obtains the function pointer variable, And be the symbol of function pointer variable loading correspondence kernel state interface function.
A4, the method according to claim A1 or A2, it is characterised in that the application state connects Mouth creation module includes:
Application example creation module, is suitable to create and applies state example;
Using state initialization module, it is suitable in application state example, obtains the function pointer variable, And be the symbol of function pointer variable loading correspondence application state interface function.
A5, the method according to claim A1, it is characterised in that kernel state interface creation module Also include:
Kernel interface function export module, is suitable to obtain the calling interface of the common interface function, and Calling interface according to the common interface function derives kernel interface function file;
The application state interface creation module also includes:
Application interface function export module, is suitable to obtain the calling interface of the common interface function, and Calling interface according to the common interface function derives application interface function file.
A6, the method according to claim A1, it is characterised in that also include:
Using state program debugging module, be suitable to by application state routine interface select file and/or, standard Input and output debud mode, and/or debugging output debud mode;The application state program debugging interface mould Intend kernel state program debugging interface.
The invention discloses B7, a kind of compatible interface creation method, including:
It is global function pointer variable loading correspondence kernel state interface function in kernel state example First object;The function pointer variable is for a pair of kernel state interface functions and applies state interface letter Number;The pair of kernel state interface function and there is identical parameter using state interface function
It is the global function pointer variable loading correspondence application state interface letter in application state example The first several objects;
It is common interface function generation calling interface according to the function pointer variable;It is described public to connect Mouth function has the kernel state interface function and applies state interface function identical parameter.
B8, the method according to claim B7, it is characterised in that in kernel state example, be Global function pointer variable loads the first object of correspondence kernel state interface function and in application state example In, be the global function pointer variable loading correspondence application state interface function the first object it Before, also include:
It is that each pair kernel state interface function and application state interface function define same global function pointer Variable.
B9, the method according to claim B7 or B8, it is characterised in that described in kernel state It is the first object bag of global function pointer variable loading correspondence kernel state interface function in example Include:
Create kernel state example;
In kernel state example, the function pointer variable is obtained, and for the loading of function pointer variable is right Answer the symbol of kernel state interface function.
B10, the method according to claim B7 or B8, it is characterised in that described in application state It is the first object of the global function pointer variable loading correspondence application state interface function in example Including:
Create and apply state example;
In application state example, the function pointer variable is obtained, and for the loading of function pointer variable is right The symbol of state interface function should be applied.
B11, the method according to claim B7, it is characterised in that also include:
Obtain the calling interface of the common interface function, and calling according to the common interface function Interface derives kernel interface function file;
With the calling interface for obtaining the common interface function, and according to the tune of the common interface function Application interface function file is derived with interface.
B12, the method according to claim B7, it is characterised in that also include:
By application state routine interface select file and/or, standard input and output debud mode, and/or tune Examination output debud mode;The application state program debugging interface simulates kernel state program debugging interface.
C13, a kind of compatible interface create equipment, including:
Memory, is loaded with a plurality of executable instruction;
Processor, performs a plurality of executable instruction;The a plurality of executable instruction include perform with The method of lower step:
It is global function pointer variable loading correspondence kernel state interface function in kernel state example First object;The function pointer variable is for a pair of kernel state interface functions and applies state interface letter Number;The pair of kernel state interface function and there is identical parameter using state interface function
It is the global function pointer variable loading correspondence application state interface letter in application state example The first several objects;
It is common interface function generation calling interface according to the function pointer variable;It is described public to connect Mouth function has the kernel state interface function and applies state interface function identical parameter.

Claims (10)

1. a kind of compatible interface creates system, including:
Kernel state interface creation module, using state interface creation module, common interface storehouse;
Kernel state interface creation module, is suitable in kernel state example, is global function pointer variable First object of loading correspondence kernel state interface function;The function pointer variable is directed to a pair of kernel states Interface function and application state interface function;The pair of kernel state interface function and application state interface function With identical parameter;
Using state interface creation module, it is suitable in application state example, is the global function pointer First object of variable loading correspondence application state interface function;
Common interface storehouse, is suitable to according to the function pointer variable, is that the generation of common interface function is called Interface;The common interface function has the kernel state interface function identical with application state interface function Parameter.
2. method according to claim 1, it is characterised in that in kernel state interface creation module Also include with before application state interface creation module:
Global pointer definition module, is suitable for each pair kernel state interface function and application state interface function is determined The same global function pointer variable of justice.
3. method according to claim 1 and 2, it is characterised in that the kernel state interface wound Modeling block includes:
Kernel execution instance creation module, is suitable to create kernel state example;
Kernel state initialization module, is suitable in kernel state example, obtains the function pointer variable, And be the symbol of function pointer variable loading correspondence kernel state interface function.
4. method according to claim 1 and 2, it is characterised in that the application state interface wound Modeling block includes:
Application example creation module, is suitable to create and applies state example;
Using state initialization module, it is suitable in application state example, obtains the function pointer variable, And be the symbol of function pointer variable loading correspondence application state interface function.
5. method according to claim 1, it is characterised in that kernel state interface creation module is also Including:
Kernel interface function export module, is suitable to obtain the calling interface of the common interface function, and Calling interface according to the common interface function derives kernel interface function file;
The application state interface creation module also includes:
Application interface function export module, is suitable to obtain the calling interface of the common interface function, and Calling interface according to the common interface function derives application interface function file.
6. method according to claim 1, it is characterised in that also include:
Using state program debugging module, be suitable to by application state routine interface select file and/or, standard Input and output debud mode, and/or debugging output debud mode;The application state program debugging interface mould Intend kernel state program debugging interface.
7. a kind of compatible interface creation method, including:
It is global function pointer variable loading correspondence kernel state interface function in kernel state example First object;The function pointer variable is for a pair of kernel state interface functions and applies state interface letter Number;The pair of kernel state interface function and there is identical parameter using state interface function
It is the global function pointer variable loading correspondence application state interface letter in application state example The first several objects;
It is common interface function generation calling interface according to the function pointer variable;It is described public to connect Mouth function has the kernel state interface function and applies state interface function identical parameter.
8. method according to claim 7, it is characterised in that be complete in kernel state example The function pointer variable of office loads the first object of correspondence kernel state interface function and in application state example In, be the global function pointer variable loading correspondence application state interface function the first object it Before, also include:
It is that each pair kernel state interface function and application state interface function define same global function pointer Variable.
9. the method according to claim 7 or 8, it is characterised in that described in kernel state example In, it is that the first object of global function pointer variable loading correspondence kernel state interface function includes:
Create kernel state example;
In kernel state example, the function pointer variable is obtained, and for the loading of function pointer variable is right Answer the symbol of kernel state interface function.
10. a kind of compatible interface creates equipment, including:
Memory, is loaded with a plurality of executable instruction;
Processor, performs a plurality of executable instruction;The a plurality of executable instruction include perform with The method of lower step:
It is global function pointer variable loading correspondence kernel state interface function in kernel state example First object;The function pointer variable is for a pair of kernel state interface functions and applies state interface letter Number;The pair of kernel state interface function and there is identical parameter using state interface function
It is the global function pointer variable loading correspondence application state interface letter in application state example The first several objects;
It is common interface function generation calling interface according to the function pointer variable;It is described public to connect Mouth function has the kernel state interface function and applies state interface function identical parameter.
CN201510971806.XA 2015-12-22 2015-12-22 A kind of compatible interface creation method and system Pending CN106909430A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510971806.XA CN106909430A (en) 2015-12-22 2015-12-22 A kind of compatible interface creation method and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510971806.XA CN106909430A (en) 2015-12-22 2015-12-22 A kind of compatible interface creation method and system

Publications (1)

Publication Number Publication Date
CN106909430A true CN106909430A (en) 2017-06-30

Family

ID=59201036

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510971806.XA Pending CN106909430A (en) 2015-12-22 2015-12-22 A kind of compatible interface creation method and system

Country Status (1)

Country Link
CN (1) CN106909430A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107766263A (en) * 2017-10-12 2018-03-06 硅谷数模半导体(北京)有限公司 Control method, device, storage medium and the processor of interface chip
WO2022206226A1 (en) * 2021-03-30 2022-10-06 阿里巴巴(中国)有限公司 Interface processing method and apparatus

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107766263A (en) * 2017-10-12 2018-03-06 硅谷数模半导体(北京)有限公司 Control method, device, storage medium and the processor of interface chip
WO2022206226A1 (en) * 2021-03-30 2022-10-06 阿里巴巴(中国)有限公司 Interface processing method and apparatus

Similar Documents

Publication Publication Date Title
US7865350B1 (en) Partitioning a model in modeling environments
US9697109B2 (en) Dynamically configurable test doubles for software testing and validation
Treichler et al. Language support for dynamic, hierarchical data partitioning
US7613953B2 (en) Method of converting a regression test script of an automated testing tool into a function
CN107526625A (en) A kind of Java intelligence contract safety detection methods based on bytecode inspection
CN102880452A (en) Programming language capable of cross-language reusing
US9058427B2 (en) Iterative generation of symbolic test drivers for object-oriented languages
Goldsack et al. Formal methods and object technology
Djurfeldt et al. Efficient generation of connectivity in neuronal networks from simulator-independent descriptions
US7421715B1 (en) System and method for dynamic late-binding of persistent object implementations in software-based systems
CN106909430A (en) A kind of compatible interface creation method and system
CN104321774B (en) For the anti-reversing engineering and/or method alterred program, system and equipment
CN108153664A (en) A kind of static code scan method and device
Rajan et al. Capsule-oriented programming in the Panini language
CN104778323A (en) Method for simulating complex equipment operation process integrating multisource performance analysis data
Lee et al. Object-oriented programming for engineering applications
CN107122184A (en) A kind of virtual reality software open type developing system and method
CN116243923A (en) Applet processing method and device and electronic equipment
Dong Aspect oriented programming technology and the strategy of its implementation
US7451436B2 (en) Aggregate handling of operator overloading
Goudarzi et al. The ODYSSEY tool-set for system-level synthesis of object-oriented models
Fachada et al. cf4ocl: AC framework for OpenCL
Clair Learning Objective-C 2.0: A hands-on guide to Objective-C for Mac and iOS developers
CN115455380A (en) Program running method and device, electronic equipment and medium
Beham et al. Scripting and framework integration in heuristic optimization environments

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
WD01 Invention patent application deemed withdrawn after publication

Application publication date: 20170630

WD01 Invention patent application deemed withdrawn after publication