-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathwindivert_device.go
84 lines (73 loc) · 2 KB
/
windivert_device.go
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package windivert
const (
METHOD_BUFFERED = 0
METHOD_IN_DIRECT = 1
METHOD_OUT_DIRECT = 2
METHOD_NEITHER = 3
)
const (
FILE_READ_DATA = 1
FILE_WRITE_DATA = 2
)
const (
FILE_DEVICE_NETWORK = 0x00000012
FILE_DEVICE_NETWORK_BROWSER = 0x00000013
FILE_DEVICE_NETWORK_FILE_SYSTEM = 0x00000014
FILE_DEVICE_NETWORK_REDIRECTOR = 0x00000028
)
func CTL_CODE(DeviceType, Function, Method, Access uint32) CtlCode {
return CtlCode(((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method))
}
var (
IoCtlInitialize = CTL_CODE(FILE_DEVICE_NETWORK, 0x921, METHOD_OUT_DIRECT, FILE_READ_DATA|FILE_WRITE_DATA)
IoCtlStartup = CTL_CODE(FILE_DEVICE_NETWORK, 0x922, METHOD_IN_DIRECT, FILE_READ_DATA|FILE_WRITE_DATA)
IoCtlRecv = CTL_CODE(FILE_DEVICE_NETWORK, 0x923, METHOD_OUT_DIRECT, FILE_READ_DATA)
IoCtlSend = CTL_CODE(FILE_DEVICE_NETWORK, 0x924, METHOD_IN_DIRECT, FILE_READ_DATA|FILE_WRITE_DATA)
IoCtlSetParam = CTL_CODE(FILE_DEVICE_NETWORK, 0x925, METHOD_IN_DIRECT, FILE_READ_DATA|FILE_WRITE_DATA)
IoCtlGetParam = CTL_CODE(FILE_DEVICE_NETWORK, 0x926, METHOD_OUT_DIRECT, FILE_READ_DATA)
IoCtlShutdown = CTL_CODE(FILE_DEVICE_NETWORK, 0x927, METHOD_IN_DIRECT, FILE_READ_DATA|FILE_WRITE_DATA)
)
func (code CtlCode) String() string {
switch code {
case IoCtlInitialize:
return "IOCTL_WINDIVERT_INITIALIZE"
case IoCtlStartup:
return "IOCTL_WINDIVERT_STARTUP"
case IoCtlRecv:
return "IOCTL_WINDIVERT_RECV"
case IoCtlSend:
return "IOCTL_WINDIVERT_SEND"
case IoCtlSetParam:
return "IOCTL_WINDIVERT_SET_PARAM"
case IoCtlGetParam:
return "IOCTL_WINDIVERT_GET_PARAM"
case IoCtlShutdown:
return "IOCTL_WINDIVERT_SHUTDOWN"
default:
return ""
}
}
type initialize struct {
Layer uint32
Priority uint32
Flags uint64
}
type startup struct {
Flags uint64
_ uint64
}
type shutdown struct {
How uint32
_ uint32
_ uint64
}
type getParam struct {
Param uint32
_ uint32
Value uint64
}
type setParam struct {
Value uint64
Param uint32
_ uint32
}