mirror of
				https://github.com/winfsp/winfsp.git
				synced 2025-11-03 20:48:08 -06:00 
			
		
		
		
	dll: FspFsctlCreateVolume: compute default security descriptor
This commit is contained in:
		@@ -23,12 +23,45 @@ FSP_API NTSTATUS FspFsctlCreateVolume(PWSTR DevicePath,
 | 
			
		||||
    NTSTATUS Result = STATUS_SUCCESS;
 | 
			
		||||
    WCHAR DevicePathBuf[MAX_PATH];
 | 
			
		||||
    FSP_FSCTL_VOLUME_PARAMS *ParamsBuf;
 | 
			
		||||
    HANDLE Token;
 | 
			
		||||
    PVOID DaclBuf = 0;
 | 
			
		||||
    SECURITY_DESCRIPTOR SecurityDescriptorStruct;
 | 
			
		||||
    PSECURITY_DESCRIPTOR SecurityDescriptorBuf = 0;
 | 
			
		||||
    DWORD SecurityDescriptorSize, Bytes;
 | 
			
		||||
    HANDLE DeviceHandle = INVALID_HANDLE_VALUE;
 | 
			
		||||
 | 
			
		||||
    VolumePathBuf[0] = L'\0';
 | 
			
		||||
 | 
			
		||||
    if (0 == SecurityDescriptor)
 | 
			
		||||
    {
 | 
			
		||||
        if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &Token))
 | 
			
		||||
        {
 | 
			
		||||
            Result = FspNtStatusFromWin32(GetLastError());
 | 
			
		||||
            goto exit;
 | 
			
		||||
        }
 | 
			
		||||
        GetTokenInformation(Token, TokenDefaultDacl, 0, 0, &Bytes);
 | 
			
		||||
        DaclBuf = malloc(Bytes);
 | 
			
		||||
        if (0 == DaclBuf)
 | 
			
		||||
        {
 | 
			
		||||
            CloseHandle(Token);
 | 
			
		||||
            Result = STATUS_INSUFFICIENT_RESOURCES;
 | 
			
		||||
            goto exit;
 | 
			
		||||
        }
 | 
			
		||||
        if (GetTokenInformation(Token, TokenDefaultDacl, DaclBuf, Bytes, &Bytes) &&
 | 
			
		||||
            InitializeSecurityDescriptor(&SecurityDescriptorStruct, SECURITY_DESCRIPTOR_REVISION) &&
 | 
			
		||||
            SetSecurityDescriptorDacl(&SecurityDescriptorStruct, TRUE, DaclBuf, FALSE))
 | 
			
		||||
        {
 | 
			
		||||
            SecurityDescriptor = &SecurityDescriptorStruct;
 | 
			
		||||
            CloseHandle(Token);
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            Result = FspNtStatusFromWin32(GetLastError());
 | 
			
		||||
            CloseHandle(Token);
 | 
			
		||||
            goto exit;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    SecurityDescriptorSize = GetSecurityDescriptorLength(SecurityDescriptor);
 | 
			
		||||
    ParamsBuf = malloc(sizeof *ParamsBuf + SecurityDescriptorSize);
 | 
			
		||||
    if (0 == ParamsBuf)
 | 
			
		||||
@@ -65,6 +98,7 @@ exit:
 | 
			
		||||
    if (INVALID_HANDLE_VALUE != DeviceHandle)
 | 
			
		||||
        CloseHandle(DeviceHandle);
 | 
			
		||||
    free(SecurityDescriptorBuf);
 | 
			
		||||
    free(DaclBuf);
 | 
			
		||||
    return Result;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,8 +1,20 @@
 | 
			
		||||
#include <winfsp/winfsp.h>
 | 
			
		||||
#include <winfsp/fsctl.h>
 | 
			
		||||
#include <tlib/testsuite.h>
 | 
			
		||||
 | 
			
		||||
void mount_dotest(PWSTR DeviceName)
 | 
			
		||||
{
 | 
			
		||||
    NTSTATUS Result;
 | 
			
		||||
    FSP_FSCTL_VOLUME_PARAMS Params;
 | 
			
		||||
 | 
			
		||||
    Params.SectorSize = 65536;
 | 
			
		||||
    //Result = FspFsctlCreateVolume(DeviceName, &Params, );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void mount_test(void)
 | 
			
		||||
{
 | 
			
		||||
    mount_dotest("WinFsp.Disk");
 | 
			
		||||
    mount_dotest("WinFsp.Net");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void mount_tests(void)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user