CN1257455C - Inter-process calling gate technique - Google Patents

Inter-process calling gate technique Download PDF

Info

Publication number
CN1257455C
CN1257455C CN 02125325 CN02125325A CN1257455C CN 1257455 C CN1257455 C CN 1257455C CN 02125325 CN02125325 CN 02125325 CN 02125325 A CN02125325 A CN 02125325A CN 1257455 C CN1257455 C CN 1257455C
Authority
CN
China
Prior art keywords
service
function
call
processes
client
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.)
Expired - Fee Related
Application number
CN 02125325
Other languages
Chinese (zh)
Other versions
CN1470988A (en
Inventor
梁肇新
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Individual
Original Assignee
Individual
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 Individual filed Critical Individual
Priority to CN 02125325 priority Critical patent/CN1257455C/en
Publication of CN1470988A publication Critical patent/CN1470988A/en
Application granted granted Critical
Publication of CN1257455C publication Critical patent/CN1257455C/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Images

Landscapes

  • Stored Programmes (AREA)

Abstract

The present invention relates to calling gate technology among processes, which enables an object of one process to directly call the function of one object in another process. A registry table does not need to be dependent on in the process of final execution, processes of a single instance can realize multiple instances by multiple processes, and a component object model (COM) does not have the function. Meanwhile, the client end does not need to realize the storage of a dynamic link library (DLL), but the client end directly realizes storage. The client end and the server end are completely transparent to developers, and thereby, the developers have larger opportunities for participating in control processes. Most of application programs for C language development formerly are single instances and non objectization. If the programs are innovated by COM technology, the cost is large, and the realization is impossible sometimes. The calling gate technology is easy to solve the problems of large cost and impossible realization by adopting the COM technology. The calling gate technology only needs slight alteration for the original program and can realize multiple instances and objectization by a method for multiple processes.

Description

Inter-process calling gate technique
1 technical field
The present invention relates to a kind of being used for, the method for single example module multiple example type the module objectization of original non-objectization.And be particularly related to a kind of novelty and the effective software engineering (calling gate technique) of process communication, particularly, relate to and a kind of the function call parameter is broken into uniform data format, and come the technology of the real-time Communication for Power between implementation process with single transmission interface.
2 background technologies
In recent years, the software engineering develop rapidly, the renewal speed of software product is also more and more faster.Software product is a kind of basic trend with combining of network.And many companies original software product (or module) be non-objectification with single-instancing, this has hindered its application aspect network and multi-user, and the update of corresponding product.
At the objectification design aspect of software product, the The Component Object Model of MICROSOFT (hereinafter to be referred as COM) technology is one and well selects.But if rewrite these modules according to the COM standard fully, its cost will be huge.
Calling gate technique can well address this problem.Adopt this technology, only need to be used as less modification, just can make its objectification and multiple example type original.
By answering user's routine interface (hereinafter to be referred as API) function definition and calling in dynamic link library (DLL) implementation process is very general technology.The method that defines and call with the api function between executable file (as EXE) implementation process has multiple, as Local Procedure Call (LPC) and remote procedure call (RPC) etc., the mechanism of these methods is opaque for the developer, and can not realize directly calling another in-process api function.
3 summary of the invention
Calling gate technique makes the object of a process can directly call the function of the object in the another one process by certain method.It is to extend from the correlation technique of operating system, its a lot of ways of thinking and COM are the same, but do not need to depend on registration table in the time of final the execution, and can realize many examples to the program of single example by multi-process, this is that COM is unexistent.Simultaneously can need not realize the DLL counterfoil in client, but directly realize counterfoil, the client and server end all is fully transparent to the developer, thereby the developer has the chance of maximum participation control procedure.
Of the present invention theing contents are as follows:
(1) by call gate, the specified services process can be created and close to the object in the client process space;
(2) by call gate, the object in the client process space can be created a service specified object in the service processes space, and obtains the handle of this object;
(3) by call gate, the object in the client process space can call the function of object of an appointment in service processes space, and obtains the rreturn value of this function;
The soluble problem of the present invention is as follows:
(1) method with executable file (as EXE) realizes the api function interface, realizes another process directly calling these api functions by call gate;
(2) by call gate, the outer service routine of the process of can creating;
(3) by call gate, can realize many examples to the program of single example by multi-process.
4 description of drawings
Fig. 1 has provided the process that the object in the object in client process space and service processes space communicates by call gate.Call gate is as transfer, the service processes space is translated and be sent to the function call of the object that comes from the client process space (or other request), in the service processes space, call corresponding function then, and at last rreturn value is transferred back to the client process space.
Fig. 2 has provided the process of function call that call gate is handled the object in client process space.
Fig. 3 has provided the operational process sketch of client.
Fig. 4 has provided the operational process sketch of service end.
Fig. 5 has provided function time institute's event and the process thereof that client object is called the service end object.
5 embodiments
The present invention makes the directly function of the object of invoking server end of client object by certain mechanism, and obtains corresponding rreturn value.Its basic thought is:
● the object of client and server end derives from identical virtual base class, thereby they have identical virtual table (hereinafter to be referred as VTABLE), working as client object like this is sent to the address of relative address of function (with respect to client object) and server end object in the process of server end, then the server end process adds relative address to the server object handle, just can obtain the function that client will be called;
● transmit call parameters and information by shared drive at server end and server;
● by incident finish function call between process synchronously;
Client and server end object are in the different address spaces, do not know the other side's address between them, and their function is in respectively in the different address spaces, therefore can not directly call mutually.Client and server end can be shared same dynamic base, thereby they share identical code segment, and still, operating system might not be mapped to dynamic base in the identical address section of the different process spaces, therefore, can not directly pass through the corresponding function of these calls by location.
All com objects all derive from class IUnknown, and IUnknown is a pure virtual base class.Like this, first three interface of the VTABLE of all com objects is all identical, thereby all objects can search other interface by identical interface QueryInterface.Function calling method among the class IUnknown is obeyed standard WINDOWS function call (hereinafter to be referred as STDCALL) and is called rule.This rule of calling is only sent out the parameter that transmits fixed number, and it can not transmit the situation of variable element, therefore, the present invention has defined the pure virtual base class IBase of oneself, it does not adopt the STDCALL of COM to call rule, but adopts C to call rule, can transmit the function parameter of indefinite number like this.
IBase is defined as follows:
#ifdef_cplusplus
class IBase
{
public:
virtual?HRESULT?QueryInterface(REFIID?iid,void**?ppvObject)=0;
virtual?ULONG AddRef(void) =0;
virtual?ULONG Release(void)?=0;
};
#endif
#ifdef_cplusplus
typedef?int(IBase::*LPCLASSAPI)(...);
#else
typedef?int(*LPCLASSAPI)();
#endif
The server end object derives from identical interface with client object, and it can be the IBase interface, also can be the derivation interface of IBase.Client object has identical VTABLE with server object like this, and all is to obey C to call rule.
When client object is wanted the function of invoking server end object, client server end pointer to object and object function and parameter by CallGateFunc () thus be transformed into the object reference between implementation process of calling at the server end object.Provide call gate api interface function C allGateFunc definition among Fig. 2.Because the two ends object has identical VTABLE, so this calling is feasible.
Fig. 1 provides is the process that the object in the object in client process space and service processes space communicates by call gate.What Fig. 3 and Fig. 4 gave is the operational process of client and server end.
If client object needs the service of server end object, then it can be by the api function in call gate storehouse
HANDLE APIENTRY CreateServer (LPSTR lpExeFile, LPGUID lpSvrID) creates the service specified process, wherein lpExeFile is the path of process, and lpSvrID is service object's a sign, and it is a unified sign (hereinafter to be referred as a GUID) sign.This function returns the process handle of service processes.
When not needing the process of appointment, it can call the process that api function is closed appointment, and this api function is defined as follows:
INT?APIENTRY?DeleteServer(HANDLE?Handle);
In the entrance of service end process function m ain or WinMain, call api function
INT?APIENTRY BeginServer(LPEXEGETCLASSOBJECT
lpGetClassObject,
LPEXECANEXITNOW lpExeCanExitNow, LPGUID lpSvrID) notice call gate storehouse oneself starts, simultaneously, and three information importing oneself into:
First lpGetClassObject is the function pointer that process oneself is used to create object, and it is defined as follows:
typedef?I?NT(APIENTRY*LPEXEGETCLASSOBJECT)(REFCLSID?rclsid,
REFIID?riid,LPVOID*ppv);
Second lpExeCanExitNow is the function pointer that process oneself control is withdrawed from, and it is defined as follows:
typedef?VO?ID(APIENTRY*LPEXECANEXITNOW)(VOID);
The GUID sign that the 3rd lpSvrID is process, it is used for unique identification oneself.
When service processes finishes, call api function EndServer notice call gate storehouse oneself and close, this function is defined as follows:
VOID?APIENTRY?EndServer(VOID);
The process identification (PID) lpSvrID of service processes has been known in the call gate storehouse, process handle, create service object's function pointer lpGetClassObject and the function pointer lpExeCanExitNow that the control service is closed, like this it should effectively to control service processes be the client process service.
When the client process object needed the service object, it can call api function CreateObjectInstance and notify the call gate storehouse to create the service specified object, and CreateObjectInstance is defined as follows:
INTAPIENTRY?CreateObjectInstance(HANDLE?Handle,REFCLSID?rclsID,
REFIID?riID,LPVOID*lppv);
Wherein Handle is the handle of service processes object, and rclsID is service object's class ID, and riId is service object ID, and lppv is an address pointer of accepting service object's pointer.
The object of appointment is created in the call gate storehouse by the lpGetClassObject function pointer.As aforementioned, all server end object and client object all realize the IBase interface, and identical VTABLE is arranged, and by the call gate storehouse, client object docking port function calls can well convert calling the server end interface to.
Call gate api function CallGateFunc can only transmit pointer type and integer type, if call function will transmit word string or other type, then can adopt the shared drive mode.Call end the client, create a shared drive, the information that copy will transmit is sent to server end to the handle of shared drive by CallGateFunc then in shared drive; Server end can take out corresponding data after obtaining this internal memory handle, and calls the corresponding interface function, to finish calling of client; After server end was finished the work, client can be removed shared drive.
Client realizes the calling by call gate and macro definition of object of service end.For example, the client object A QueryInterface method of calling the service end object B can be changed by following macro definition:
#define?A_QueryInterface(B,iid,lppv)\
CallGateFunc(hServer,(sizeof(iid)+sizeof(lppv))/4,
(LPCLASSAPI)B->QueryInterface,lpObject,iid,lppv))
Fig. 1 has provided the reciprocal process of client process and server end process.Client process calls api function CreateServer request and creates a process ((1) among Fig. 1), and it is passed to the path of the process that call gate will create and will create the sign GUID of process; After call gate obtained this request, calling system api function CreateProcess created the process ((2) among Fig. 1) of appointment, and obtained the handle of this process; In the process that service processes starts, it can call api function BeginServer to call gate registration oneself, and the content of registration comprises that the function pointer LPEXEGETCLASSOBJECT that creates the service object, function pointer LPEXECANEXITNOW that the suggest services process is closed and the GUID of process identify.Call gate is just known the situation of service processes like this, and can create service object and control service processes by these functions.
After client is created the object success, can call api function CreateObjectInstance and create a service object ((3) among Fig. 1) at server end, call gate obtains ((4 and 5) among Fig. 1) after this request, call the LPEXEGETCLASSOBJECT function pointer of corresponding process, create a service object, and return to client.
When client will be called function of service object ((6) among Fig. 1), client is sent to service processes ((7) among Fig. 1) to the be called handle of process, the number of call parameters, invoked function and parameter list by api function CallGateFunc; Call gate calls the function of appointment and rreturn value is passed back caller ((8) among Fig. 1) in service processes.So just finish the function call of a striding course.
If client no longer needs the service object, method that then can call function discharges ((9,10 and 11) among Fig. 1) to the service end object.
If client will be closed service processes, then can call api function DeleteServer and close service processes ((12 and 13) among Fig. 1).When service processes is closed, can call api function EndServer notice call gate oneself and close.
What Fig. 3 and Fig. 4 provided respectively is the operational process of client and server end.Fig. 2 has provided the process of function call that call gate is handled the object in client process space.Api function CallGateFune can transmit many arbitrarily argument of type integers, parameter is pop down ((14) among Fig. 2) from left to right, follow service object's handle pop down (((15) among Fig. 2), directly call the function ((16) among Fig. 2) of service object's correspondence then in the service processes space, last call gate sends back client process ((17) among Fig. 2) to the rreturn value of function.
What Fig. 5 provided is the process that client object is called the function of service end object.Invoked procedure is as follows:
(1) client object is initiated call ((18) among Fig. 5) to the function 3 of server end object;
(2) client object pack to calling parameter ((19) among Fig. 5) before entering call gate;
(3) then enter call gate ((20) among Fig. 5), call gate imports the parameter of function call into service processes;
(4) call gate starting service object's function 3, this function carries out parameter and unpacks ((21) among Fig. 5);
(5) service object's function 3 is carried out (((22) among Fig. 5);
(6) service object's function 3 rreturn value is packed ((23) among Fig. 5);
(7) call gate is obtained the good rreturn value ((24) among Fig. 5) of packing of service object's function 3, and sends client object to;
(8) client object rreturn value that call gate is passed back unpacks ((25) among Fig. 5);
(9) client obtains the rreturn value ((26) among Fig. 5) of the object of service end, so far, the client object success finished once invoked procedure to the server end object.
Calling gate technique is having same good performance with the COM technology aspect the outer service of implementation process, and it can make the developer farthest control development process.Simultaneously, it can solve the indeterminable problem of COM technology, and the front points out, is mostly single example and non-objectization with the application programs of C exploitation before the great majority.If adopt these programs of COM technological transformation, then its cost will be huge, and also be impossible sometimes.By calling gate technique, can address this problem easily.
Calling gate technique only needs original program is done little change, just can realize many examples and objectification by the method for multi-process.The basic thought of its change is:
Each example is exactly a service processes, and it can create a service object; When client process need be created a plurality of service object, just can create a plurality of service processess was customer service.Like this, for client process, just being equivalent to service processes is many examples.
Such as, the demoder of the MPEG1 stream of an existing motion picture expert group (MPEG), it is single example.Open a process and can only play the stream of a MPEG1 form.If realize supervisory system, require to have 16 monitoring terminals on the desktop with this demoder.The player of single example if use it, then will be created 16 broadcast processes hereto, and these 16 processes will be independently.If the developer need not calling gate technique of the present invention, he will face the technological challenge of the broadcast window of these 16 processes of control.If adopt calling gate technique of the present invention, only need original MPEG1 demoder is made seldom modification, make it can create a service object.Newly write a client object in addition, this to as if many examples, its each example all creates a service processes object accordingly.Realize supervisory system with this client object again, will be more easy to control.The developer is when this system of realization, and only the control that need be absorbed in client gets final product.By this method, the mpeg player of the new many examples of support of exploitation that do not need to require efforts again.

