⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dcomlib.cpp

📁 dcom机制在vxworks上的实现源代码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/* dcomLib.cpp - DCOM library (VxDCOM) *//* Copyright (c) 1999 Wind River Systems, Inc. *//*modification history--------------------03z,03jan02,nel  Remove OLE2T.03y,17dec01,nel  Add include sybmol for diab build.03x,02nov01,nel  Correct docs errors.03w,10oct01,nel  SPR#70838. Ensure that all threads are started with                 VX_FP_TASK to get round any FP/longlong issues with certain                 BSPs and also usage of FP in DCOM servers.03v,06aug01,dbs  remove instance-creation from SCM03u,02aug01,dbs  use simplified Thread API03t,31jul01,dbs  change vxdcomPSRegister to autoreg ctor03s,19jul01,dbs  fix include path of vxdcomGlobals.h03r,16jul01,dbs  add library termination function03q,13jul01,dbs  fix up includes03p,02may01,nel  SPR#66227. Correct format of comments for refgen.03o,02mar01,nel  SPR#62130. Add CoDisconectObject API.03n,28feb00,dgp  update docs formatiing03m,11feb00,dbs  IIDs moved to idl directory, no longer need to force                 linkage of system stubs03l,13oct99,dbs  add reference material/man pages03k,26aug99,aim  protect pMshl->UnmarshalInterface Release03j,24aug99,dbs  fix extraction of results from MQI in CoGetClassObject03i,19aug99,aim  removed TASK_SPAWN03h,17aug99,dbs  add skeleton CoInitSecurity()03g,17aug99,aim  added g_vxdcomExportAddress globals03f,13aug99,aim  reworked dcomLibInit03e,13aug99,aim  added g_vxdcomMinThreads & g_vxdcomMaxThreads03d,02aug99,dbs  replace p/s init funcs with extern symbols03c,29jul99,drm  Adding bool to dcomLibInit for client priority.03b,28jul99,drm  Moving g_defaultServerPriority to comLib.cpp.03a,27jul99,drm  Adding global for default server priority.02z,26jul99,dbs  move marshaling into exporter02y,23jul99,drm  Adding stack size param to dcomLibInit().02x,21jul99,drm  Changing dcomLibInit() to accept additional arguments.02w,12jul99,aim  change SCM task entry point02v,09jul99,dbs  change to new ObjectExporter naming02u,06jul99,dbs  make CoCIEx() call SCM method02t,30jun99,dbs  add a ref to StdProxy when created in CoUnmarshalInterface()02s,28jun99,dbs  tighten up default authn setting02r,28jun99,dbs  add vxdcomUserAdd() function02q,28jun99,dbs  add default authn level as arg to dcomLibInit()02p,25jun99,aim  remove SCM::startService on non target build02o,24jun99,aim  fix solaris build warnings02n,24jun99,dbs  add authn APIs02m,10jun99,aim  uses new SCM02l,08jun99,dbs  simplify creation of StdProxy02k,04jun99,dbs  fix registry-access functions02j,03jun99,dbs  remove reliance on TLS from CoMarshalInterface02i,02jun99,aim  changes for solaris build02h,02jun99,dbs  use new OS-specific macros02g,01jun99,dbs  add NOPING flag02f,28may99,dbs  make stub disp-tbl a structure02e,27may99,dbs  change to vxdcomTarget.h02d,25may99,dbs  correctly free allocated DSA02c,24may99,dbs  ask SCM for local object exporter02b,21may99,dbs  remove unnecessary registry entry02a,20may99,dbs  fix handling of returned array-types01z,11may99,dbs  remove unnecessary registry-entries for p/s01y,11may99,dbs  rename VXCOM to VXDCOM01x,10may99,dbs  don't delete binding after call to IRemoteActivation01w,10may99,dbs  simplify binding-handle usage01v,03may99,drm  preliminary priority scheme support01u,29apr99,dbs  fix -Wall warnings01t,28apr99,dbs  remove extraneous AddRef() in CoMarshalInterface01s,28apr99,dbs  don't release RPC binding-handle after remote activation01r,27apr99,dbs  add mem-alloc functions01q,27apr99,dbs  use right new for std-mashaler class01p,26apr99,aim  added TRACE_CALL01o,23apr99,dbs  use streams properly01n,23apr99,dbs  remove warnings for unused locals01m,22apr99,dbs  tidy up potential leaks01l,15apr99,dbs  increase _ACTIVATION_MAX limit01k,13apr99,dbs  remove unused includes01j,09apr99,drm  adding diagnostic output01i,11mar99,dbs  add IOXIDResolver support01h,01mar99,dbs  help tidy up RPC startup01g,11feb99,dbs  check for correct COM initialization01f,10feb99,dbs  improve handling of endpoints01e,08feb99,dbs  formalize naming convention and ORPC/RPC interface01d,03feb99,dbs  simplify p/s architecture01c,11jan99,dbs  reduce STL usage01b,22dec98,dbs  improve ORPC interface01a,18dec98,dbs  move plain COM functions into vxcomLib.cpp01c,11dec98,dbs  simplify registry01b,26nov98,dbs  add IRemUnknown functionality01a,17nov98,dbs  created*/#include "private/comMisc.h"            // for misc support funcs#include "dcomProxy.h"			// for ndr_xxx() funcs#include "StdProxy.h"			// for StdProxy class #include "MemoryStream.h"		// for VxRWMemStream class#include "ObjectExporter.h"		// for ObjectExporter class#include "SCM.h"			// for SCM class#include "orpcLib.h"			// for ORPC constants#include "RemoteOxid.h"			// for RemoteOxid class#include "StdMarshaler.h"		// for StdMarshaler class#include "PSFactory.h"			// for PSFactory class#include "private/vxdcomGlobals.h"      // global variables#include "taskLib.h"                    // VxWorks tasks#include "RemoteRegistry.h"             // DCOM registry/*DESCRIPTIONThis library provides a subset of the Win32 COM/DCOM API calls, inorder to support the implementation of COM and DCOM in the VxWorksenvironment.     *//* Include symbol for diab */extern "C" int include_vxdcom_dcomLib (void)    {    return 0;    }    /* Well-known GUIDs that are required by DCOM... */const IID CLSID_StdMarshal =    {0x00000017,0x0000,0x0000,{0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46}};const IID IID_IRpcChannelBuffer =    {0xD5F56B60,0x593B,0x101A,{0xB5,0x69,0x08,0x00,0x2B,0x2D,0xBF,0x7A}};const IID IID_IRpcProxyBuffer =    {0xD5F56A34,0x593B,0x101A,{0xB5,0x69,0x08,0x00,0x2B,0x2D,0xBF,0x7A}};extern "C"int scmTask ()    {    return SCM::startService ();    }/**************************************************************************** dcomLibInit - dcomLib initialization function** This function is called from the initialization stage of the* VxWorks boot procedure, and establishes the VxDCOM environment* according to the given arguments. These arguments are normally set* via the Tornado Project Facility, and are detailed in the VxDCOM* Component Supplement.** RETURNS: the task-id of the SCM task.*/extern "C" int dcomLibInit    (    int			bstrPolicy,	/* BSTR policy */    int			authnLevel,	/* DCOM Authentication level */    unsigned int	priority,	/* thread priority */    unsigned int	numStatic,	/* Static threads */    unsigned int	numDynamic,	/* Dynamic threads */    unsigned int	stackSize,	/* Stack Size of server thread */    unsigned int	scmStackSize,	/* Stack Size of SCM thread */    int			clientPrioPropagation,	/* Client Priority propagation */    int			objectExporterPortNumber	/* Object Exporter Port Number */    )    {    vxdcomBSTRPolicy = bstrPolicy;    // Initialize the Remote Registry...    dcomRemoteRegistryInit ();        // Set the default authn level for NTLMSSP...    if ((authnLevel < RPC_C_AUTHN_LEVEL_NONE) ||	(authnLevel > RPC_C_AUTHN_LEVEL_CONNECT))	authnLevel = RPC_C_AUTHN_LEVEL_NONE;	    g_defaultAuthnLevel = authnLevel;    // Set priority scheme global variables     g_defaultServerPriority = (int) priority;    g_clientPriorityPropagation = clientPrioPropagation;        g_vxdcomThreadPoolPriority = priority;    g_vxdcomMinThreads = numStatic;    g_vxdcomMaxThreads = numStatic + numDynamic;    g_vxdcomDefaultStackSize = stackSize;	    g_scmTaskStackSize = scmStackSize;    g_vxdcomObjectExporterPortNumber = objectExporterPortNumber;    return ::taskSpawn ("tScmTask",                        g_scmTaskPriority,                        VX_FP_TASK,                        g_scmTaskStackSize,                        reinterpret_cast<FUNCPTR> (scmTask),                        0, 0, 0, 0, 0, 0, 0, 0, 0, 0);    }/**************************************************************************** dcomLibTerm - dcomLib termination function** This function can be called to shut down the SCM and so terminate* the DCOM functionality.*/void dcomLibTerm ()    {    SCM::stopService ();    }/**************************************************************************** CoGetClassObject - return an instance of the class-object for a coclass** This function differs from the Win32 equivalent in that it is only* available when DCOM support is enabled, and not when only COM is* enabled. It accepts only the CLSCTX_INPROC_SERVER or* CLSCTX_REMOTE_SERVER values for 'dwClsContext' as the {local server}* model is not implemented in VxDCOM.** RETURNS: an HRESULT value*/HRESULT CoGetClassObject    (    REFCLSID		rclsid,		/* CLSID of class object */    DWORD		dwClsContext,	/* context */    COSERVERINFO*	pServerInfo,    /* machine info */    REFIID		riid,		/* IID of desired interface */    void**		ppv		/* var to receive i/f ptr */    )    {    char * hint = 0;    if (pServerInfo->pwszName)	{	hint = new char [comWideStrLen (pServerInfo->pwszName) + 1];	comWideToAscii (hint,			pServerInfo->pwszName, 			comWideStrLen (pServerInfo->pwszName) + 1);	}    HRESULT hr =  comClassObjectGet (rclsid,				     dwClsContext,                                     hint,                                     riid,                                     ppv);    if (hint)	delete []hint;    return hr;    }/**************************************************************************** CoRegisterClassObject - Register a class-object with the global class factory.** Register a class-object with the global class-factory table. This is * called from the server object when it is registered.** RETURNS: S_OK on success, or CO_E_OBJISREG if the class is already in * the class object table.*/HRESULT CoRegisterClassObject    (    REFCLSID		rclsid,		/* CLSID to be registered */    IUnknown*		pUnkCF,		/* pointer to the class object */    DWORD		dwClsContext,	/* context (inproc/local/remote) */    DWORD		flags,		/* how to connect to the class object */    DWORD*		lpdwRegister	/* returned token */    )    {    TRACE_CALL;    // Validate args    if (! pUnkCF)	return E_INVALIDARG;    //    // 1. Marshal IUnknown of Class-factory, creating a new GOT entry.    //    IStream* pStream;    HRESULT hr = VxRWMemStream::CreateInstance (0, IID_IStream, (void**) &pStream);    if (FAILED (hr))	return hr;        hr = CoMarshalInterface (pStream,			     IID_IUnknown,			     pUnkCF,			     MSHCTX_LOCAL,			     0,			     MSHLFLAGS_NORMAL);    if (FAILED (hr))	{	pStream->Release ();	return hr;	}    //    // 2. Save CF in object-table. This is where it will be accessed    // later by the client. The OID is the one we just got from    // marshaling the interface-ptr...    //    ObjectExporter*	px = SCM::objectExporter ();    ObjectTableEntry*	pOTE = px->objectFindByStream (pStream);    DWORD		dwRegister = (DWORD) pOTE;    if (pOTE)	{	pOTE->punkCF = pUnkCF;	pOTE->clsid = rclsid;	pOTE->dwRegToken = dwRegister;	}    *lpdwRegister = dwRegister;        px->Release ();    return S_OK;        }/**************************************************************************** CoRevokeClassObject - Unregister the class object.** Un-register the class-factory from the class-factory table.** RETURNS: S_OK on success, or S_FALSE on error.*/HRESULT CoRevokeClassObject    (    DWORD		dwRegister	/* token for class object */    )    {    TRACE_CALL;        ObjectExporter*	px = SCM::objectExporter ();    ObjectTableEntry*	pOTE = px->objectFindByToken (dwRegister);    HRESULT		hr = S_OK;        if (pOTE)	px->objectUnregister (pOTE->oid);    else	hr = S_FALSE;        px->Release ();    return hr;    }/**************************************************************************** CoCreateInstanceEx - create a single instance of an object** This function differs from the Win32 equivalent in that it is only* available when DCOM support is enabled, and not when only COM is* enabled.** RETURNS: an HRESULT value*/HRESULT CoCreateInstanceEx    (    REFCLSID            rclsid,         /* CLSID of the object           */    IUnknown*           pUnkOuter,      /* ptr to aggregating object     */    DWORD               dwClsCtx,       /* one of CLSCTX values          */    COSERVERINFO*       pServerInfo,    /* machine to create object on   */    ULONG               nInterfaces,	/* number of MULTI_QI structures */     MULTI_QI*           pResults        /* array of MULTI_QI structures  */    )    {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -