fresh git tree for public release

we regretfully had to remove our git history for licensing reasons

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
This commit is contained in:
Casey Bodley 2010-10-11 14:59:26 -04:00
commit 0ad4db4fad
271 changed files with 71255 additions and 0 deletions

8
sys/makefile Normal file
View file

@ -0,0 +1,8 @@
#
# DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source
# file to this component. This file merely indirects to the real make file
# that is shared by all the driver components of the Windows NT DDK
#
!INCLUDE $(NTMAKEENV)\makefile.def

685
sys/nfs41_debug.c Normal file
View file

@ -0,0 +1,685 @@
/* Copyright (c) 2010
* The Regents of the University of Michigan
* All Rights Reserved
*
* Permission is granted to use, copy and redistribute this software
* for noncommercial education and research purposes, so long as no
* fee is charged, and so long as the name of the University of Michigan
* is not used in any advertising or publicity pertaining to the use
* or distribution of this software without specific, written prior
* authorization. Permission to modify or otherwise create derivative
* works of this software is not granted.
*
* This software is provided as is, without representation or warranty
* of any kind either express or implied, including without limitation
* the implied warranties of merchantability, fitness for a particular
* purpose, or noninfringement. The Regents of the University of
* Michigan shall not be liable for any damages, including special,
* indirect, incidental, or consequential damages, with respect to any
* claim arising out of or in connection with the use of the software,
* even if it has been or is hereafter advised of the possibility of
* such damages.
*/
#define MINIRDR__NAME "Value is ignored, only fact of definition"
#include <rx.h>
#include "nfs41_driver.h"
#include "nfs41_debug.h"
#include <stdio.h>
#include <stdarg.h>
#include <ntstrsafe.h>
#include <winerror.h>
//#define INCLUDE_TIMESTAMPS
ULONG __cdecl DbgP(IN PCCH fmt, ...)
{
CHAR msg[512];
va_list args;
NTSTATUS status;
va_start(args, fmt);
ASSERT(fmt != NULL);
status = RtlStringCbVPrintfA(msg, sizeof(msg), fmt, args);
if (NT_SUCCESS(status)) {
#ifdef INCLUDE_TIMESTAMPS
LARGE_INTEGER timestamp, local_time;
TIME_FIELDS time_fields;
KeQuerySystemTime(&timestamp);
ExSystemTimeToLocalTime(&timestamp,&local_time);
RtlTimeToTimeFields(&local_time, &time_fields);
DbgPrintEx(DPFLTR_IHVNETWORK_ID, DPFLTR_ERROR_LEVEL,
"[%ld].[%02u:%02u:%02u.%u] %s", IoGetCurrentProcess(),
time_fields.Hour, time_fields.Minute, time_fields.Second,
time_fields.Milliseconds, msg);
#else
DbgPrintEx(DPFLTR_IHVNETWORK_ID, DPFLTR_ERROR_LEVEL,
"[%ld] %s", IoGetCurrentProcess(), msg);
#endif
}
va_end(args);
return 0;
}
void print_hexbuf(int on, unsigned char *title, unsigned char *buf, int len)
{
int j, k;
LARGE_INTEGER timestamp, local_time;
TIME_FIELDS time_fields;
if (!on) return;
KeQuerySystemTime(&timestamp);
ExSystemTimeToLocalTime(&timestamp,&local_time);
RtlTimeToTimeFields(&local_time, &time_fields);
DbgPrintEx(DPFLTR_IHVNETWORK_ID, DPFLTR_ERROR_LEVEL,
"[%ld].[%02u:%02u:%02u.%u] %s\n", IoGetCurrentProcess(),
time_fields.Hour, time_fields.Minute, time_fields.Second,
time_fields.Milliseconds, title);
for(j = 0, k = 0; j < len; j++, k++) {
DbgPrintEx(DPFLTR_IHVNETWORK_ID, DPFLTR_ERROR_LEVEL,
"%02x ", buf[j]);
if (((k+1) % 30 == 0 && k > 0))
DbgPrintEx(DPFLTR_IHVNETWORK_ID, DPFLTR_ERROR_LEVEL, "\n");
}
DbgPrintEx(DPFLTR_IHVNETWORK_ID, DPFLTR_ERROR_LEVEL, "\n");
}
void print_ioctl(int on, int op)
{
if(!on) return;
switch(op) {
case IRP_MJ_FILE_SYSTEM_CONTROL:
DbgP("IRP_MJ_FILE_SYSTEM_CONTROL\n");
break;
case IRP_MJ_DEVICE_CONTROL:
DbgP("IRP_MJ_DEVICE_CONTROL\n");
break;
case IRP_MJ_INTERNAL_DEVICE_CONTROL:
DbgP("IRP_MJ_INTERNAL_DEVICE_CONTROL\n");
break;
default:
DbgP("UNKNOWN MJ IRP %d\n", op);
};
}
void print_fs_ioctl(int on, int op)
{
if(!on) return;
switch(op) {
case IOCTL_NFS41_INVALCACHE:
DbgP("IOCTL_NFS41_INVALCACHE\n");
break;
case IOCTL_NFS41_READ:
DbgP("IOCTL_NFS41_UPCALL\n");
break;
case IOCTL_NFS41_WRITE:
DbgP("IOCTL_NFS41_DOWNCALL\n");
break;
case IOCTL_NFS41_ADDCONN:
DbgP("IOCTL_NFS41_ADDCONN\n");
break;
case IOCTL_NFS41_DELCONN:
DbgP("IOCTL_NFS41_DELCONN\n");
break;
case IOCTL_NFS41_GETSTATE:
DbgP("IOCTL_NFS41_GETSTATE\n");
break;
case IOCTL_NFS41_START:
DbgP("IOCTL_NFS41_START\n");
break;
case IOCTL_NFS41_STOP:
DbgP("IOCTL_NFS41_STOP\n");
break;
default:
DbgP("UNKNOWN FS IOCTL %d\n", op);
};
}
void print_driver_state(int state)
{
switch (state) {
case NFS41_START_DRIVER_STARTABLE:
DbgP("NFS41_START_DRIVER_STARTABLE\n");
break;
case NFS41_START_DRIVER_STOPPED:
DbgP("NFS41_START_DRIVER_STOPPED\n");
break;
case NFS41_START_DRIVER_START_IN_PROGRESS:
DbgP("NFS41_START_DRIVER_START_IN_PROGRESS\n");
break;
case NFS41_START_DRIVER_STARTED:
DbgP("NFS41_START_DRIVER_STARTED\n");
break;
default:
DbgP("UNKNOWN DRIVER STATE %d\n", state);
};
}
void print_basic_info(int on, PFILE_BASIC_INFORMATION info)
{
if (!on) return;
DbgP("BASIC_INFO: Create=%x Access=%x Write=%x Change=%x Attr=%x\n",
info->CreationTime.QuadPart, info->LastAccessTime.QuadPart,
info->LastWriteTime.QuadPart, info->ChangeTime.QuadPart,
info->FileAttributes);
}
void print_std_info(int on, PFILE_STANDARD_INFORMATION info)
{
if (!on) return;
DbgP("STD_INFO: Type=%s #Links=%d Alloc=%x EOF=%x Delete=%d\n",
info->Directory?"DIR":"FILE", info->NumberOfLinks,
info->AllocationSize, info->EndOfFile, info->DeletePending);
}
void print_ea_info(int on, PFILE_FULL_EA_INFORMATION info)
{
if (!on) return;
DbgP("FULL_EA_INFO: NextOffset=%d Flags=%x EaNameLength=%d "
"ExValueLength=%x EaName=%s\n", info->NextEntryOffset, info->Flags,
info->EaNameLength, info->EaValueLength, info->EaName);
if (info->EaValueLength)
print_hexbuf(0, (unsigned char *)"eavalue",
(unsigned char *)info->EaName + info->EaNameLength + 1,
info->EaValueLength);
}
void print_get_ea(int on, PFILE_GET_EA_INFORMATION info)
{
if (!on) return;
DbgP("GET_EA_INFO: NextOffset=%d EaNameLength=%d EaName=%s\n",
info->NextEntryOffset, info->EaNameLength, info->EaName);
}
VOID print_srv_call(int on, IN PMRX_SRV_CALL p)
{
if (!on) return;
DbgP("PMRX_SRV_CALL %p\n", p);
#if 0
DbgP("\tNodeReferenceCount %ld\n", p->NodeReferenceCount);
//DbgP("Context %p\n", p->Context);
//DbgP("Context2 %p\n", p->Context2);
//DbgP("pSrvCallName %wZ\n", p->pSrvCallName);
//DbgP("pPrincipalName %wZ\n", p->pPrincipalName);
//DbgP("PDomainName %wZ\n", p->pDomainName);
//DbgP("Flags %08lx\n", p->Flags);
//DbgP("MaximumNumberOfCloseDelayedFiles %ld\n", p->MaximumNumberOfCloseDelayedFiles);
//DbgP("Status %ld\n", p->Status);
DbgP("*****************\n");
#endif
}
VOID print_net_root(int on, IN PMRX_NET_ROOT p)
{
if (!on) return;
DbgP("PMRX_NET_ROOT %p\n", p);
#if 0
DbgP("\tNodeReferenceCount %ld\n", p->NodeReferenceCount);
DbgP("\tpSrvCall %p\n", p->pSrvCall);
//DbgP("Context %p\n", p->Context);
//DbgP("Context2 %p\n", p->Context2);
//DbgP("Flags %08lx\n", p->Flags);
DbgP("\tNumberOfFcbs %ld\n", p->NumberOfFcbs);
DbgP("\tNumberofSrvOpens %ld\n", p->NumberOfSrvOpens);
//DbgP("MRxNetRootState %ld\n", p->MRxNetRootState);
//DbgP("Type %ld\n", p->Type);
//DbgP("DeviceType %ld\n", p->DeviceType);
//DbgP("pNetRootName %wZ\n", p->pNetRootName);
//DbgP("InnerNamePrefix %wZ\n", &p->InnerNamePrefix);
DbgP("*****************\n");
#endif
}
VOID print_v_net_root(int on, IN PMRX_V_NET_ROOT p)
{
if (!on) return;
DbgP("PMRX_V_NET_ROOT %p\n", p);
#if 0
DbgP("\tNodeReferenceCount %ld\n", p->NodeReferenceCount);
DbgP("\tpNetRoot %p\n", p->pNetRoot);
//DbgP("Context %p\n", p->Context);
//DbgP("Context2 %p\n", p->Context2);
//DbgP("Flags %08lx\n", p->Flags);
DbgP("\tNumberofOpens %ld\n", p->NumberOfOpens);
DbgP("\tNumberofFobxs %ld\n", p->NumberOfFobxs);
//DbgP("LogonId\n");
//DbgP("pUserDomainName %wZ\n", p->pUserDomainName);
//DbgP("pUserName %wZ\n", p->pUserName);
//DbgP("pPassword %wZ\n", p->pPassword);
//DbgP("SessionId %ld\n", p->SessionId);
//DbgP("ConstructionStatus %08lx\n", p->ConstructionStatus);
//DbgP("IsExplicitConnection %d\n", p->IsExplicitConnection);
DbgP("*****************\n");
#endif
}
void print_file_object(int on, PFILE_OBJECT file)
{
if (!on) return;
DbgP("FsContext %p FsContext2 %p\n", file->FsContext, file->FsContext2);
DbgP("DeletePending %d ReadAccess %d WriteAccess %d DeleteAccess %d\n",
file->DeletePending, file->WriteAccess, file->DeleteAccess);
DbgP("SharedRead %d SharedWrite %d SharedDelete %d Flags %x\n",
file->SharedRead, file->SharedWrite, file->SharedDelete, file->Flags);
}
VOID print_fcb(int on, IN PMRX_FCB p)
{
if (!on) return;
DbgP("PMRX_FCB %p OpenCount %d\n", p, p->OpenCount);
#if 0
DbgP("\tNodeReferenceCount %ld\n", p->NodeReferenceCount);
DbgP("\tpNetRoot %p\n", p->pNetRoot);
//DbgP("Context %p\n", p->Context);
//DbgP("Context2 %p\n", p->Context2);
//DbgP("FcbState %ld\n", p->FcbState);
//DbgP("UncleanCount %ld\n", p->UncleanCount);
//DbgP("UncachedUncleanCount %ld\n", p->UncachedUncleanCount);
DbgP("\tOpenCount %ld\n", p->OpenCount);
//DbgP("OutstandingLockOperationsCount %ld\n", p->OutstandingLockOperationsCount);
//DbgP("ActualAllocationLength %ull\n", p->ActualAllocationLength);
//DbgP("Attributes %ld\n", p->Attributes);
//DbgP("IsFileWritten %d\n", p->IsFileWritten);
//DbgP("fShouldBeOrphaned %d\n", p->fShouldBeOrphaned);
//DbgP("fMiniInited %ld\n", p->fMiniInited);
//DbgP("CachedNetRootType %c\n", p->CachedNetRootType);
//DbgP("SrvOpenList\n");
//DbgP("SrvOpenListVersion %ld\n", p->SrvOpenListVersion);
DbgP("*****************\n");
#endif
}
VOID print_srv_open(int on, IN PMRX_SRV_OPEN p)
{
if (!on) return;
DbgP("PMRX_SRV_OPEN %p\n", p);
#if 0
DbgP("\tNodeReferenceCount %ld\n", p->NodeReferenceCount);
DbgP("\tpFcb %p\n", p->pFcb);
DbgP("\tpVNetRoot %p\n", p->pVNetRoot);
//DbgP("Context %p\n", p->Context);
//DbgP("Context2 %p\n", p->Context2);
//DbgP("Flags %08lx\n", p->Flags);
//DbgP("pAlreadyPrefixedName %wZ\n", p->pAlreadyPrefixedName);
//DbgP("UncleanFobxCount %ld\n", p->UncleanFobxCount);
DbgP("\tOpenCount %ld\n", p->OpenCount);
//DbgP("Key %p\n", p->Key);
//DbgP("DesiredAccess\n");
//DbgP("ShareAccess %ld\n", p->ShareAccess);
//DbgP("CreateOptions %ld\n", p->CreateOptions);
//DbgP("BufferingFlags %ld\n", p->BufferingFlags);
//DbgP("ulFileSizeVersion %ld\n", p->ulFileSizeVersion);
//DbgP("SrvOpenQLinks\n");
DbgP("*****************\n");
#endif
}
VOID print_fobx(int on, IN PMRX_FOBX p)
{
if (!on) return;
DbgP("PMRX_FOBX %p\n", p);
#if 0
DbgP("\tNodeReferenceCount %ld\n", p->NodeReferenceCount);
DbgP("\tpSrvOpen %p\n", p->pSrvOpen);
DbgP("\tAssociatedFileObject %p\n", p->AssociatedFileObject);
//DbgP("Context %p\n", p->Context);
//DbgP("Context2 %p\n", p->Context2);
//DbgP("Flags %08lx\n", p->Flags);
DbgP("*****************\n");
#endif
}
VOID print_irp_flags(int on, PIRP irp)
{
if (!on) return;
DbgP("RxContext->CurrentIrp %p\n", irp);
DbgP("IRP FLAGS:\n");
if (irp->Flags & IRP_NOCACHE)
DbgP("\tIRP_NOCACHE\n");
if (irp->Flags & IRP_PAGING_IO)
DbgP("\tIRP_PAGING_IO\n");
if (irp->Flags & IRP_MOUNT_COMPLETION)
DbgP("\tIRP_MOUNT_COMPLETION\n");
if (irp->Flags & IRP_SYNCHRONOUS_API)
DbgP("\tIRP_SYNCHRONOUS_API\n");
if (irp->Flags & IRP_ASSOCIATED_IRP)
DbgP("\tIRP_ASSOCIATED_IRP\n");
if (irp->Flags & IRP_BUFFERED_IO)
DbgP("\tIRP_BUFFERED_IO\n");
if (irp->Flags & IRP_DEALLOCATE_BUFFER)
DbgP("\tIRP_DEALLOCATE_BUFFER\n");
if (irp->Flags & IRP_INPUT_OPERATION)
DbgP("\tIRP_INPUT_OPERATION\n");
if (irp->Flags & IRP_SYNCHRONOUS_PAGING_IO)
DbgP("\tIRP_SYNCHRONOUS_PAGING_IO\n");
if (irp->Flags & IRP_CREATE_OPERATION)
DbgP("\tIRP_CREATE_OPERATION\n");
if (irp->Flags & IRP_READ_OPERATION)
DbgP("\tIRP_READ_OPERATION\n");
if (irp->Flags & IRP_WRITE_OPERATION)
DbgP("\tIRP_WRITE_OPERATION\n");
if (irp->Flags & IRP_CLOSE_OPERATION)
DbgP("\tIRP_CLOSE_OPERATION\n");
if (irp->Flags & IRP_DEFER_IO_COMPLETION)
DbgP("\tIRP_DEFER_IO_COMPLETION\n");
}
void print_irps_flags(int on, PIO_STACK_LOCATION irps)
{
if (!on) return;
DbgP("RxContext->CurrentIrpSp %p\n", irps);
if(irps->Flags & SL_CASE_SENSITIVE)
DbgP("\tSL_CASE_SENSITIVE\n");
if(irps->Flags & SL_OPEN_PAGING_FILE)
DbgP("\tSL_OPEN_PAGING_FILE\n");
if(irps->Flags & SL_FORCE_ACCESS_CHECK)
DbgP("\tSL_FORCE_ACCESS_CHECK\n");
if(irps->Flags & SL_OPEN_TARGET_DIRECTORY)
DbgP("\tSL_OPEN_TARGET_DIRECTORY\n");
}
void print_nt_create_params(int on, NT_CREATE_PARAMETERS params)
{
if (!on) return;
DbgP("File attributes %ld: %s %s %s %s %s\n", params.FileAttributes,
(params.FileAttributes & FILE_ATTRIBUTE_TEMPORARY)?"TEMPFILE":"",
(params.FileAttributes & FILE_ATTRIBUTE_READONLY)?"READONLY":"",
(params.FileAttributes & FILE_ATTRIBUTE_HIDDEN)?"HIDDEN":"",
(params.FileAttributes & FILE_ATTRIBUTE_SYSTEM)?"SYSTEM":"",
(params.FileAttributes & FILE_ATTRIBUTE_ARCHIVE)?"ARCHIVE":"");
if (params.Disposition == FILE_SUPERSEDE)
DbgP("Create Dispositions: FILE_SUPERSEDE\n");
if (params.Disposition == FILE_CREATE)
DbgP("Create Dispositions: FILE_CREATE\n");
if (params.Disposition == FILE_OPEN)
DbgP("Create Dispositions: FILE_OPEN\n");
if (params.Disposition == FILE_OPEN_IF)
DbgP("Create Dispositions: FILE_OPEN_IF\n");
if (params.Disposition == FILE_OVERWRITE)
DbgP("Create Dispositions: FILE_OVERWRITE\n");
if (params.Disposition == FILE_OVERWRITE_IF)
DbgP("Create Dispositions: FILE_OVERWRITE_IF\n");
DbgP("Create Attributes: %s %s %s\n",
(params.CreateOptions & FILE_DIRECTORY_FILE)?"DIRFILE":"",
(params.CreateOptions & FILE_NON_DIRECTORY_FILE)?"FILE":"",
(params.CreateOptions & FILE_DELETE_ON_CLOSE)?"DELETEONCLOSE":"");
if (on > 1) {
DbgP("More Create Attrss:\n");
if (params.CreateOptions & FILE_WRITE_THROUGH)
DbgP("\tFILE_WRITE_THROUGH\n");
if (params.CreateOptions & FILE_SEQUENTIAL_ONLY)
DbgP("\tFILE_SEQUENTIAL_ONLY\n");
if (params.CreateOptions & FILE_RANDOM_ACCESS)
DbgP("\tFILE_RANDOM_ACCESS\n");
if (params.CreateOptions & FILE_NO_INTERMEDIATE_BUFFERING)
DbgP("\tFILE_NO_INTERMEDIATE_BUFFERING\n");
if (params.CreateOptions & FILE_SYNCHRONOUS_IO_ALERT)
DbgP("\tFILE_SYNCHRONOUS_IO_ALERT\n");
if (params.CreateOptions & FILE_SYNCHRONOUS_IO_NONALERT)
DbgP("\tFILE_SYNCHRONOUS_IO_NONALERT\n");
if (params.CreateOptions & FILE_CREATE_TREE_CONNECTION)
DbgP("\tFILE_CREATE_TREE_CONNECTION\n");
if (params.CreateOptions & FILE_COMPLETE_IF_OPLOCKED)
DbgP("\tFILE_COMPLETE_IF_OPLOCKED\n");
if (params.CreateOptions & FILE_NO_EA_KNOWLEDGE)
DbgP("\tFILE_NO_EA_KNOWLEDGE\n");
if (params.CreateOptions & FILE_OPEN_REPARSE_POINT)
DbgP("\tFILE_OPEN_REPARSE_POINT\n");
if (params.CreateOptions & FILE_OPEN_BY_FILE_ID)
DbgP("\tFILE_OPEN_BY_FILE_ID\n");
if (params.CreateOptions & FILE_OPEN_FOR_BACKUP_INTENT)
DbgP("\tFILE_OPEN_FOR_BACKUP_INTENT\n");
if (params.CreateOptions & FILE_RESERVE_OPFILTER)
DbgP("\tFILE_RESERVE_OPFILTER \n");
}
DbgP("Share Access: %s %s %s\n",
(params.ShareAccess & FILE_SHARE_READ)?"READ ":"",
(params.ShareAccess & FILE_SHARE_WRITE)?"WRITE ":"",
(params.ShareAccess & FILE_SHARE_DELETE)?"DELETE":"");
DbgP("Desired Access: %s %s %s %s %s %s %s %s %s %s %s %s\n",
(params.DesiredAccess & FILE_READ_DATA)?"READ":"",
(params.DesiredAccess & STANDARD_RIGHTS_READ)?"READ_ACL":"",
(params.DesiredAccess & FILE_READ_ATTRIBUTES)?"GETATTR":"",
(params.DesiredAccess & FILE_READ_EA)?"READ_EA":"",
(params.DesiredAccess & FILE_WRITE_DATA)?"WRITE":"",
(params.DesiredAccess & STANDARD_RIGHTS_WRITE)?"WRITE_ACL":"",
(params.DesiredAccess & FILE_WRITE_ATTRIBUTES)?"SETATTR":"",
(params.DesiredAccess & FILE_WRITE_EA)?"WRITE_EA":"",
(params.DesiredAccess & FILE_APPEND_DATA)?"APPEND":"",
(params.DesiredAccess & FILE_EXECUTE)?"EXEC":"",
(params.DesiredAccess & FILE_LIST_DIRECTORY)?"LSDIR":"",
(params.DesiredAccess & FILE_TRAVERSE)?"TRAVERSE":"");
}
unsigned char * print_file_information_class(int InfoClass)
{
switch(InfoClass) {
case FileBothDirectoryInformation:
return (unsigned char *)"FileBothDirectoryInformation";
case FileDirectoryInformation:
return (unsigned char *)"FileDirectoryInformation";
case FileFullDirectoryInformation:
return (unsigned char *)"FileFullDirectoryInformation";
case FileIdBothDirectoryInformation:
return (unsigned char *)"FileIdBothDirectoryInformation";
case FileIdFullDirectoryInformation:
return (unsigned char *)"FileIdFullDirectoryInformation";
case FileNamesInformation:
return (unsigned char *)"FileNamesInformation";
case FileObjectIdInformation:
return (unsigned char *)"FileObjectIdInformation";
case FileQuotaInformation:
return (unsigned char *)"FileQuotaInformation";
case FileReparsePointInformation:
return (unsigned char *)"FileReparsePointInformation";
case FileAllInformation:
return (unsigned char *)"FileAllInformation";
case FileAttributeTagInformation:
return (unsigned char *)"FileAttributeTagInformation";
case FileBasicInformation:
return (unsigned char *)"FileBasicInformation";
case FileCompressionInformation:
return (unsigned char *)"FileCompressionInformation";
case FileEaInformation:
return (unsigned char *)"FileEaInformation";
case FileInternalInformation:
return (unsigned char *)"FileInternalInformation";
case FileNameInformation:
return (unsigned char *)"FileNameInformation";
case FileNetworkOpenInformation:
return (unsigned char *)"FileNetworkOpenInformation";
case FilePositionInformation:
return (unsigned char *)"FilePositionInformation";
case FileStandardInformation:
return (unsigned char *)"FileStandardInformation";
case FileStreamInformation:
return (unsigned char *)"FileStreamInformation";
case FileAllocationInformation:
return (unsigned char *)"FileAllocationInformation";
case FileDispositionInformation:
return (unsigned char *)"FileDispositionInformation";
case FileEndOfFileInformation:
return (unsigned char *)"FileEndOfFileInformation";
case FileLinkInformation:
return (unsigned char *)"FileLinkInformation";
case FileRenameInformation:
return (unsigned char *)"FileRenameInformation";
case FileValidDataLengthInformation:
return (unsigned char *)"FileValidDataLengthInformation";
default:
return (unsigned char *)"UNKNOWN";
}
}
unsigned char *print_fs_information_class(int InfoClass)
{
switch (InfoClass) {
case FileFsAttributeInformation:
return (unsigned char *)"FileFsAttributeInformation";
case FileFsControlInformation:
return (unsigned char *)"FileFsControlInformation";
case FileFsDeviceInformation:
return (unsigned char *)"FileFsDeviceInformation";
case FileFsDriverPathInformation:
return (unsigned char *)"FileFsDriverPathInformation";
case FileFsFullSizeInformation:
return (unsigned char *)"FileFsFullSizeInformation";
case FileFsObjectIdInformation:
return (unsigned char *)"FileFsObjectIdInformation";
case FileFsSizeInformation:
return (unsigned char *)"FileFsSizeInformation";
case FileFsVolumeInformation:
return (unsigned char *)"FileFsVolumeInformation";
default:
return (unsigned char *)"UNKNOWN";
}
}
void print_caching_level(int on, ULONG flag)
{
if (!on) return;
switch(flag) {
case 0:
DbgP("DISABLE_CACHING\n");
break;
case 1:
DbgP("ENABLE_READ_CACHING\n");
break;
case 2:
DbgP("ENABLE_WRITE_CACHING\n");
break;
case 3:
DbgP("ENABLE_READWRITE_CACHING\n");
break;
}
}
const char *opcode2string(int opcode)
{
switch(opcode) {
case NFS41_SHUTDOWN: return "NFS41_SHUTDOWN";
case NFS41_MOUNT: return "NFS41_MOUNT";
case NFS41_UNMOUNT: return "NFS41_UNMOUNT";
case NFS41_OPEN: return "NFS41_OPEN";
case NFS41_CLOSE: return "NFS41_CLOSE";
case NFS41_READ: return "NFS41_READ";
case NFS41_WRITE: return "NFS41_WRITE";
case NFS41_LOCK: return "NFS41_LOCK";
case NFS41_UNLOCK: return "NFS41_UNLOCK";
case NFS41_DIR_QUERY: return "NFS41_DIR_QUERY";
case NFS41_FILE_QUERY: return "NFS41_FILE_QUERY";
case NFS41_FILE_SET: return "NFS41_FILE_SET";
case NFS41_EA_SET: return "NFS41_EA_SET";
case NFS41_VOLUME_QUERY: return "NFS41_VOLUME_QUERY";
default: return "UNKNOWN";
}
}
void print_open_error(int on, int status)
{
switch (status) {
case ERROR_ACCESS_DENIED:
DbgP("[ERROR] nfs41_Create: STATUS_NETWORK_ACCESS_DENIED\n");
break;
case ERROR_INVALID_NAME:
DbgP("[ERROR] nfs41_Create: STATUS_OBJECT_NAME_INVALID\n");
break;
case ERROR_FILE_EXISTS:
DbgP("[ERROR] nfs41_Create: ERROR_FILE_EXISTS\n");
break;
case ERROR_FILE_INVALID:
DbgP("[ERROR] nfs41_Create: STATUS_FILE_INVALID\n");
break;
case ERROR_FILE_NOT_FOUND:
DbgP("[ERROR] nfs41_Create: ERROR_FILE_NOT_FOUND\n");
break;
case ERROR_FILENAME_EXCED_RANGE:
DbgP("[ERROR] nfs41_Create: STATUS_NAME_TOO_LONG\n");
break;
case ERROR_NETWORK_ACCESS_DENIED:
DbgP("[ERROR] nfs41_Create: ERROR_NETWORK_ACCESS_DENIED\n");
break;
case ERROR_PATH_NOT_FOUND:
DbgP("[ERROR] nfs41_Create: STATUS_OBJECT_PATH_NOT_FOUND\n");
break;
case ERROR_SHARING_VIOLATION:
DbgP("[ERROR] nfs41_Create: STATUS_SHARING_VIOLATION\n");
break;
default:
DbgP("[ERROR] nfs41_Create: upcall returned %d returning "
"STATUS_INSUFFICIENT_RESOURCES\n", status);
case ERROR_OUTOFMEMORY:
DbgP("[ERROR] nfs41_Create: STATUS_INSUFFICIENT_RESOURCES\n");
}
}
void print_wait_status(int on, const char *prefix, NTSTATUS status,
const char *opcode, PVOID entry, int xid)
{
switch (status) {
case STATUS_SUCCESS:
if (opcode)
DbgP("%s Got a wakeup call, finishing %s entry=%p xid=%d\n",
prefix, opcode, entry, xid);
else
DbgP("%s Got a wakeup call\n", prefix);
break;
case STATUS_USER_APC:
DbgP("%s KeWaitForSingleObject returned STATUS_USER_APC\n", prefix);
break;
case STATUS_ALERTED:
DbgP("%s KeWaitForSingleObject returned STATUS_ALERTED\n", prefix);
break;
default:
DbgP("%s KeWaitForSingleObject returned %d\n", prefix, status);
}
}
/* This is taken from toaster/func. Rumor says this should be replaced
* with a WMI interface???
*/
ULONG
dprintk(
IN PCHAR func,
IN ULONG flags,
IN PCHAR format,
...)
{
#define TEMP_BUFFER_SIZE 1024
va_list list;
CHAR debugMessageBuffer[TEMP_BUFFER_SIZE];
NTSTATUS status, rv = STATUS_SUCCESS;
va_start(list, format);
if (format)
{
//
// Use the safe string function, RtlStringCbVPrintfA, instead of _vsnprintf.
// RtlStringCbVPrintfA NULL terminates the output buffer even if the message
// is longer than the buffer. This prevents malicious code from compromising
// the security of the system.
//
status = RtlStringCbVPrintfA(debugMessageBuffer, sizeof(debugMessageBuffer),
format, list);
if (!NT_SUCCESS(status))
rv = DbgPrintEx(PNFS_FLTR_ID, DPFLTR_MASK | flags,
"RtlStringCbVPrintfA failed %x \n", status);
else
rv = DbgPrintEx(PNFS_FLTR_ID, DPFLTR_MASK | flags, "%s %s: %s\n",
PNFS_TRACE_TAG, func, debugMessageBuffer);
}
va_end(list);
return rv;
}