Claims (1)

1. a method that makes target client in the client process can directly call the function of the service object in the service processes comprises the steps:
Call gate is created service processes according to the solicited message of the target client in the client process, and described solicited message comprises: the path of service processes and the overall situation of service processes are unified identification code;
Service processes starts, and to the information of call gate registration oneself, comprising: create service object's function pointer, the function pointer that the notification service process is closed and the overall situation of service processes are unified identification code;
Call gate is created the service object according to target client's solicited message in service processes, solicited message comprises: the process handle of service processes, and service object's class identification code, service object's identification code is accepted the address pointer of service object's pointer;
When the target client need call service object's function, call gate is the process handle of service processes, service object's pointer, invoked function, the number of function parameter and function parameter tabulation are sent to service processes, call gate calls the function of service specified object in service processes, after invoked procedure finished, call gate returned the function call rreturn value to client process;
If the target client no longer needs the service object, then call gate discharges the service object according to target client's release service object's solicited message in service processes;
If the target client no longer needs service processes, the process handle of the service processes that provides according to the target client of call gate then calls and closes function and close service processes.
CN 02125325 2002-07-25 2002-07-25 Inter-process calling gate technique Expired - Fee Related CN1257455C (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN 02125325 CN1257455C (en) 2002-07-25 2002-07-25 Inter-process calling gate technique

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN 02125325 CN1257455C (en) 2002-07-25 2002-07-25 Inter-process calling gate technique

Publications (2)

Publication Number Publication Date
CN1470988A CN1470988A (en) 2004-01-28
CN1257455C true CN1257455C (en) 2006-05-24

Family

ID=34142841

Family Applications (1)

Application Number Title Priority Date Filing Date
CN 02125325 Expired - Fee Related CN1257455C (en) 2002-07-25 2002-07-25 Inter-process calling gate technique

Country Status (1)

Country Link
CN (1) CN1257455C (en)

Families Citing this family (17)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7784025B2 (en) * 2005-10-13 2010-08-24 International Business Machines Corporation Mechanism for using processlets to model service processes
CN100464305C (en) * 2007-03-13 2009-02-25 华为技术有限公司 Method and apparatus for calling dynamic library and dynamic library server
CN101853174B (en) * 2009-04-03 2014-03-12 中兴通讯股份有限公司 Method and device for synchronizing defining and calling of string resource
CN101902458B (en) * 2010-02-21 2013-04-24 中国联合网络通信集团有限公司 Interprocess communication method across host machine, device thereof and system thereof
CN102103526A (en) * 2011-02-14 2011-06-22 博视联(苏州)信息科技有限公司 Method and system for performing inter-process communication between server and client by service management
US9003323B2 (en) * 2011-05-19 2015-04-07 International Business Machines Corporation Method for management and broadcasting an event context
WO2013091195A1 (en) * 2011-12-21 2013-06-27 华为技术有限公司 Transaction processing method, device and system in distributed system
CN102591726B (en) * 2011-12-31 2014-04-09 青岛海信宽带多媒体技术有限公司 Multiprocess communication method
CN103309730B (en) * 2012-03-15 2016-03-16 腾讯科技(深圳)有限公司 The method of striding course readjustment and device
CN102662778A (en) * 2012-04-28 2012-09-12 杭州格畅科技有限公司 Callback response method of inter-application communication on online application platform, application and online application platform
CN103841134B (en) * 2012-11-22 2017-03-01 阿里巴巴集团控股有限公司 Based on API transmission, the method for receive information, apparatus and system
CN103324542B (en) * 2013-07-17 2017-04-12 天脉聚源(北京)传媒科技有限公司 Method and device for inter-module calls
CN104516740B (en) * 2013-09-26 2019-07-16 腾讯科技(深圳)有限公司 A kind of function calling method, device and mobile terminal
CN104410909B (en) * 2014-11-28 2018-01-09 江苏银河电子股份有限公司 Application method of the linux system software module in TVOS systems
CN104536839B (en) * 2014-12-26 2019-02-01 北京奇虎科技有限公司 The method and device of method call is carried out between process
CN110245027B (en) * 2018-09-21 2024-05-14 浙江大华技术股份有限公司 Inter-process communication method and device
CN112631815B (en) * 2021-03-10 2021-08-17 国能信控互联技术有限公司 Inter-process communication method and system based on COM cross-process calling and shared memory

Also Published As

Publication number Publication date
CN1470988A (en) 2004-01-28

Similar Documents

Publication Publication Date Title
CN1257455C (en) Inter-process calling gate technique
CN100337235C (en) Method and apparatus for accessing database
CN1205537C (en) Methods and apparatus for linking program for remote execution
JPH1069394A (en) Processing system and method for intermediate code data stream originated in object-oriented language program or multi-media data stream
RU2006113596A (en) SYSTEM AND METHOD FOR A UNIFIED COMPOSITION MACHINE IN A GRAPHICS PROCESSING SYSTEM
CN1573688A (en) Systems and methods for employing tagged types in a dynamic runtime environment
CN1991768A (en) Instruction set architecture-based inter-sequencer communications with a heterogeneous resource
CN1270229C (en) Method of realizing cross address space establishing construction member target based on dynamic core
CN107506247A (en) A kind of task processing method and equipment based on asynchronism callback
CN1685363A (en) Block-based rotation of arbitrary-shaped images
CN101043381A (en) System and method for collecting service grid traceback information
US20120278814A1 (en) Shared Drivers in Multi-Core Processor
CN1766841A (en) Message transmitting processor
CN1503188A (en) Emulation method and device
CN1856784A (en) System and method for locking and isolation in a storage platform
Su Architecting the future through heterogeneous computing
CN1264090C (en) Packaging method for intelligent pointer of calling structure object function
CN1320456C (en) Automatic forming method for intelligent instrument interface
CN1414492A (en) Rosources package and network integration method based on mobile Agent
CN1932767A (en) Virtual hardware accelerating method and system
Daily et al. Using the Global Arrays Toolkit to Reimplement NumPy for Distributed Computation.
CN1656447A (en) Software development tool for ensuring links between UML models and the implementation thereof in a CORBA environment
CN1908896A (en) Component inheritance method
CN1870505A (en) Embedded system and its information processing method
CN1808438A (en) Integrated multimedia application platform

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
C57 Notification of unclear or unknown address
DD01 Delivery of document by public notice

Addressee: Song Junshan

Document name: payment instructions

C19 Lapse of patent right due to non-payment of the annual fee
CF01 Termination of patent right due to non-payment of annual fee