Example #1
0
static void test_endpoint_mapper(RPC_CSTR protseq, RPC_CSTR address)
{
    static unsigned char annotation[] = "Test annotation string.";
    RPC_STATUS status;
    RPC_BINDING_VECTOR *binding_vector;
    handle_t handle;
    unsigned char *binding;

    status = RpcServerRegisterIf(IFoo_v0_0_s_ifspec, NULL, NULL);
    ok(status == RPC_S_OK, "%s: RpcServerRegisterIf failed (%u)\n", protseq, status);

    status = RpcServerInqBindings(&binding_vector);
    ok(status == RPC_S_OK, "%s: RpcServerInqBindings failed with error %u\n", protseq, status);

    /* register endpoints created in test_RpcServerUseProtseq */
    status = RpcEpRegisterA(IFoo_v0_0_s_ifspec, binding_vector, NULL, annotation);
    ok(status == RPC_S_OK, "%s: RpcEpRegisterA failed with error %u\n", protseq, status);
    /* reregister the same endpoint with no annotation */
    status = RpcEpRegisterA(IFoo_v0_0_s_ifspec, binding_vector, NULL, NULL);
    ok(status == RPC_S_OK, "%s: RpcEpRegisterA failed with error %u\n", protseq, status);

    status = RpcStringBindingComposeA(NULL, protseq, address,
                                     NULL, NULL, &binding);
    ok(status == RPC_S_OK, "%s: RpcStringBindingCompose failed (%u)\n", protseq, status);

    status = RpcBindingFromStringBindingA(binding, &handle);
    ok(status == RPC_S_OK, "%s: RpcBindingFromStringBinding failed (%u)\n", protseq, status);

    RpcStringFreeA(&binding);

    status = RpcBindingReset(handle);
    ok(status == RPC_S_OK, "%s: RpcBindingReset failed with error %u\n", protseq, status);

    status = RpcEpResolveBinding(handle, IFoo_v0_0_s_ifspec);
    ok(status == RPC_S_OK || broken(status == RPC_S_SERVER_UNAVAILABLE), /* win9x */
       "%s: RpcEpResolveBinding failed with error %u\n", protseq, status);

    status = RpcBindingReset(handle);
    ok(status == RPC_S_OK, "%s: RpcBindingReset failed with error %u\n", protseq, status);

    status = RpcBindingFree(&handle);
    ok(status == RPC_S_OK, "%s: RpcBindingFree failed with error %u\n", protseq, status);

    status = RpcServerUnregisterIf(NULL, NULL, FALSE);
    ok(status == RPC_S_OK, "%s: RpcServerUnregisterIf failed (%u)\n", protseq, status);

    status = RpcEpUnregister(IFoo_v0_0_s_ifspec, binding_vector, NULL);
    ok(status == RPC_S_OK, "%s: RpcEpUnregisterA failed with error %u\n", protseq, status);

    status = RpcBindingVectorFree(&binding_vector);
    ok(status == RPC_S_OK, "%s: RpcBindingVectorFree failed with error %u\n", protseq, status);
}
Example #2
0
void rpcSrv_terminate() {
	RPC_STATUS status;
	CloseHandle(nvdaUnregisteredEvent);
	nvdaUnregisteredEvent=NULL;
	UUID_VECTOR nvdaInprocUuidVector={1,&nvdaInprocUuid};
	for(int i=0;i<ARRAYSIZE(availableInterfaces);++i) {
		if((status=RpcEpUnregister(availableInterfaces[i],bindingVector,&nvdaInprocUuidVector))!=RPC_S_OK) {
			LOG_ERROR(L"RpcEpUnregister failed for interface at index "<<i<<L" with status "<<status);
		}
		if((status=RpcServerUnregisterIfEx(availableInterfaces[i],NULL,1))!=RPC_S_OK) {
			LOG_ERROR(L"RpcServerUnregisterIfEx for interface at index "<<i<<L" failed with status "<<status);
		}
	}
	RpcBindingVectorFree(&bindingVector);
}
Example #3
0
//
//  FUNCTION: ServiceStart
//
//  PURPOSE: Actual code of the service
//           that does the work.
//
//  PARAMETERS:
//    dwArgc   - number of command line arguments
//    lpszArgv - array of command line arguments
//
//  RETURN VALUE:
//    none
//
//  COMMENTS:
//    Starts the service listening for RPC requests.
//
VOID ServiceStart (HWND NotifyWindow)
{
    UINT i;
    RPC_BINDING_VECTOR *pbindingVector = 0;
    RPC_STATUS status;
    BOOL fListening = FALSE;

    ///////////////////////////////////////////////////
    //
    // Service initialization
    //

    //
    // Use protocol sequences (protseqs) specified in ProtocolArray.
    //

    if(NotifyWindow) 
	PostMessage(NotifyWindow,MPM_SERVER_STARTING,0,0);

    for(i = 0; i < sizeof(ProtocolArray)/sizeof(TCHAR *); i++)
        {


        status = RpcServerUseProtseq(ProtocolArray[i],
                                     ProtocolBuffer,
                                     0);

        if (status == RPC_S_OK)
            {
	    if(NotifyWindow) PostMessage(NotifyWindow,MPM_SERVER_PENDING,0,0);
            fListening = TRUE;
            }
        }

    if (!fListening)
        {
        // Unable to listen to any protocol!
        //
	    if(NotifyWindow) 
		PostMessage(NotifyWindow,MPM_SERVER_STOPPED,0,status);
	    dwErr = status;
        return;
        }

    //
    // Register the services interface(s).
    //

    status = RpcServerRegisterIf(R_MPE_v1_0_s_ifspec,0,0);


    if (status != RPC_S_OK) {
        if(NotifyWindow) 
	    PostMessage(NotifyWindow,MPM_SERVER_STOPPED,0,status);

        dwErr = status;
	hMainThread = 0;
        return;
    } 

    if(NotifyWindow) 
	PostMessage(NotifyWindow,MPM_SERVER_PENDING,0,0);


    // Register interface(s) and binding(s) (endpoints) with
    // the endpoint mapper.
    //

    status = RpcServerInqBindings(&pbindingVector);

    if (status != RPC_S_OK) {
	if(NotifyWindow) 
	    PostMessage(NotifyWindow,MPM_SERVER_STOPPED,0,status);
	dwErr = status;
	hMainThread = 0;
        return;
    }

    if(NotifyWindow) 
	PostMessage(NotifyWindow,MPM_SERVER_PENDING,0,0);


    status = RpcEpRegister(R_MPE_v1_0_s_ifspec,pbindingVector,0,0);

    if (status != RPC_S_OK) {
	dwErr = status;
	if(NotifyWindow) 
	    PostMessage(NotifyWindow,MPM_SERVER_STOPPED,0,status);
	hMainThread = 0;
        return;
    }


    if(NotifyWindow) 
	PostMessage(NotifyWindow,MPM_SERVER_PENDING,0,0);


    // Enable NT LM Security Support Provider (NtLmSsp service)
    //
    status = RpcServerRegisterAuthInfo(0,
                                       RPC_C_AUTHN_WINNT,
                                       0,
                                       0
                                       );
    if (status != RPC_S_OK){
	dwErr = status;
	if(NotifyWindow) 
	    PostMessage(NotifyWindow,MPM_SERVER_STOPPED,0,status);
	hMainThread = 0;
        return;
    }

    if(NotifyWindow) 
	PostMessage(NotifyWindow,MPM_SERVER_PENDING,0,0);

    

    // Start accepting client calls.
    //
    status = RpcServerListen(MinimumThreads,
                             RPC_C_LISTEN_MAX_CALLS_DEFAULT,  // rpcdce.h
                             TRUE);                           // don't block.

    if (status != RPC_S_OK) {
	dwErr = status;
	PostMessage(NotifyWindow,MPM_SERVER_STOPPED,0,status);
	hMainThread = 0;
        return;
    }


    //
    // End of initialization
    //
    ////////////////////////////////////////////////////////////

    if(NotifyWindow) 
	PostMessage(NotifyWindow,MPM_SERVER_STARTED,0,status);
    else 
	SetEvent(StartEvent);


    ////////////////////////////////////////////////////////////
    //
    // Cleanup
    //

    // RpcMgmtWaitServerListen() will block until the server has
    // stopped listening.  If this service had something better to
    // do with this thread, it would delay this call until
    // ServiceStop() had been called. (Set an event in ServiceStop()).
    //
    status = RpcMgmtWaitServerListen();

    if (status != RPC_S_OK) {
	dwErr = status;
	PostMessage(NotifyWindow,MPM_SERVER_STOPPED,0,status);
	hMainThread = 0;
        return;
    }


    NotifyWindow = g_hNotifyWindow;
    if(NotifyWindow) 
	PostMessage(NotifyWindow,MPM_SERVER_PENDING,0,0);

    // ASSERT(status == RPC_S_OK)

    status = RpcServerUnregisterIf(R_MPE_v1_0_s_ifspec,0,TRUE);

    if(NotifyWindow) 
	PostMessage(NotifyWindow,MPM_SERVER_PENDING,0,0);

    // Remove entries from the endpoint mapper database.
    //
    RpcEpUnregister(R_MPE_v1_0_s_ifspec,   // from rpcsvc.h
                    pbindingVector,
                    0);

    if(NotifyWindow) 
	PostMessage(NotifyWindow,MPM_SERVER_PENDING,0,0);
    // Delete the binding vector
    //
    status = RpcBindingVectorFree(&pbindingVector);
    if(NotifyWindow) 
	PostMessage(NotifyWindow,MPM_SERVER_STOPPED,0,status);

    //
    ////////////////////////////////////////////////////////////
    
    return;
}
Example #4
0
void RpcListen()
{
    RPC_STATUS		status;
    char			*task;
    RPC_BINDING_VECTOR	*ptrBindingVector = NULL;
    BOOLEAN			ifaceRegistered = FALSE;
    BOOLEAN			epRegistered = FALSE;

#ifdef	NOOSIDEBUGSERVER	/* Use All Protseqs already done in OSI */

    status = RpcServerUseAllProtseqs(1, NULL);
    if (status != RPC_S_OK) {
        task = "Use All Protocol Sequences";
        goto cleanup;
    }

#endif	/* NOOSIDEBUGSERVER */

    status = RpcServerRegisterIf(afsrpc_v1_0_s_ifspec, NULL, NULL);
    if (status != RPC_S_OK) {
        task = "Register Interface";
        goto cleanup;
    }
    ifaceRegistered = TRUE;

    status = RpcServerInqBindings(&ptrBindingVector);
    if (status != RPC_S_OK) {
        task = "Inquire Bindings";
        goto cleanup;
    }

    status = RpcServerRegisterAuthInfo(NULL, RPC_C_AUTHN_WINNT, NULL, NULL);
    if (status != RPC_S_OK) {
        task = "Register Authentication Info";
        goto cleanup;
    }

    status = RpcEpRegister(afsrpc_v1_0_s_ifspec, ptrBindingVector,
                            NULL, "AFS session key interface");
    if (status != RPC_S_OK) {
        task = "Register Endpoints";
        goto cleanup;
    }
    epRegistered = TRUE;

    afsi_log("RPC server listening");

    status = RpcServerListen(OSI_MAXRPCCALLS, OSI_MAXRPCCALLS, 0);
    if (status != RPC_S_OK) {
        task = "Server Listen";
    }

cleanup:
    if (epRegistered)
        (void) RpcEpUnregister(afsrpc_v1_0_s_ifspec, ptrBindingVector,
                                NULL);

    if (ptrBindingVector)
        (void) RpcBindingVectorFree(&ptrBindingVector);

    if (ifaceRegistered)
        (void) RpcServerUnregisterIf(afsrpc_v1_0_s_ifspec, NULL, FALSE);

    if (status != RPC_S_OK)
        afsi_log("RPC problem, code %d for %s", status, task);
    else
        afsi_log("RPC shutdown");

    if (rpc_ShutdownEvent != NULL)
        thrd_SetEvent(rpc_ShutdownEvent);
    return;
}