101
sys/nfs41_debug.h Normal file
View file

@ -0,0 +1,101 @@
/* Copyright (c) 2010
* The Regents of the University of Michigan
* All Rights Reserved
*
* Permission is granted to use, copy and redistribute this software
* for noncommercial education and research purposes, so long as no
* fee is charged, and so long as the name of the University of Michigan
* is not used in any advertising or publicity pertaining to the use
* or distribution of this software without specific, written prior
* authorization. Permission to modify or otherwise create derivative
* works of this software is not granted.
*
* This software is provided as is, without representation or warranty
* of any kind either express or implied, including without limitation
* the implied warranties of merchantability, fitness for a particular
* purpose, or noninfringement. The Regents of the University of
* Michigan shall not be liable for any damages, including special,
* indirect, incidental, or consequential damages, with respect to any
* claim arising out of or in connection with the use of the software,
* even if it has been or is hereafter advised of the possibility of
* such damages.
*/
#ifndef _NFS41_DEBUG_
#define _NFS41_DEBUG_
#define _DRIVER_NAME_ "NFS4.1 Driver"
ULONG __cdecl DbgP(IN PCCH fmt, ...);
VOID print_srv_call(int on, IN PMRX_SRV_CALL p);
VOID print_net_root(int on, IN PMRX_NET_ROOT p);
VOID print_v_net_root(int on, IN PMRX_V_NET_ROOT p);
VOID print_fcb(int on, IN PMRX_FCB p);
VOID print_srv_open(int on, IN PMRX_SRV_OPEN p);
VOID print_fobx(int on, IN PMRX_FOBX p);
VOID print_irp_flags(int on, PIRP irp);
VOID print_irps_flags(int on, PIO_STACK_LOCATION irps);
void print_nt_create_params(int on, NT_CREATE_PARAMETERS params);
unsigned char *print_file_information_class(int InfoClass);
unsigned char *print_fs_information_class(int InfoClass);
void print_hexbuf(int on, unsigned char *title, unsigned char *buf, int len);
void print_ioctl(int on, int op);
void print_fs_ioctl(int on, int op);
void print_driver_state(int state);
void print_file_object(int on, PFILE_OBJECT file);
void print_basic_info(int on, PFILE_BASIC_INFORMATION info);
void print_std_info(int on, PFILE_STANDARD_INFORMATION info);
void print_ea_info(int on, PFILE_FULL_EA_INFORMATION info);
void print_get_ea(int on, PFILE_GET_EA_INFORMATION info);
void print_caching_level(int on, ULONG flag);
const char *opcode2string(int opcode);
void print_open_error(int on, int status);
void print_wait_status(int on, const char *str, NTSTATUS status,
const char *opcode, PVOID entry, int xid);
#define DbgEn() DbgPrintEx(DPFLTR_IHVNETWORK_ID, DPFLTR_ERROR_LEVEL, \
"--> [%s] [%d] %s\n", _DRIVER_NAME_, IoGetCurrentProcess(), \
__FUNCTION__); try {
#define DbgEx() DbgPrintEx(DPFLTR_IHVNETWORK_ID, DPFLTR_ERROR_LEVEL, \
"<-- [%s] [%d] %s status = %08lx\n", _DRIVER_NAME_, IoGetCurrentProcess(), \
__FUNCTION__, status); \
} except (EXCEPTION_EXECUTE_HANDLER) { \
status = GetExceptionCode() ; \
DbgP("Exception encountered with value = Ox%x\n", status); \
}
#define DbgR() DbgPrintEx(DPFLTR_IHVNETWORK_ID, DPFLTR_ERROR_LEVEL, \
"<-- [%s] [%d] %s\n", _DRIVER_NAME_, IoGetCurrentProcess(), __FUNCTION__); \
} except (EXCEPTION_EXECUTE_HANDLER) { \
NTSTATUS status; \
status = GetExceptionCode() ; \
DbgP("Exception encountered with value = Ox%x\n", status); \
}
/* These are for ToasterDebugPrint */
#define DBG_ERROR 0x00000001
#define DBG_WARN 0x00000002
#define DBG_TRACE 0x00000004
#define DBG_INFO 0x00000008
#define DBG_DISP_IN 0x00000010 /* Marks entry into dispatch functions */
#define DBG_DISP_OUT 0x00000020 /* Marks exit from dispatch functions */
/* I want to do:
* #define dprintk(flags, args...) DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_MASK | flags, ## args)
* but the ... is gcc specific, can't seem to do it here.
*/
#define PNFS_TRACE_TAG "PNFSMRX: "
#define PNFS_FLTR_ID DPFLTR_IHVDRIVER_ID
#define DbgEnter() DbgPrintEx(PNFS_FLTR_ID, DPFLTR_MASK | DBG_DISP_IN, "%s*** %s ***\n", \
PNFS_TRACE_TAG, __FUNCTION__);
#define DbgExit(status) DbgPrintEx(PNFS_FLTR_ID, DPFLTR_MASK | DBG_DISP_OUT, "%s<-- %s <-- 0x%08lx\n", \
PNFS_TRACE_TAG, __FUNCTION__, status);
ULONG
dprintk(
IN PCHAR func,
IN ULONG flags,
IN PCHAR format,
...);
#endif

