sys: create basic driver structure

This commit is contained in:
Bill Zissimopoulos 2015-11-16 15:40:31 -08:00
parent 20a5e668c6
commit 99c2a6a5e5
19 changed files with 551 additions and 4 deletions

View File

@ -118,7 +118,22 @@
<FilesToPackage Include="$(TargetPath)" /> <FilesToPackage Include="$(TargetPath)" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\..\src\sys\cleanup.c" />
<ClCompile Include="..\..\src\sys\close.c" />
<ClCompile Include="..\..\src\sys\create.c" />
<ClCompile Include="..\..\src\sys\devctrl.c" />
<ClCompile Include="..\..\src\sys\dirctrl.c" />
<ClCompile Include="..\..\src\sys\driver.c" /> <ClCompile Include="..\..\src\sys\driver.c" />
<ClCompile Include="..\..\src\sys\ea.c" />
<ClCompile Include="..\..\src\sys\fileinfo.c" />
<ClCompile Include="..\..\src\sys\flush.c" />
<ClCompile Include="..\..\src\sys\fsctrl.c" />
<ClCompile Include="..\..\src\sys\lockctrl.c" />
<ClCompile Include="..\..\src\sys\read.c" />
<ClCompile Include="..\..\src\sys\seinfo.c" />
<ClCompile Include="..\..\src\sys\shutdown.c" />
<ClCompile Include="..\..\src\sys\volinfo.c" />
<ClCompile Include="..\..\src\sys\write.c" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\..\src\sys\driver.h" /> <ClInclude Include="..\..\src\sys\driver.h" />

View File

@ -18,6 +18,51 @@
<ClCompile Include="..\..\src\sys\driver.c"> <ClCompile Include="..\..\src\sys\driver.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\src\sys\cleanup.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\sys\close.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\sys\create.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\sys\read.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\sys\write.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\sys\devctrl.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\sys\dirctrl.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\sys\fsctrl.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\sys\flush.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\sys\lockctrl.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\sys\fileinfo.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\sys\volinfo.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\sys\ea.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\sys\seinfo.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\sys\shutdown.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\..\src\sys\driver.h"> <ClInclude Include="..\..\src\sys\driver.h">

24
src/sys/cleanup.c Normal file
View File

@ -0,0 +1,24 @@
/**
* @file sys/cleanup.c
*
* @copyright 2015 Bill Zissimopoulos
*/
#include <sys/driver.h>
DRIVER_DISPATCH FspCleanup;
#ifdef ALLOC_PRAGMA
#pragma alloc_text(PAGE, FspCleanup)
#endif
NTSTATUS
FspCleanup(
_In_ PDEVICE_OBJECT DeviceObject,
_In_ PIRP Irp)
{
UNREFERENCED_PARAMETER(DeviceObject);
UNREFERENCED_PARAMETER(Irp);
return STATUS_NOT_IMPLEMENTED;
}

24
src/sys/close.c Normal file
View File

@ -0,0 +1,24 @@
/**
* @file sys/close.c
*
* @copyright 2015 Bill Zissimopoulos
*/
#include <sys/driver.h>
DRIVER_DISPATCH FspClose;
#ifdef ALLOC_PRAGMA
#pragma alloc_text(PAGE, FspClose)
#endif
NTSTATUS
FspClose(
_In_ PDEVICE_OBJECT DeviceObject,
_In_ PIRP Irp)
{
UNREFERENCED_PARAMETER(DeviceObject);
UNREFERENCED_PARAMETER(Irp);
return STATUS_NOT_IMPLEMENTED;
}

24
src/sys/create.c Normal file
View File

@ -0,0 +1,24 @@
/**
* @file sys/create.c
*
* @copyright 2015 Bill Zissimopoulos
*/
#include <sys/driver.h>
DRIVER_DISPATCH FspCreate;
#ifdef ALLOC_PRAGMA
#pragma alloc_text(PAGE, FspCreate)
#endif
NTSTATUS
FspCreate(
_In_ PDEVICE_OBJECT DeviceObject,
_In_ PIRP Irp)
{
UNREFERENCED_PARAMETER(DeviceObject);
UNREFERENCED_PARAMETER(Irp);
return STATUS_NOT_IMPLEMENTED;
}

