-
-
Notifications
You must be signed in to change notification settings - Fork 240
/
Copy pathWOFHelper.vb
70 lines (54 loc) · 2.2 KB
/
WOFHelper.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
Imports System.Runtime.InteropServices
Public Module WOFHelper
Public Const WOF_PROVIDER_FILE As ULong = 2
Public Const FSCTL_DELETE_EXTERNAL_BACKING As UInteger = &H90314
Public Function WOFConvertCompressionLevel(compressionlevel As Integer) As Integer
Select Case compressionlevel
Case 0 : Return CompressionAlgorithm.XPRESS4K
Case 1 : Return CompressionAlgorithm.XPRESS8K
Case 2 : Return CompressionAlgorithm.XPRESS16K
Case 3 : Return CompressionAlgorithm.LZX
Case Else : Return CompressionAlgorithm.XPRESS4K
End Select
End Function
Public Function WOFConvertBackCompressionLevel(WOFCompressionLevel As CompressionAlgorithm) As Integer
Select Case WOFCompressionLevel
Case CompressionAlgorithm.XPRESS4K : Return 0
Case CompressionAlgorithm.XPRESS8K : Return 1
Case CompressionAlgorithm.XPRESS16K : Return 2
Case CompressionAlgorithm.LZX : Return 3
Case Else : Return 0
End Select
End Function
Public Structure WOF_FILE_COMPRESSION_INFO_V1
Public Algorithm As CompressionAlgorithm
Public Flags As ULong
End Structure
<DllImport("WofUtil.dll")>
Friend Function WofIsExternalFile(
<MarshalAs(UnmanagedType.LPWStr)> ByVal Filepath As String,
<Out> ByRef IsExternalFile As Integer,
<Out> ByRef Provider As UInteger,
<Out> ByRef Info As WOF_FILE_COMPRESSION_INFO_V1,
ByRef BufferLength As UInteger) As Integer
End Function
<DllImport("WofUtil.dll")>
Friend Function WofSetFileDataLocation(
FileHandle As IntPtr,
Provider As ULong,
ExternalFileInfo As IntPtr,
Length As ULong) As Integer
End Function
'Most of these should be optional if MS Docs are to be believed -.-
<DllImport("kernel32.dll")>
Friend Function DeviceIoControl(
hDevice As IntPtr,
dwIoControlCode As UInteger,
lpInBuffer As IntPtr,
nInBufferSize As UInteger,
lpOutBuffer As IntPtr,
nOutBufferSize As UInteger,
<Out> lpBytesReturned As IntPtr,
<Out> lpOverlapped As IntPtr) As Integer
End Function
End Module