private static void Notify(bool created, string sourceVolumeName, string targetVolumeName) { using (MemoryAlloc data = new MemoryAlloc( MountMgrVolumeMountPoint.SizeOf + sourceVolumeName.Length * 2 + targetVolumeName.Length * 2 )) { MountMgrVolumeMountPoint mountPoint = new MountMgrVolumeMountPoint { SourceVolumeNameLength = (ushort)(sourceVolumeName.Length * 2), SourceVolumeNameOffset = (ushort)MountMgrVolumeMountPoint.SizeOf, TargetVolumeNameLength = (ushort)(targetVolumeName.Length * 2) }; mountPoint.TargetVolumeNameOffset = (ushort)(mountPoint.SourceVolumeNameOffset + mountPoint.SourceVolumeNameLength); data.WriteStruct(mountPoint); data.WriteUnicodeString(mountPoint.SourceVolumeNameOffset, sourceVolumeName); data.WriteUnicodeString(mountPoint.TargetVolumeNameOffset, targetVolumeName); using (FileHandle fhandle = OpenMountManager(FileAccess.GenericRead | FileAccess.GenericWrite)) { fhandle.IoControl( created ? IoCtlVolumeMountPointCreated : IoCtlVolumeMountPointDeleted, data.Memory, data.Size, IntPtr.Zero, 0 ); } } }
public static unsafe StorageHotplugInfo GetHotplugInfo(FileHandle fileHandle) { StorageHotplugInfo hotplugInfo; fileHandle.IoControl(IoCtlGetHotplugInfo, null, 0, &hotplugInfo, StorageHotplugInfo.SizeOf); return(hotplugInfo); }
public static unsafe StorageHotplugInfo GetHotplugInfo(FileHandle fileHandle) { StorageHotplugInfo hotplugInfo; fileHandle.IoControl(IoCtlGetHotplugInfo, null, 0, &hotplugInfo, StorageHotplugInfo.SizeOf); return hotplugInfo; }
public static StorageHotplugInfo GetHotplugInfo(FileHandle fileHandle) { unsafe { StorageHotplugInfo hotplugInfo; fileHandle.IoControl(IoCtlGetHotplugInfo, null, 0, &hotplugInfo, Marshal.SizeOf(typeof(StorageHotplugInfo))); return(hotplugInfo); } }
public static StorageHotplugInfo GetHotplugInfo(FileHandle fileHandle) { unsafe { StorageHotplugInfo hotplugInfo; fileHandle.IoControl(IoCtlGetHotplugInfo, null, 0, &hotplugInfo, Marshal.SizeOf(typeof(StorageHotplugInfo))); return hotplugInfo; } }
public static string GetDeviceName(FileHandle fhandle) { using (MemoryAlloc data = new MemoryAlloc(600)) { fhandle.IoControl(IoCtlQueryDeviceName, IntPtr.Zero, 0, data, data.Size); MountDevName name = data.ReadStruct <MountDevName>(); return(data.ReadUnicodeString(MountDevName.NameOffset, name.NameLength / 2)); } }
public static unsafe DiskCacheState GetCacheSetting(FileHandle fileHandle, out bool isPowerProtected) { DiskCacheSetting diskCacheSetting; fileHandle.IoControl( IoCtlGetCacheSetting, null, 0, &diskCacheSetting, DiskCacheSetting.SizeOf ); isPowerProtected = diskCacheSetting.IsPowerProtected; return diskCacheSetting.State; }
public static unsafe void SetCacheSetting(FileHandle fileHandle, DiskCacheState state, bool isPowerProtected) { DiskCacheSetting diskCacheSetting; diskCacheSetting.Version = DiskCacheSetting.SizeOf; diskCacheSetting.State = state; diskCacheSetting.IsPowerProtected = isPowerProtected; fileHandle.IoControl( IoCtlSetCacheSetting, &diskCacheSetting, DiskCacheSetting.SizeOf, null, 0 ); }
public static unsafe DiskCacheState GetCacheSetting(FileHandle fileHandle, out bool isPowerProtected) { DiskCacheSetting diskCacheSetting; fileHandle.IoControl( IoCtlGetCacheSetting, null, 0, &diskCacheSetting, DiskCacheSetting.SizeOf ); isPowerProtected = diskCacheSetting.IsPowerProtected; return(diskCacheSetting.State); }
public static DiskCacheState GetCacheSetting(FileHandle fileHandle, out bool isPowerProtected) { unsafe { DiskCacheSetting diskCacheSetting; fileHandle.IoControl( IoCtlGetCacheSetting, null, 0, &diskCacheSetting, Marshal.SizeOf(typeof(DiskCacheSetting)) ); isPowerProtected = diskCacheSetting.IsPowerProtected; return diskCacheSetting.State; } }
public static void SetCacheSetting(FileHandle fileHandle, DiskCacheState state, bool isPowerProtected) { unsafe { DiskCacheSetting diskCacheSetting; diskCacheSetting.Version = Marshal.SizeOf(typeof(DiskCacheSetting)); diskCacheSetting.State = state; diskCacheSetting.IsPowerProtected = isPowerProtected; fileHandle.IoControl( IoCtlSetCacheSetting, &diskCacheSetting, Marshal.SizeOf(typeof(DiskCacheSetting)), null, 0 ); } }
public static DiskCacheState GetCacheSetting(FileHandle fileHandle, out bool isPowerProtected) { unsafe { DiskCacheSetting diskCacheSetting; fileHandle.IoControl( IoCtlGetCacheSetting, null, 0, &diskCacheSetting, Marshal.SizeOf(typeof(DiskCacheSetting)) ); isPowerProtected = diskCacheSetting.IsPowerProtected; return(diskCacheSetting.State); } }
private static string GetReparsePointTarget(FileHandle fhandle) { using (MemoryAlloc data = new MemoryAlloc(FileSystem.MaximumReparseDataBufferSize)) { fhandle.IoControl(FileSystem.FsCtlGetReparsePoint, IntPtr.Zero, 0, data, data.Size); FileSystem.ReparseDataBuffer buffer = data.ReadStruct <FileSystem.ReparseDataBuffer>(); // Make sure it is in fact a mount point. if (buffer.ReparseTag != (uint)IoReparseTag.MountPoint) { Win32.Throw(NtStatus.InvalidParameter); } return(data.ReadUnicodeString( FileSystem.ReparseDataBuffer.MountPointPathBuffer + buffer.SubstituteNameOffset, buffer.SubstituteNameLength / 2 )); } }
public static void EjectMedia(FileHandle fileHandle) { fileHandle.IoControl(IoCtlEjectMedia, IntPtr.Zero, 0, IntPtr.Zero, 0); }
private static string GetReparsePointTarget(FileHandle fhandle) { using (MemoryAlloc data = new MemoryAlloc(FileSystem.MaximumReparseDataBufferSize)) { fhandle.IoControl(FileSystem.FsCtlGetReparsePoint, IntPtr.Zero, 0, data, data.Size); FileSystem.ReparseDataBuffer buffer = data.ReadStruct<FileSystem.ReparseDataBuffer>(); // Make sure it is in fact a mount point. if (buffer.ReparseTag != (uint)IoReparseTag.MountPoint) Win32.Throw(NtStatus.InvalidParameter); return data.ReadUnicodeString( FileSystem.ReparseDataBuffer.MountPointPathBuffer + buffer.SubstituteNameOffset, buffer.SubstituteNameLength / 2 ); } }
public KphFeatures KphGetFeatures() { KphGetFeaturesInput input; int features; input.Features = &features; _fileHandle.IoControl(IoCtlGetFeatures, &input, sizeof(KphGetFeaturesInput), null, 0); return((KphFeatures)features); }
public static string GetDeviceName(FileHandle fhandle) { using (MemoryAlloc data = new MemoryAlloc(600)) { fhandle.IoControl(IoCtlQueryDeviceName, IntPtr.Zero, 0, data, data.Size); MountDevName name = data.ReadStruct<MountDevName>(); return data.ReadUnicodeString(MountDevName.NameOffset, name.NameLength / 2); } }
public void ClientCloseHandle(IntPtr handle) { byte *inData = stackalloc byte[4]; *(int *)inData = handle.ToInt32(); _fileHandle.IoControl(CtlCode(Control.ClientCloseHandle), inData, 4, null, 0); }