NTSTATUS SrvBuildExecContext( IN PLWIO_SRV_CONNECTION pConnection, IN PSMB_PACKET pSmbRequest, IN BOOLEAN bInternal, OUT PSRV_EXEC_CONTEXT* ppContext ) { NTSTATUS ntStatus = STATUS_SUCCESS; PSRV_EXEC_CONTEXT pContext = NULL; ntStatus = SrvBuildEmptyExecContext(&pContext); BAIL_ON_NT_STATUS(ntStatus); ntStatus = SrvLogContextUpdateFilter( pContext->pLogContext, pConnection->pClientAddress, pConnection->clientAddrLen); BAIL_ON_NT_STATUS(ntStatus); pContext->pConnection = SrvConnectionAcquire(pConnection); pContext->pSmbRequest = pSmbRequest; if (pSmbRequest) { InterlockedIncrement(&pSmbRequest->refCount); } pContext->bInternal = bInternal; pContext->bInline = TRUE; *ppContext = pContext; cleanup: return ntStatus; error: *ppContext = NULL; goto cleanup; }
NTSTATUS SrvNotifyCreateState( PLWIO_SRV_CONNECTION pConnection, PLWIO_SRV_SESSION pSession, PLWIO_SRV_TREE pTree, PLWIO_SRV_FILE pFile, USHORT usMid, ULONG ulPid, ULONG ulRequestSequence, ULONG ulCompletionFilter, BOOLEAN bWatchTree, ULONG ulMaxBufferSize, PSRV_CHANGE_NOTIFY_STATE_SMB_V1* ppNotifyState ) { NTSTATUS ntStatus = STATUS_SUCCESS; PSRV_CHANGE_NOTIFY_STATE_SMB_V1 pNotifyState = NULL; ntStatus = SrvAllocateMemory( sizeof(SRV_CHANGE_NOTIFY_STATE_SMB_V1), (PVOID*)&pNotifyState); BAIL_ON_NT_STATUS(ntStatus); pNotifyState->refCount = 1; pthread_mutex_init(&pNotifyState->mutex, NULL); pNotifyState->pMutex = &pNotifyState->mutex; pNotifyState->ullNotifyId = SrvAsyncStateBuildId(ulPid, usMid); pNotifyState->pConnection = SrvConnectionAcquire(pConnection); pNotifyState->ulCompletionFilter = ulCompletionFilter; pNotifyState->bWatchTree = bWatchTree; pNotifyState->usUid = pSession->uid; pNotifyState->usTid = pTree->tid; pNotifyState->usFid = pFile->fid; pNotifyState->usMid = usMid; pNotifyState->ulPid = ulPid; pNotifyState->ulRequestSequence = ulRequestSequence; pNotifyState->ulMaxBufferSize = ulMaxBufferSize; if (ulMaxBufferSize) { ntStatus = SrvAllocateMemory( ulMaxBufferSize, (PVOID*)&pNotifyState->pBuffer); BAIL_ON_NT_STATUS(ntStatus); } pNotifyState->ulBufferLength = ulMaxBufferSize; *ppNotifyState = pNotifyState; cleanup: return ntStatus; error: *ppNotifyState = NULL; if (pNotifyState) { SrvNotifyStateFree(pNotifyState); } goto cleanup; }