-
Notifications
You must be signed in to change notification settings - Fork 5
/
limits_ui.go
84 lines (68 loc) · 2.78 KB
/
limits_ui.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
// +build windows
package winjob
import "github.com/kolesnikovae/go-winjob/jobapi"
// WithDesktopLimit prevents processes associated with the job from creating
// desktops and switching desktops using the CreateDesktop and SwitchDesktop
// functions.
func WithDesktopLimit() Limit {
return LimitDesktop
}
// WithDisplaySettingsLimit prevents processes associated with the job from
// calling the ChangeDisplaySettings function.
func WithDisplaySettingsLimit() Limit {
return LimitDisplaySettings
}
// WithExitWindowsLimit prevents processes associated with the job from calling
// the ExitWindows or ExitWindowsEx function.
func WithExitWindowsLimit() Limit {
return LimitExitWindows
}
// WithGlobalAtomsLimit prevents processes associated with the job from
// accessing global atoms. When this limit is used, each job has its own atom
// table.
func WithGlobalAtomsLimit() Limit {
return LimitGlobalAtoms
}
// WithHandlesLimit prevents processes associated with the job from using USER
// handles owned by processes not associated with the same job.
func WithHandlesLimit() Limit {
return LimitHandles
}
// WithReadClipboardLimit prevents processes associated with the job from
// reading data from the clipboard.
func WithReadClipboardLimit() Limit {
return LimitReadClipboard
}
// WithSystemParametersLimit prevents processes associated with the job from
// changing system parameters by using the SystemParametersInfo function.
func WithSystemParametersLimit() Limit {
return LimitSystemParameters
}
// WithWriteClipboardLimit prevents processes associated with the job from
// writing data to the clipboard.
func WithWriteClipboardLimit() Limit {
return LimitWriteClipboard
}
var (
LimitDesktop = uiRestriction(jobapi.JOB_OBJECT_UILIMIT_DESKTOP)
LimitDisplaySettings = uiRestriction(jobapi.JOB_OBJECT_UILIMIT_DISPLAYSETTINGS)
LimitExitWindows = uiRestriction(jobapi.JOB_OBJECT_UILIMIT_EXITWINDOWS)
LimitGlobalAtoms = uiRestriction(jobapi.JOB_OBJECT_UILIMIT_GLOBALATOMS)
LimitHandles = uiRestriction(jobapi.JOB_OBJECT_UILIMIT_HANDLES)
LimitSystemParameters = uiRestriction(jobapi.JOB_OBJECT_UILIMIT_SYSTEMPARAMETERS)
LimitWriteClipboard = uiRestriction(jobapi.JOB_OBJECT_UILIMIT_WRITECLIPBOARD)
LimitReadClipboard = uiRestriction(jobapi.JOB_OBJECT_UILIMIT_READCLIPBOARD)
)
type uiRestriction jobapi.UIRestrictionsClass
func (r uiRestriction) set(job *JobObject) {
job.UIRestrictions.UIRestrictionsClass |= jobapi.UIRestrictionsClass(r)
}
func (r uiRestriction) reset(job *JobObject) {
job.UIRestrictions.UIRestrictionsClass &^= jobapi.UIRestrictionsClass(r)
}
func (r uiRestriction) IsSet(job *JobObject) bool {
return job.UIRestrictions.UIRestrictionsClass&jobapi.UIRestrictionsClass(r) > 0
}
func (r uiRestriction) Value(job *JobObject) interface{} {
return r.IsSet(job)
}