1
0
This repository has been archived on 2025-07-27. You can view files and clone it, but cannot push or open issues or pull requests.
Files
siadrive/SiaDrive.Dokan.Api/SiaDokenDrive.cpp
Scott E. Graves b471f48706 Dokan drive
2017-02-10 19:09:22 -06:00

113 lines
2.5 KiB
C++

#include "stdafx.h"
#include "SiaDokenDrive.h"
#include <dokan\dokan.h>
using namespace Sia::Api;
using namespace Sia::Api::Dokan;
class DokanImpl
{
private:
static std::mutex _dokanMutex;
static CSiaApi* _siaApi;
static DOKAN_OPERATIONS _dokanOps;
private:
static NTSTATUS DOKAN_CALLBACK SiaDrive_ZwCreateFile(
LPCWSTR FileName,
PDOKAN_IO_SECURITY_CONTEXT SecurityContext,
ACCESS_MASK DesiredAccess,
ULONG FileAttributes,
ULONG ShareAccess,
ULONG CreateDisposition,
ULONG CreateOptions,
PDOKAN_FILE_INFO DokanFileInfo)
{
}
static NTSTATUS DOKAN_CALLBACK SiaDrive_FindFiles(
LPCWSTR FileName,
PFillFindData FillFindData,
PDOKAN_FILE_INFO DokanFileInfo)
{
}
public:
static void Initialize(CSiaApi* siaApi)
{
_siaApi = siaApi;
_dokanOps.Cleanup = nullptr;
_dokanOps.CloseFile = nullptr;
_dokanOps.DeleteDirectory = nullptr;
_dokanOps.DeleteFileW = nullptr;
_dokanOps.FindFiles = SiaDrive_FindFiles;
_dokanOps.FindFilesWithPattern = nullptr;
_dokanOps.FindStreams = nullptr;
_dokanOps.FlushFileBuffers = nullptr;
_dokanOps.GetDiskFreeSpaceW = nullptr;
_dokanOps.GetFileInformation = nullptr;
_dokanOps.GetFileSecurityW = nullptr;
_dokanOps.GetVolumeInformationW = nullptr;
_dokanOps.LockFile = nullptr;
_dokanOps.Mounted = nullptr;
_dokanOps.MoveFileW = nullptr;
_dokanOps.ReadFile = nullptr;
_dokanOps.SetAllocationSize = nullptr;
_dokanOps.SetEndOfFile = nullptr;
_dokanOps.SetFileAttributesW = nullptr;
_dokanOps.SetFileSecurityW = nullptr;
_dokanOps.SetFileTime = nullptr;
_dokanOps.UnlockFile = nullptr;
_dokanOps.Unmounted = nullptr;
_dokanOps.WriteFile = nullptr;
_dokanOps.ZwCreateFile = SiaDrive_ZwCreateFile;
}
static void Shutdown()
{
_siaApi = nullptr;
ZeroMemory(&_dokanOps, sizeof(_dokanOps));
}
static std::mutex& GetMutex()
{
return _dokanMutex;
}
static bool IsInitialized()
{
return _siaApi != nullptr;
}
};
std::mutex DokanImpl::_dokanMutex;
CSiaApi* DokanImpl::_siaApi = nullptr;
DOKAN_OPERATIONS DokanImpl::_dokanOps = { 0 };
CSiaDokenDrive::CSiaDokenDrive(CSiaApi& siaApi) :
_siaApi(siaApi)
{
std::lock_guard<std::mutex> l(DokanImpl::GetMutex());
if (DokanImpl::IsInitialized())
{
throw SiaDokenDriveException("Sia drive has already been activated");
}
else
{
DokanImpl::Initialize(&_siaApi);
}
}
CSiaDokenDrive::~CSiaDokenDrive()
{
std::lock_guard<std::mutex> l(DokanImpl::GetMutex());
Unmount();
DokanImpl::Shutdown();
}
void CSiaDokenDrive::Mount(const wchar_t& driveLetter)
{
}
void CSiaDokenDrive::Unmount()
{
}