4499
sys/nfs41_driver.c Normal file

File diff suppressed because it is too large Load diff

84
sys/nfs41_driver.h Normal file
View file

@ -0,0 +1,84 @@
/* Copyright (c) 2010
* The Regents of the University of Michigan
* All Rights Reserved
*
* Permission is granted to use, copy and redistribute this software
* for noncommercial education and research purposes, so long as no
* fee is charged, and so long as the name of the University of Michigan
* is not used in any advertising or publicity pertaining to the use
* or distribution of this software without specific, written prior
* authorization. Permission to modify or otherwise create derivative
* works of this software is not granted.
*
* This software is provided as is, without representation or warranty
* of any kind either express or implied, including without limitation
* the implied warranties of merchantability, fitness for a particular
* purpose, or noninfringement. The Regents of the University of
* Michigan shall not be liable for any damages, including special,
* indirect, incidental, or consequential damages, with respect to any
* claim arising out of or in connection with the use of the software,
* even if it has been or is hereafter advised of the possibility of
* such damages.
*/
#ifndef _NFS41_DRIVER_
#define _NFS41_DRIVER_
#define NFS41_DEVICE_NAME L"\\Device\\nfs41_driver"
#define NFS41_SHADOW_DEVICE_NAME L"\\??\\nfs41_driver"
#define NFS41_USER_DEVICE_NAME L"\\\\.\\nfs41_driver"
#define NFS41_USER_DEVICE_NAME_A "\\\\.\\nfs41_driver"
#define NFS41_PROVIDER_NAME_A "NFS41 Network"
#define NFS41_PROVIDER_NAME_U L"NFS41 Network"
#define NFS41_PIPE_NAME L"\\Device\\nfs41_pipe"
#define NFS41_SHADOW_PIPE_NAME L"\\??\\nfs41_pipe"
#define NFS41_USER_PIPE_NAME L"\\\\.\\nfs41_pipe"
#define NFS41_SHARED_MEMORY_NAME L"\\BaseNamedObjects\\nfs41_shared_memory"
#define NFS41_USER_SHARED_MEMORY_NAME "Global\\nfs41_shared_memory"
// See "Defining I/O Control Codes" in WDK docs
#define _RDR_CTL_CODE(code, method) \
CTL_CODE(FILE_DEVICE_NETWORK_REDIRECTOR, 0x800 | (code), method, FILE_ANY_ACCESS)
#define IOCTL_NFS41_START _RDR_CTL_CODE(0, METHOD_NEITHER)
#define IOCTL_NFS41_STOP _RDR_CTL_CODE(1, METHOD_NEITHER)
#define IOCTL_NFS41_GETSTATE _RDR_CTL_CODE(3, METHOD_NEITHER)
#define IOCTL_NFS41_ADDCONN _RDR_CTL_CODE(4, METHOD_BUFFERED)
#define IOCTL_NFS41_DELCONN _RDR_CTL_CODE(5, METHOD_BUFFERED)
#define IOCTL_NFS41_READ _RDR_CTL_CODE(6, METHOD_BUFFERED)
#define IOCTL_NFS41_WRITE _RDR_CTL_CODE(7, METHOD_BUFFERED)
#define IOCTL_NFS41_INVALCACHE _RDR_CTL_CODE(8, METHOD_BUFFERED)
typedef enum _nfs41_opcodes {
NFS41_MOUNT,
NFS41_UNMOUNT,
NFS41_OPEN,
NFS41_CLOSE,
NFS41_READ,
NFS41_WRITE,
NFS41_LOCK,
NFS41_UNLOCK,
NFS41_DIR_QUERY,
NFS41_FILE_QUERY,
NFS41_FILE_SET,
NFS41_EA_SET,
NFS41_VOLUME_QUERY,
NFS41_SHUTDOWN,
INVALID_OPCODE
} nfs41_opcodes;
typedef enum _nfs41_init_driver_state {
NFS41_INIT_DRIVER_STARTABLE,
NFS41_INIT_DRIVER_START_IN_PROGRESS,
NFS41_INIT_DRIVER_STARTED
} nfs41_init_driver_state;
typedef enum _nfs41_start_driver_state {
NFS41_START_DRIVER_STARTABLE,
NFS41_START_DRIVER_START_IN_PROGRESS,
NFS41_START_DRIVER_STARTED,
NFS41_START_DRIVER_STOPPED
} nfs41_start_driver_state;
#endif

