This repository has been archived by the owner on Jul 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwpeutil.go
165 lines (123 loc) · 4.14 KB
/
wpeutil.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
// +build windows
package wpeutil
import "syscall"
var (
// Library
libwpeutil uintptr
// Functions
createPageFile uintptr
disableExtendedCharactersForVolume uintptr
disableFirewall uintptr
enableExtendedCharactersForVolume uintptr
enableFirewall uintptr
initializeNetwork uintptr
listKeyboardLayouts uintptr
reboot uintptr
saveProfile uintptr
setKeyboardLayout uintptr
setMuiLanguage uintptr
setUserLocale uintptr
shutdown uintptr
updateBootInfo uintptr
waitForNetwork uintptr
waitForRemovableStorage uintptr
)
func MustLoadLibrary(name string) uintptr {
lib, err := syscall.LoadLibrary(name)
if err != nil {
panic(err)
}
return uintptr(lib)
}
func MustGetProcAddress(lib uintptr, name string) uintptr {
addr, err := syscall.GetProcAddress(syscall.Handle(lib), name)
if err != nil {
panic(err)
}
return uintptr(addr)
}
func init() {
// Library
libwpeutil = MustLoadLibrary("wpeutil.dll")
// Functions
createPageFile = MustGetProcAddress(libwpeutil, "CreatePageFile")
disableExtendedCharactersForVolume = MustGetProcAddress(libwpeutil, "DisableExtendedCharactersForVolume")
disableFirewall = MustGetProcAddress(libwpeutil, "DisableFirewall")
enableExtendedCharactersForVolume = MustGetProcAddress(libwpeutil, "EnableExtendedCharactersForVolume")
enableFirewall = MustGetProcAddress(libwpeutil, "EnableFirewall")
initializeNetwork = MustGetProcAddress(libwpeutil, "InitializeNetwork")
listKeyboardLayouts = MustGetProcAddress(libwpeutil, "ListKeyboardLayouts")
reboot = MustGetProcAddress(libwpeutil, "Reboot")
saveProfile = MustGetProcAddress(libwpeutil, "SaveProfile")
setKeyboardLayout = MustGetProcAddress(libwpeutil, "SetKeyboardLayout")
setMuiLanguage = MustGetProcAddress(libwpeutil, "SetMuiLanguage")
setUserLocale = MustGetProcAddress(libwpeutil, "SetUserLocale")
shutdown = MustGetProcAddress(libwpeutil, "Shutdown")
updateBootInfo = MustGetProcAddress(libwpeutil, "UpdateBootInfo")
waitForNetwork = MustGetProcAddress(libwpeutil, "WaitForNetwork")
waitForRemovableStorage = MustGetProcAddress(libwpeutil, "WaitForRemovableStorage")
}
func CreatePageFile() int32 {
ret, _, _ := syscall.Syscall(createPageFile, 0, 0, 0, 0)
return int32(ret)
}
func DisableExtendedCharactersForVolume() int32 {
ret, _, _ := syscall.Syscall(disableExtendedCharactersForVolume, 0, 0, 0, 0)
return int32(ret)
}
func DisableFirewall() int32 {
ret, _, _ := syscall.Syscall(disableFirewall, 0, 0, 0, 0)
return int32(ret)
}
func EnableExtendedCharactersForVolume() int32 {
ret, _, _ := syscall.Syscall(enableExtendedCharactersForVolume, 0, 0, 0, 0)
return int32(ret)
}
func EnableFirewall() int32 {
ret, _, _ := syscall.Syscall(enableFirewall, 0, 0, 0, 0)
return int32(ret)
}
func InitializeNetwork() int32 {
ret, _, _ := syscall.Syscall(initializeNetwork, 0, 0, 0, 0)
return int32(ret)
}
func ListKeyboardLayouts() int32 {
ret, _, _ := syscall.Syscall(listKeyboardLayouts, 0, 0, 0, 0)
return int32(ret)
}
func Reboot() int32 {
ret, _, _ := syscall.Syscall(reboot, 0, 0, 0, 0)
return int32(ret)
}
func SaveProfile() int32 {
ret, _, _ := syscall.Syscall(saveProfile, 0, 0, 0, 0)
return int32(ret)
}
func SetKeyboardLayout() int32 {
ret, _, _ := syscall.Syscall(setKeyboardLayout, 0, 0, 0, 0)
return int32(ret)
}
func SetMuiLanguage() int32 {
ret, _, _ := syscall.Syscall(setMuiLanguage, 0, 0, 0, 0)
return int32(ret)
}
func SetUserLocale() int32 {
ret, _, _ := syscall.Syscall(setUserLocale, 0, 0, 0, 0)
return int32(ret)
}
func Shutdown() int32 {
ret, _, _ := syscall.Syscall(shutdown, 0, 0, 0, 0)
return int32(ret)
}
func UpdateBootInfo() int32 {
ret, _, _ := syscall.Syscall(updateBootInfo, 0, 0, 0, 0)
return int32(ret)
}
func WaitForNetwork() int32 {
ret, _, _ := syscall.Syscall(waitForNetwork, 0, 0, 0, 0)
return int32(ret)
}
func WaitForRemovableStorage() int32 {
ret, _, _ := syscall.Syscall(waitForRemovableStorage, 0, 0, 0, 0)
return int32(ret)
}