24
src/sys/devctrl.c Normal file
View File

@ -0,0 +1,24 @@
/**
* @file sys/devctrl.c
*
* @copyright 2015 Bill Zissimopoulos
*/
#include <sys/driver.h>
DRIVER_DISPATCH FspDeviceControl;
#ifdef ALLOC_PRAGMA
#pragma alloc_text(PAGE, FspDeviceControl)
#endif
NTSTATUS
FspDeviceControl(
_In_ PDEVICE_OBJECT DeviceObject,
_In_ PIRP Irp)
{
UNREFERENCED_PARAMETER(DeviceObject);
UNREFERENCED_PARAMETER(Irp);
return STATUS_NOT_IMPLEMENTED;
}

24
src/sys/dirctrl.c Normal file
View File

@ -0,0 +1,24 @@
/**
* @file sys/dirctrl.c
*
* @copyright 2015 Bill Zissimopoulos
*/
#include <sys/driver.h>
DRIVER_DISPATCH FspDirectoryControl;
#ifdef ALLOC_PRAGMA
#pragma alloc_text(PAGE, FspDirectoryControl)
#endif
NTSTATUS
FspDirectoryControl(
_In_ PDEVICE_OBJECT DeviceObject,
_In_ PIRP Irp)
{
UNREFERENCED_PARAMETER(DeviceObject);
UNREFERENCED_PARAMETER(Irp);
return STATUS_NOT_IMPLEMENTED;
}

View File

@ -6,10 +6,14 @@
#include <sys/driver.h> #include <sys/driver.h>
PDEVICE_OBJECT FspDeviceObject;
DRIVER_INITIALIZE DriverEntry; DRIVER_INITIALIZE DriverEntry;
DRIVER_UNLOAD FspUnload;
#ifdef ALLOC_PRAGMA #ifdef ALLOC_PRAGMA
#pragma alloc_text(INIT, DriverEntry) #pragma alloc_text(INIT, DriverEntry)
#pragma alloc_text(PAGE, FspUnload)
#endif #endif
NTSTATUS NTSTATUS
@ -17,8 +21,55 @@ DriverEntry(
_In_ PDRIVER_OBJECT DriverObject, _In_ PDRIVER_OBJECT DriverObject,
_In_ PUNICODE_STRING RegistryPath) _In_ PUNICODE_STRING RegistryPath)
{ {
UNREFERENCED_PARAMETER(DriverObject);
UNREFERENCED_PARAMETER(RegistryPath); UNREFERENCED_PARAMETER(RegistryPath);
DEBUGLOG("");
return STATUS_NOT_IMPLEMENTED; NTSTATUS Status;
UNICODE_STRING DeviceName;
/* create the file system device object */
RtlInitUnicodeString(&DeviceName, L"" DRIVER_NAME);
Status = IoCreateDevice(DriverObject, 0, &DeviceName, FILE_DEVICE_FILE_SYSTEM, 0, FALSE,
&FspDeviceObject);
if (!NT_SUCCESS(Status))
return Status;
/* setup the driver object */
DriverObject->DriverUnload = FspUnload;
DriverObject->MajorFunction[IRP_MJ_CREATE] = FspCreate;
DriverObject->MajorFunction[IRP_MJ_CREATE_NAMED_PIPE] = 0;
DriverObject->MajorFunction[IRP_MJ_CLOSE] = FspClose;
DriverObject->MajorFunction[IRP_MJ_READ] = FspRead;
DriverObject->MajorFunction[IRP_MJ_WRITE] = FspWrite;
DriverObject->MajorFunction[IRP_MJ_QUERY_INFORMATION] = FspQueryInformation;
DriverObject->MajorFunction[IRP_MJ_SET_INFORMATION] = FspSetInformation;
DriverObject->MajorFunction[IRP_MJ_QUERY_EA] = FspQueryEa;
DriverObject->MajorFunction[IRP_MJ_SET_EA] = FspSetEa;
DriverObject->MajorFunction[IRP_MJ_FLUSH_BUFFERS] = FspFlushBuffers;
DriverObject->MajorFunction[IRP_MJ_QUERY_VOLUME_INFORMATION] = FspQueryVolumeInformation;
DriverObject->MajorFunction[IRP_MJ_SET_VOLUME_INFORMATION] = FspSetVolumeInformation;
DriverObject->MajorFunction[IRP_MJ_DIRECTORY_CONTROL] = FspDirectoryControl;
DriverObject->MajorFunction[IRP_MJ_FILE_SYSTEM_CONTROL] = FspFileSystemControl;
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = FspDeviceControl;
DriverObject->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = 0;
DriverObject->MajorFunction[IRP_MJ_SHUTDOWN] = FspShutdown;
DriverObject->MajorFunction[IRP_MJ_LOCK_CONTROL] = FspLockControl;
DriverObject->MajorFunction[IRP_MJ_CLEANUP] = FspCleanup;
DriverObject->MajorFunction[IRP_MJ_CREATE_MAILSLOT] = 0;
DriverObject->MajorFunction[IRP_MJ_QUERY_SECURITY] = FspQuerySecurity;
DriverObject->MajorFunction[IRP_MJ_SET_SECURITY] = FspSetSecurity;
DriverObject->MajorFunction[IRP_MJ_POWER] = 0;
DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = 0;
DriverObject->MajorFunction[IRP_MJ_DEVICE_CHANGE] = 0;
DriverObject->MajorFunction[IRP_MJ_QUERY_QUOTA] = 0;
DriverObject->MajorFunction[IRP_MJ_SET_QUOTA] = 0;
DriverObject->MajorFunction[IRP_MJ_PNP] = 0;
return STATUS_SUCCESS;
}
VOID
FspUnload(
_In_ PDRIVER_OBJECT DriverObject)
{
UNREFERENCED_PARAMETER(DriverObject);
} }