13
sys/nfs41_driver.ini Normal file
View file

@ -0,0 +1,13 @@
\registry\machine\system\currentcontrolset\services\nfs41_driver
Description = nfs41_driver
DisplayName = nfs41_driver
ErrorControl = REG_DWORD 0x00000001
Group = Network
ImagePath = System32\DRIVERS\nfs41_driver.sys
LastLoadStatus = REG_DWORD 0
Start = REG_DWORD 0x00000001
Type = REG_DWORD 0x00000002
\registry\machine\system\currentcontrolset\services\nfs41_driver\NetworkProvider
DeviceName = \Device\nfs41_driver
Name = NFS41 Network
ProviderPath = System32\nfs41_np.dll

11
sys/nfs41_driver.rc Normal file
View file

@ -0,0 +1,11 @@
#include <windows.h>
#include <ntverp.h>
#define VER_FILETYPE VFT_DRV
#define VER_FILESUBTYPE VFT2_DRV_SYSTEM
#define VER_FILEDESCRIPTION_STR "CITI's nfs41 driver"
#define VER_INTERNALNAME_STR "nfs41_driver.sys"
#define VER_ORIGINALFILENAME_STR "nfs41_driver.Sys"
#include "common.ver"

26
sys/sources Normal file
View file

@ -0,0 +1,26 @@
TARGETNAME=nfs41_driver
TARGETTYPE=DRIVER
#KMDF_VERSION_MAJOR=1
TARGETLIBS = $(TARGETLIBS) \
$(DDK_LIB_PATH)\ksecdd.lib \
$(DDK_LIB_PATH)\rxce.lib \
$(DDK_LIB_PATH)\rdbsslib.lib \
$(DDK_LIB_PATH)\copysup.lib
C_DEFINES= -DEXPLODE_POOLTAGS -DMONOLITHIC_MINIRDR
!IF 0
Enable Buffer Security Check
!ENDIF
USER_C_FLAGS=/GS
INCLUDES=..\dll
SOURCES= nfs41_driver.rc nfs41_driver.c wmlkm.c nfs41_debug.c
!IF 0
/W3 is default level
bump to /Wall, but suppress warnings generated by system includes,
as well as the following warnings:
4100 - unused function call arguments (we have lots of stubs)
4127 - constant conditional (I like to use if(0) or if(1))
4204 - nonstandard extension used : non-constant aggregate initializer
!ENDIF
MSC_WARNING_LEVEL=/Wall /wd4668 /wd4619 /wd4820 /wd4255 /wd4100 /wd4127 /wd4201 /wd4204 /wd4115 /wd4711

