mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-22 08:23:05 -05:00
dll: fsctl.c, ntstatus.c
This commit is contained in:
parent
ceb46a8c55
commit
1ad43de1a1
@ -164,6 +164,7 @@
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\src\dll\fsctl.c" />
|
||||
<ClCompile Include="..\..\src\dll\ntstatus.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\inc\winfsp\fsctl.h" />
|
||||
|
@ -17,6 +17,9 @@
|
||||
<ClCompile Include="..\..\src\dll\fsctl.c">
|
||||
<Filter>Source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\dll\ntstatus.c">
|
||||
<Filter>Source</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\inc\winfsp\fsctl.h">
|
||||
|
@ -29,7 +29,7 @@ extern const __declspec(selectany) GUID FspFsvrtDeviceClassGuid =
|
||||
#define FSP_FSCTL_TRANSACT \
|
||||
CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 0x800 + 'T', METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
|
||||
#define FSP_FSCTL_CREATE_BUFFER_SIZE 64
|
||||
#define FSP_FSCTL_CREATE_BUFFER_SIZE 128
|
||||
#define FSP_FSCTL_TRANSACT_BUFFER_SIZE 4096
|
||||
#define FSP_FSCTL_TRANSACT_REQ_SIZEMAX 1536
|
||||
|
||||
@ -60,8 +60,10 @@ typedef struct
|
||||
#pragma warning(pop)
|
||||
|
||||
#if !defined(WINFSP_SYS_DRIVER_H_INTERNAL)
|
||||
NTSTATUS FspFsctlCreateVolume(PSECURITY_DESCRIPTOR SecurityDescriptor, PHANDLE *PHandle);
|
||||
NTSTATUS FspFsctlOpenVolume(PWSTR VolumeName);
|
||||
NTSTATUS FspFsctlCreateVolume(PWSTR DevicePath, PSECURITY_DESCRIPTOR SecurityDescriptor,
|
||||
PHANDLE *PHandle);
|
||||
NTSTATUS FspFsctlOpenVolume(PWSTR VolumePath,
|
||||
PHANDLE *PHandle);
|
||||
NTSTATUS FspFsctlDeleteVolume(HANDLE Handle);
|
||||
NTSTATUS FspFsctlTransact(HANDLE Handle,
|
||||
const FSP_TRANSACT_RSP *Responses, size_t NumResponses,
|
||||
|
@ -13,4 +13,6 @@
|
||||
#include <winternl.h>
|
||||
#include <ntstatus.h>
|
||||
|
||||
NTSTATUS FspNtStatusFromWin32(DWORD Error);
|
||||
|
||||
#endif
|
||||
|
@ -6,3 +6,99 @@
|
||||
|
||||
#include <winfsp/winfsp.h>
|
||||
#include <winfsp/fsctl.h>
|
||||
#include <strsafe.h>
|
||||
|
||||
#define GLOBALROOT L"\\\\?\\GLOBALROOT"
|
||||
|
||||
NTSTATUS FspFsctlCreateVolume(PWSTR DevicePath, PSECURITY_DESCRIPTOR SecurityDescriptor,
|
||||
PHANDLE *PHandle)
|
||||
{
|
||||
NTSTATUS Result = STATUS_SUCCESS;
|
||||
WCHAR DevicePathBuf[(sizeof GLOBALROOT + FSP_FSCTL_CREATE_BUFFER_SIZE) / sizeof(WCHAR)];
|
||||
WCHAR VolumePathBuf[FSP_FSCTL_CREATE_BUFFER_SIZE / sizeof(WCHAR)];
|
||||
PSECURITY_DESCRIPTOR SecurityDescriptorBuf = 0;
|
||||
DWORD SecurityDescriptorLen, Bytes;
|
||||
HANDLE DeviceHandle = INVALID_HANDLE_VALUE;
|
||||
|
||||
*PHandle = 0;
|
||||
|
||||
DevicePathBuf[0] = L'\0';
|
||||
StringCbPrintf(DevicePathBuf, sizeof DevicePathBuf, GLOBALROOT "%S", DevicePath);
|
||||
|
||||
if (!MakeSelfRelativeSD(SecurityDescriptor, 0, &SecurityDescriptorLen))
|
||||
{
|
||||
SecurityDescriptorBuf = malloc(SecurityDescriptorLen);
|
||||
if (0 == SecurityDescriptorBuf)
|
||||
{
|
||||
Result = STATUS_INSUFFICIENT_RESOURCES;
|
||||
goto exit;
|
||||
}
|
||||
if (!MakeSelfRelativeSD(SecurityDescriptor, SecurityDescriptorBuf, &SecurityDescriptorLen))
|
||||
{
|
||||
Result = FspNtStatusFromWin32(GetLastError());
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
|
||||
DeviceHandle = CreateFileW(DevicePathBuf,
|
||||
0, FILE_SHARE_WRITE | FILE_SHARE_WRITE | FILE_SHARE_DELETE, 0, OPEN_EXISTING, 0, 0);
|
||||
if (INVALID_HANDLE_VALUE == DeviceHandle)
|
||||
{
|
||||
Result = FspNtStatusFromWin32(GetLastError());
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (!DeviceIoControl(DeviceHandle, FSP_FSCTL_CREATE,
|
||||
SecurityDescriptorBuf, SecurityDescriptorLen, VolumePathBuf, sizeof VolumePathBuf,
|
||||
&Bytes, 0))
|
||||
{
|
||||
Result = FspNtStatusFromWin32(GetLastError());
|
||||
goto exit;
|
||||
}
|
||||
|
||||
Result = FspFsctlOpenVolume(VolumePathBuf, PHandle);
|
||||
|
||||
exit:
|
||||
if (INVALID_HANDLE_VALUE != DeviceHandle)
|
||||
CloseHandle(DeviceHandle);
|
||||
free(SecurityDescriptorBuf);
|
||||
return Result;
|
||||
}
|
||||
|
||||
NTSTATUS FspFsctlOpenVolume(PWSTR VolumePath,
|
||||
PHANDLE *PHandle)
|
||||
{
|
||||
NTSTATUS Result = STATUS_SUCCESS;
|
||||
WCHAR DevicePathBuf[(sizeof GLOBALROOT + FSP_FSCTL_CREATE_BUFFER_SIZE) / sizeof(WCHAR)];
|
||||
HANDLE DeviceHandle;
|
||||
|
||||
*PHandle = 0;
|
||||
|
||||
DevicePathBuf[0] = L'\0';
|
||||
StringCbPrintf(DevicePathBuf, sizeof DevicePathBuf, GLOBALROOT "%S", VolumePath);
|
||||
|
||||
DeviceHandle = CreateFileW(DevicePathBuf,
|
||||
0, FILE_SHARE_WRITE | FILE_SHARE_WRITE | FILE_SHARE_DELETE, 0, OPEN_EXISTING, 0, 0);
|
||||
if (INVALID_HANDLE_VALUE == DeviceHandle)
|
||||
{
|
||||
Result = FspNtStatusFromWin32(GetLastError());
|
||||
goto exit;
|
||||
}
|
||||
|
||||
*PHandle = DeviceHandle;
|
||||
|
||||
exit:
|
||||
return Result;
|
||||
}
|
||||
|
||||
NTSTATUS FspFsctlDeleteVolume(HANDLE Handle)
|
||||
{
|
||||
return STATUS_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NTSTATUS FspFsctlTransact(HANDLE Handle,
|
||||
const FSP_TRANSACT_RSP *Responses, size_t NumResponses,
|
||||
const FSP_TRANSACT_REQ *Requests, size_t *NumRequests)
|
||||
{
|
||||
return STATUS_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
12
src/dll/ntstatus.c
Normal file
12
src/dll/ntstatus.c
Normal file
@ -0,0 +1,12 @@
|
||||
/**
|
||||
* @file dll/ntstatus.c
|
||||
*
|
||||
* @copyright 2015 Bill Zissimopoulos
|
||||
*/
|
||||
|
||||
#include <winfsp/winfsp.h>
|
||||
|
||||
NTSTATUS FspNtStatusFromWin32(DWORD Error)
|
||||
{
|
||||
return STATUS_ACCESS_DENIED;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user