View File

@ -9,10 +9,34 @@
#include <wdm.h> #include <wdm.h>
#define DRIVER_NAME "winfsp"
#if DBG #if DBG
#define DEBUGLOG(fmt, ...) DbgPrint(__FUNCTION__ ": " fmt "\n", __VA_ARGS__) #define DEBUGLOG(fmt, ...) \
DbgPrint(DRIVER_NAME ": " __FUNCTION__ ": " fmt "\n", __VA_ARGS__)
#else #else
#define DEBUGLOG(fmt, ...) ((void)0) #define DEBUGLOG(fmt, ...) ((void)0)
#endif #endif
/* driver major functions */
DRIVER_DISPATCH FspCleanup;
DRIVER_DISPATCH FspClose;
DRIVER_DISPATCH FspCreate;
DRIVER_DISPATCH FspDeviceControl;
DRIVER_DISPATCH FspDirectoryControl;
DRIVER_DISPATCH FspFileSystemControl;
DRIVER_DISPATCH FspFlushBuffers;
DRIVER_DISPATCH FspLockControl;
DRIVER_DISPATCH FspQueryEa;
DRIVER_DISPATCH FspQueryInformation;
DRIVER_DISPATCH FspQuerySecurity;
DRIVER_DISPATCH FspQueryVolumeInformation;
DRIVER_DISPATCH FspRead;
DRIVER_DISPATCH FspSetEa;
DRIVER_DISPATCH FspSetInformation;
DRIVER_DISPATCH FspSetSecurity;
DRIVER_DISPATCH FspSetVolumeInformation;
DRIVER_DISPATCH FspShutdown;
DRIVER_DISPATCH FspWrite;
#endif #endif

37
src/sys/ea.c Normal file
View File

@ -0,0 +1,37 @@
/**
* @file sys/ea.c
*
* @copyright 2015 Bill Zissimopoulos
*/
#include <sys/driver.h>
DRIVER_DISPATCH FspQueryEa;
DRIVER_DISPATCH FspSetEa;
#ifdef ALLOC_PRAGMA
#pragma alloc_text(PAGE, FspQueryEa)
#pragma alloc_text(PAGE, FspSetEa)
#endif
NTSTATUS
FspQueryEa(
_In_ PDEVICE_OBJECT DeviceObject,
_In_ PIRP Irp)
{
UNREFERENCED_PARAMETER(DeviceObject);
UNREFERENCED_PARAMETER(Irp);
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
FspSetEa(
_In_ PDEVICE_OBJECT DeviceObject,
_In_ PIRP Irp)
{
UNREFERENCED_PARAMETER(DeviceObject);
UNREFERENCED_PARAMETER(Irp);
return STATUS_NOT_IMPLEMENTED;
}

37
src/sys/fileinfo.c Normal file
View File

@ -0,0 +1,37 @@
/**
* @file sys/fileinfo.c
*
* @copyright 2015 Bill Zissimopoulos
*/
#include <sys/driver.h>
DRIVER_DISPATCH FspQueryInformation;
DRIVER_DISPATCH FspSetInformation;
#ifdef ALLOC_PRAGMA
#pragma alloc_text(PAGE, FspQueryInformation)
#pragma alloc_text(PAGE, FspSetInformation)
#endif
NTSTATUS
FspQueryInformation(
_In_ PDEVICE_OBJECT DeviceObject,
_In_ PIRP Irp)
{
UNREFERENCED_PARAMETER(DeviceObject);
UNREFERENCED_PARAMETER(Irp);
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
FspSetInformation(
_In_ PDEVICE_OBJECT DeviceObject,
_In_ PIRP Irp)
{
UNREFERENCED_PARAMETER(DeviceObject);
UNREFERENCED_PARAMETER(Irp);
return STATUS_NOT_IMPLEMENTED;
}

24
src/sys/flush.c Normal file
View File

@ -0,0 +1,24 @@
/**
* @file sys/flush.c
*
* @copyright 2015 Bill Zissimopoulos
*/
#include <sys/driver.h>
DRIVER_DISPATCH FspFlushBuffers;
#ifdef ALLOC_PRAGMA
#pragma alloc_text(PAGE, FspFlushBuffers)
#endif
NTSTATUS
FspFlushBuffers(
_In_ PDEVICE_OBJECT DeviceObject,
_In_ PIRP Irp)
{
UNREFERENCED_PARAMETER(DeviceObject);
UNREFERENCED_PARAMETER(Irp);
return STATUS_NOT_IMPLEMENTED;
}

24
src/sys/fsctrl.c Normal file
View File

@ -0,0 +1,24 @@
/**
* @file sys/fsctrl.c
*
* @copyright 2015 Bill Zissimopoulos
*/
#include <sys/driver.h>
DRIVER_DISPATCH FspFileSystemControl;
#ifdef ALLOC_PRAGMA
#pragma alloc_text(PAGE, FspFileSystemControl)
#endif
NTSTATUS
FspFileSystemControl(
_In_ PDEVICE_OBJECT DeviceObject,
_In_ PIRP Irp)
{
UNREFERENCED_PARAMETER(DeviceObject);
UNREFERENCED_PARAMETER(Irp);
return STATUS_NOT_IMPLEMENTED;
}

24
src/sys/lockctrl.c Normal file
View File

@ -0,0 +1,24 @@
/**
* @file sys/lockctrl.c
*
* @copyright 2015 Bill Zissimopoulos
*/
#include <sys/driver.h>
DRIVER_DISPATCH FspLockControl;
#ifdef ALLOC_PRAGMA
#pragma alloc_text(PAGE, FspLockControl)
#endif
NTSTATUS
FspLockControl(
_In_ PDEVICE_OBJECT DeviceObject,
_In_ PIRP Irp)
{
UNREFERENCED_PARAMETER(DeviceObject);
UNREFERENCED_PARAMETER(Irp);
return STATUS_NOT_IMPLEMENTED;
}

24
src/sys/read.c Normal file
View File

@ -0,0 +1,24 @@
/**
* @file sys/read.c
*
* @copyright 2015 Bill Zissimopoulos
*/
#include <sys/driver.h>
DRIVER_DISPATCH FspRead;
#ifdef ALLOC_PRAGMA
#pragma alloc_text(PAGE, FspRead)
#endif
NTSTATUS
FspRead(
_In_ PDEVICE_OBJECT DeviceObject,
_In_ PIRP Irp)
{
UNREFERENCED_PARAMETER(DeviceObject);
UNREFERENCED_PARAMETER(Irp);
return STATUS_NOT_IMPLEMENTED;
}

37
src/sys/seinfo.c Normal file
View File

@ -0,0 +1,37 @@
/**
* @file sys/seinfo.c
*
* @copyright 2015 Bill Zissimopoulos
*/
#include <sys/driver.h>
DRIVER_DISPATCH FspQuerySecurity;
DRIVER_DISPATCH FspSetSecurity;
#ifdef ALLOC_PRAGMA
#pragma alloc_text(PAGE, FspQuerySecurity)
#pragma alloc_text(PAGE, FspSetSecurity)
#endif
NTSTATUS
FspQuerySecurity(
_In_ PDEVICE_OBJECT DeviceObject,
_In_ PIRP Irp)
{
UNREFERENCED_PARAMETER(DeviceObject);
UNREFERENCED_PARAMETER(Irp);
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
FspSetSecurity(
_In_ PDEVICE_OBJECT DeviceObject,
_In_ PIRP Irp)
{
UNREFERENCED_PARAMETER(DeviceObject);
UNREFERENCED_PARAMETER(Irp);
return STATUS_NOT_IMPLEMENTED;
}

24
src/sys/shutdown.c Normal file
View File

@ -0,0 +1,24 @@
/**
* @file sys/shutdown.c
*
* @copyright 2015 Bill Zissimopoulos
*/
#include <sys/driver.h>
DRIVER_DISPATCH FspShutdown;
#ifdef ALLOC_PRAGMA
#pragma alloc_text(PAGE, FspShutdown)
#endif
NTSTATUS
FspShutdown(
_In_ PDEVICE_OBJECT DeviceObject,
_In_ PIRP Irp)
{
UNREFERENCED_PARAMETER(DeviceObject);
UNREFERENCED_PARAMETER(Irp);
return STATUS_NOT_IMPLEMENTED;
}

37
src/sys/volinfo.c Normal file
View File

@ -0,0 +1,37 @@
/**
* @file sys/volinfo.c
*
* @copyright 2015 Bill Zissimopoulos
*/
#include <sys/driver.h>
DRIVER_DISPATCH FspQueryVolumeInformation;
DRIVER_DISPATCH FspSetVolumeInformation;
#ifdef ALLOC_PRAGMA
#pragma alloc_text(PAGE, FspQueryVolumeInformation)
#pragma alloc_text(PAGE, FspSetVolumeInformation)
#endif
NTSTATUS
FspQueryVolumeInformation(
_In_ PDEVICE_OBJECT DeviceObject,
_In_ PIRP Irp)
{
UNREFERENCED_PARAMETER(DeviceObject);
UNREFERENCED_PARAMETER(Irp);
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
FspSetVolumeInformation(
_In_ PDEVICE_OBJECT DeviceObject,
_In_ PIRP Irp)
{
UNREFERENCED_PARAMETER(DeviceObject);
UNREFERENCED_PARAMETER(Irp);
return STATUS_NOT_IMPLEMENTED;
}

24
src/sys/write.c Normal file
View File

@ -0,0 +1,24 @@
/**
* @file sys/write.c
*
* @copyright 2015 Bill Zissimopoulos
*/
#include <sys/driver.h>
DRIVER_DISPATCH FspWrite;
#ifdef ALLOC_PRAGMA
#pragma alloc_text(PAGE, FspWrite)
#endif
NTSTATUS
FspWrite(
_In_ PDEVICE_OBJECT DeviceObject,
_In_ PIRP Irp)
{
UNREFERENCED_PARAMETER(DeviceObject);
UNREFERENCED_PARAMETER(Irp);
return STATUS_NOT_IMPLEMENTED;
}