/*
* Copyright (c) 2008, 2009, 2010, 2011 Kernel Drivers, LLC.
- * Copyright (c) 2009, 2010, 2011, 2012, 2013 Your File System, Inc.
+ * Copyright (c) 2009, 2010, 2011, 2012, 2013, 2015 Your File System, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
return;
}
-LARGE_INTEGER
-AFSGetAuthenticationId()
+NTSTATUS
+AFSGetAuthenticationId( OUT LARGE_INTEGER *pliAuthId)
+{
+ AFSWorkItem *pWorkItem = NULL;
+ NTSTATUS ntStatus;
+
+ __try
+ {
+
+ RtlZeroMemory( pliAuthId, sizeof(LARGE_INTEGER));
+
+ pWorkItem = (AFSWorkItem *) AFSExAllocatePoolWithTag( NonPagedPool,
+ sizeof(AFSWorkItem),
+ AFS_WORK_ITEM_TAG);
+ if (NULL == pWorkItem)
+ {
+
+ AFSDbgTrace(( AFS_SUBSYSTEM_NETWORK_PROVIDER,
+ AFS_TRACE_LEVEL_ERROR,
+ "AFSGetAuthenticationId Failed to allocate work item\n"));
+
+ try_return( ntStatus = STATUS_INSUFFICIENT_RESOURCES );
+ }
+
+ RtlZeroMemory( pWorkItem,
+ sizeof(AFSWorkItem));
+
+ pWorkItem->Size = sizeof( AFSWorkItem);
+
+ pWorkItem->RequestType = AFS_WORK_GET_AUTH_ID;
+
+ pWorkItem->RequestFlags = AFS_SYNCHRONOUS_REQUEST;
+
+ KeInitializeEvent(&pWorkItem->Event,
+ NotificationEvent,
+ FALSE);
+
+ pWorkItem->Specific.GetAuthId.peProcess = PsGetCurrentProcess();
+
+ pWorkItem->Specific.GetAuthId.peThread = PsGetCurrentThread();
+
+ AFSDbgTrace(( AFS_SUBSYSTEM_WORKER_PROCESSING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSGetAuthenticationId Workitem %p\n",
+ pWorkItem));
+
+ ntStatus = AFSQueueWorkerRequest( pWorkItem);
+
+try_exit:
+
+ if( NT_SUCCESS( ntStatus))
+ {
+
+ *pliAuthId = pWorkItem->Specific.GetAuthId.AuthId;
+
+ ntStatus = pWorkItem->Status;
+
+ AFSDbgTrace(( AFS_SUBSYSTEM_WORKER_PROCESSING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSGetAuthenticationId Request complete Status %08lX\n",
+ ntStatus));
+ }
+ else {
+
+ AFSDbgTrace(( AFS_SUBSYSTEM_FILE_PROCESSING,
+ AFS_TRACE_LEVEL_ERROR,
+ "AFSGetAuthenticationId Failed to queue request Status %08lX\n",
+ ntStatus));
+ }
+
+ if( pWorkItem != NULL)
+ {
+
+ AFSExFreePoolWithTag( pWorkItem,
+ AFS_WORK_ITEM_TAG);
+ }
+ }
+ __except( AFSExceptionFilter( __FUNCTION__, GetExceptionCode(), GetExceptionInformation()) )
+ {
+
+ AFSDbgTrace(( 0,
+ 0,
+ "EXCEPTION - AFSGetAuthenticationId\n"));
+
+ AFSDumpTraceFilesFnc();
+ }
+
+ return ntStatus;
+}
+
+NTSTATUS
+AFSPerformGetAuthId( IN PEPROCESS peProcess,
+ IN PETHREAD peThread,
+ OUT LARGE_INTEGER *outAuthId)
{
LARGE_INTEGER liAuthId = {0,0};
__Enter
{
- hToken = PsReferenceImpersonationToken( PsGetCurrentThread(),
+ hToken = PsReferenceImpersonationToken( peThread,
&bCopyOnOpen,
&bEffectiveOnly,
&stImpersonationLevel);
if( hToken == NULL)
{
- hToken = PsReferencePrimaryToken( PsGetCurrentProcess());
+ hToken = PsReferencePrimaryToken( peProcess);
if( hToken == NULL)
{
AFSDbgTrace(( AFS_SUBSYSTEM_NETWORK_PROVIDER,
AFS_TRACE_LEVEL_ERROR,
- "AFSGetAuthenticationId Failed to retrieve impersonation or primary token\n"));
+ "AFSPerformGetAuthId Failed to retrieve impersonation or primary token\n"));
try_return( ntStatus);
}
AFSDbgTrace(( AFS_SUBSYSTEM_NETWORK_PROVIDER,
AFS_TRACE_LEVEL_ERROR,
- "AFSGetAuthenticationId Failed to retrieve information Status %08lX\n",
+ "AFSPerformGetAuthId Failed to retrieve information Status %08lX\n",
ntStatus));
try_return( ntStatus);
AFSDbgTrace(( AFS_SUBSYSTEM_NETWORK_PROVIDER,
AFS_TRACE_LEVEL_VERBOSE,
- "AFSGetAuthenticationId Successfully retrieved authentication ID %I64X\n",
+ "AFSPerformGetAuthId Successfully retrieved authentication ID %I64X\n",
liAuthId.QuadPart));
try_exit:
ExFreePool( pTokenInfo); // Allocated by SeQueryInformationToken
}
+
+ *outAuthId = liAuthId;
}
- return liAuthId;
+ return ntStatus;
}
void
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kernel Drivers, LLC.
- * Copyright (c) 2009, 2010, 2011 Your File System, Inc.
+ * Copyright (c) 2009, 2010, 2011, 2015 Your File System, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
if( ConnectCB->AuthenticationId.QuadPart == 0)
{
- ConnectCB->AuthenticationId = AFSGetAuthenticationId();
+ ntStatus = AFSGetAuthenticationId(&ConnectCB->AuthenticationId);
- if ( ConnectCB->AuthenticationId.QuadPart == 0)
+ if ( !NT_SUCCESS( ntStatus))
{
AFSDbgTrace(( AFS_SUBSYSTEM_NETWORK_PROVIDER,
AFS_TRACE_LEVEL_ERROR,
- "AFSAddConnection Unable to retrieve authentication id\n"));
+ "AFSAddConnection Unable to retrieve authentication id %08lX\n",
+ ntStatus));
- return STATUS_ACCESS_DENIED;
+ return ntStatus;
}
AFSDbgTrace(( AFS_SUBSYSTEM_NETWORK_PROVIDER,
if( ConnectCB->AuthenticationId.QuadPart == 0)
{
- ConnectCB->AuthenticationId = AFSGetAuthenticationId();
+ ntStatus = AFSGetAuthenticationId(&ConnectCB->AuthenticationId);
- if ( ConnectCB->AuthenticationId.QuadPart == 0)
+ if ( !NT_SUCCESS( ntStatus))
{
AFSDbgTrace(( AFS_SUBSYSTEM_NETWORK_PROVIDER,
AFS_TRACE_LEVEL_ERROR,
- "AFSCancelConnection Unable to retrieve authentication id\n"));
+ "AFSCancelConnection Unable to retrieve authentication id %08lX\n",
+ ntStatus));
- return STATUS_ACCESS_DENIED;
+ return ntStatus;
}
AFSDbgTrace(( AFS_SUBSYSTEM_NETWORK_PROVIDER,
if( ConnectCB->AuthenticationId.QuadPart == 0)
{
- ConnectCB->AuthenticationId = AFSGetAuthenticationId();
+ ntStatus = AFSGetAuthenticationId(&ConnectCB->AuthenticationId);
- if ( ConnectCB->AuthenticationId.QuadPart == 0)
+ if ( !NT_SUCCESS( ntStatus))
{
AFSDbgTrace(( AFS_SUBSYSTEM_NETWORK_PROVIDER,
AFS_TRACE_LEVEL_ERROR,
- "AFSGetConnection Unable to retrieve authentication id\n"));
+ "AFSGetConnection Unable to retrieve authentication id %08lX\n",
+ ntStatus));
- return STATUS_ACCESS_DENIED;
+ return ntStatus;
}
AFSDbgTrace(( AFS_SUBSYSTEM_NETWORK_PROVIDER,
if( ConnectCB->AuthenticationId.QuadPart == 0)
{
- ConnectCB->AuthenticationId = AFSGetAuthenticationId();
+ ntStatus = AFSGetAuthenticationId(&ConnectCB->AuthenticationId);
- if ( ConnectCB->AuthenticationId.QuadPart == 0)
+ if ( !NT_SUCCESS( ntStatus))
{
AFSDbgTrace(( AFS_SUBSYSTEM_NETWORK_PROVIDER,
AFS_TRACE_LEVEL_ERROR,
- "AFSListConnections Unable to retrieve authentication id\n"));
+ "AFSListConnection Unable to retrieve authentication id %08lX\n",
+ ntStatus));
- return STATUS_ACCESS_DENIED;
+ return ntStatus;
}
AFSDbgTrace(( AFS_SUBSYSTEM_NETWORK_PROVIDER,
if( ConnectCB->AuthenticationId.QuadPart == 0)
{
- ConnectCB->AuthenticationId = AFSGetAuthenticationId();
+ ntStatus = AFSGetAuthenticationId(&ConnectCB->AuthenticationId);
- if ( ConnectCB->AuthenticationId.QuadPart == 0)
+ if ( !NT_SUCCESS( ntStatus))
{
AFSDbgTrace(( AFS_SUBSYSTEM_NETWORK_PROVIDER,
AFS_TRACE_LEVEL_ERROR,
- "AFSGetConnectionInfo Unable to retrieve authentication id\n"));
+ "AFSGetConnectionInfo Unable to retrieve authentication id %08lX\n",
+ ntStatus));
- return STATUS_ACCESS_DENIED;
+ return ntStatus;
}
AFSDbgTrace(( AFS_SUBSYSTEM_NETWORK_PROVIDER,
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kernel Drivers, LLC.
- * Copyright (c) 2009, 2010, 2011, 2012, 2013 Your File System, Inc.
+ * Copyright (c) 2009, 2010, 2011, 2012, 2013, 2015 Your File System, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
else
{
- freeWorkItem = TRUE;
+ freeWorkItem = !(pWorkItem->RequestFlags & AFS_SYNCHRONOUS_REQUEST);
//
// Switch on the type of work item to process
AFSPerformObjectInvalidate( pWorkItem->Specific.Invalidate.ObjectInfo,
pWorkItem->Specific.Invalidate.InvalidateReason);
- freeWorkItem = TRUE;
-
break;
}
case AFS_WORK_START_IOS:
{
- freeWorkItem = TRUE;
-
break;
}
+ case AFS_WORK_GET_AUTH_ID:
+ {
+
+ pWorkItem->Status =
+ AFSPerformGetAuthId( pWorkItem->Specific.GetAuthId.peProcess,
+ pWorkItem->Specific.GetAuthId.peThread,
+ &pWorkItem->Specific.GetAuthId.AuthId);
+
+ break;
+ }
+
default:
AFSDbgTrace(( AFS_SUBSYSTEM_FILE_PROCESSING,
AFSExFreePoolWithTag( pWorkItem,
AFS_WORK_ITEM_TAG);
}
+ else
+ {
+
+ KeSetEvent( &pWorkItem->Event,
+ 0,
+ FALSE);
+ }
ntStatus = STATUS_SUCCESS;
}
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kernel Drivers, LLC.
- * Copyright (c) 2009, 2010, 2011 Your File System, Inc.
+ * Copyright (c) 2009, 2010, 2011, 2015 Your File System, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
AFSRemoveNameEntry( IN AFSObjectInfoCB *ParentObjectInfo,
IN AFSDirectoryCB *DirEntry);
-LARGE_INTEGER
-AFSGetAuthenticationId( void);
+NTSTATUS
+AFSGetAuthenticationId( OUT LARGE_INTEGER *pliAuthId);
+
+NTSTATUS
+AFSPerformGetAuthId( IN PEPROCESS peProcess,
+ IN PETHREAD peThread,
+ OUT LARGE_INTEGER *outAuthId);
void
AFSUnwindFileInfo( IN AFSFcb *Fcb,
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kernel Drivers, LLC.
- * Copyright (c) 2009, 2010, 2011, 2014 Your File System, Inc.
+ * Copyright (c) 2009, 2010, 2011, 2014, 2015 Your File System, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
// Worker Thread codes
//
-#define AFS_WORK_UNUSED_1 0x0001
+#define AFS_WORK_GET_AUTH_ID 0x0001
#define AFS_WORK_FLUSH_FCB 0x0002
#define AFS_WORK_UNUSED_3 0x0003
#define AFS_WORK_UNUSED_4 0x0004
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kernel Drivers, LLC.
- * Copyright (c) 2009, 2010, 2011 Your File System, Inc.
+ * Copyright (c) 2009, 2010, 2011, 2015 Your File System, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
} Invalidate;
+ struct
+ {
+ PETHREAD peThread;
+
+ PEPROCESS peProcess;
+
+ LARGE_INTEGER AuthId;
+
+ } GetAuthId;
+
struct
{
char Context[ 1];