From 01453d0006a1ebbdc1797b464a0c6171326748f5 Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Fri, 10 Feb 2017 17:16:09 -0600 Subject: [PATCH] More Dokan changes --- SiaDrive.Dokan.Api/SiaDokenDrive.cpp | 25 +++++++++++++++++++++++-- SiaDrive.Dokan.Api/SiaDokenDrive.h | 20 +++++++++++++++++--- SiaDrive.Dokan.Api/stdafx.h | 1 - 3 files changed, 40 insertions(+), 6 deletions(-) diff --git a/SiaDrive.Dokan.Api/SiaDokenDrive.cpp b/SiaDrive.Dokan.Api/SiaDokenDrive.cpp index 5fbe0b7..3e0b18e 100644 --- a/SiaDrive.Dokan.Api/SiaDokenDrive.cpp +++ b/SiaDrive.Dokan.Api/SiaDokenDrive.cpp @@ -6,7 +6,13 @@ using namespace Sia::Api; using namespace Sia::Api::Dokan; -static NTSTATUS DOKAN_CALLBACK _ZwCreateFile( + +static bool s_dokenInitialized = false; +static CSiaDokenDrive* s_dokenDrive = nullptr; +static DOKAN_OPERATIONS s_dokanOps = {0}; + + +static NTSTATUS DOKAN_CALLBACK SiaDrive_ZwCreateFile( LPCWSTR FileName, PDOKAN_IO_SECURITY_CONTEXT SecurityContext, ACCESS_MASK DesiredAccess, @@ -18,16 +24,31 @@ static NTSTATUS DOKAN_CALLBACK _ZwCreateFile( { } + CSiaDokenDrive::CSiaDokenDrive(CSiaApi& siaApi) : _siaApi(siaApi) { + if (s_dokenDrive) + { + throw SiaDokenDriveException("Sia drive has already been activated"); + } + else + { + s_dokenDrive = this; + s_dokanOps.ZwCreateFile = SiaDrive_ZwCreateFile; + } } CSiaDokenDrive::~CSiaDokenDrive() { + Unmount(); + s_dokenDrive = nullptr; } -void CSiaDokenDrive::InitializeOperations() +void CSiaDokenDrive::Mount(const wchar_t& driveLetter) { +} +void CSiaDokenDrive::Unmount() +{ } \ No newline at end of file diff --git a/SiaDrive.Dokan.Api/SiaDokenDrive.h b/SiaDrive.Dokan.Api/SiaDokenDrive.h index fba0ec0..8f7cd4b 100644 --- a/SiaDrive.Dokan.Api/SiaDokenDrive.h +++ b/SiaDrive.Dokan.Api/SiaDokenDrive.h @@ -5,10 +5,22 @@ NS_BEGIN(Sia) NS_BEGIN(Api) NS_BEGIN(Dokan) +class SiaDokenDriveException : + std::exception +{ +public: + SiaDokenDriveException(char* message) : + std::exception(message) + { + + } +}; + class AFX_EXT_CLASS CSiaDokenDrive { public: - CSiaDokenDrive(CSiaApi& siaApi); + // throws SiaDokenDriveException + CSiaDokenDrive(CSiaApi& siaApi); public: ~CSiaDokenDrive(); @@ -16,8 +28,10 @@ public: private: CSiaApi& _siaApi; -private: - void InitializeOperations(); +public: + void Mount(const wchar_t& driveLetter); + + void Unmount( ); }; NS_END(3) \ No newline at end of file diff --git a/SiaDrive.Dokan.Api/stdafx.h b/SiaDrive.Dokan.Api/stdafx.h index 9277429..5550070 100644 --- a/SiaDrive.Dokan.Api/stdafx.h +++ b/SiaDrive.Dokan.Api/stdafx.h @@ -7,7 +7,6 @@ #ifndef VC_EXTRALEAN #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers #endif - #include "targetver.h" #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit