dokan

package
v0.1.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 14, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DOKAN_OPTION_DEBUG              = 1
	DOKAN_OPTION_STDERR             = 2
	DOKAN_OPTION_ALT_STREAM         = 4
	DOKAN_OPTION_WRITE_PROTECT      = 8
	DOKAN_OPTION_NETWORK            = 16
	DOKAN_OPTION_REMOVABLE          = 32
	DOKAN_OPTION_MOUNT_MANAGER      = 64
	DOKAN_OPTION_CURRENT_SESSION    = 128
	DOKAN_OPTION_FILELOCK_USER_MODE = 256
)

DokanOptions

View Source
const (
	STATUS_SUCCESS               = NTStatus(0)
	STATUS_INVALID_PARAMETER     = NTStatus(0xC000000D)
	STATUS_END_OF_FILE           = NTStatus(0xC0000011)
	STATUS_ACCESS_DENIED         = NTStatus(0xC0000022)
	STATUS_OBJECT_NAME_NOT_FOUND = NTStatus(0xC0000034)
	STATUS_OBJECT_NAME_COLLISION = NTStatus(0xC0000035)
	STATUS_OBJECT_PATH_NOT_FOUND = NTStatus(0xC000003A)
	STATUS_FILE_IS_A_DIRECTORY   = NTStatus(0xC00000BA)
	STATUS_NOT_SAME_DEVICE       = NTStatus(0xC00000D4)
	STATUS_NOT_SUPPORTED         = NTStatus(0xC00000BB)
	STATUS_DIRECTORY_NOT_EMPTY   = NTStatus(0xC0000101)
	STATUS_NOT_A_DIRECTORY       = NTStatus(0xC0000103)
)

NTSTATUS

View Source
const (
	FILE_ATTRIBUTE_READONLY  = 1
	FILE_ATTRIBUTE_HIDDEN    = 2
	FILE_ATTRIBUTE_SYSTEM    = 4
	FILE_ATTRIBUTE_DIRECTORY = 16
	FILE_ATTRIBUTE_ARCHIVE   = 32
	FILE_ATTRIBUTE_NORMAL    = 128
)

File attribute

View Source
const (
	// options
	FILE_DIRECTORY_FILE     = 0x01
	FILE_WRITE_THROUGH      = 0x02
	FILE_SEQUENTIAL_ONLY    = 0x04
	FILE_NON_DIRECTORY_FILE = 0x40
	FILE_DELETE_ON_CLOSE    = 0x000010

	// disposition
	FILE_SUPERSEDE    = 0
	FILE_OPEN         = 1
	FILE_CREATE       = 2
	FILE_OPEN_IF      = 3
	FILE_OVERWRITE    = 4
	FILE_OVERWRITE_IF = 5

	// access
	FILE_READ_DATA        = 1
	FILE_WRITE_DATA       = 2
	FILE_APPEND_DATA      = 4
	FILE_READ_EA          = 8
	FILE_WRITE_EA         = 0x10
	FILE_EXECUTE          = 0x20
	FILE_DELETE_CHILD     = 0x40
	FILE_READ_ATTRIBUTES  = 0x80
	FILE_WRITE_ATTRIBUTES = 0x100
)

ZwCreateFile options https://docs.microsoft.com/en-us/windows/win32/api/winternl/nf-winternl-ntcreatefile

View Source
const DOKAN_MINIMUM_COMPATIBLE_VERSION = 200
View Source
const MAX_PATH = 260
View Source
const UnixTimeOffset = 116444736000000000

UnixTime epoch from 16001-01-01 (UTC) in 0.1us.

View Source
const VOLUME_SECURITY_DESCRIPTOR_MAX_SIZE = (1024 * 16)

Variables

View Source
var ErrBadDriveLetter = errors.New("Bad drive letter")
View Source
var ErrBadMountPoint = errors.New("Mount point is invalid")
View Source
var ErrDokan = errors.New("Failed to mount")
View Source
var ErrDokanVersion = errors.New("Version error")
View Source
var ErrDriverInstall = errors.New("Dokan install error")
View Source
var ErrFailedToLoadDokan = errors.New("Failed to load dokan2.dll")
View Source
var ErrMount = errors.New("Dokan mount failed")
View Source
var ErrStart = errors.New("Dokan start error")

Functions

func DriverVersion

func DriverVersion() (uint32, error)

api

func Init

func Init() error

func NotifyCreate

func NotifyCreate(instance MountHandle, filePath string, isDirectory bool) error

notify

func NotifyDelete

func NotifyDelete(instance MountHandle, filePath string, isDirectory bool) error

func NotifyRename

func NotifyRename(instance MountHandle, oldPath, newPath string, isDirectory bool) error

func NotifyUpdate

func NotifyUpdate(instance MountHandle, filePath string) error

func NotifyXAttrUpdate

func NotifyXAttrUpdate(instance MountHandle, filePath string) error

func Shutdown

func Shutdown() error

func UTF16FromString added in v0.1.4

func UTF16FromString(s string) ([]uint16, error)

func UTF16PtrFromString added in v0.1.4

func UTF16PtrFromString(s string) (*uint16, error)

func Version

func Version() (uint32, error)

Types

type ByHandleFileInfo

type ByHandleFileInfo struct {
	FileAttributes     int32
	CreationTime       FileTime
	LastAccessTime     FileTime
	LastWriteTime      FileTime
	VolumeSerialNumber int32
	FileSizeHigh       uint32
	FileSizeLow        uint32
	NumberOfLinks      int32
	FileIndexHigh      int32
	FileIndexLow       int32
}

type Disk added in v0.1.2

type Disk interface {
	GetVolumeInformation(finfo *FileInfo) (VolumeInformation, NTStatus)
	GetDiskFreeSpace(availableBytes *uint64, totalBytes *uint64, freeBytes *uint64, finfo *FileInfo) NTStatus
	CreateFile(name string, secCtx uintptr, access, attrs, share, disposition, options uint32, finfo *FileInfo) (FileHandle, NTStatus)
}

type DokanOperations

type DokanOperations struct {
	ZwCreateFile         uintptr
	Cleanup              uintptr
	CloseFile            uintptr
	ReadFile             uintptr
	WriteFile            uintptr
	FlushFileBuffers     uintptr
	GetFileInformation   uintptr
	FindFiles            uintptr
	FindFilesWithPattern uintptr
	SetFileAttributes    uintptr
	SetFileTime          uintptr
	DeleteFile           uintptr
	DeleteDirectory      uintptr
	MoveFile             uintptr
	SetEndOfFile         uintptr
	SetAllocationSize    uintptr

	LockFile   uintptr
	UnlockFile uintptr

	GetDiskFreeSpace     uintptr
	GetVolumeInformation uintptr
	Mounted              uintptr
	Unmounted            uintptr

	GetFileSecurity uintptr
	SetFileSecurity uintptr

	FindStreams uintptr
}

type DokanOptions

type DokanOptions struct {
	Version       uint16
	SingleThread  uint8
	Options       uint32
	GlobalContext unsafe.Pointer

	MountPoint unsafe.Pointer // LPCWSTR
	UNCName    unsafe.Pointer // LPCWSTR

	Timeout                        uint32
	AllocationUnitSize             uint32
	SectorSize                     uint32
	VolumeSecurityDescriptorLength uint32
	VolumeSecurityDescriptor       [VOLUME_SECURITY_DESCRIPTOR_MAX_SIZE]byte
}

type FileHandle added in v0.1.2

type FileHandle interface {
	FindFiles(fillFindDataCallBack func(fi *WIN32_FIND_DATAW) (buffferFull bool, err error), finfo *FileInfo) NTStatus
	GetFileInformation(fi *ByHandleFileInfo, finfo *FileInfo) NTStatus

	ReadFile(buf []byte, read *int32, offset int64, finfo *FileInfo) NTStatus
	WriteFile(buf []byte, written *int32, offset int64, finfo *FileInfo) NTStatus
	SetEndOfFile(offset int64, finfo *FileInfo) NTStatus

	MoveFile(newname string, replaceIfExisting bool, finfo *FileInfo) NTStatus
	DeleteFile(finfo *FileInfo) NTStatus
	DeleteDirectory(finfo *FileInfo) NTStatus
	Cleanup(finfo *FileInfo) NTStatus
	CloseFile(*FileInfo)
}