51
sys/wmlkm.c Normal file
View file

@ -0,0 +1,51 @@
/* Copyright (c) 2010
* The Regents of the University of Michigan
* All Rights Reserved
*
* Permission is granted to use, copy and redistribute this software
* for noncommercial education and research purposes, so long as no
* fee is charged, and so long as the name of the University of Michigan
* is not used in any advertising or publicity pertaining to the use
* or distribution of this software without specific, written prior
* authorization. Permission to modify or otherwise create derivative
* works of this software is not granted.
*
* This software is provided as is, without representation or warranty
* of any kind either express or implied, including without limitation
* the implied warranties of merchantability, fitness for a particular
* purpose, or noninfringement. The Regents of the University of
* Michigan shall not be liable for any damages, including special,
* indirect, incidental, or consequential damages, with respect to any
* claim arising out of or in connection with the use of the software,
* even if it has been or is hereafter advised of the possibility of
* such damages.
*
* Comments: RDBSS depends on wmlkm files. See comments in nulmrx/wmlkm
*/
#pragma hdrstop
#include <ntddk.h>
#include <ntdef.h>
#define LPVOID PVOID64 // BUG - need to find include for this
#include "wmlkm.h"
NTSTATUS
WmlTinySystemControl(
__inout PVOID WmiLibInfo,
__in PVOID DeviceObject,
__in PVOID Irp
)
{
return(STATUS_WMI_GUID_NOT_FOUND);
}
ULONG
WmlTrace(
__in ULONG Type,
__in LPVOID TraceGuid,
__in ULONG64 LoggerHandle,
... // Pairs: Address, Length
)
{
return STATUS_SUCCESS;
}

51
sys/wmlkm.h Normal file
View file

@ -0,0 +1,51 @@
/* Copyright (c) 2010
* The Regents of the University of Michigan
* All Rights Reserved
*
* Permission is granted to use, copy and redistribute this software
* for noncommercial education and research purposes, so long as no
* fee is charged, and so long as the name of the University of Michigan
* is not used in any advertising or publicity pertaining to the use
* or distribution of this software without specific, written prior
* authorization. Permission to modify or otherwise create derivative
* works of this software is not granted.
*
* This software is provided as is, without representation or warranty
* of any kind either express or implied, including without limitation
* the implied warranties of merchantability, fitness for a particular
* purpose, or noninfringement. The Regents of the University of
* Michigan shall not be liable for any damages, including special,
* indirect, incidental, or consequential damages, with respect to any
* claim arising out of or in connection with the use of the software,
* even if it has been or is hereafter advised of the possibility of
* such damages.
*/
#ifndef NFS41_WMLKM_H
#define NFS41_WMLKM_H 1
#ifdef __cplusplus
extern "C" {
#endif
NTSTATUS
WmlTinySystemControl(
__inout PVOID WmiLibInfo,
__in PVOID DeviceObject,
__in PVOID Irp
);
ULONG
WmlTrace(
__in ULONG Type,
__in LPVOID TraceGuid,
__in ULONG64 LoggerHandle,
... // Pairs: Address, Length
);
#ifdef __cplusplus
};
#endif
#endif // NFS41_WMLKM_H