type FileInfo added in v0.1.2

type FileInfo struct {
	Context           unsafe.Pointer
	DokanContext      uint64
	DokanOptions      *DokanOptions
	ProcessingContext uintptr
	ProcessId         uint32
	IsDirectory       uint8
	DeleteOnClose     uint8
	PagingIo          uint8
	SynchronousIo     uint8
	Nocache           uint8
	WriteToEndOfFile  uint8
}

func (*FileInfo) IsDeleteOnClose added in v0.1.2

func (fi *FileInfo) IsDeleteOnClose() bool

type FileTime

type FileTime [2]uint32 // {LowDateTime, HighDateTime}

func UnixNanoToFileTime added in v0.1.3

func UnixNanoToFileTime(nano int64) FileTime

type MountHandle added in v0.1.2

type MountHandle uintptr

func CreateFileSystem

func CreateFileSystem(options *DokanOptions, operations *DokanOperations) (MountHandle, error)

func (MountHandle) Close added in v0.1.2

func (mh MountHandle) Close() error

type MountInfo added in v0.1.2

type MountInfo struct {
	// contains filtered or unexported fields
}

func MountDisk added in v0.1.2

func MountDisk(mountPoint string, d Disk, optionFlags uint32) (*MountInfo, error)

func (*MountInfo) Close added in v0.1.2

func (mi *MountInfo) Close() error

Close close MountInfo to unmount this filesystem. MountInfo must be closed when it is no longer needed.

func (*MountInfo) Disk added in v0.1.2

func (m *MountInfo) Disk() Disk

func (*MountInfo) NotifyCreate added in v0.1.2

func (m *MountInfo) NotifyCreate(path string, isDir bool) error

NotifyCreate notify file create event.

func (*MountInfo) NotifyDelete added in v0.1.2

func (m *MountInfo) NotifyDelete(path string, isDir bool) error

NotifyDelete notify file delete event.

func (*MountInfo) NotifyRename added in v0.1.2

func (m *MountInfo) NotifyRename(oldPath, newPath string, isDir bool) error

NotifyRename notify file rename event.

func (*MountInfo) NotifyUpdate added in v0.1.2

func (m *MountInfo) NotifyUpdate(path string) error

NotifyUpdate notify attributes update event.

func (*MountInfo) NotifyXAttrUpdate added in v0.1.2

func (m *MountInfo) NotifyXAttrUpdate(path string) error

NotifyXAttrUpdate notify extended attributes update event.

func (*MountInfo) OpenedFileCount added in v0.1.2

func (m *MountInfo) OpenedFileCount() int

OpenedFileCount returns number of files currently open in this filesystem.

type MountPointInfo

type MountPointInfo struct {
	Type         uint32
	MountPoint   string
	UNCName      string
	DeviceName   string
	SessionID    uint32
	MountOptions uint32
}

func MountPoints

func MountPoints() ([]*MountPointInfo, error)

type NTStatus added in v0.1.2

type NTStatus uintptr

func ErrorToNTStatus

func ErrorToNTStatus(err error) NTStatus

ErrorToNTStatus map typical IO errrors to NTStatus

type VolumeInformation added in v0.1.2

type VolumeInformation struct {
	Name                   string
	SerialNumber           uint32
	MaximumComponentLength uint32
	FileSystemFlags        uint32
	FileSystemName         string
}

type WIN32_FIND_DATAW

type WIN32_FIND_DATAW struct {
	FileAttributes    int32
	CreationTime      FileTime
	LastAccessTime    FileTime
	LastWriteTime     FileTime
	FileSizeHigh      uint32
	FileSizeLow       uint32
	Reserved0         int32
	Reserved1         int32
	FileName          [MAX_PATH]uint16
	AlternateFileName [14]uint16
	FileType          int32
	CreatorType       int32
	FinderFlags       int16
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL