blob: 722be2480ef012cc0a46fd64a70b604423ef6a17 [file] [log] [blame]
Zack Williamse940c7a2019-08-21 14:25:39 -07001// Code generated by 'go generate'; DO NOT EDIT.
2
3package windows
4
5import (
6 "syscall"
7 "unsafe"
8)
9
10var _ unsafe.Pointer
11
12// Do the interface allocations only once for common
13// Errno values.
14const (
15 errnoERROR_IO_PENDING = 997
16)
17
18var (
19 errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING)
20)
21
22// errnoErr returns common boxed Errno values, to prevent
23// allocations at runtime.
24func errnoErr(e syscall.Errno) error {
25 switch e {
26 case 0:
27 return nil
28 case errnoERROR_IO_PENDING:
29 return errERROR_IO_PENDING
30 }
31 // TODO: add more here, after collecting data on the common
32 // error values see on Windows. (perhaps when running
33 // all.bat?)
34 return e
35}
36
37var (
38 modadvapi32 = NewLazySystemDLL("advapi32.dll")
39 modkernel32 = NewLazySystemDLL("kernel32.dll")
40 modshell32 = NewLazySystemDLL("shell32.dll")
41 moduserenv = NewLazySystemDLL("userenv.dll")
42 modmswsock = NewLazySystemDLL("mswsock.dll")
43 modcrypt32 = NewLazySystemDLL("crypt32.dll")
44 moduser32 = NewLazySystemDLL("user32.dll")
divyadesai19009132020-03-04 12:58:08 +000045 modole32 = NewLazySystemDLL("ole32.dll")
46 modntdll = NewLazySystemDLL("ntdll.dll")
Zack Williamse940c7a2019-08-21 14:25:39 -070047 modws2_32 = NewLazySystemDLL("ws2_32.dll")
48 moddnsapi = NewLazySystemDLL("dnsapi.dll")
49 modiphlpapi = NewLazySystemDLL("iphlpapi.dll")
50 modsecur32 = NewLazySystemDLL("secur32.dll")
51 modnetapi32 = NewLazySystemDLL("netapi32.dll")
52 modwtsapi32 = NewLazySystemDLL("wtsapi32.dll")
53
divyadesai19009132020-03-04 12:58:08 +000054 procRegisterEventSourceW = modadvapi32.NewProc("RegisterEventSourceW")
55 procDeregisterEventSource = modadvapi32.NewProc("DeregisterEventSource")
56 procReportEventW = modadvapi32.NewProc("ReportEventW")
57 procOpenSCManagerW = modadvapi32.NewProc("OpenSCManagerW")
58 procCloseServiceHandle = modadvapi32.NewProc("CloseServiceHandle")
59 procCreateServiceW = modadvapi32.NewProc("CreateServiceW")
60 procOpenServiceW = modadvapi32.NewProc("OpenServiceW")
61 procDeleteService = modadvapi32.NewProc("DeleteService")
62 procStartServiceW = modadvapi32.NewProc("StartServiceW")
63 procQueryServiceStatus = modadvapi32.NewProc("QueryServiceStatus")
64 procQueryServiceLockStatusW = modadvapi32.NewProc("QueryServiceLockStatusW")
65 procControlService = modadvapi32.NewProc("ControlService")
66 procStartServiceCtrlDispatcherW = modadvapi32.NewProc("StartServiceCtrlDispatcherW")
67 procSetServiceStatus = modadvapi32.NewProc("SetServiceStatus")
68 procChangeServiceConfigW = modadvapi32.NewProc("ChangeServiceConfigW")
69 procQueryServiceConfigW = modadvapi32.NewProc("QueryServiceConfigW")
70 procChangeServiceConfig2W = modadvapi32.NewProc("ChangeServiceConfig2W")
71 procQueryServiceConfig2W = modadvapi32.NewProc("QueryServiceConfig2W")
72 procEnumServicesStatusExW = modadvapi32.NewProc("EnumServicesStatusExW")
73 procQueryServiceStatusEx = modadvapi32.NewProc("QueryServiceStatusEx")
74 procNotifyServiceStatusChangeW = modadvapi32.NewProc("NotifyServiceStatusChangeW")
75 procGetLastError = modkernel32.NewProc("GetLastError")
76 procLoadLibraryW = modkernel32.NewProc("LoadLibraryW")
77 procLoadLibraryExW = modkernel32.NewProc("LoadLibraryExW")
78 procFreeLibrary = modkernel32.NewProc("FreeLibrary")
79 procGetProcAddress = modkernel32.NewProc("GetProcAddress")
80 procGetVersion = modkernel32.NewProc("GetVersion")
81 procFormatMessageW = modkernel32.NewProc("FormatMessageW")
82 procExitProcess = modkernel32.NewProc("ExitProcess")
83 procIsWow64Process = modkernel32.NewProc("IsWow64Process")
84 procCreateFileW = modkernel32.NewProc("CreateFileW")
85 procReadFile = modkernel32.NewProc("ReadFile")
86 procWriteFile = modkernel32.NewProc("WriteFile")
87 procGetOverlappedResult = modkernel32.NewProc("GetOverlappedResult")
88 procSetFilePointer = modkernel32.NewProc("SetFilePointer")
89 procCloseHandle = modkernel32.NewProc("CloseHandle")
90 procGetStdHandle = modkernel32.NewProc("GetStdHandle")
91 procSetStdHandle = modkernel32.NewProc("SetStdHandle")
92 procFindFirstFileW = modkernel32.NewProc("FindFirstFileW")
93 procFindNextFileW = modkernel32.NewProc("FindNextFileW")
94 procFindClose = modkernel32.NewProc("FindClose")
95 procGetFileInformationByHandle = modkernel32.NewProc("GetFileInformationByHandle")
96 procGetFileInformationByHandleEx = modkernel32.NewProc("GetFileInformationByHandleEx")
97 procGetCurrentDirectoryW = modkernel32.NewProc("GetCurrentDirectoryW")
98 procSetCurrentDirectoryW = modkernel32.NewProc("SetCurrentDirectoryW")
99 procCreateDirectoryW = modkernel32.NewProc("CreateDirectoryW")
100 procRemoveDirectoryW = modkernel32.NewProc("RemoveDirectoryW")
101 procDeleteFileW = modkernel32.NewProc("DeleteFileW")
102 procMoveFileW = modkernel32.NewProc("MoveFileW")
103 procMoveFileExW = modkernel32.NewProc("MoveFileExW")
104 procLockFileEx = modkernel32.NewProc("LockFileEx")
105 procUnlockFileEx = modkernel32.NewProc("UnlockFileEx")
106 procGetComputerNameW = modkernel32.NewProc("GetComputerNameW")
107 procGetComputerNameExW = modkernel32.NewProc("GetComputerNameExW")
108 procSetEndOfFile = modkernel32.NewProc("SetEndOfFile")
109 procGetSystemTimeAsFileTime = modkernel32.NewProc("GetSystemTimeAsFileTime")
110 procGetSystemTimePreciseAsFileTime = modkernel32.NewProc("GetSystemTimePreciseAsFileTime")
111 procGetTimeZoneInformation = modkernel32.NewProc("GetTimeZoneInformation")
112 procCreateIoCompletionPort = modkernel32.NewProc("CreateIoCompletionPort")
113 procGetQueuedCompletionStatus = modkernel32.NewProc("GetQueuedCompletionStatus")
114 procPostQueuedCompletionStatus = modkernel32.NewProc("PostQueuedCompletionStatus")
115 procCancelIo = modkernel32.NewProc("CancelIo")
116 procCancelIoEx = modkernel32.NewProc("CancelIoEx")
117 procCreateProcessW = modkernel32.NewProc("CreateProcessW")
118 procOpenProcess = modkernel32.NewProc("OpenProcess")
119 procShellExecuteW = modshell32.NewProc("ShellExecuteW")
120 procSHGetKnownFolderPath = modshell32.NewProc("SHGetKnownFolderPath")
121 procTerminateProcess = modkernel32.NewProc("TerminateProcess")
122 procGetExitCodeProcess = modkernel32.NewProc("GetExitCodeProcess")
123 procGetStartupInfoW = modkernel32.NewProc("GetStartupInfoW")
124 procGetProcessTimes = modkernel32.NewProc("GetProcessTimes")
125 procDuplicateHandle = modkernel32.NewProc("DuplicateHandle")
126 procWaitForSingleObject = modkernel32.NewProc("WaitForSingleObject")
127 procWaitForMultipleObjects = modkernel32.NewProc("WaitForMultipleObjects")
128 procGetTempPathW = modkernel32.NewProc("GetTempPathW")
129 procCreatePipe = modkernel32.NewProc("CreatePipe")
130 procGetFileType = modkernel32.NewProc("GetFileType")
131 procCryptAcquireContextW = modadvapi32.NewProc("CryptAcquireContextW")
132 procCryptReleaseContext = modadvapi32.NewProc("CryptReleaseContext")
133 procCryptGenRandom = modadvapi32.NewProc("CryptGenRandom")
134 procGetEnvironmentStringsW = modkernel32.NewProc("GetEnvironmentStringsW")
135 procFreeEnvironmentStringsW = modkernel32.NewProc("FreeEnvironmentStringsW")
136 procGetEnvironmentVariableW = modkernel32.NewProc("GetEnvironmentVariableW")
137 procSetEnvironmentVariableW = modkernel32.NewProc("SetEnvironmentVariableW")
138 procCreateEnvironmentBlock = moduserenv.NewProc("CreateEnvironmentBlock")
139 procDestroyEnvironmentBlock = moduserenv.NewProc("DestroyEnvironmentBlock")
140 procGetTickCount64 = modkernel32.NewProc("GetTickCount64")
141 procSetFileTime = modkernel32.NewProc("SetFileTime")
142 procGetFileAttributesW = modkernel32.NewProc("GetFileAttributesW")
143 procSetFileAttributesW = modkernel32.NewProc("SetFileAttributesW")
144 procGetFileAttributesExW = modkernel32.NewProc("GetFileAttributesExW")
145 procGetCommandLineW = modkernel32.NewProc("GetCommandLineW")
146 procCommandLineToArgvW = modshell32.NewProc("CommandLineToArgvW")
147 procLocalFree = modkernel32.NewProc("LocalFree")
148 procSetHandleInformation = modkernel32.NewProc("SetHandleInformation")
149 procFlushFileBuffers = modkernel32.NewProc("FlushFileBuffers")
150 procGetFullPathNameW = modkernel32.NewProc("GetFullPathNameW")
151 procGetLongPathNameW = modkernel32.NewProc("GetLongPathNameW")
152 procGetShortPathNameW = modkernel32.NewProc("GetShortPathNameW")
153 procCreateFileMappingW = modkernel32.NewProc("CreateFileMappingW")
154 procMapViewOfFile = modkernel32.NewProc("MapViewOfFile")
155 procUnmapViewOfFile = modkernel32.NewProc("UnmapViewOfFile")
156 procFlushViewOfFile = modkernel32.NewProc("FlushViewOfFile")
157 procVirtualLock = modkernel32.NewProc("VirtualLock")
158 procVirtualUnlock = modkernel32.NewProc("VirtualUnlock")
159 procVirtualAlloc = modkernel32.NewProc("VirtualAlloc")
160 procVirtualFree = modkernel32.NewProc("VirtualFree")
161 procVirtualProtect = modkernel32.NewProc("VirtualProtect")
162 procTransmitFile = modmswsock.NewProc("TransmitFile")
163 procReadDirectoryChangesW = modkernel32.NewProc("ReadDirectoryChangesW")
164 procCertOpenSystemStoreW = modcrypt32.NewProc("CertOpenSystemStoreW")
165 procCertOpenStore = modcrypt32.NewProc("CertOpenStore")
166 procCertEnumCertificatesInStore = modcrypt32.NewProc("CertEnumCertificatesInStore")
167 procCertAddCertificateContextToStore = modcrypt32.NewProc("CertAddCertificateContextToStore")
168 procCertCloseStore = modcrypt32.NewProc("CertCloseStore")
169 procCertGetCertificateChain = modcrypt32.NewProc("CertGetCertificateChain")
170 procCertFreeCertificateChain = modcrypt32.NewProc("CertFreeCertificateChain")
171 procCertCreateCertificateContext = modcrypt32.NewProc("CertCreateCertificateContext")
172 procCertFreeCertificateContext = modcrypt32.NewProc("CertFreeCertificateContext")
173 procCertVerifyCertificateChainPolicy = modcrypt32.NewProc("CertVerifyCertificateChainPolicy")
174 procRegOpenKeyExW = modadvapi32.NewProc("RegOpenKeyExW")
175 procRegCloseKey = modadvapi32.NewProc("RegCloseKey")
176 procRegQueryInfoKeyW = modadvapi32.NewProc("RegQueryInfoKeyW")
177 procRegEnumKeyExW = modadvapi32.NewProc("RegEnumKeyExW")
178 procRegQueryValueExW = modadvapi32.NewProc("RegQueryValueExW")
179 procGetCurrentProcessId = modkernel32.NewProc("GetCurrentProcessId")
180 procGetConsoleMode = modkernel32.NewProc("GetConsoleMode")
181 procSetConsoleMode = modkernel32.NewProc("SetConsoleMode")
182 procGetConsoleScreenBufferInfo = modkernel32.NewProc("GetConsoleScreenBufferInfo")
183 procWriteConsoleW = modkernel32.NewProc("WriteConsoleW")
184 procReadConsoleW = modkernel32.NewProc("ReadConsoleW")
185 procCreateToolhelp32Snapshot = modkernel32.NewProc("CreateToolhelp32Snapshot")
186 procProcess32FirstW = modkernel32.NewProc("Process32FirstW")
187 procProcess32NextW = modkernel32.NewProc("Process32NextW")
188 procThread32First = modkernel32.NewProc("Thread32First")
189 procThread32Next = modkernel32.NewProc("Thread32Next")
190 procDeviceIoControl = modkernel32.NewProc("DeviceIoControl")
191 procCreateSymbolicLinkW = modkernel32.NewProc("CreateSymbolicLinkW")
192 procCreateHardLinkW = modkernel32.NewProc("CreateHardLinkW")
193 procGetCurrentThreadId = modkernel32.NewProc("GetCurrentThreadId")
194 procCreateEventW = modkernel32.NewProc("CreateEventW")
195 procCreateEventExW = modkernel32.NewProc("CreateEventExW")
196 procOpenEventW = modkernel32.NewProc("OpenEventW")
197 procSetEvent = modkernel32.NewProc("SetEvent")
198 procResetEvent = modkernel32.NewProc("ResetEvent")
199 procPulseEvent = modkernel32.NewProc("PulseEvent")
200 procCreateMutexW = modkernel32.NewProc("CreateMutexW")
201 procCreateMutexExW = modkernel32.NewProc("CreateMutexExW")
202 procOpenMutexW = modkernel32.NewProc("OpenMutexW")
203 procReleaseMutex = modkernel32.NewProc("ReleaseMutex")
204 procSleepEx = modkernel32.NewProc("SleepEx")
205 procCreateJobObjectW = modkernel32.NewProc("CreateJobObjectW")
206 procAssignProcessToJobObject = modkernel32.NewProc("AssignProcessToJobObject")
207 procTerminateJobObject = modkernel32.NewProc("TerminateJobObject")
208 procSetErrorMode = modkernel32.NewProc("SetErrorMode")
209 procResumeThread = modkernel32.NewProc("ResumeThread")
210 procSetPriorityClass = modkernel32.NewProc("SetPriorityClass")
211 procGetPriorityClass = modkernel32.NewProc("GetPriorityClass")
212 procSetInformationJobObject = modkernel32.NewProc("SetInformationJobObject")
213 procGenerateConsoleCtrlEvent = modkernel32.NewProc("GenerateConsoleCtrlEvent")
214 procGetProcessId = modkernel32.NewProc("GetProcessId")
215 procOpenThread = modkernel32.NewProc("OpenThread")
216 procSetProcessPriorityBoost = modkernel32.NewProc("SetProcessPriorityBoost")
217 procDefineDosDeviceW = modkernel32.NewProc("DefineDosDeviceW")
218 procDeleteVolumeMountPointW = modkernel32.NewProc("DeleteVolumeMountPointW")
219 procFindFirstVolumeW = modkernel32.NewProc("FindFirstVolumeW")
220 procFindFirstVolumeMountPointW = modkernel32.NewProc("FindFirstVolumeMountPointW")
221 procFindNextVolumeW = modkernel32.NewProc("FindNextVolumeW")
222 procFindNextVolumeMountPointW = modkernel32.NewProc("FindNextVolumeMountPointW")
223 procFindVolumeClose = modkernel32.NewProc("FindVolumeClose")
224 procFindVolumeMountPointClose = modkernel32.NewProc("FindVolumeMountPointClose")
225 procGetDriveTypeW = modkernel32.NewProc("GetDriveTypeW")
226 procGetLogicalDrives = modkernel32.NewProc("GetLogicalDrives")
227 procGetLogicalDriveStringsW = modkernel32.NewProc("GetLogicalDriveStringsW")
228 procGetVolumeInformationW = modkernel32.NewProc("GetVolumeInformationW")
229 procGetVolumeInformationByHandleW = modkernel32.NewProc("GetVolumeInformationByHandleW")
230 procGetVolumeNameForVolumeMountPointW = modkernel32.NewProc("GetVolumeNameForVolumeMountPointW")
231 procGetVolumePathNameW = modkernel32.NewProc("GetVolumePathNameW")
232 procGetVolumePathNamesForVolumeNameW = modkernel32.NewProc("GetVolumePathNamesForVolumeNameW")
233 procQueryDosDeviceW = modkernel32.NewProc("QueryDosDeviceW")
234 procSetVolumeLabelW = modkernel32.NewProc("SetVolumeLabelW")
235 procSetVolumeMountPointW = modkernel32.NewProc("SetVolumeMountPointW")
236 procMessageBoxW = moduser32.NewProc("MessageBoxW")
237 procExitWindowsEx = moduser32.NewProc("ExitWindowsEx")
238 procInitiateSystemShutdownExW = modadvapi32.NewProc("InitiateSystemShutdownExW")
239 procSetProcessShutdownParameters = modkernel32.NewProc("SetProcessShutdownParameters")
240 procGetProcessShutdownParameters = modkernel32.NewProc("GetProcessShutdownParameters")
241 procCLSIDFromString = modole32.NewProc("CLSIDFromString")
242 procStringFromGUID2 = modole32.NewProc("StringFromGUID2")
243 procCoCreateGuid = modole32.NewProc("CoCreateGuid")
244 procCoTaskMemFree = modole32.NewProc("CoTaskMemFree")
245 procRtlGetVersion = modntdll.NewProc("RtlGetVersion")
246 procRtlGetNtVersionNumbers = modntdll.NewProc("RtlGetNtVersionNumbers")
247 procWSAStartup = modws2_32.NewProc("WSAStartup")
248 procWSACleanup = modws2_32.NewProc("WSACleanup")
249 procWSAIoctl = modws2_32.NewProc("WSAIoctl")
250 procsocket = modws2_32.NewProc("socket")
251 procsetsockopt = modws2_32.NewProc("setsockopt")
252 procgetsockopt = modws2_32.NewProc("getsockopt")
253 procbind = modws2_32.NewProc("bind")
254 procconnect = modws2_32.NewProc("connect")
255 procgetsockname = modws2_32.NewProc("getsockname")
256 procgetpeername = modws2_32.NewProc("getpeername")
257 proclisten = modws2_32.NewProc("listen")
258 procshutdown = modws2_32.NewProc("shutdown")
259 procclosesocket = modws2_32.NewProc("closesocket")
260 procAcceptEx = modmswsock.NewProc("AcceptEx")
261 procGetAcceptExSockaddrs = modmswsock.NewProc("GetAcceptExSockaddrs")
262 procWSARecv = modws2_32.NewProc("WSARecv")
263 procWSASend = modws2_32.NewProc("WSASend")
264 procWSARecvFrom = modws2_32.NewProc("WSARecvFrom")
265 procWSASendTo = modws2_32.NewProc("WSASendTo")
266 procgethostbyname = modws2_32.NewProc("gethostbyname")
267 procgetservbyname = modws2_32.NewProc("getservbyname")
268 procntohs = modws2_32.NewProc("ntohs")
269 procgetprotobyname = modws2_32.NewProc("getprotobyname")
270 procDnsQuery_W = moddnsapi.NewProc("DnsQuery_W")
271 procDnsRecordListFree = moddnsapi.NewProc("DnsRecordListFree")
272 procDnsNameCompare_W = moddnsapi.NewProc("DnsNameCompare_W")
273 procGetAddrInfoW = modws2_32.NewProc("GetAddrInfoW")
274 procFreeAddrInfoW = modws2_32.NewProc("FreeAddrInfoW")
275 procGetIfEntry = modiphlpapi.NewProc("GetIfEntry")
276 procGetAdaptersInfo = modiphlpapi.NewProc("GetAdaptersInfo")
277 procSetFileCompletionNotificationModes = modkernel32.NewProc("SetFileCompletionNotificationModes")
278 procWSAEnumProtocolsW = modws2_32.NewProc("WSAEnumProtocolsW")
279 procGetAdaptersAddresses = modiphlpapi.NewProc("GetAdaptersAddresses")
280 procGetACP = modkernel32.NewProc("GetACP")
281 procMultiByteToWideChar = modkernel32.NewProc("MultiByteToWideChar")
282 procTranslateNameW = modsecur32.NewProc("TranslateNameW")
283 procGetUserNameExW = modsecur32.NewProc("GetUserNameExW")
284 procNetUserGetInfo = modnetapi32.NewProc("NetUserGetInfo")
285 procNetGetJoinInformation = modnetapi32.NewProc("NetGetJoinInformation")
286 procNetApiBufferFree = modnetapi32.NewProc("NetApiBufferFree")
287 procLookupAccountSidW = modadvapi32.NewProc("LookupAccountSidW")
288 procLookupAccountNameW = modadvapi32.NewProc("LookupAccountNameW")
289 procConvertSidToStringSidW = modadvapi32.NewProc("ConvertSidToStringSidW")
290 procConvertStringSidToSidW = modadvapi32.NewProc("ConvertStringSidToSidW")
291 procGetLengthSid = modadvapi32.NewProc("GetLengthSid")
292 procCopySid = modadvapi32.NewProc("CopySid")
293 procAllocateAndInitializeSid = modadvapi32.NewProc("AllocateAndInitializeSid")
294 procCreateWellKnownSid = modadvapi32.NewProc("CreateWellKnownSid")
295 procIsWellKnownSid = modadvapi32.NewProc("IsWellKnownSid")
296 procFreeSid = modadvapi32.NewProc("FreeSid")
297 procEqualSid = modadvapi32.NewProc("EqualSid")
298 procGetSidIdentifierAuthority = modadvapi32.NewProc("GetSidIdentifierAuthority")
299 procGetSidSubAuthorityCount = modadvapi32.NewProc("GetSidSubAuthorityCount")
300 procGetSidSubAuthority = modadvapi32.NewProc("GetSidSubAuthority")
301 procIsValidSid = modadvapi32.NewProc("IsValidSid")
302 procCheckTokenMembership = modadvapi32.NewProc("CheckTokenMembership")
303 procOpenProcessToken = modadvapi32.NewProc("OpenProcessToken")
304 procOpenThreadToken = modadvapi32.NewProc("OpenThreadToken")
305 procImpersonateSelf = modadvapi32.NewProc("ImpersonateSelf")
306 procRevertToSelf = modadvapi32.NewProc("RevertToSelf")
307 procSetThreadToken = modadvapi32.NewProc("SetThreadToken")
308 procLookupPrivilegeValueW = modadvapi32.NewProc("LookupPrivilegeValueW")
309 procAdjustTokenPrivileges = modadvapi32.NewProc("AdjustTokenPrivileges")
310 procAdjustTokenGroups = modadvapi32.NewProc("AdjustTokenGroups")
311 procGetTokenInformation = modadvapi32.NewProc("GetTokenInformation")
312 procSetTokenInformation = modadvapi32.NewProc("SetTokenInformation")
313 procDuplicateTokenEx = modadvapi32.NewProc("DuplicateTokenEx")
314 procGetUserProfileDirectoryW = moduserenv.NewProc("GetUserProfileDirectoryW")
315 procGetSystemDirectoryW = modkernel32.NewProc("GetSystemDirectoryW")
316 procGetWindowsDirectoryW = modkernel32.NewProc("GetWindowsDirectoryW")
317 procGetSystemWindowsDirectoryW = modkernel32.NewProc("GetSystemWindowsDirectoryW")
318 procWTSQueryUserToken = modwtsapi32.NewProc("WTSQueryUserToken")
319 procWTSEnumerateSessionsW = modwtsapi32.NewProc("WTSEnumerateSessionsW")
320 procWTSFreeMemory = modwtsapi32.NewProc("WTSFreeMemory")
321 procGetSecurityInfo = modadvapi32.NewProc("GetSecurityInfo")
322 procSetSecurityInfo = modadvapi32.NewProc("SetSecurityInfo")
323 procGetNamedSecurityInfoW = modadvapi32.NewProc("GetNamedSecurityInfoW")
324 procSetNamedSecurityInfoW = modadvapi32.NewProc("SetNamedSecurityInfoW")
325 procBuildSecurityDescriptorW = modadvapi32.NewProc("BuildSecurityDescriptorW")
326 procInitializeSecurityDescriptor = modadvapi32.NewProc("InitializeSecurityDescriptor")
327 procGetSecurityDescriptorControl = modadvapi32.NewProc("GetSecurityDescriptorControl")
328 procGetSecurityDescriptorDacl = modadvapi32.NewProc("GetSecurityDescriptorDacl")
329 procGetSecurityDescriptorSacl = modadvapi32.NewProc("GetSecurityDescriptorSacl")
330 procGetSecurityDescriptorOwner = modadvapi32.NewProc("GetSecurityDescriptorOwner")
331 procGetSecurityDescriptorGroup = modadvapi32.NewProc("GetSecurityDescriptorGroup")
332 procGetSecurityDescriptorLength = modadvapi32.NewProc("GetSecurityDescriptorLength")
333 procGetSecurityDescriptorRMControl = modadvapi32.NewProc("GetSecurityDescriptorRMControl")
334 procIsValidSecurityDescriptor = modadvapi32.NewProc("IsValidSecurityDescriptor")
335 procSetSecurityDescriptorControl = modadvapi32.NewProc("SetSecurityDescriptorControl")
336 procSetSecurityDescriptorDacl = modadvapi32.NewProc("SetSecurityDescriptorDacl")
337 procSetSecurityDescriptorSacl = modadvapi32.NewProc("SetSecurityDescriptorSacl")
338 procSetSecurityDescriptorOwner = modadvapi32.NewProc("SetSecurityDescriptorOwner")
339 procSetSecurityDescriptorGroup = modadvapi32.NewProc("SetSecurityDescriptorGroup")
340 procSetSecurityDescriptorRMControl = modadvapi32.NewProc("SetSecurityDescriptorRMControl")
341 procConvertStringSecurityDescriptorToSecurityDescriptorW = modadvapi32.NewProc("ConvertStringSecurityDescriptorToSecurityDescriptorW")
342 procConvertSecurityDescriptorToStringSecurityDescriptorW = modadvapi32.NewProc("ConvertSecurityDescriptorToStringSecurityDescriptorW")
343 procMakeAbsoluteSD = modadvapi32.NewProc("MakeAbsoluteSD")
344 procMakeSelfRelativeSD = modadvapi32.NewProc("MakeSelfRelativeSD")
345 procSetEntriesInAclW = modadvapi32.NewProc("SetEntriesInAclW")
Zack Williamse940c7a2019-08-21 14:25:39 -0700346)
347
348func RegisterEventSource(uncServerName *uint16, sourceName *uint16) (handle Handle, err error) {
349 r0, _, e1 := syscall.Syscall(procRegisterEventSourceW.Addr(), 2, uintptr(unsafe.Pointer(uncServerName)), uintptr(unsafe.Pointer(sourceName)), 0)
350 handle = Handle(r0)
351 if handle == 0 {
352 if e1 != 0 {
353 err = errnoErr(e1)
354 } else {
355 err = syscall.EINVAL
356 }
357 }
358 return
359}
360
361func DeregisterEventSource(handle Handle) (err error) {
362 r1, _, e1 := syscall.Syscall(procDeregisterEventSource.Addr(), 1, uintptr(handle), 0, 0)
363 if r1 == 0 {
364 if e1 != 0 {
365 err = errnoErr(e1)
366 } else {
367 err = syscall.EINVAL
368 }
369 }
370 return
371}
372
373func ReportEvent(log Handle, etype uint16, category uint16, eventId uint32, usrSId uintptr, numStrings uint16, dataSize uint32, strings **uint16, rawData *byte) (err error) {
374 r1, _, e1 := syscall.Syscall9(procReportEventW.Addr(), 9, uintptr(log), uintptr(etype), uintptr(category), uintptr(eventId), uintptr(usrSId), uintptr(numStrings), uintptr(dataSize), uintptr(unsafe.Pointer(strings)), uintptr(unsafe.Pointer(rawData)))
375 if r1 == 0 {
376 if e1 != 0 {
377 err = errnoErr(e1)
378 } else {
379 err = syscall.EINVAL
380 }
381 }
382 return
383}
384
385func OpenSCManager(machineName *uint16, databaseName *uint16, access uint32) (handle Handle, err error) {
386 r0, _, e1 := syscall.Syscall(procOpenSCManagerW.Addr(), 3, uintptr(unsafe.Pointer(machineName)), uintptr(unsafe.Pointer(databaseName)), uintptr(access))
387 handle = Handle(r0)
388 if handle == 0 {
389 if e1 != 0 {
390 err = errnoErr(e1)
391 } else {
392 err = syscall.EINVAL
393 }
394 }
395 return
396}
397
398func CloseServiceHandle(handle Handle) (err error) {
399 r1, _, e1 := syscall.Syscall(procCloseServiceHandle.Addr(), 1, uintptr(handle), 0, 0)
400 if r1 == 0 {
401 if e1 != 0 {
402 err = errnoErr(e1)
403 } else {
404 err = syscall.EINVAL
405 }
406 }
407 return
408}
409
410func CreateService(mgr Handle, serviceName *uint16, displayName *uint16, access uint32, srvType uint32, startType uint32, errCtl uint32, pathName *uint16, loadOrderGroup *uint16, tagId *uint32, dependencies *uint16, serviceStartName *uint16, password *uint16) (handle Handle, err error) {
411 r0, _, e1 := syscall.Syscall15(procCreateServiceW.Addr(), 13, uintptr(mgr), uintptr(unsafe.Pointer(serviceName)), uintptr(unsafe.Pointer(displayName)), uintptr(access), uintptr(srvType), uintptr(startType), uintptr(errCtl), uintptr(unsafe.Pointer(pathName)), uintptr(unsafe.Pointer(loadOrderGroup)), uintptr(unsafe.Pointer(tagId)), uintptr(unsafe.Pointer(dependencies)), uintptr(unsafe.Pointer(serviceStartName)), uintptr(unsafe.Pointer(password)), 0, 0)
412 handle = Handle(r0)
413 if handle == 0 {
414 if e1 != 0 {
415 err = errnoErr(e1)
416 } else {
417 err = syscall.EINVAL
418 }
419 }
420 return
421}
422
423func OpenService(mgr Handle, serviceName *uint16, access uint32) (handle Handle, err error) {
424 r0, _, e1 := syscall.Syscall(procOpenServiceW.Addr(), 3, uintptr(mgr), uintptr(unsafe.Pointer(serviceName)), uintptr(access))
425 handle = Handle(r0)
426 if handle == 0 {
427 if e1 != 0 {
428 err = errnoErr(e1)
429 } else {
430 err = syscall.EINVAL
431 }
432 }
433 return
434}
435
436func DeleteService(service Handle) (err error) {
437 r1, _, e1 := syscall.Syscall(procDeleteService.Addr(), 1, uintptr(service), 0, 0)
438 if r1 == 0 {
439 if e1 != 0 {
440 err = errnoErr(e1)
441 } else {
442 err = syscall.EINVAL
443 }
444 }
445 return
446}
447
448func StartService(service Handle, numArgs uint32, argVectors **uint16) (err error) {
449 r1, _, e1 := syscall.Syscall(procStartServiceW.Addr(), 3, uintptr(service), uintptr(numArgs), uintptr(unsafe.Pointer(argVectors)))
450 if r1 == 0 {
451 if e1 != 0 {
452 err = errnoErr(e1)
453 } else {
454 err = syscall.EINVAL
455 }
456 }
457 return
458}
459
460func QueryServiceStatus(service Handle, status *SERVICE_STATUS) (err error) {
461 r1, _, e1 := syscall.Syscall(procQueryServiceStatus.Addr(), 2, uintptr(service), uintptr(unsafe.Pointer(status)), 0)
462 if r1 == 0 {
463 if e1 != 0 {
464 err = errnoErr(e1)
465 } else {
466 err = syscall.EINVAL
467 }
468 }
469 return
470}
471
divyadesai19009132020-03-04 12:58:08 +0000472func QueryServiceLockStatus(mgr Handle, lockStatus *QUERY_SERVICE_LOCK_STATUS, bufSize uint32, bytesNeeded *uint32) (err error) {
473 r1, _, e1 := syscall.Syscall6(procQueryServiceLockStatusW.Addr(), 4, uintptr(mgr), uintptr(unsafe.Pointer(lockStatus)), uintptr(bufSize), uintptr(unsafe.Pointer(bytesNeeded)), 0, 0)
474 if r1 == 0 {
475 if e1 != 0 {
476 err = errnoErr(e1)
477 } else {
478 err = syscall.EINVAL
479 }
480 }
481 return
482}
483
Zack Williamse940c7a2019-08-21 14:25:39 -0700484func ControlService(service Handle, control uint32, status *SERVICE_STATUS) (err error) {
485 r1, _, e1 := syscall.Syscall(procControlService.Addr(), 3, uintptr(service), uintptr(control), uintptr(unsafe.Pointer(status)))
486 if r1 == 0 {
487 if e1 != 0 {
488 err = errnoErr(e1)
489 } else {
490 err = syscall.EINVAL
491 }
492 }
493 return
494}
495
496func StartServiceCtrlDispatcher(serviceTable *SERVICE_TABLE_ENTRY) (err error) {
497 r1, _, e1 := syscall.Syscall(procStartServiceCtrlDispatcherW.Addr(), 1, uintptr(unsafe.Pointer(serviceTable)), 0, 0)
498 if r1 == 0 {
499 if e1 != 0 {
500 err = errnoErr(e1)
501 } else {
502 err = syscall.EINVAL
503 }
504 }
505 return
506}
507
508func SetServiceStatus(service Handle, serviceStatus *SERVICE_STATUS) (err error) {
509 r1, _, e1 := syscall.Syscall(procSetServiceStatus.Addr(), 2, uintptr(service), uintptr(unsafe.Pointer(serviceStatus)), 0)
510 if r1 == 0 {
511 if e1 != 0 {
512 err = errnoErr(e1)
513 } else {
514 err = syscall.EINVAL
515 }
516 }
517 return
518}
519
520func ChangeServiceConfig(service Handle, serviceType uint32, startType uint32, errorControl uint32, binaryPathName *uint16, loadOrderGroup *uint16, tagId *uint32, dependencies *uint16, serviceStartName *uint16, password *uint16, displayName *uint16) (err error) {
521 r1, _, e1 := syscall.Syscall12(procChangeServiceConfigW.Addr(), 11, uintptr(service), uintptr(serviceType), uintptr(startType), uintptr(errorControl), uintptr(unsafe.Pointer(binaryPathName)), uintptr(unsafe.Pointer(loadOrderGroup)), uintptr(unsafe.Pointer(tagId)), uintptr(unsafe.Pointer(dependencies)), uintptr(unsafe.Pointer(serviceStartName)), uintptr(unsafe.Pointer(password)), uintptr(unsafe.Pointer(displayName)), 0)
522 if r1 == 0 {
523 if e1 != 0 {
524 err = errnoErr(e1)
525 } else {
526 err = syscall.EINVAL
527 }
528 }
529 return
530}
531
532func QueryServiceConfig(service Handle, serviceConfig *QUERY_SERVICE_CONFIG, bufSize uint32, bytesNeeded *uint32) (err error) {
533 r1, _, e1 := syscall.Syscall6(procQueryServiceConfigW.Addr(), 4, uintptr(service), uintptr(unsafe.Pointer(serviceConfig)), uintptr(bufSize), uintptr(unsafe.Pointer(bytesNeeded)), 0, 0)
534 if r1 == 0 {
535 if e1 != 0 {
536 err = errnoErr(e1)
537 } else {
538 err = syscall.EINVAL
539 }
540 }
541 return
542}
543
544func ChangeServiceConfig2(service Handle, infoLevel uint32, info *byte) (err error) {
545 r1, _, e1 := syscall.Syscall(procChangeServiceConfig2W.Addr(), 3, uintptr(service), uintptr(infoLevel), uintptr(unsafe.Pointer(info)))
546 if r1 == 0 {
547 if e1 != 0 {
548 err = errnoErr(e1)
549 } else {
550 err = syscall.EINVAL
551 }
552 }
553 return
554}
555
556func QueryServiceConfig2(service Handle, infoLevel uint32, buff *byte, buffSize uint32, bytesNeeded *uint32) (err error) {
557 r1, _, e1 := syscall.Syscall6(procQueryServiceConfig2W.Addr(), 5, uintptr(service), uintptr(infoLevel), uintptr(unsafe.Pointer(buff)), uintptr(buffSize), uintptr(unsafe.Pointer(bytesNeeded)), 0)
558 if r1 == 0 {
559 if e1 != 0 {
560 err = errnoErr(e1)
561 } else {
562 err = syscall.EINVAL
563 }
564 }
565 return
566}
567
568func EnumServicesStatusEx(mgr Handle, infoLevel uint32, serviceType uint32, serviceState uint32, services *byte, bufSize uint32, bytesNeeded *uint32, servicesReturned *uint32, resumeHandle *uint32, groupName *uint16) (err error) {
569 r1, _, e1 := syscall.Syscall12(procEnumServicesStatusExW.Addr(), 10, uintptr(mgr), uintptr(infoLevel), uintptr(serviceType), uintptr(serviceState), uintptr(unsafe.Pointer(services)), uintptr(bufSize), uintptr(unsafe.Pointer(bytesNeeded)), uintptr(unsafe.Pointer(servicesReturned)), uintptr(unsafe.Pointer(resumeHandle)), uintptr(unsafe.Pointer(groupName)), 0, 0)
570 if r1 == 0 {
571 if e1 != 0 {
572 err = errnoErr(e1)
573 } else {
574 err = syscall.EINVAL
575 }
576 }
577 return
578}
579
580func QueryServiceStatusEx(service Handle, infoLevel uint32, buff *byte, buffSize uint32, bytesNeeded *uint32) (err error) {
581 r1, _, e1 := syscall.Syscall6(procQueryServiceStatusEx.Addr(), 5, uintptr(service), uintptr(infoLevel), uintptr(unsafe.Pointer(buff)), uintptr(buffSize), uintptr(unsafe.Pointer(bytesNeeded)), 0)
582 if r1 == 0 {
583 if e1 != 0 {
584 err = errnoErr(e1)
585 } else {
586 err = syscall.EINVAL
587 }
588 }
589 return
590}
591
592func NotifyServiceStatusChange(service Handle, notifyMask uint32, notifier *SERVICE_NOTIFY) (ret error) {
593 r0, _, _ := syscall.Syscall(procNotifyServiceStatusChangeW.Addr(), 3, uintptr(service), uintptr(notifyMask), uintptr(unsafe.Pointer(notifier)))
594 if r0 != 0 {
595 ret = syscall.Errno(r0)
596 }
597 return
598}
599
600func GetLastError() (lasterr error) {
601 r0, _, _ := syscall.Syscall(procGetLastError.Addr(), 0, 0, 0, 0)
602 if r0 != 0 {
603 lasterr = syscall.Errno(r0)
604 }
605 return
606}
607
608func LoadLibrary(libname string) (handle Handle, err error) {
609 var _p0 *uint16
610 _p0, err = syscall.UTF16PtrFromString(libname)
611 if err != nil {
612 return
613 }
614 return _LoadLibrary(_p0)
615}
616
617func _LoadLibrary(libname *uint16) (handle Handle, err error) {
618 r0, _, e1 := syscall.Syscall(procLoadLibraryW.Addr(), 1, uintptr(unsafe.Pointer(libname)), 0, 0)
619 handle = Handle(r0)
620 if handle == 0 {
621 if e1 != 0 {
622 err = errnoErr(e1)
623 } else {
624 err = syscall.EINVAL
625 }
626 }
627 return
628}
629
630func LoadLibraryEx(libname string, zero Handle, flags uintptr) (handle Handle, err error) {
631 var _p0 *uint16
632 _p0, err = syscall.UTF16PtrFromString(libname)
633 if err != nil {
634 return
635 }
636 return _LoadLibraryEx(_p0, zero, flags)
637}
638
639func _LoadLibraryEx(libname *uint16, zero Handle, flags uintptr) (handle Handle, err error) {
640 r0, _, e1 := syscall.Syscall(procLoadLibraryExW.Addr(), 3, uintptr(unsafe.Pointer(libname)), uintptr(zero), uintptr(flags))
641 handle = Handle(r0)
642 if handle == 0 {
643 if e1 != 0 {
644 err = errnoErr(e1)
645 } else {
646 err = syscall.EINVAL
647 }
648 }
649 return
650}
651
652func FreeLibrary(handle Handle) (err error) {
653 r1, _, e1 := syscall.Syscall(procFreeLibrary.Addr(), 1, uintptr(handle), 0, 0)
654 if r1 == 0 {
655 if e1 != 0 {
656 err = errnoErr(e1)
657 } else {
658 err = syscall.EINVAL
659 }
660 }
661 return
662}
663
664func GetProcAddress(module Handle, procname string) (proc uintptr, err error) {
665 var _p0 *byte
666 _p0, err = syscall.BytePtrFromString(procname)
667 if err != nil {
668 return
669 }
670 return _GetProcAddress(module, _p0)
671}
672
673func _GetProcAddress(module Handle, procname *byte) (proc uintptr, err error) {
674 r0, _, e1 := syscall.Syscall(procGetProcAddress.Addr(), 2, uintptr(module), uintptr(unsafe.Pointer(procname)), 0)
675 proc = uintptr(r0)
676 if proc == 0 {
677 if e1 != 0 {
678 err = errnoErr(e1)
679 } else {
680 err = syscall.EINVAL
681 }
682 }
683 return
684}
685
686func GetVersion() (ver uint32, err error) {
687 r0, _, e1 := syscall.Syscall(procGetVersion.Addr(), 0, 0, 0, 0)
688 ver = uint32(r0)
689 if ver == 0 {
690 if e1 != 0 {
691 err = errnoErr(e1)
692 } else {
693 err = syscall.EINVAL
694 }
695 }
696 return
697}
698
699func FormatMessage(flags uint32, msgsrc uintptr, msgid uint32, langid uint32, buf []uint16, args *byte) (n uint32, err error) {
700 var _p0 *uint16
701 if len(buf) > 0 {
702 _p0 = &buf[0]
703 }
704 r0, _, e1 := syscall.Syscall9(procFormatMessageW.Addr(), 7, uintptr(flags), uintptr(msgsrc), uintptr(msgid), uintptr(langid), uintptr(unsafe.Pointer(_p0)), uintptr(len(buf)), uintptr(unsafe.Pointer(args)), 0, 0)
705 n = uint32(r0)
706 if n == 0 {
707 if e1 != 0 {
708 err = errnoErr(e1)
709 } else {
710 err = syscall.EINVAL
711 }
712 }
713 return
714}
715
716func ExitProcess(exitcode uint32) {
717 syscall.Syscall(procExitProcess.Addr(), 1, uintptr(exitcode), 0, 0)
718 return
719}
720
721func IsWow64Process(handle Handle, isWow64 *bool) (err error) {
divyadesai19009132020-03-04 12:58:08 +0000722 var _p0 uint32
723 if *isWow64 {
724 _p0 = 1
725 } else {
726 _p0 = 0
727 }
728 r1, _, e1 := syscall.Syscall(procIsWow64Process.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(&_p0)), 0)
729 *isWow64 = _p0 != 0
Zack Williamse940c7a2019-08-21 14:25:39 -0700730 if r1 == 0 {
731 if e1 != 0 {
732 err = errnoErr(e1)
733 } else {
734 err = syscall.EINVAL
735 }
736 }
737 return
738}
739
740func CreateFile(name *uint16, access uint32, mode uint32, sa *SecurityAttributes, createmode uint32, attrs uint32, templatefile Handle) (handle Handle, err error) {
741 r0, _, e1 := syscall.Syscall9(procCreateFileW.Addr(), 7, uintptr(unsafe.Pointer(name)), uintptr(access), uintptr(mode), uintptr(unsafe.Pointer(sa)), uintptr(createmode), uintptr(attrs), uintptr(templatefile), 0, 0)
742 handle = Handle(r0)
743 if handle == InvalidHandle {
744 if e1 != 0 {
745 err = errnoErr(e1)
746 } else {
747 err = syscall.EINVAL
748 }
749 }
750 return
751}
752
753func ReadFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) (err error) {
754 var _p0 *byte
755 if len(buf) > 0 {
756 _p0 = &buf[0]
757 }
758 r1, _, e1 := syscall.Syscall6(procReadFile.Addr(), 5, uintptr(handle), uintptr(unsafe.Pointer(_p0)), uintptr(len(buf)), uintptr(unsafe.Pointer(done)), uintptr(unsafe.Pointer(overlapped)), 0)
759 if r1 == 0 {
760 if e1 != 0 {
761 err = errnoErr(e1)
762 } else {
763 err = syscall.EINVAL
764 }
765 }
766 return
767}
768
769func WriteFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) (err error) {
770 var _p0 *byte
771 if len(buf) > 0 {
772 _p0 = &buf[0]
773 }
774 r1, _, e1 := syscall.Syscall6(procWriteFile.Addr(), 5, uintptr(handle), uintptr(unsafe.Pointer(_p0)), uintptr(len(buf)), uintptr(unsafe.Pointer(done)), uintptr(unsafe.Pointer(overlapped)), 0)
775 if r1 == 0 {
776 if e1 != 0 {
777 err = errnoErr(e1)
778 } else {
779 err = syscall.EINVAL
780 }
781 }
782 return
783}
784
785func GetOverlappedResult(handle Handle, overlapped *Overlapped, done *uint32, wait bool) (err error) {
786 var _p0 uint32
787 if wait {
788 _p0 = 1
789 } else {
790 _p0 = 0
791 }
792 r1, _, e1 := syscall.Syscall6(procGetOverlappedResult.Addr(), 4, uintptr(handle), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(done)), uintptr(_p0), 0, 0)
793 if r1 == 0 {
794 if e1 != 0 {
795 err = errnoErr(e1)
796 } else {
797 err = syscall.EINVAL
798 }
799 }
800 return
801}
802
803func SetFilePointer(handle Handle, lowoffset int32, highoffsetptr *int32, whence uint32) (newlowoffset uint32, err error) {
804 r0, _, e1 := syscall.Syscall6(procSetFilePointer.Addr(), 4, uintptr(handle), uintptr(lowoffset), uintptr(unsafe.Pointer(highoffsetptr)), uintptr(whence), 0, 0)
805 newlowoffset = uint32(r0)
806 if newlowoffset == 0xffffffff {
807 if e1 != 0 {
808 err = errnoErr(e1)
809 } else {
810 err = syscall.EINVAL
811 }
812 }
813 return
814}
815
816func CloseHandle(handle Handle) (err error) {
817 r1, _, e1 := syscall.Syscall(procCloseHandle.Addr(), 1, uintptr(handle), 0, 0)
818 if r1 == 0 {
819 if e1 != 0 {
820 err = errnoErr(e1)
821 } else {
822 err = syscall.EINVAL
823 }
824 }
825 return
826}
827
828func GetStdHandle(stdhandle uint32) (handle Handle, err error) {
829 r0, _, e1 := syscall.Syscall(procGetStdHandle.Addr(), 1, uintptr(stdhandle), 0, 0)
830 handle = Handle(r0)
831 if handle == InvalidHandle {
832 if e1 != 0 {
833 err = errnoErr(e1)
834 } else {
835 err = syscall.EINVAL
836 }
837 }
838 return
839}
840
841func SetStdHandle(stdhandle uint32, handle Handle) (err error) {
842 r1, _, e1 := syscall.Syscall(procSetStdHandle.Addr(), 2, uintptr(stdhandle), uintptr(handle), 0)
843 if r1 == 0 {
844 if e1 != 0 {
845 err = errnoErr(e1)
846 } else {
847 err = syscall.EINVAL
848 }
849 }
850 return
851}
852
853func findFirstFile1(name *uint16, data *win32finddata1) (handle Handle, err error) {
854 r0, _, e1 := syscall.Syscall(procFindFirstFileW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(data)), 0)
855 handle = Handle(r0)
856 if handle == InvalidHandle {
857 if e1 != 0 {
858 err = errnoErr(e1)
859 } else {
860 err = syscall.EINVAL
861 }
862 }
863 return
864}
865
866func findNextFile1(handle Handle, data *win32finddata1) (err error) {
867 r1, _, e1 := syscall.Syscall(procFindNextFileW.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(data)), 0)
868 if r1 == 0 {
869 if e1 != 0 {
870 err = errnoErr(e1)
871 } else {
872 err = syscall.EINVAL
873 }
874 }
875 return
876}
877
878func FindClose(handle Handle) (err error) {
879 r1, _, e1 := syscall.Syscall(procFindClose.Addr(), 1, uintptr(handle), 0, 0)
880 if r1 == 0 {
881 if e1 != 0 {
882 err = errnoErr(e1)
883 } else {
884 err = syscall.EINVAL
885 }
886 }
887 return
888}
889
890func GetFileInformationByHandle(handle Handle, data *ByHandleFileInformation) (err error) {
891 r1, _, e1 := syscall.Syscall(procGetFileInformationByHandle.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(data)), 0)
892 if r1 == 0 {
893 if e1 != 0 {
894 err = errnoErr(e1)
895 } else {
896 err = syscall.EINVAL
897 }
898 }
899 return
900}
901
902func GetFileInformationByHandleEx(handle Handle, class uint32, outBuffer *byte, outBufferLen uint32) (err error) {
903 r1, _, e1 := syscall.Syscall6(procGetFileInformationByHandleEx.Addr(), 4, uintptr(handle), uintptr(class), uintptr(unsafe.Pointer(outBuffer)), uintptr(outBufferLen), 0, 0)
904 if r1 == 0 {
905 if e1 != 0 {
906 err = errnoErr(e1)
907 } else {
908 err = syscall.EINVAL
909 }
910 }
911 return
912}
913
914func GetCurrentDirectory(buflen uint32, buf *uint16) (n uint32, err error) {
915 r0, _, e1 := syscall.Syscall(procGetCurrentDirectoryW.Addr(), 2, uintptr(buflen), uintptr(unsafe.Pointer(buf)), 0)
916 n = uint32(r0)
917 if n == 0 {
918 if e1 != 0 {
919 err = errnoErr(e1)
920 } else {
921 err = syscall.EINVAL
922 }
923 }
924 return
925}
926
927func SetCurrentDirectory(path *uint16) (err error) {
928 r1, _, e1 := syscall.Syscall(procSetCurrentDirectoryW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0)
929 if r1 == 0 {
930 if e1 != 0 {
931 err = errnoErr(e1)
932 } else {
933 err = syscall.EINVAL
934 }
935 }
936 return
937}
938
939func CreateDirectory(path *uint16, sa *SecurityAttributes) (err error) {
940 r1, _, e1 := syscall.Syscall(procCreateDirectoryW.Addr(), 2, uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(sa)), 0)
941 if r1 == 0 {
942 if e1 != 0 {
943 err = errnoErr(e1)
944 } else {
945 err = syscall.EINVAL
946 }
947 }
948 return
949}
950
951func RemoveDirectory(path *uint16) (err error) {
952 r1, _, e1 := syscall.Syscall(procRemoveDirectoryW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0)
953 if r1 == 0 {
954 if e1 != 0 {
955 err = errnoErr(e1)
956 } else {
957 err = syscall.EINVAL
958 }
959 }
960 return
961}
962
963func DeleteFile(path *uint16) (err error) {
964 r1, _, e1 := syscall.Syscall(procDeleteFileW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0)
965 if r1 == 0 {
966 if e1 != 0 {
967 err = errnoErr(e1)
968 } else {
969 err = syscall.EINVAL
970 }
971 }
972 return
973}
974
975func MoveFile(from *uint16, to *uint16) (err error) {
976 r1, _, e1 := syscall.Syscall(procMoveFileW.Addr(), 2, uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(to)), 0)
977 if r1 == 0 {
978 if e1 != 0 {
979 err = errnoErr(e1)
980 } else {
981 err = syscall.EINVAL
982 }
983 }
984 return
985}
986
987func MoveFileEx(from *uint16, to *uint16, flags uint32) (err error) {
988 r1, _, e1 := syscall.Syscall(procMoveFileExW.Addr(), 3, uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(to)), uintptr(flags))
989 if r1 == 0 {
990 if e1 != 0 {
991 err = errnoErr(e1)
992 } else {
993 err = syscall.EINVAL
994 }
995 }
996 return
997}
998
divyadesai19009132020-03-04 12:58:08 +0000999func LockFileEx(file Handle, flags uint32, reserved uint32, bytesLow uint32, bytesHigh uint32, overlapped *Overlapped) (err error) {
1000 r1, _, e1 := syscall.Syscall6(procLockFileEx.Addr(), 6, uintptr(file), uintptr(flags), uintptr(reserved), uintptr(bytesLow), uintptr(bytesHigh), uintptr(unsafe.Pointer(overlapped)))
1001 if r1 == 0 {
1002 if e1 != 0 {
1003 err = errnoErr(e1)
1004 } else {
1005 err = syscall.EINVAL
1006 }
1007 }
1008 return
1009}
1010
1011func UnlockFileEx(file Handle, reserved uint32, bytesLow uint32, bytesHigh uint32, overlapped *Overlapped) (err error) {
1012 r1, _, e1 := syscall.Syscall6(procUnlockFileEx.Addr(), 5, uintptr(file), uintptr(reserved), uintptr(bytesLow), uintptr(bytesHigh), uintptr(unsafe.Pointer(overlapped)), 0)
1013 if r1 == 0 {
1014 if e1 != 0 {
1015 err = errnoErr(e1)
1016 } else {
1017 err = syscall.EINVAL
1018 }
1019 }
1020 return
1021}
1022
Zack Williamse940c7a2019-08-21 14:25:39 -07001023func GetComputerName(buf *uint16, n *uint32) (err error) {
1024 r1, _, e1 := syscall.Syscall(procGetComputerNameW.Addr(), 2, uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(n)), 0)
1025 if r1 == 0 {
1026 if e1 != 0 {
1027 err = errnoErr(e1)
1028 } else {
1029 err = syscall.EINVAL
1030 }
1031 }
1032 return
1033}
1034
1035func GetComputerNameEx(nametype uint32, buf *uint16, n *uint32) (err error) {
1036 r1, _, e1 := syscall.Syscall(procGetComputerNameExW.Addr(), 3, uintptr(nametype), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(n)))
1037 if r1 == 0 {
1038 if e1 != 0 {
1039 err = errnoErr(e1)
1040 } else {
1041 err = syscall.EINVAL
1042 }
1043 }
1044 return
1045}
1046
1047func SetEndOfFile(handle Handle) (err error) {
1048 r1, _, e1 := syscall.Syscall(procSetEndOfFile.Addr(), 1, uintptr(handle), 0, 0)
1049 if r1 == 0 {
1050 if e1 != 0 {
1051 err = errnoErr(e1)
1052 } else {
1053 err = syscall.EINVAL
1054 }
1055 }
1056 return
1057}
1058
1059func GetSystemTimeAsFileTime(time *Filetime) {
1060 syscall.Syscall(procGetSystemTimeAsFileTime.Addr(), 1, uintptr(unsafe.Pointer(time)), 0, 0)
1061 return
1062}
1063
1064func GetSystemTimePreciseAsFileTime(time *Filetime) {
1065 syscall.Syscall(procGetSystemTimePreciseAsFileTime.Addr(), 1, uintptr(unsafe.Pointer(time)), 0, 0)
1066 return
1067}
1068
1069func GetTimeZoneInformation(tzi *Timezoneinformation) (rc uint32, err error) {
1070 r0, _, e1 := syscall.Syscall(procGetTimeZoneInformation.Addr(), 1, uintptr(unsafe.Pointer(tzi)), 0, 0)
1071 rc = uint32(r0)
1072 if rc == 0xffffffff {
1073 if e1 != 0 {
1074 err = errnoErr(e1)
1075 } else {
1076 err = syscall.EINVAL
1077 }
1078 }
1079 return
1080}
1081
1082func CreateIoCompletionPort(filehandle Handle, cphandle Handle, key uint32, threadcnt uint32) (handle Handle, err error) {
1083 r0, _, e1 := syscall.Syscall6(procCreateIoCompletionPort.Addr(), 4, uintptr(filehandle), uintptr(cphandle), uintptr(key), uintptr(threadcnt), 0, 0)
1084 handle = Handle(r0)
1085 if handle == 0 {
1086 if e1 != 0 {
1087 err = errnoErr(e1)
1088 } else {
1089 err = syscall.EINVAL
1090 }
1091 }
1092 return
1093}
1094
1095func GetQueuedCompletionStatus(cphandle Handle, qty *uint32, key *uint32, overlapped **Overlapped, timeout uint32) (err error) {
1096 r1, _, e1 := syscall.Syscall6(procGetQueuedCompletionStatus.Addr(), 5, uintptr(cphandle), uintptr(unsafe.Pointer(qty)), uintptr(unsafe.Pointer(key)), uintptr(unsafe.Pointer(overlapped)), uintptr(timeout), 0)
1097 if r1 == 0 {
1098 if e1 != 0 {
1099 err = errnoErr(e1)
1100 } else {
1101 err = syscall.EINVAL
1102 }
1103 }
1104 return
1105}
1106
1107func PostQueuedCompletionStatus(cphandle Handle, qty uint32, key uint32, overlapped *Overlapped) (err error) {
1108 r1, _, e1 := syscall.Syscall6(procPostQueuedCompletionStatus.Addr(), 4, uintptr(cphandle), uintptr(qty), uintptr(key), uintptr(unsafe.Pointer(overlapped)), 0, 0)
1109 if r1 == 0 {
1110 if e1 != 0 {
1111 err = errnoErr(e1)
1112 } else {
1113 err = syscall.EINVAL
1114 }
1115 }
1116 return
1117}
1118
1119func CancelIo(s Handle) (err error) {
1120 r1, _, e1 := syscall.Syscall(procCancelIo.Addr(), 1, uintptr(s), 0, 0)
1121 if r1 == 0 {
1122 if e1 != 0 {
1123 err = errnoErr(e1)
1124 } else {
1125 err = syscall.EINVAL
1126 }
1127 }
1128 return
1129}
1130
1131func CancelIoEx(s Handle, o *Overlapped) (err error) {
1132 r1, _, e1 := syscall.Syscall(procCancelIoEx.Addr(), 2, uintptr(s), uintptr(unsafe.Pointer(o)), 0)
1133 if r1 == 0 {
1134 if e1 != 0 {
1135 err = errnoErr(e1)
1136 } else {
1137 err = syscall.EINVAL
1138 }
1139 }
1140 return
1141}
1142
1143func CreateProcess(appName *uint16, commandLine *uint16, procSecurity *SecurityAttributes, threadSecurity *SecurityAttributes, inheritHandles bool, creationFlags uint32, env *uint16, currentDir *uint16, startupInfo *StartupInfo, outProcInfo *ProcessInformation) (err error) {
1144 var _p0 uint32
1145 if inheritHandles {
1146 _p0 = 1
1147 } else {
1148 _p0 = 0
1149 }
1150 r1, _, e1 := syscall.Syscall12(procCreateProcessW.Addr(), 10, uintptr(unsafe.Pointer(appName)), uintptr(unsafe.Pointer(commandLine)), uintptr(unsafe.Pointer(procSecurity)), uintptr(unsafe.Pointer(threadSecurity)), uintptr(_p0), uintptr(creationFlags), uintptr(unsafe.Pointer(env)), uintptr(unsafe.Pointer(currentDir)), uintptr(unsafe.Pointer(startupInfo)), uintptr(unsafe.Pointer(outProcInfo)), 0, 0)
1151 if r1 == 0 {
1152 if e1 != 0 {
1153 err = errnoErr(e1)
1154 } else {
1155 err = syscall.EINVAL
1156 }
1157 }
1158 return
1159}
1160
divyadesai19009132020-03-04 12:58:08 +00001161func OpenProcess(desiredAccess uint32, inheritHandle bool, processId uint32) (handle Handle, err error) {
Zack Williamse940c7a2019-08-21 14:25:39 -07001162 var _p0 uint32
1163 if inheritHandle {
1164 _p0 = 1
1165 } else {
1166 _p0 = 0
1167 }
divyadesai19009132020-03-04 12:58:08 +00001168 r0, _, e1 := syscall.Syscall(procOpenProcess.Addr(), 3, uintptr(desiredAccess), uintptr(_p0), uintptr(processId))
Zack Williamse940c7a2019-08-21 14:25:39 -07001169 handle = Handle(r0)
1170 if handle == 0 {
1171 if e1 != 0 {
1172 err = errnoErr(e1)
1173 } else {
1174 err = syscall.EINVAL
1175 }
1176 }
1177 return
1178}
1179
1180func ShellExecute(hwnd Handle, verb *uint16, file *uint16, args *uint16, cwd *uint16, showCmd int32) (err error) {
1181 r1, _, e1 := syscall.Syscall6(procShellExecuteW.Addr(), 6, uintptr(hwnd), uintptr(unsafe.Pointer(verb)), uintptr(unsafe.Pointer(file)), uintptr(unsafe.Pointer(args)), uintptr(unsafe.Pointer(cwd)), uintptr(showCmd))
1182 if r1 == 0 {
1183 if e1 != 0 {
1184 err = errnoErr(e1)
1185 } else {
1186 err = syscall.EINVAL
1187 }
1188 }
1189 return
1190}
1191
divyadesai19009132020-03-04 12:58:08 +00001192func shGetKnownFolderPath(id *KNOWNFOLDERID, flags uint32, token Token, path **uint16) (ret error) {
1193 r0, _, _ := syscall.Syscall6(procSHGetKnownFolderPath.Addr(), 4, uintptr(unsafe.Pointer(id)), uintptr(flags), uintptr(token), uintptr(unsafe.Pointer(path)), 0, 0)
1194 if r0 != 0 {
1195 ret = syscall.Errno(r0)
1196 }
1197 return
1198}
1199
Zack Williamse940c7a2019-08-21 14:25:39 -07001200func TerminateProcess(handle Handle, exitcode uint32) (err error) {
1201 r1, _, e1 := syscall.Syscall(procTerminateProcess.Addr(), 2, uintptr(handle), uintptr(exitcode), 0)
1202 if r1 == 0 {
1203 if e1 != 0 {
1204 err = errnoErr(e1)
1205 } else {
1206 err = syscall.EINVAL
1207 }
1208 }
1209 return
1210}
1211
1212func GetExitCodeProcess(handle Handle, exitcode *uint32) (err error) {
1213 r1, _, e1 := syscall.Syscall(procGetExitCodeProcess.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(exitcode)), 0)
1214 if r1 == 0 {
1215 if e1 != 0 {
1216 err = errnoErr(e1)
1217 } else {
1218 err = syscall.EINVAL
1219 }
1220 }
1221 return
1222}
1223
1224func GetStartupInfo(startupInfo *StartupInfo) (err error) {
1225 r1, _, e1 := syscall.Syscall(procGetStartupInfoW.Addr(), 1, uintptr(unsafe.Pointer(startupInfo)), 0, 0)
1226 if r1 == 0 {
1227 if e1 != 0 {
1228 err = errnoErr(e1)
1229 } else {
1230 err = syscall.EINVAL
1231 }
1232 }
1233 return
1234}
1235
Zack Williamse940c7a2019-08-21 14:25:39 -07001236func GetProcessTimes(handle Handle, creationTime *Filetime, exitTime *Filetime, kernelTime *Filetime, userTime *Filetime) (err error) {
1237 r1, _, e1 := syscall.Syscall6(procGetProcessTimes.Addr(), 5, uintptr(handle), uintptr(unsafe.Pointer(creationTime)), uintptr(unsafe.Pointer(exitTime)), uintptr(unsafe.Pointer(kernelTime)), uintptr(unsafe.Pointer(userTime)), 0)
1238 if r1 == 0 {
1239 if e1 != 0 {
1240 err = errnoErr(e1)
1241 } else {
1242 err = syscall.EINVAL
1243 }
1244 }
1245 return
1246}
1247
1248func DuplicateHandle(hSourceProcessHandle Handle, hSourceHandle Handle, hTargetProcessHandle Handle, lpTargetHandle *Handle, dwDesiredAccess uint32, bInheritHandle bool, dwOptions uint32) (err error) {
1249 var _p0 uint32
1250 if bInheritHandle {
1251 _p0 = 1
1252 } else {
1253 _p0 = 0
1254 }
1255 r1, _, e1 := syscall.Syscall9(procDuplicateHandle.Addr(), 7, uintptr(hSourceProcessHandle), uintptr(hSourceHandle), uintptr(hTargetProcessHandle), uintptr(unsafe.Pointer(lpTargetHandle)), uintptr(dwDesiredAccess), uintptr(_p0), uintptr(dwOptions), 0, 0)
1256 if r1 == 0 {
1257 if e1 != 0 {
1258 err = errnoErr(e1)
1259 } else {
1260 err = syscall.EINVAL
1261 }
1262 }
1263 return
1264}
1265
1266func WaitForSingleObject(handle Handle, waitMilliseconds uint32) (event uint32, err error) {
1267 r0, _, e1 := syscall.Syscall(procWaitForSingleObject.Addr(), 2, uintptr(handle), uintptr(waitMilliseconds), 0)
1268 event = uint32(r0)
1269 if event == 0xffffffff {
1270 if e1 != 0 {
1271 err = errnoErr(e1)
1272 } else {
1273 err = syscall.EINVAL
1274 }
1275 }
1276 return
1277}
1278
1279func waitForMultipleObjects(count uint32, handles uintptr, waitAll bool, waitMilliseconds uint32) (event uint32, err error) {
1280 var _p0 uint32
1281 if waitAll {
1282 _p0 = 1
1283 } else {
1284 _p0 = 0
1285 }
1286 r0, _, e1 := syscall.Syscall6(procWaitForMultipleObjects.Addr(), 4, uintptr(count), uintptr(handles), uintptr(_p0), uintptr(waitMilliseconds), 0, 0)
1287 event = uint32(r0)
1288 if event == 0xffffffff {
1289 if e1 != 0 {
1290 err = errnoErr(e1)
1291 } else {
1292 err = syscall.EINVAL
1293 }
1294 }
1295 return
1296}
1297
1298func GetTempPath(buflen uint32, buf *uint16) (n uint32, err error) {
1299 r0, _, e1 := syscall.Syscall(procGetTempPathW.Addr(), 2, uintptr(buflen), uintptr(unsafe.Pointer(buf)), 0)
1300 n = uint32(r0)
1301 if n == 0 {
1302 if e1 != 0 {
1303 err = errnoErr(e1)
1304 } else {
1305 err = syscall.EINVAL
1306 }
1307 }
1308 return
1309}
1310
1311func CreatePipe(readhandle *Handle, writehandle *Handle, sa *SecurityAttributes, size uint32) (err error) {
1312 r1, _, e1 := syscall.Syscall6(procCreatePipe.Addr(), 4, uintptr(unsafe.Pointer(readhandle)), uintptr(unsafe.Pointer(writehandle)), uintptr(unsafe.Pointer(sa)), uintptr(size), 0, 0)
1313 if r1 == 0 {
1314 if e1 != 0 {
1315 err = errnoErr(e1)
1316 } else {
1317 err = syscall.EINVAL
1318 }
1319 }
1320 return
1321}
1322
1323func GetFileType(filehandle Handle) (n uint32, err error) {
1324 r0, _, e1 := syscall.Syscall(procGetFileType.Addr(), 1, uintptr(filehandle), 0, 0)
1325 n = uint32(r0)
1326 if n == 0 {
1327 if e1 != 0 {
1328 err = errnoErr(e1)
1329 } else {
1330 err = syscall.EINVAL
1331 }
1332 }
1333 return
1334}
1335
1336func CryptAcquireContext(provhandle *Handle, container *uint16, provider *uint16, provtype uint32, flags uint32) (err error) {
1337 r1, _, e1 := syscall.Syscall6(procCryptAcquireContextW.Addr(), 5, uintptr(unsafe.Pointer(provhandle)), uintptr(unsafe.Pointer(container)), uintptr(unsafe.Pointer(provider)), uintptr(provtype), uintptr(flags), 0)
1338 if r1 == 0 {
1339 if e1 != 0 {
1340 err = errnoErr(e1)
1341 } else {
1342 err = syscall.EINVAL
1343 }
1344 }
1345 return
1346}
1347
1348func CryptReleaseContext(provhandle Handle, flags uint32) (err error) {
1349 r1, _, e1 := syscall.Syscall(procCryptReleaseContext.Addr(), 2, uintptr(provhandle), uintptr(flags), 0)
1350 if r1 == 0 {
1351 if e1 != 0 {
1352 err = errnoErr(e1)
1353 } else {
1354 err = syscall.EINVAL
1355 }
1356 }
1357 return
1358}
1359
1360func CryptGenRandom(provhandle Handle, buflen uint32, buf *byte) (err error) {
1361 r1, _, e1 := syscall.Syscall(procCryptGenRandom.Addr(), 3, uintptr(provhandle), uintptr(buflen), uintptr(unsafe.Pointer(buf)))
1362 if r1 == 0 {
1363 if e1 != 0 {
1364 err = errnoErr(e1)
1365 } else {
1366 err = syscall.EINVAL
1367 }
1368 }
1369 return
1370}
1371
1372func GetEnvironmentStrings() (envs *uint16, err error) {
1373 r0, _, e1 := syscall.Syscall(procGetEnvironmentStringsW.Addr(), 0, 0, 0, 0)
1374 envs = (*uint16)(unsafe.Pointer(r0))
1375 if envs == nil {
1376 if e1 != 0 {
1377 err = errnoErr(e1)
1378 } else {
1379 err = syscall.EINVAL
1380 }
1381 }
1382 return
1383}
1384
1385func FreeEnvironmentStrings(envs *uint16) (err error) {
1386 r1, _, e1 := syscall.Syscall(procFreeEnvironmentStringsW.Addr(), 1, uintptr(unsafe.Pointer(envs)), 0, 0)
1387 if r1 == 0 {
1388 if e1 != 0 {
1389 err = errnoErr(e1)
1390 } else {
1391 err = syscall.EINVAL
1392 }
1393 }
1394 return
1395}
1396
1397func GetEnvironmentVariable(name *uint16, buffer *uint16, size uint32) (n uint32, err error) {
1398 r0, _, e1 := syscall.Syscall(procGetEnvironmentVariableW.Addr(), 3, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(buffer)), uintptr(size))
1399 n = uint32(r0)
1400 if n == 0 {
1401 if e1 != 0 {
1402 err = errnoErr(e1)
1403 } else {
1404 err = syscall.EINVAL
1405 }
1406 }
1407 return
1408}
1409
1410func SetEnvironmentVariable(name *uint16, value *uint16) (err error) {
1411 r1, _, e1 := syscall.Syscall(procSetEnvironmentVariableW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(value)), 0)
1412 if r1 == 0 {
1413 if e1 != 0 {
1414 err = errnoErr(e1)
1415 } else {
1416 err = syscall.EINVAL
1417 }
1418 }
1419 return
1420}
1421
1422func CreateEnvironmentBlock(block **uint16, token Token, inheritExisting bool) (err error) {
1423 var _p0 uint32
1424 if inheritExisting {
1425 _p0 = 1
1426 } else {
1427 _p0 = 0
1428 }
1429 r1, _, e1 := syscall.Syscall(procCreateEnvironmentBlock.Addr(), 3, uintptr(unsafe.Pointer(block)), uintptr(token), uintptr(_p0))
1430 if r1 == 0 {
1431 if e1 != 0 {
1432 err = errnoErr(e1)
1433 } else {
1434 err = syscall.EINVAL
1435 }
1436 }
1437 return
1438}
1439
1440func DestroyEnvironmentBlock(block *uint16) (err error) {
1441 r1, _, e1 := syscall.Syscall(procDestroyEnvironmentBlock.Addr(), 1, uintptr(unsafe.Pointer(block)), 0, 0)
1442 if r1 == 0 {
1443 if e1 != 0 {
1444 err = errnoErr(e1)
1445 } else {
1446 err = syscall.EINVAL
1447 }
1448 }
1449 return
1450}
1451
David Bainbridge86971522019-09-26 22:09:39 +00001452func getTickCount64() (ms uint64) {
1453 r0, _, _ := syscall.Syscall(procGetTickCount64.Addr(), 0, 0, 0, 0)
1454 ms = uint64(r0)
1455 return
1456}
1457
Zack Williamse940c7a2019-08-21 14:25:39 -07001458func SetFileTime(handle Handle, ctime *Filetime, atime *Filetime, wtime *Filetime) (err error) {
1459 r1, _, e1 := syscall.Syscall6(procSetFileTime.Addr(), 4, uintptr(handle), uintptr(unsafe.Pointer(ctime)), uintptr(unsafe.Pointer(atime)), uintptr(unsafe.Pointer(wtime)), 0, 0)
1460 if r1 == 0 {
1461 if e1 != 0 {
1462 err = errnoErr(e1)
1463 } else {
1464 err = syscall.EINVAL
1465 }
1466 }
1467 return
1468}
1469
1470func GetFileAttributes(name *uint16) (attrs uint32, err error) {
1471 r0, _, e1 := syscall.Syscall(procGetFileAttributesW.Addr(), 1, uintptr(unsafe.Pointer(name)), 0, 0)
1472 attrs = uint32(r0)
1473 if attrs == INVALID_FILE_ATTRIBUTES {
1474 if e1 != 0 {
1475 err = errnoErr(e1)
1476 } else {
1477 err = syscall.EINVAL
1478 }
1479 }
1480 return
1481}
1482
1483func SetFileAttributes(name *uint16, attrs uint32) (err error) {
1484 r1, _, e1 := syscall.Syscall(procSetFileAttributesW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(attrs), 0)
1485 if r1 == 0 {
1486 if e1 != 0 {
1487 err = errnoErr(e1)
1488 } else {
1489 err = syscall.EINVAL
1490 }
1491 }
1492 return
1493}
1494
1495func GetFileAttributesEx(name *uint16, level uint32, info *byte) (err error) {
1496 r1, _, e1 := syscall.Syscall(procGetFileAttributesExW.Addr(), 3, uintptr(unsafe.Pointer(name)), uintptr(level), uintptr(unsafe.Pointer(info)))
1497 if r1 == 0 {
1498 if e1 != 0 {
1499 err = errnoErr(e1)
1500 } else {
1501 err = syscall.EINVAL
1502 }
1503 }
1504 return
1505}
1506
1507func GetCommandLine() (cmd *uint16) {
1508 r0, _, _ := syscall.Syscall(procGetCommandLineW.Addr(), 0, 0, 0, 0)
1509 cmd = (*uint16)(unsafe.Pointer(r0))
1510 return
1511}
1512
1513func CommandLineToArgv(cmd *uint16, argc *int32) (argv *[8192]*[8192]uint16, err error) {
1514 r0, _, e1 := syscall.Syscall(procCommandLineToArgvW.Addr(), 2, uintptr(unsafe.Pointer(cmd)), uintptr(unsafe.Pointer(argc)), 0)
1515 argv = (*[8192]*[8192]uint16)(unsafe.Pointer(r0))
1516 if argv == nil {
1517 if e1 != 0 {
1518 err = errnoErr(e1)
1519 } else {
1520 err = syscall.EINVAL
1521 }
1522 }
1523 return
1524}
1525
1526func LocalFree(hmem Handle) (handle Handle, err error) {
1527 r0, _, e1 := syscall.Syscall(procLocalFree.Addr(), 1, uintptr(hmem), 0, 0)
1528 handle = Handle(r0)
1529 if handle != 0 {
1530 if e1 != 0 {
1531 err = errnoErr(e1)
1532 } else {
1533 err = syscall.EINVAL
1534 }
1535 }
1536 return
1537}
1538
1539func SetHandleInformation(handle Handle, mask uint32, flags uint32) (err error) {
1540 r1, _, e1 := syscall.Syscall(procSetHandleInformation.Addr(), 3, uintptr(handle), uintptr(mask), uintptr(flags))
1541 if r1 == 0 {
1542 if e1 != 0 {
1543 err = errnoErr(e1)
1544 } else {
1545 err = syscall.EINVAL
1546 }
1547 }
1548 return
1549}
1550
1551func FlushFileBuffers(handle Handle) (err error) {
1552 r1, _, e1 := syscall.Syscall(procFlushFileBuffers.Addr(), 1, uintptr(handle), 0, 0)
1553 if r1 == 0 {
1554 if e1 != 0 {
1555 err = errnoErr(e1)
1556 } else {
1557 err = syscall.EINVAL
1558 }
1559 }
1560 return
1561}
1562
1563func GetFullPathName(path *uint16, buflen uint32, buf *uint16, fname **uint16) (n uint32, err error) {
1564 r0, _, e1 := syscall.Syscall6(procGetFullPathNameW.Addr(), 4, uintptr(unsafe.Pointer(path)), uintptr(buflen), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(fname)), 0, 0)
1565 n = uint32(r0)
1566 if n == 0 {
1567 if e1 != 0 {
1568 err = errnoErr(e1)
1569 } else {
1570 err = syscall.EINVAL
1571 }
1572 }
1573 return
1574}
1575
1576func GetLongPathName(path *uint16, buf *uint16, buflen uint32) (n uint32, err error) {
1577 r0, _, e1 := syscall.Syscall(procGetLongPathNameW.Addr(), 3, uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(buf)), uintptr(buflen))
1578 n = uint32(r0)
1579 if n == 0 {
1580 if e1 != 0 {
1581 err = errnoErr(e1)
1582 } else {
1583 err = syscall.EINVAL
1584 }
1585 }
1586 return
1587}
1588
1589func GetShortPathName(longpath *uint16, shortpath *uint16, buflen uint32) (n uint32, err error) {
1590 r0, _, e1 := syscall.Syscall(procGetShortPathNameW.Addr(), 3, uintptr(unsafe.Pointer(longpath)), uintptr(unsafe.Pointer(shortpath)), uintptr(buflen))
1591 n = uint32(r0)
1592 if n == 0 {
1593 if e1 != 0 {
1594 err = errnoErr(e1)
1595 } else {
1596 err = syscall.EINVAL
1597 }
1598 }
1599 return
1600}
1601
1602func CreateFileMapping(fhandle Handle, sa *SecurityAttributes, prot uint32, maxSizeHigh uint32, maxSizeLow uint32, name *uint16) (handle Handle, err error) {
1603 r0, _, e1 := syscall.Syscall6(procCreateFileMappingW.Addr(), 6, uintptr(fhandle), uintptr(unsafe.Pointer(sa)), uintptr(prot), uintptr(maxSizeHigh), uintptr(maxSizeLow), uintptr(unsafe.Pointer(name)))
1604 handle = Handle(r0)
1605 if handle == 0 {
1606 if e1 != 0 {
1607 err = errnoErr(e1)
1608 } else {
1609 err = syscall.EINVAL
1610 }
1611 }
1612 return
1613}
1614
1615func MapViewOfFile(handle Handle, access uint32, offsetHigh uint32, offsetLow uint32, length uintptr) (addr uintptr, err error) {
1616 r0, _, e1 := syscall.Syscall6(procMapViewOfFile.Addr(), 5, uintptr(handle), uintptr(access), uintptr(offsetHigh), uintptr(offsetLow), uintptr(length), 0)
1617 addr = uintptr(r0)
1618 if addr == 0 {
1619 if e1 != 0 {
1620 err = errnoErr(e1)
1621 } else {
1622 err = syscall.EINVAL
1623 }
1624 }
1625 return
1626}
1627
1628func UnmapViewOfFile(addr uintptr) (err error) {
1629 r1, _, e1 := syscall.Syscall(procUnmapViewOfFile.Addr(), 1, uintptr(addr), 0, 0)
1630 if r1 == 0 {
1631 if e1 != 0 {
1632 err = errnoErr(e1)
1633 } else {
1634 err = syscall.EINVAL
1635 }
1636 }
1637 return
1638}
1639
1640func FlushViewOfFile(addr uintptr, length uintptr) (err error) {
1641 r1, _, e1 := syscall.Syscall(procFlushViewOfFile.Addr(), 2, uintptr(addr), uintptr(length), 0)
1642 if r1 == 0 {
1643 if e1 != 0 {
1644 err = errnoErr(e1)
1645 } else {
1646 err = syscall.EINVAL
1647 }
1648 }
1649 return
1650}
1651
1652func VirtualLock(addr uintptr, length uintptr) (err error) {
1653 r1, _, e1 := syscall.Syscall(procVirtualLock.Addr(), 2, uintptr(addr), uintptr(length), 0)
1654 if r1 == 0 {
1655 if e1 != 0 {
1656 err = errnoErr(e1)
1657 } else {
1658 err = syscall.EINVAL
1659 }
1660 }
1661 return
1662}
1663
1664func VirtualUnlock(addr uintptr, length uintptr) (err error) {
1665 r1, _, e1 := syscall.Syscall(procVirtualUnlock.Addr(), 2, uintptr(addr), uintptr(length), 0)
1666 if r1 == 0 {
1667 if e1 != 0 {
1668 err = errnoErr(e1)
1669 } else {
1670 err = syscall.EINVAL
1671 }
1672 }
1673 return
1674}
1675
1676func VirtualAlloc(address uintptr, size uintptr, alloctype uint32, protect uint32) (value uintptr, err error) {
1677 r0, _, e1 := syscall.Syscall6(procVirtualAlloc.Addr(), 4, uintptr(address), uintptr(size), uintptr(alloctype), uintptr(protect), 0, 0)
1678 value = uintptr(r0)
1679 if value == 0 {
1680 if e1 != 0 {
1681 err = errnoErr(e1)
1682 } else {
1683 err = syscall.EINVAL
1684 }
1685 }
1686 return
1687}
1688
1689func VirtualFree(address uintptr, size uintptr, freetype uint32) (err error) {
1690 r1, _, e1 := syscall.Syscall(procVirtualFree.Addr(), 3, uintptr(address), uintptr(size), uintptr(freetype))
1691 if r1 == 0 {
1692 if e1 != 0 {
1693 err = errnoErr(e1)
1694 } else {
1695 err = syscall.EINVAL
1696 }
1697 }
1698 return
1699}
1700
1701func VirtualProtect(address uintptr, size uintptr, newprotect uint32, oldprotect *uint32) (err error) {
1702 r1, _, e1 := syscall.Syscall6(procVirtualProtect.Addr(), 4, uintptr(address), uintptr(size), uintptr(newprotect), uintptr(unsafe.Pointer(oldprotect)), 0, 0)
1703 if r1 == 0 {
1704 if e1 != 0 {
1705 err = errnoErr(e1)
1706 } else {
1707 err = syscall.EINVAL
1708 }
1709 }
1710 return
1711}
1712
1713func TransmitFile(s Handle, handle Handle, bytesToWrite uint32, bytsPerSend uint32, overlapped *Overlapped, transmitFileBuf *TransmitFileBuffers, flags uint32) (err error) {
1714 r1, _, e1 := syscall.Syscall9(procTransmitFile.Addr(), 7, uintptr(s), uintptr(handle), uintptr(bytesToWrite), uintptr(bytsPerSend), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(transmitFileBuf)), uintptr(flags), 0, 0)
1715 if r1 == 0 {
1716 if e1 != 0 {
1717 err = errnoErr(e1)
1718 } else {
1719 err = syscall.EINVAL
1720 }
1721 }
1722 return
1723}
1724
1725func ReadDirectoryChanges(handle Handle, buf *byte, buflen uint32, watchSubTree bool, mask uint32, retlen *uint32, overlapped *Overlapped, completionRoutine uintptr) (err error) {
1726 var _p0 uint32
1727 if watchSubTree {
1728 _p0 = 1
1729 } else {
1730 _p0 = 0
1731 }
1732 r1, _, e1 := syscall.Syscall9(procReadDirectoryChangesW.Addr(), 8, uintptr(handle), uintptr(unsafe.Pointer(buf)), uintptr(buflen), uintptr(_p0), uintptr(mask), uintptr(unsafe.Pointer(retlen)), uintptr(unsafe.Pointer(overlapped)), uintptr(completionRoutine), 0)
1733 if r1 == 0 {
1734 if e1 != 0 {
1735 err = errnoErr(e1)
1736 } else {
1737 err = syscall.EINVAL
1738 }
1739 }
1740 return
1741}
1742
1743func CertOpenSystemStore(hprov Handle, name *uint16) (store Handle, err error) {
1744 r0, _, e1 := syscall.Syscall(procCertOpenSystemStoreW.Addr(), 2, uintptr(hprov), uintptr(unsafe.Pointer(name)), 0)
1745 store = Handle(r0)
1746 if store == 0 {
1747 if e1 != 0 {
1748 err = errnoErr(e1)
1749 } else {
1750 err = syscall.EINVAL
1751 }
1752 }
1753 return
1754}
1755
1756func CertOpenStore(storeProvider uintptr, msgAndCertEncodingType uint32, cryptProv uintptr, flags uint32, para uintptr) (handle Handle, err error) {
1757 r0, _, e1 := syscall.Syscall6(procCertOpenStore.Addr(), 5, uintptr(storeProvider), uintptr(msgAndCertEncodingType), uintptr(cryptProv), uintptr(flags), uintptr(para), 0)
1758 handle = Handle(r0)
1759 if handle == InvalidHandle {
1760 if e1 != 0 {
1761 err = errnoErr(e1)
1762 } else {
1763 err = syscall.EINVAL
1764 }
1765 }
1766 return
1767}
1768
1769func CertEnumCertificatesInStore(store Handle, prevContext *CertContext) (context *CertContext, err error) {
1770 r0, _, e1 := syscall.Syscall(procCertEnumCertificatesInStore.Addr(), 2, uintptr(store), uintptr(unsafe.Pointer(prevContext)), 0)
1771 context = (*CertContext)(unsafe.Pointer(r0))
1772 if context == nil {
1773 if e1 != 0 {
1774 err = errnoErr(e1)
1775 } else {
1776 err = syscall.EINVAL
1777 }
1778 }
1779 return
1780}
1781
1782func CertAddCertificateContextToStore(store Handle, certContext *CertContext, addDisposition uint32, storeContext **CertContext) (err error) {
1783 r1, _, e1 := syscall.Syscall6(procCertAddCertificateContextToStore.Addr(), 4, uintptr(store), uintptr(unsafe.Pointer(certContext)), uintptr(addDisposition), uintptr(unsafe.Pointer(storeContext)), 0, 0)
1784 if r1 == 0 {
1785 if e1 != 0 {
1786 err = errnoErr(e1)
1787 } else {
1788 err = syscall.EINVAL
1789 }
1790 }
1791 return
1792}
1793
1794func CertCloseStore(store Handle, flags uint32) (err error) {
1795 r1, _, e1 := syscall.Syscall(procCertCloseStore.Addr(), 2, uintptr(store), uintptr(flags), 0)
1796 if r1 == 0 {
1797 if e1 != 0 {
1798 err = errnoErr(e1)
1799 } else {
1800 err = syscall.EINVAL
1801 }
1802 }
1803 return
1804}
1805
1806func CertGetCertificateChain(engine Handle, leaf *CertContext, time *Filetime, additionalStore Handle, para *CertChainPara, flags uint32, reserved uintptr, chainCtx **CertChainContext) (err error) {
1807 r1, _, e1 := syscall.Syscall9(procCertGetCertificateChain.Addr(), 8, uintptr(engine), uintptr(unsafe.Pointer(leaf)), uintptr(unsafe.Pointer(time)), uintptr(additionalStore), uintptr(unsafe.Pointer(para)), uintptr(flags), uintptr(reserved), uintptr(unsafe.Pointer(chainCtx)), 0)
1808 if r1 == 0 {
1809 if e1 != 0 {
1810 err = errnoErr(e1)
1811 } else {
1812 err = syscall.EINVAL
1813 }
1814 }
1815 return
1816}
1817
1818func CertFreeCertificateChain(ctx *CertChainContext) {
1819 syscall.Syscall(procCertFreeCertificateChain.Addr(), 1, uintptr(unsafe.Pointer(ctx)), 0, 0)
1820 return
1821}
1822
1823func CertCreateCertificateContext(certEncodingType uint32, certEncoded *byte, encodedLen uint32) (context *CertContext, err error) {
1824 r0, _, e1 := syscall.Syscall(procCertCreateCertificateContext.Addr(), 3, uintptr(certEncodingType), uintptr(unsafe.Pointer(certEncoded)), uintptr(encodedLen))
1825 context = (*CertContext)(unsafe.Pointer(r0))
1826 if context == nil {
1827 if e1 != 0 {
1828 err = errnoErr(e1)
1829 } else {
1830 err = syscall.EINVAL
1831 }
1832 }
1833 return
1834}
1835
1836func CertFreeCertificateContext(ctx *CertContext) (err error) {
1837 r1, _, e1 := syscall.Syscall(procCertFreeCertificateContext.Addr(), 1, uintptr(unsafe.Pointer(ctx)), 0, 0)
1838 if r1 == 0 {
1839 if e1 != 0 {
1840 err = errnoErr(e1)
1841 } else {
1842 err = syscall.EINVAL
1843 }
1844 }
1845 return
1846}
1847
1848func CertVerifyCertificateChainPolicy(policyOID uintptr, chain *CertChainContext, para *CertChainPolicyPara, status *CertChainPolicyStatus) (err error) {
1849 r1, _, e1 := syscall.Syscall6(procCertVerifyCertificateChainPolicy.Addr(), 4, uintptr(policyOID), uintptr(unsafe.Pointer(chain)), uintptr(unsafe.Pointer(para)), uintptr(unsafe.Pointer(status)), 0, 0)
1850 if r1 == 0 {
1851 if e1 != 0 {
1852 err = errnoErr(e1)
1853 } else {
1854 err = syscall.EINVAL
1855 }
1856 }
1857 return
1858}
1859
1860func RegOpenKeyEx(key Handle, subkey *uint16, options uint32, desiredAccess uint32, result *Handle) (regerrno error) {
1861 r0, _, _ := syscall.Syscall6(procRegOpenKeyExW.Addr(), 5, uintptr(key), uintptr(unsafe.Pointer(subkey)), uintptr(options), uintptr(desiredAccess), uintptr(unsafe.Pointer(result)), 0)
1862 if r0 != 0 {
1863 regerrno = syscall.Errno(r0)
1864 }
1865 return
1866}
1867
1868func RegCloseKey(key Handle) (regerrno error) {
1869 r0, _, _ := syscall.Syscall(procRegCloseKey.Addr(), 1, uintptr(key), 0, 0)
1870 if r0 != 0 {
1871 regerrno = syscall.Errno(r0)
1872 }
1873 return
1874}
1875
1876func RegQueryInfoKey(key Handle, class *uint16, classLen *uint32, reserved *uint32, subkeysLen *uint32, maxSubkeyLen *uint32, maxClassLen *uint32, valuesLen *uint32, maxValueNameLen *uint32, maxValueLen *uint32, saLen *uint32, lastWriteTime *Filetime) (regerrno error) {
1877 r0, _, _ := syscall.Syscall12(procRegQueryInfoKeyW.Addr(), 12, uintptr(key), uintptr(unsafe.Pointer(class)), uintptr(unsafe.Pointer(classLen)), uintptr(unsafe.Pointer(reserved)), uintptr(unsafe.Pointer(subkeysLen)), uintptr(unsafe.Pointer(maxSubkeyLen)), uintptr(unsafe.Pointer(maxClassLen)), uintptr(unsafe.Pointer(valuesLen)), uintptr(unsafe.Pointer(maxValueNameLen)), uintptr(unsafe.Pointer(maxValueLen)), uintptr(unsafe.Pointer(saLen)), uintptr(unsafe.Pointer(lastWriteTime)))
1878 if r0 != 0 {
1879 regerrno = syscall.Errno(r0)
1880 }
1881 return
1882}
1883
1884func RegEnumKeyEx(key Handle, index uint32, name *uint16, nameLen *uint32, reserved *uint32, class *uint16, classLen *uint32, lastWriteTime *Filetime) (regerrno error) {
1885 r0, _, _ := syscall.Syscall9(procRegEnumKeyExW.Addr(), 8, uintptr(key), uintptr(index), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(nameLen)), uintptr(unsafe.Pointer(reserved)), uintptr(unsafe.Pointer(class)), uintptr(unsafe.Pointer(classLen)), uintptr(unsafe.Pointer(lastWriteTime)), 0)
1886 if r0 != 0 {
1887 regerrno = syscall.Errno(r0)
1888 }
1889 return
1890}
1891
1892func RegQueryValueEx(key Handle, name *uint16, reserved *uint32, valtype *uint32, buf *byte, buflen *uint32) (regerrno error) {
1893 r0, _, _ := syscall.Syscall6(procRegQueryValueExW.Addr(), 6, uintptr(key), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(reserved)), uintptr(unsafe.Pointer(valtype)), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(buflen)))
1894 if r0 != 0 {
1895 regerrno = syscall.Errno(r0)
1896 }
1897 return
1898}
1899
divyadesai19009132020-03-04 12:58:08 +00001900func GetCurrentProcessId() (pid uint32) {
Zack Williamse940c7a2019-08-21 14:25:39 -07001901 r0, _, _ := syscall.Syscall(procGetCurrentProcessId.Addr(), 0, 0, 0, 0)
1902 pid = uint32(r0)
1903 return
1904}
1905
1906func GetConsoleMode(console Handle, mode *uint32) (err error) {
1907 r1, _, e1 := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(console), uintptr(unsafe.Pointer(mode)), 0)
1908 if r1 == 0 {
1909 if e1 != 0 {
1910 err = errnoErr(e1)
1911 } else {
1912 err = syscall.EINVAL
1913 }
1914 }
1915 return
1916}
1917
1918func SetConsoleMode(console Handle, mode uint32) (err error) {
1919 r1, _, e1 := syscall.Syscall(procSetConsoleMode.Addr(), 2, uintptr(console), uintptr(mode), 0)
1920 if r1 == 0 {
1921 if e1 != 0 {
1922 err = errnoErr(e1)
1923 } else {
1924 err = syscall.EINVAL
1925 }
1926 }
1927 return
1928}
1929
1930func GetConsoleScreenBufferInfo(console Handle, info *ConsoleScreenBufferInfo) (err error) {
1931 r1, _, e1 := syscall.Syscall(procGetConsoleScreenBufferInfo.Addr(), 2, uintptr(console), uintptr(unsafe.Pointer(info)), 0)
1932 if r1 == 0 {
1933 if e1 != 0 {
1934 err = errnoErr(e1)
1935 } else {
1936 err = syscall.EINVAL
1937 }
1938 }
1939 return
1940}
1941
1942func WriteConsole(console Handle, buf *uint16, towrite uint32, written *uint32, reserved *byte) (err error) {
1943 r1, _, e1 := syscall.Syscall6(procWriteConsoleW.Addr(), 5, uintptr(console), uintptr(unsafe.Pointer(buf)), uintptr(towrite), uintptr(unsafe.Pointer(written)), uintptr(unsafe.Pointer(reserved)), 0)
1944 if r1 == 0 {
1945 if e1 != 0 {
1946 err = errnoErr(e1)
1947 } else {
1948 err = syscall.EINVAL
1949 }
1950 }
1951 return
1952}
1953
1954func ReadConsole(console Handle, buf *uint16, toread uint32, read *uint32, inputControl *byte) (err error) {
1955 r1, _, e1 := syscall.Syscall6(procReadConsoleW.Addr(), 5, uintptr(console), uintptr(unsafe.Pointer(buf)), uintptr(toread), uintptr(unsafe.Pointer(read)), uintptr(unsafe.Pointer(inputControl)), 0)
1956 if r1 == 0 {
1957 if e1 != 0 {
1958 err = errnoErr(e1)
1959 } else {
1960 err = syscall.EINVAL
1961 }
1962 }
1963 return
1964}
1965
1966func CreateToolhelp32Snapshot(flags uint32, processId uint32) (handle Handle, err error) {
1967 r0, _, e1 := syscall.Syscall(procCreateToolhelp32Snapshot.Addr(), 2, uintptr(flags), uintptr(processId), 0)
1968 handle = Handle(r0)
1969 if handle == InvalidHandle {
1970 if e1 != 0 {
1971 err = errnoErr(e1)
1972 } else {
1973 err = syscall.EINVAL
1974 }
1975 }
1976 return
1977}
1978
1979func Process32First(snapshot Handle, procEntry *ProcessEntry32) (err error) {
1980 r1, _, e1 := syscall.Syscall(procProcess32FirstW.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(procEntry)), 0)
1981 if r1 == 0 {
1982 if e1 != 0 {
1983 err = errnoErr(e1)
1984 } else {
1985 err = syscall.EINVAL
1986 }
1987 }
1988 return
1989}
1990
1991func Process32Next(snapshot Handle, procEntry *ProcessEntry32) (err error) {
1992 r1, _, e1 := syscall.Syscall(procProcess32NextW.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(procEntry)), 0)
1993 if r1 == 0 {
1994 if e1 != 0 {
1995 err = errnoErr(e1)
1996 } else {
1997 err = syscall.EINVAL
1998 }
1999 }
2000 return
2001}
2002
divyadesai19009132020-03-04 12:58:08 +00002003func Thread32First(snapshot Handle, threadEntry *ThreadEntry32) (err error) {
2004 r1, _, e1 := syscall.Syscall(procThread32First.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(threadEntry)), 0)
2005 if r1 == 0 {
2006 if e1 != 0 {
2007 err = errnoErr(e1)
2008 } else {
2009 err = syscall.EINVAL
2010 }
2011 }
2012 return
2013}
2014
2015func Thread32Next(snapshot Handle, threadEntry *ThreadEntry32) (err error) {
2016 r1, _, e1 := syscall.Syscall(procThread32Next.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(threadEntry)), 0)
2017 if r1 == 0 {
2018 if e1 != 0 {
2019 err = errnoErr(e1)
2020 } else {
2021 err = syscall.EINVAL
2022 }
2023 }
2024 return
2025}
2026
Zack Williamse940c7a2019-08-21 14:25:39 -07002027func DeviceIoControl(handle Handle, ioControlCode uint32, inBuffer *byte, inBufferSize uint32, outBuffer *byte, outBufferSize uint32, bytesReturned *uint32, overlapped *Overlapped) (err error) {
2028 r1, _, e1 := syscall.Syscall9(procDeviceIoControl.Addr(), 8, uintptr(handle), uintptr(ioControlCode), uintptr(unsafe.Pointer(inBuffer)), uintptr(inBufferSize), uintptr(unsafe.Pointer(outBuffer)), uintptr(outBufferSize), uintptr(unsafe.Pointer(bytesReturned)), uintptr(unsafe.Pointer(overlapped)), 0)
2029 if r1 == 0 {
2030 if e1 != 0 {
2031 err = errnoErr(e1)
2032 } else {
2033 err = syscall.EINVAL
2034 }
2035 }
2036 return
2037}
2038
2039func CreateSymbolicLink(symlinkfilename *uint16, targetfilename *uint16, flags uint32) (err error) {
2040 r1, _, e1 := syscall.Syscall(procCreateSymbolicLinkW.Addr(), 3, uintptr(unsafe.Pointer(symlinkfilename)), uintptr(unsafe.Pointer(targetfilename)), uintptr(flags))
2041 if r1&0xff == 0 {
2042 if e1 != 0 {
2043 err = errnoErr(e1)
2044 } else {
2045 err = syscall.EINVAL
2046 }
2047 }
2048 return
2049}
2050
2051func CreateHardLink(filename *uint16, existingfilename *uint16, reserved uintptr) (err error) {
2052 r1, _, e1 := syscall.Syscall(procCreateHardLinkW.Addr(), 3, uintptr(unsafe.Pointer(filename)), uintptr(unsafe.Pointer(existingfilename)), uintptr(reserved))
2053 if r1&0xff == 0 {
2054 if e1 != 0 {
2055 err = errnoErr(e1)
2056 } else {
2057 err = syscall.EINVAL
2058 }
2059 }
2060 return
2061}
2062
2063func GetCurrentThreadId() (id uint32) {
2064 r0, _, _ := syscall.Syscall(procGetCurrentThreadId.Addr(), 0, 0, 0, 0)
2065 id = uint32(r0)
2066 return
2067}
2068
2069func CreateEvent(eventAttrs *SecurityAttributes, manualReset uint32, initialState uint32, name *uint16) (handle Handle, err error) {
2070 r0, _, e1 := syscall.Syscall6(procCreateEventW.Addr(), 4, uintptr(unsafe.Pointer(eventAttrs)), uintptr(manualReset), uintptr(initialState), uintptr(unsafe.Pointer(name)), 0, 0)
2071 handle = Handle(r0)
2072 if handle == 0 {
2073 if e1 != 0 {
2074 err = errnoErr(e1)
2075 } else {
2076 err = syscall.EINVAL
2077 }
2078 }
2079 return
2080}
2081
2082func CreateEventEx(eventAttrs *SecurityAttributes, name *uint16, flags uint32, desiredAccess uint32) (handle Handle, err error) {
2083 r0, _, e1 := syscall.Syscall6(procCreateEventExW.Addr(), 4, uintptr(unsafe.Pointer(eventAttrs)), uintptr(unsafe.Pointer(name)), uintptr(flags), uintptr(desiredAccess), 0, 0)
2084 handle = Handle(r0)
2085 if handle == 0 {
2086 if e1 != 0 {
2087 err = errnoErr(e1)
2088 } else {
2089 err = syscall.EINVAL
2090 }
2091 }
2092 return
2093}
2094
2095func OpenEvent(desiredAccess uint32, inheritHandle bool, name *uint16) (handle Handle, err error) {
2096 var _p0 uint32
2097 if inheritHandle {
2098 _p0 = 1
2099 } else {
2100 _p0 = 0
2101 }
2102 r0, _, e1 := syscall.Syscall(procOpenEventW.Addr(), 3, uintptr(desiredAccess), uintptr(_p0), uintptr(unsafe.Pointer(name)))
2103 handle = Handle(r0)
2104 if handle == 0 {
2105 if e1 != 0 {
2106 err = errnoErr(e1)
2107 } else {
2108 err = syscall.EINVAL
2109 }
2110 }
2111 return
2112}
2113
2114func SetEvent(event Handle) (err error) {
2115 r1, _, e1 := syscall.Syscall(procSetEvent.Addr(), 1, uintptr(event), 0, 0)
2116 if r1 == 0 {
2117 if e1 != 0 {
2118 err = errnoErr(e1)
2119 } else {
2120 err = syscall.EINVAL
2121 }
2122 }
2123 return
2124}
2125
2126func ResetEvent(event Handle) (err error) {
2127 r1, _, e1 := syscall.Syscall(procResetEvent.Addr(), 1, uintptr(event), 0, 0)
2128 if r1 == 0 {
2129 if e1 != 0 {
2130 err = errnoErr(e1)
2131 } else {
2132 err = syscall.EINVAL
2133 }
2134 }
2135 return
2136}
2137
2138func PulseEvent(event Handle) (err error) {
2139 r1, _, e1 := syscall.Syscall(procPulseEvent.Addr(), 1, uintptr(event), 0, 0)
2140 if r1 == 0 {
2141 if e1 != 0 {
2142 err = errnoErr(e1)
2143 } else {
2144 err = syscall.EINVAL
2145 }
2146 }
2147 return
2148}
2149
divyadesai19009132020-03-04 12:58:08 +00002150func CreateMutex(mutexAttrs *SecurityAttributes, initialOwner bool, name *uint16) (handle Handle, err error) {
2151 var _p0 uint32
2152 if initialOwner {
2153 _p0 = 1
2154 } else {
2155 _p0 = 0
2156 }
2157 r0, _, e1 := syscall.Syscall(procCreateMutexW.Addr(), 3, uintptr(unsafe.Pointer(mutexAttrs)), uintptr(_p0), uintptr(unsafe.Pointer(name)))
2158 handle = Handle(r0)
2159 if handle == 0 {
2160 if e1 != 0 {
2161 err = errnoErr(e1)
2162 } else {
2163 err = syscall.EINVAL
2164 }
2165 }
2166 return
2167}
2168
2169func CreateMutexEx(mutexAttrs *SecurityAttributes, name *uint16, flags uint32, desiredAccess uint32) (handle Handle, err error) {
2170 r0, _, e1 := syscall.Syscall6(procCreateMutexExW.Addr(), 4, uintptr(unsafe.Pointer(mutexAttrs)), uintptr(unsafe.Pointer(name)), uintptr(flags), uintptr(desiredAccess), 0, 0)
2171 handle = Handle(r0)
2172 if handle == 0 {
2173 if e1 != 0 {
2174 err = errnoErr(e1)
2175 } else {
2176 err = syscall.EINVAL
2177 }
2178 }
2179 return
2180}
2181
2182func OpenMutex(desiredAccess uint32, inheritHandle bool, name *uint16) (handle Handle, err error) {
2183 var _p0 uint32
2184 if inheritHandle {
2185 _p0 = 1
2186 } else {
2187 _p0 = 0
2188 }
2189 r0, _, e1 := syscall.Syscall(procOpenMutexW.Addr(), 3, uintptr(desiredAccess), uintptr(_p0), uintptr(unsafe.Pointer(name)))
2190 handle = Handle(r0)
2191 if handle == 0 {
2192 if e1 != 0 {
2193 err = errnoErr(e1)
2194 } else {
2195 err = syscall.EINVAL
2196 }
2197 }
2198 return
2199}
2200
2201func ReleaseMutex(mutex Handle) (err error) {
2202 r1, _, e1 := syscall.Syscall(procReleaseMutex.Addr(), 1, uintptr(mutex), 0, 0)
2203 if r1 == 0 {
2204 if e1 != 0 {
2205 err = errnoErr(e1)
2206 } else {
2207 err = syscall.EINVAL
2208 }
2209 }
2210 return
2211}
2212
Zack Williamse940c7a2019-08-21 14:25:39 -07002213func SleepEx(milliseconds uint32, alertable bool) (ret uint32) {
2214 var _p0 uint32
2215 if alertable {
2216 _p0 = 1
2217 } else {
2218 _p0 = 0
2219 }
2220 r0, _, _ := syscall.Syscall(procSleepEx.Addr(), 2, uintptr(milliseconds), uintptr(_p0), 0)
2221 ret = uint32(r0)
2222 return
2223}
2224
2225func CreateJobObject(jobAttr *SecurityAttributes, name *uint16) (handle Handle, err error) {
2226 r0, _, e1 := syscall.Syscall(procCreateJobObjectW.Addr(), 2, uintptr(unsafe.Pointer(jobAttr)), uintptr(unsafe.Pointer(name)), 0)
2227 handle = Handle(r0)
2228 if handle == 0 {
2229 if e1 != 0 {
2230 err = errnoErr(e1)
2231 } else {
2232 err = syscall.EINVAL
2233 }
2234 }
2235 return
2236}
2237
2238func AssignProcessToJobObject(job Handle, process Handle) (err error) {
2239 r1, _, e1 := syscall.Syscall(procAssignProcessToJobObject.Addr(), 2, uintptr(job), uintptr(process), 0)
2240 if r1 == 0 {
2241 if e1 != 0 {
2242 err = errnoErr(e1)
2243 } else {
2244 err = syscall.EINVAL
2245 }
2246 }
2247 return
2248}
2249
2250func TerminateJobObject(job Handle, exitCode uint32) (err error) {
2251 r1, _, e1 := syscall.Syscall(procTerminateJobObject.Addr(), 2, uintptr(job), uintptr(exitCode), 0)
2252 if r1 == 0 {
2253 if e1 != 0 {
2254 err = errnoErr(e1)
2255 } else {
2256 err = syscall.EINVAL
2257 }
2258 }
2259 return
2260}
2261
2262func SetErrorMode(mode uint32) (ret uint32) {
2263 r0, _, _ := syscall.Syscall(procSetErrorMode.Addr(), 1, uintptr(mode), 0, 0)
2264 ret = uint32(r0)
2265 return
2266}
2267
2268func ResumeThread(thread Handle) (ret uint32, err error) {
2269 r0, _, e1 := syscall.Syscall(procResumeThread.Addr(), 1, uintptr(thread), 0, 0)
2270 ret = uint32(r0)
2271 if ret == 0xffffffff {
2272 if e1 != 0 {
2273 err = errnoErr(e1)
2274 } else {
2275 err = syscall.EINVAL
2276 }
2277 }
2278 return
2279}
2280
2281func SetPriorityClass(process Handle, priorityClass uint32) (err error) {
2282 r1, _, e1 := syscall.Syscall(procSetPriorityClass.Addr(), 2, uintptr(process), uintptr(priorityClass), 0)
2283 if r1 == 0 {
2284 if e1 != 0 {
2285 err = errnoErr(e1)
2286 } else {
2287 err = syscall.EINVAL
2288 }
2289 }
2290 return
2291}
2292
2293func GetPriorityClass(process Handle) (ret uint32, err error) {
2294 r0, _, e1 := syscall.Syscall(procGetPriorityClass.Addr(), 1, uintptr(process), 0, 0)
2295 ret = uint32(r0)
2296 if ret == 0 {
2297 if e1 != 0 {
2298 err = errnoErr(e1)
2299 } else {
2300 err = syscall.EINVAL
2301 }
2302 }
2303 return
2304}
2305
2306func SetInformationJobObject(job Handle, JobObjectInformationClass uint32, JobObjectInformation uintptr, JobObjectInformationLength uint32) (ret int, err error) {
2307 r0, _, e1 := syscall.Syscall6(procSetInformationJobObject.Addr(), 4, uintptr(job), uintptr(JobObjectInformationClass), uintptr(JobObjectInformation), uintptr(JobObjectInformationLength), 0, 0)
2308 ret = int(r0)
2309 if ret == 0 {
2310 if e1 != 0 {
2311 err = errnoErr(e1)
2312 } else {
2313 err = syscall.EINVAL
2314 }
2315 }
2316 return
2317}
2318
David Bainbridge86971522019-09-26 22:09:39 +00002319func GenerateConsoleCtrlEvent(ctrlEvent uint32, processGroupID uint32) (err error) {
2320 r1, _, e1 := syscall.Syscall(procGenerateConsoleCtrlEvent.Addr(), 2, uintptr(ctrlEvent), uintptr(processGroupID), 0)
2321 if r1 == 0 {
2322 if e1 != 0 {
2323 err = errnoErr(e1)
2324 } else {
2325 err = syscall.EINVAL
2326 }
2327 }
2328 return
2329}
2330
divyadesai19009132020-03-04 12:58:08 +00002331func GetProcessId(process Handle) (id uint32, err error) {
2332 r0, _, e1 := syscall.Syscall(procGetProcessId.Addr(), 1, uintptr(process), 0, 0)
2333 id = uint32(r0)
2334 if id == 0 {
2335 if e1 != 0 {
2336 err = errnoErr(e1)
2337 } else {
2338 err = syscall.EINVAL
2339 }
2340 }
2341 return
2342}
2343
2344func OpenThread(desiredAccess uint32, inheritHandle bool, threadId uint32) (handle Handle, err error) {
2345 var _p0 uint32
2346 if inheritHandle {
2347 _p0 = 1
2348 } else {
2349 _p0 = 0
2350 }
2351 r0, _, e1 := syscall.Syscall(procOpenThread.Addr(), 3, uintptr(desiredAccess), uintptr(_p0), uintptr(threadId))
2352 handle = Handle(r0)
2353 if handle == 0 {
2354 if e1 != 0 {
2355 err = errnoErr(e1)
2356 } else {
2357 err = syscall.EINVAL
2358 }
2359 }
2360 return
2361}
2362
2363func SetProcessPriorityBoost(process Handle, disable bool) (err error) {
2364 var _p0 uint32
2365 if disable {
2366 _p0 = 1
2367 } else {
2368 _p0 = 0
2369 }
2370 r1, _, e1 := syscall.Syscall(procSetProcessPriorityBoost.Addr(), 2, uintptr(process), uintptr(_p0), 0)
2371 if r1 == 0 {
2372 if e1 != 0 {
2373 err = errnoErr(e1)
2374 } else {
2375 err = syscall.EINVAL
2376 }
2377 }
2378 return
2379}
2380
Zack Williamse940c7a2019-08-21 14:25:39 -07002381func DefineDosDevice(flags uint32, deviceName *uint16, targetPath *uint16) (err error) {
2382 r1, _, e1 := syscall.Syscall(procDefineDosDeviceW.Addr(), 3, uintptr(flags), uintptr(unsafe.Pointer(deviceName)), uintptr(unsafe.Pointer(targetPath)))
2383 if r1 == 0 {
2384 if e1 != 0 {
2385 err = errnoErr(e1)
2386 } else {
2387 err = syscall.EINVAL
2388 }
2389 }
2390 return
2391}
2392
2393func DeleteVolumeMountPoint(volumeMountPoint *uint16) (err error) {
2394 r1, _, e1 := syscall.Syscall(procDeleteVolumeMountPointW.Addr(), 1, uintptr(unsafe.Pointer(volumeMountPoint)), 0, 0)
2395 if r1 == 0 {
2396 if e1 != 0 {
2397 err = errnoErr(e1)
2398 } else {
2399 err = syscall.EINVAL
2400 }
2401 }
2402 return
2403}
2404
2405func FindFirstVolume(volumeName *uint16, bufferLength uint32) (handle Handle, err error) {
2406 r0, _, e1 := syscall.Syscall(procFindFirstVolumeW.Addr(), 2, uintptr(unsafe.Pointer(volumeName)), uintptr(bufferLength), 0)
2407 handle = Handle(r0)
2408 if handle == InvalidHandle {
2409 if e1 != 0 {
2410 err = errnoErr(e1)
2411 } else {
2412 err = syscall.EINVAL
2413 }
2414 }
2415 return
2416}
2417
2418func FindFirstVolumeMountPoint(rootPathName *uint16, volumeMountPoint *uint16, bufferLength uint32) (handle Handle, err error) {
2419 r0, _, e1 := syscall.Syscall(procFindFirstVolumeMountPointW.Addr(), 3, uintptr(unsafe.Pointer(rootPathName)), uintptr(unsafe.Pointer(volumeMountPoint)), uintptr(bufferLength))
2420 handle = Handle(r0)
2421 if handle == InvalidHandle {
2422 if e1 != 0 {
2423 err = errnoErr(e1)
2424 } else {
2425 err = syscall.EINVAL
2426 }
2427 }
2428 return
2429}
2430
2431func FindNextVolume(findVolume Handle, volumeName *uint16, bufferLength uint32) (err error) {
2432 r1, _, e1 := syscall.Syscall(procFindNextVolumeW.Addr(), 3, uintptr(findVolume), uintptr(unsafe.Pointer(volumeName)), uintptr(bufferLength))
2433 if r1 == 0 {
2434 if e1 != 0 {
2435 err = errnoErr(e1)
2436 } else {
2437 err = syscall.EINVAL
2438 }
2439 }
2440 return
2441}
2442
2443func FindNextVolumeMountPoint(findVolumeMountPoint Handle, volumeMountPoint *uint16, bufferLength uint32) (err error) {
2444 r1, _, e1 := syscall.Syscall(procFindNextVolumeMountPointW.Addr(), 3, uintptr(findVolumeMountPoint), uintptr(unsafe.Pointer(volumeMountPoint)), uintptr(bufferLength))
2445 if r1 == 0 {
2446 if e1 != 0 {
2447 err = errnoErr(e1)
2448 } else {
2449 err = syscall.EINVAL
2450 }
2451 }
2452 return
2453}
2454
2455func FindVolumeClose(findVolume Handle) (err error) {
2456 r1, _, e1 := syscall.Syscall(procFindVolumeClose.Addr(), 1, uintptr(findVolume), 0, 0)
2457 if r1 == 0 {
2458 if e1 != 0 {
2459 err = errnoErr(e1)
2460 } else {
2461 err = syscall.EINVAL
2462 }
2463 }
2464 return
2465}
2466
2467func FindVolumeMountPointClose(findVolumeMountPoint Handle) (err error) {
2468 r1, _, e1 := syscall.Syscall(procFindVolumeMountPointClose.Addr(), 1, uintptr(findVolumeMountPoint), 0, 0)
2469 if r1 == 0 {
2470 if e1 != 0 {
2471 err = errnoErr(e1)
2472 } else {
2473 err = syscall.EINVAL
2474 }
2475 }
2476 return
2477}
2478
2479func GetDriveType(rootPathName *uint16) (driveType uint32) {
2480 r0, _, _ := syscall.Syscall(procGetDriveTypeW.Addr(), 1, uintptr(unsafe.Pointer(rootPathName)), 0, 0)
2481 driveType = uint32(r0)
2482 return
2483}
2484
2485func GetLogicalDrives() (drivesBitMask uint32, err error) {
2486 r0, _, e1 := syscall.Syscall(procGetLogicalDrives.Addr(), 0, 0, 0, 0)
2487 drivesBitMask = uint32(r0)
2488 if drivesBitMask == 0 {
2489 if e1 != 0 {
2490 err = errnoErr(e1)
2491 } else {
2492 err = syscall.EINVAL
2493 }
2494 }
2495 return
2496}
2497
2498func GetLogicalDriveStrings(bufferLength uint32, buffer *uint16) (n uint32, err error) {
2499 r0, _, e1 := syscall.Syscall(procGetLogicalDriveStringsW.Addr(), 2, uintptr(bufferLength), uintptr(unsafe.Pointer(buffer)), 0)
2500 n = uint32(r0)
2501 if n == 0 {
2502 if e1 != 0 {
2503 err = errnoErr(e1)
2504 } else {
2505 err = syscall.EINVAL
2506 }
2507 }
2508 return
2509}
2510
2511func GetVolumeInformation(rootPathName *uint16, volumeNameBuffer *uint16, volumeNameSize uint32, volumeNameSerialNumber *uint32, maximumComponentLength *uint32, fileSystemFlags *uint32, fileSystemNameBuffer *uint16, fileSystemNameSize uint32) (err error) {
2512 r1, _, e1 := syscall.Syscall9(procGetVolumeInformationW.Addr(), 8, uintptr(unsafe.Pointer(rootPathName)), uintptr(unsafe.Pointer(volumeNameBuffer)), uintptr(volumeNameSize), uintptr(unsafe.Pointer(volumeNameSerialNumber)), uintptr(unsafe.Pointer(maximumComponentLength)), uintptr(unsafe.Pointer(fileSystemFlags)), uintptr(unsafe.Pointer(fileSystemNameBuffer)), uintptr(fileSystemNameSize), 0)
2513 if r1 == 0 {
2514 if e1 != 0 {
2515 err = errnoErr(e1)
2516 } else {
2517 err = syscall.EINVAL
2518 }
2519 }
2520 return
2521}
2522
2523func GetVolumeInformationByHandle(file Handle, volumeNameBuffer *uint16, volumeNameSize uint32, volumeNameSerialNumber *uint32, maximumComponentLength *uint32, fileSystemFlags *uint32, fileSystemNameBuffer *uint16, fileSystemNameSize uint32) (err error) {
2524 r1, _, e1 := syscall.Syscall9(procGetVolumeInformationByHandleW.Addr(), 8, uintptr(file), uintptr(unsafe.Pointer(volumeNameBuffer)), uintptr(volumeNameSize), uintptr(unsafe.Pointer(volumeNameSerialNumber)), uintptr(unsafe.Pointer(maximumComponentLength)), uintptr(unsafe.Pointer(fileSystemFlags)), uintptr(unsafe.Pointer(fileSystemNameBuffer)), uintptr(fileSystemNameSize), 0)
2525 if r1 == 0 {
2526 if e1 != 0 {
2527 err = errnoErr(e1)
2528 } else {
2529 err = syscall.EINVAL
2530 }
2531 }
2532 return
2533}
2534
2535func GetVolumeNameForVolumeMountPoint(volumeMountPoint *uint16, volumeName *uint16, bufferlength uint32) (err error) {
2536 r1, _, e1 := syscall.Syscall(procGetVolumeNameForVolumeMountPointW.Addr(), 3, uintptr(unsafe.Pointer(volumeMountPoint)), uintptr(unsafe.Pointer(volumeName)), uintptr(bufferlength))
2537 if r1 == 0 {
2538 if e1 != 0 {
2539 err = errnoErr(e1)
2540 } else {
2541 err = syscall.EINVAL
2542 }
2543 }
2544 return
2545}
2546
2547func GetVolumePathName(fileName *uint16, volumePathName *uint16, bufferLength uint32) (err error) {
2548 r1, _, e1 := syscall.Syscall(procGetVolumePathNameW.Addr(), 3, uintptr(unsafe.Pointer(fileName)), uintptr(unsafe.Pointer(volumePathName)), uintptr(bufferLength))
2549 if r1 == 0 {
2550 if e1 != 0 {
2551 err = errnoErr(e1)
2552 } else {
2553 err = syscall.EINVAL
2554 }
2555 }
2556 return
2557}
2558
2559func GetVolumePathNamesForVolumeName(volumeName *uint16, volumePathNames *uint16, bufferLength uint32, returnLength *uint32) (err error) {
2560 r1, _, e1 := syscall.Syscall6(procGetVolumePathNamesForVolumeNameW.Addr(), 4, uintptr(unsafe.Pointer(volumeName)), uintptr(unsafe.Pointer(volumePathNames)), uintptr(bufferLength), uintptr(unsafe.Pointer(returnLength)), 0, 0)
2561 if r1 == 0 {
2562 if e1 != 0 {
2563 err = errnoErr(e1)
2564 } else {
2565 err = syscall.EINVAL
2566 }
2567 }
2568 return
2569}
2570
2571func QueryDosDevice(deviceName *uint16, targetPath *uint16, max uint32) (n uint32, err error) {
2572 r0, _, e1 := syscall.Syscall(procQueryDosDeviceW.Addr(), 3, uintptr(unsafe.Pointer(deviceName)), uintptr(unsafe.Pointer(targetPath)), uintptr(max))
2573 n = uint32(r0)
2574 if n == 0 {
2575 if e1 != 0 {
2576 err = errnoErr(e1)
2577 } else {
2578 err = syscall.EINVAL
2579 }
2580 }
2581 return
2582}
2583
2584func SetVolumeLabel(rootPathName *uint16, volumeName *uint16) (err error) {
2585 r1, _, e1 := syscall.Syscall(procSetVolumeLabelW.Addr(), 2, uintptr(unsafe.Pointer(rootPathName)), uintptr(unsafe.Pointer(volumeName)), 0)
2586 if r1 == 0 {
2587 if e1 != 0 {
2588 err = errnoErr(e1)
2589 } else {
2590 err = syscall.EINVAL
2591 }
2592 }
2593 return
2594}
2595
2596func SetVolumeMountPoint(volumeMountPoint *uint16, volumeName *uint16) (err error) {
2597 r1, _, e1 := syscall.Syscall(procSetVolumeMountPointW.Addr(), 2, uintptr(unsafe.Pointer(volumeMountPoint)), uintptr(unsafe.Pointer(volumeName)), 0)
2598 if r1 == 0 {
2599 if e1 != 0 {
2600 err = errnoErr(e1)
2601 } else {
2602 err = syscall.EINVAL
2603 }
2604 }
2605 return
2606}
2607
2608func MessageBox(hwnd Handle, text *uint16, caption *uint16, boxtype uint32) (ret int32, err error) {
2609 r0, _, e1 := syscall.Syscall6(procMessageBoxW.Addr(), 4, uintptr(hwnd), uintptr(unsafe.Pointer(text)), uintptr(unsafe.Pointer(caption)), uintptr(boxtype), 0, 0)
2610 ret = int32(r0)
2611 if ret == 0 {
2612 if e1 != 0 {
2613 err = errnoErr(e1)
2614 } else {
2615 err = syscall.EINVAL
2616 }
2617 }
2618 return
2619}
2620
divyadesai19009132020-03-04 12:58:08 +00002621func ExitWindowsEx(flags uint32, reason uint32) (err error) {
2622 r1, _, e1 := syscall.Syscall(procExitWindowsEx.Addr(), 2, uintptr(flags), uintptr(reason), 0)
2623 if r1 == 0 {
2624 if e1 != 0 {
2625 err = errnoErr(e1)
2626 } else {
2627 err = syscall.EINVAL
2628 }
2629 }
2630 return
2631}
2632
2633func InitiateSystemShutdownEx(machineName *uint16, message *uint16, timeout uint32, forceAppsClosed bool, rebootAfterShutdown bool, reason uint32) (err error) {
2634 var _p0 uint32
2635 if forceAppsClosed {
2636 _p0 = 1
2637 } else {
2638 _p0 = 0
2639 }
2640 var _p1 uint32
2641 if rebootAfterShutdown {
2642 _p1 = 1
2643 } else {
2644 _p1 = 0
2645 }
2646 r1, _, e1 := syscall.Syscall6(procInitiateSystemShutdownExW.Addr(), 6, uintptr(unsafe.Pointer(machineName)), uintptr(unsafe.Pointer(message)), uintptr(timeout), uintptr(_p0), uintptr(_p1), uintptr(reason))
2647 if r1 == 0 {
2648 if e1 != 0 {
2649 err = errnoErr(e1)
2650 } else {
2651 err = syscall.EINVAL
2652 }
2653 }
2654 return
2655}
2656
2657func SetProcessShutdownParameters(level uint32, flags uint32) (err error) {
2658 r1, _, e1 := syscall.Syscall(procSetProcessShutdownParameters.Addr(), 2, uintptr(level), uintptr(flags), 0)
2659 if r1 == 0 {
2660 if e1 != 0 {
2661 err = errnoErr(e1)
2662 } else {
2663 err = syscall.EINVAL
2664 }
2665 }
2666 return
2667}
2668
2669func GetProcessShutdownParameters(level *uint32, flags *uint32) (err error) {
2670 r1, _, e1 := syscall.Syscall(procGetProcessShutdownParameters.Addr(), 2, uintptr(unsafe.Pointer(level)), uintptr(unsafe.Pointer(flags)), 0)
2671 if r1 == 0 {
2672 if e1 != 0 {
2673 err = errnoErr(e1)
2674 } else {
2675 err = syscall.EINVAL
2676 }
2677 }
2678 return
2679}
2680
2681func clsidFromString(lpsz *uint16, pclsid *GUID) (ret error) {
2682 r0, _, _ := syscall.Syscall(procCLSIDFromString.Addr(), 2, uintptr(unsafe.Pointer(lpsz)), uintptr(unsafe.Pointer(pclsid)), 0)
2683 if r0 != 0 {
2684 ret = syscall.Errno(r0)
2685 }
2686 return
2687}
2688
2689func stringFromGUID2(rguid *GUID, lpsz *uint16, cchMax int32) (chars int32) {
2690 r0, _, _ := syscall.Syscall(procStringFromGUID2.Addr(), 3, uintptr(unsafe.Pointer(rguid)), uintptr(unsafe.Pointer(lpsz)), uintptr(cchMax))
2691 chars = int32(r0)
2692 return
2693}
2694
2695func coCreateGuid(pguid *GUID) (ret error) {
2696 r0, _, _ := syscall.Syscall(procCoCreateGuid.Addr(), 1, uintptr(unsafe.Pointer(pguid)), 0, 0)
2697 if r0 != 0 {
2698 ret = syscall.Errno(r0)
2699 }
2700 return
2701}
2702
2703func CoTaskMemFree(address unsafe.Pointer) {
2704 syscall.Syscall(procCoTaskMemFree.Addr(), 1, uintptr(address), 0, 0)
2705 return
2706}
2707
2708func rtlGetVersion(info *OsVersionInfoEx) (ret error) {
2709 r0, _, _ := syscall.Syscall(procRtlGetVersion.Addr(), 1, uintptr(unsafe.Pointer(info)), 0, 0)
2710 if r0 != 0 {
2711 ret = syscall.Errno(r0)
2712 }
2713 return
2714}
2715
2716func rtlGetNtVersionNumbers(majorVersion *uint32, minorVersion *uint32, buildNumber *uint32) {
2717 syscall.Syscall(procRtlGetNtVersionNumbers.Addr(), 3, uintptr(unsafe.Pointer(majorVersion)), uintptr(unsafe.Pointer(minorVersion)), uintptr(unsafe.Pointer(buildNumber)))
2718 return
2719}
2720
Zack Williamse940c7a2019-08-21 14:25:39 -07002721func WSAStartup(verreq uint32, data *WSAData) (sockerr error) {
2722 r0, _, _ := syscall.Syscall(procWSAStartup.Addr(), 2, uintptr(verreq), uintptr(unsafe.Pointer(data)), 0)
2723 if r0 != 0 {
2724 sockerr = syscall.Errno(r0)
2725 }
2726 return
2727}
2728
2729func WSACleanup() (err error) {
2730 r1, _, e1 := syscall.Syscall(procWSACleanup.Addr(), 0, 0, 0, 0)
2731 if r1 == socket_error {
2732 if e1 != 0 {
2733 err = errnoErr(e1)
2734 } else {
2735 err = syscall.EINVAL
2736 }
2737 }
2738 return
2739}
2740
2741func WSAIoctl(s Handle, iocc uint32, inbuf *byte, cbif uint32, outbuf *byte, cbob uint32, cbbr *uint32, overlapped *Overlapped, completionRoutine uintptr) (err error) {
2742 r1, _, e1 := syscall.Syscall9(procWSAIoctl.Addr(), 9, uintptr(s), uintptr(iocc), uintptr(unsafe.Pointer(inbuf)), uintptr(cbif), uintptr(unsafe.Pointer(outbuf)), uintptr(cbob), uintptr(unsafe.Pointer(cbbr)), uintptr(unsafe.Pointer(overlapped)), uintptr(completionRoutine))
2743 if r1 == socket_error {
2744 if e1 != 0 {
2745 err = errnoErr(e1)
2746 } else {
2747 err = syscall.EINVAL
2748 }
2749 }
2750 return
2751}
2752
2753func socket(af int32, typ int32, protocol int32) (handle Handle, err error) {
2754 r0, _, e1 := syscall.Syscall(procsocket.Addr(), 3, uintptr(af), uintptr(typ), uintptr(protocol))
2755 handle = Handle(r0)
2756 if handle == InvalidHandle {
2757 if e1 != 0 {
2758 err = errnoErr(e1)
2759 } else {
2760 err = syscall.EINVAL
2761 }
2762 }
2763 return
2764}
2765
2766func Setsockopt(s Handle, level int32, optname int32, optval *byte, optlen int32) (err error) {
2767 r1, _, e1 := syscall.Syscall6(procsetsockopt.Addr(), 5, uintptr(s), uintptr(level), uintptr(optname), uintptr(unsafe.Pointer(optval)), uintptr(optlen), 0)
2768 if r1 == socket_error {
2769 if e1 != 0 {
2770 err = errnoErr(e1)
2771 } else {
2772 err = syscall.EINVAL
2773 }
2774 }
2775 return
2776}
2777
2778func Getsockopt(s Handle, level int32, optname int32, optval *byte, optlen *int32) (err error) {
2779 r1, _, e1 := syscall.Syscall6(procgetsockopt.Addr(), 5, uintptr(s), uintptr(level), uintptr(optname), uintptr(unsafe.Pointer(optval)), uintptr(unsafe.Pointer(optlen)), 0)
2780 if r1 == socket_error {
2781 if e1 != 0 {
2782 err = errnoErr(e1)
2783 } else {
2784 err = syscall.EINVAL
2785 }
2786 }
2787 return
2788}
2789
2790func bind(s Handle, name unsafe.Pointer, namelen int32) (err error) {
2791 r1, _, e1 := syscall.Syscall(procbind.Addr(), 3, uintptr(s), uintptr(name), uintptr(namelen))
2792 if r1 == socket_error {
2793 if e1 != 0 {
2794 err = errnoErr(e1)
2795 } else {
2796 err = syscall.EINVAL
2797 }
2798 }
2799 return
2800}
2801
2802func connect(s Handle, name unsafe.Pointer, namelen int32) (err error) {
2803 r1, _, e1 := syscall.Syscall(procconnect.Addr(), 3, uintptr(s), uintptr(name), uintptr(namelen))
2804 if r1 == socket_error {
2805 if e1 != 0 {
2806 err = errnoErr(e1)
2807 } else {
2808 err = syscall.EINVAL
2809 }
2810 }
2811 return
2812}
2813
2814func getsockname(s Handle, rsa *RawSockaddrAny, addrlen *int32) (err error) {
2815 r1, _, e1 := syscall.Syscall(procgetsockname.Addr(), 3, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
2816 if r1 == socket_error {
2817 if e1 != 0 {
2818 err = errnoErr(e1)
2819 } else {
2820 err = syscall.EINVAL
2821 }
2822 }
2823 return
2824}
2825
2826func getpeername(s Handle, rsa *RawSockaddrAny, addrlen *int32) (err error) {
2827 r1, _, e1 := syscall.Syscall(procgetpeername.Addr(), 3, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
2828 if r1 == socket_error {
2829 if e1 != 0 {
2830 err = errnoErr(e1)
2831 } else {
2832 err = syscall.EINVAL
2833 }
2834 }
2835 return
2836}
2837
2838func listen(s Handle, backlog int32) (err error) {
2839 r1, _, e1 := syscall.Syscall(proclisten.Addr(), 2, uintptr(s), uintptr(backlog), 0)
2840 if r1 == socket_error {
2841 if e1 != 0 {
2842 err = errnoErr(e1)
2843 } else {
2844 err = syscall.EINVAL
2845 }
2846 }
2847 return
2848}
2849
2850func shutdown(s Handle, how int32) (err error) {
2851 r1, _, e1 := syscall.Syscall(procshutdown.Addr(), 2, uintptr(s), uintptr(how), 0)
2852 if r1 == socket_error {
2853 if e1 != 0 {
2854 err = errnoErr(e1)
2855 } else {
2856 err = syscall.EINVAL
2857 }
2858 }
2859 return
2860}
2861
2862func Closesocket(s Handle) (err error) {
2863 r1, _, e1 := syscall.Syscall(procclosesocket.Addr(), 1, uintptr(s), 0, 0)
2864 if r1 == socket_error {
2865 if e1 != 0 {
2866 err = errnoErr(e1)
2867 } else {
2868 err = syscall.EINVAL
2869 }
2870 }
2871 return
2872}
2873
2874func AcceptEx(ls Handle, as Handle, buf *byte, rxdatalen uint32, laddrlen uint32, raddrlen uint32, recvd *uint32, overlapped *Overlapped) (err error) {
2875 r1, _, e1 := syscall.Syscall9(procAcceptEx.Addr(), 8, uintptr(ls), uintptr(as), uintptr(unsafe.Pointer(buf)), uintptr(rxdatalen), uintptr(laddrlen), uintptr(raddrlen), uintptr(unsafe.Pointer(recvd)), uintptr(unsafe.Pointer(overlapped)), 0)
2876 if r1 == 0 {
2877 if e1 != 0 {
2878 err = errnoErr(e1)
2879 } else {
2880 err = syscall.EINVAL
2881 }
2882 }
2883 return
2884}
2885
2886func GetAcceptExSockaddrs(buf *byte, rxdatalen uint32, laddrlen uint32, raddrlen uint32, lrsa **RawSockaddrAny, lrsalen *int32, rrsa **RawSockaddrAny, rrsalen *int32) {
2887 syscall.Syscall9(procGetAcceptExSockaddrs.Addr(), 8, uintptr(unsafe.Pointer(buf)), uintptr(rxdatalen), uintptr(laddrlen), uintptr(raddrlen), uintptr(unsafe.Pointer(lrsa)), uintptr(unsafe.Pointer(lrsalen)), uintptr(unsafe.Pointer(rrsa)), uintptr(unsafe.Pointer(rrsalen)), 0)
2888 return
2889}
2890
2891func WSARecv(s Handle, bufs *WSABuf, bufcnt uint32, recvd *uint32, flags *uint32, overlapped *Overlapped, croutine *byte) (err error) {
2892 r1, _, e1 := syscall.Syscall9(procWSARecv.Addr(), 7, uintptr(s), uintptr(unsafe.Pointer(bufs)), uintptr(bufcnt), uintptr(unsafe.Pointer(recvd)), uintptr(unsafe.Pointer(flags)), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(croutine)), 0, 0)
2893 if r1 == socket_error {
2894 if e1 != 0 {
2895 err = errnoErr(e1)
2896 } else {
2897 err = syscall.EINVAL
2898 }
2899 }
2900 return
2901}
2902
2903func WSASend(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, overlapped *Overlapped, croutine *byte) (err error) {
2904 r1, _, e1 := syscall.Syscall9(procWSASend.Addr(), 7, uintptr(s), uintptr(unsafe.Pointer(bufs)), uintptr(bufcnt), uintptr(unsafe.Pointer(sent)), uintptr(flags), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(croutine)), 0, 0)
2905 if r1 == socket_error {
2906 if e1 != 0 {
2907 err = errnoErr(e1)
2908 } else {
2909 err = syscall.EINVAL
2910 }
2911 }
2912 return
2913}
2914
2915func WSARecvFrom(s Handle, bufs *WSABuf, bufcnt uint32, recvd *uint32, flags *uint32, from *RawSockaddrAny, fromlen *int32, overlapped *Overlapped, croutine *byte) (err error) {
2916 r1, _, e1 := syscall.Syscall9(procWSARecvFrom.Addr(), 9, uintptr(s), uintptr(unsafe.Pointer(bufs)), uintptr(bufcnt), uintptr(unsafe.Pointer(recvd)), uintptr(unsafe.Pointer(flags)), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(croutine)))
2917 if r1 == socket_error {
2918 if e1 != 0 {
2919 err = errnoErr(e1)
2920 } else {
2921 err = syscall.EINVAL
2922 }
2923 }
2924 return
2925}
2926
2927func WSASendTo(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, to *RawSockaddrAny, tolen int32, overlapped *Overlapped, croutine *byte) (err error) {
2928 r1, _, e1 := syscall.Syscall9(procWSASendTo.Addr(), 9, uintptr(s), uintptr(unsafe.Pointer(bufs)), uintptr(bufcnt), uintptr(unsafe.Pointer(sent)), uintptr(flags), uintptr(unsafe.Pointer(to)), uintptr(tolen), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(croutine)))
2929 if r1 == socket_error {
2930 if e1 != 0 {
2931 err = errnoErr(e1)
2932 } else {
2933 err = syscall.EINVAL
2934 }
2935 }
2936 return
2937}
2938
2939func GetHostByName(name string) (h *Hostent, err error) {
2940 var _p0 *byte
2941 _p0, err = syscall.BytePtrFromString(name)
2942 if err != nil {
2943 return
2944 }
2945 return _GetHostByName(_p0)
2946}
2947
2948func _GetHostByName(name *byte) (h *Hostent, err error) {
2949 r0, _, e1 := syscall.Syscall(procgethostbyname.Addr(), 1, uintptr(unsafe.Pointer(name)), 0, 0)
2950 h = (*Hostent)(unsafe.Pointer(r0))
2951 if h == nil {
2952 if e1 != 0 {
2953 err = errnoErr(e1)
2954 } else {
2955 err = syscall.EINVAL
2956 }
2957 }
2958 return
2959}
2960
2961func GetServByName(name string, proto string) (s *Servent, err error) {
2962 var _p0 *byte
2963 _p0, err = syscall.BytePtrFromString(name)
2964 if err != nil {
2965 return
2966 }
2967 var _p1 *byte
2968 _p1, err = syscall.BytePtrFromString(proto)
2969 if err != nil {
2970 return
2971 }
2972 return _GetServByName(_p0, _p1)
2973}
2974
2975func _GetServByName(name *byte, proto *byte) (s *Servent, err error) {
2976 r0, _, e1 := syscall.Syscall(procgetservbyname.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(proto)), 0)
2977 s = (*Servent)(unsafe.Pointer(r0))
2978 if s == nil {
2979 if e1 != 0 {
2980 err = errnoErr(e1)
2981 } else {
2982 err = syscall.EINVAL
2983 }
2984 }
2985 return
2986}
2987
2988func Ntohs(netshort uint16) (u uint16) {
2989 r0, _, _ := syscall.Syscall(procntohs.Addr(), 1, uintptr(netshort), 0, 0)
2990 u = uint16(r0)
2991 return
2992}
2993
2994func GetProtoByName(name string) (p *Protoent, err error) {
2995 var _p0 *byte
2996 _p0, err = syscall.BytePtrFromString(name)
2997 if err != nil {
2998 return
2999 }
3000 return _GetProtoByName(_p0)
3001}
3002
3003func _GetProtoByName(name *byte) (p *Protoent, err error) {
3004 r0, _, e1 := syscall.Syscall(procgetprotobyname.Addr(), 1, uintptr(unsafe.Pointer(name)), 0, 0)
3005 p = (*Protoent)(unsafe.Pointer(r0))
3006 if p == nil {
3007 if e1 != 0 {
3008 err = errnoErr(e1)
3009 } else {
3010 err = syscall.EINVAL
3011 }
3012 }
3013 return
3014}
3015
3016func DnsQuery(name string, qtype uint16, options uint32, extra *byte, qrs **DNSRecord, pr *byte) (status error) {
3017 var _p0 *uint16
3018 _p0, status = syscall.UTF16PtrFromString(name)
3019 if status != nil {
3020 return
3021 }
3022 return _DnsQuery(_p0, qtype, options, extra, qrs, pr)
3023}
3024
3025func _DnsQuery(name *uint16, qtype uint16, options uint32, extra *byte, qrs **DNSRecord, pr *byte) (status error) {
3026 r0, _, _ := syscall.Syscall6(procDnsQuery_W.Addr(), 6, uintptr(unsafe.Pointer(name)), uintptr(qtype), uintptr(options), uintptr(unsafe.Pointer(extra)), uintptr(unsafe.Pointer(qrs)), uintptr(unsafe.Pointer(pr)))
3027 if r0 != 0 {
3028 status = syscall.Errno(r0)
3029 }
3030 return
3031}
3032
3033func DnsRecordListFree(rl *DNSRecord, freetype uint32) {
3034 syscall.Syscall(procDnsRecordListFree.Addr(), 2, uintptr(unsafe.Pointer(rl)), uintptr(freetype), 0)
3035 return
3036}
3037
3038func DnsNameCompare(name1 *uint16, name2 *uint16) (same bool) {
3039 r0, _, _ := syscall.Syscall(procDnsNameCompare_W.Addr(), 2, uintptr(unsafe.Pointer(name1)), uintptr(unsafe.Pointer(name2)), 0)
3040 same = r0 != 0
3041 return
3042}
3043
3044func GetAddrInfoW(nodename *uint16, servicename *uint16, hints *AddrinfoW, result **AddrinfoW) (sockerr error) {
3045 r0, _, _ := syscall.Syscall6(procGetAddrInfoW.Addr(), 4, uintptr(unsafe.Pointer(nodename)), uintptr(unsafe.Pointer(servicename)), uintptr(unsafe.Pointer(hints)), uintptr(unsafe.Pointer(result)), 0, 0)
3046 if r0 != 0 {
3047 sockerr = syscall.Errno(r0)
3048 }
3049 return
3050}
3051
3052func FreeAddrInfoW(addrinfo *AddrinfoW) {
3053 syscall.Syscall(procFreeAddrInfoW.Addr(), 1, uintptr(unsafe.Pointer(addrinfo)), 0, 0)
3054 return
3055}
3056
3057func GetIfEntry(pIfRow *MibIfRow) (errcode error) {
3058 r0, _, _ := syscall.Syscall(procGetIfEntry.Addr(), 1, uintptr(unsafe.Pointer(pIfRow)), 0, 0)
3059 if r0 != 0 {
3060 errcode = syscall.Errno(r0)
3061 }
3062 return
3063}
3064
3065func GetAdaptersInfo(ai *IpAdapterInfo, ol *uint32) (errcode error) {
3066 r0, _, _ := syscall.Syscall(procGetAdaptersInfo.Addr(), 2, uintptr(unsafe.Pointer(ai)), uintptr(unsafe.Pointer(ol)), 0)
3067 if r0 != 0 {
3068 errcode = syscall.Errno(r0)
3069 }
3070 return
3071}
3072
3073func SetFileCompletionNotificationModes(handle Handle, flags uint8) (err error) {
3074 r1, _, e1 := syscall.Syscall(procSetFileCompletionNotificationModes.Addr(), 2, uintptr(handle), uintptr(flags), 0)
3075 if r1 == 0 {
3076 if e1 != 0 {
3077 err = errnoErr(e1)
3078 } else {
3079 err = syscall.EINVAL
3080 }
3081 }
3082 return
3083}
3084
3085func WSAEnumProtocols(protocols *int32, protocolBuffer *WSAProtocolInfo, bufferLength *uint32) (n int32, err error) {
3086 r0, _, e1 := syscall.Syscall(procWSAEnumProtocolsW.Addr(), 3, uintptr(unsafe.Pointer(protocols)), uintptr(unsafe.Pointer(protocolBuffer)), uintptr(unsafe.Pointer(bufferLength)))
3087 n = int32(r0)
3088 if n == -1 {
3089 if e1 != 0 {
3090 err = errnoErr(e1)
3091 } else {
3092 err = syscall.EINVAL
3093 }
3094 }
3095 return
3096}
3097
3098func GetAdaptersAddresses(family uint32, flags uint32, reserved uintptr, adapterAddresses *IpAdapterAddresses, sizePointer *uint32) (errcode error) {
3099 r0, _, _ := syscall.Syscall6(procGetAdaptersAddresses.Addr(), 5, uintptr(family), uintptr(flags), uintptr(reserved), uintptr(unsafe.Pointer(adapterAddresses)), uintptr(unsafe.Pointer(sizePointer)), 0)
3100 if r0 != 0 {
3101 errcode = syscall.Errno(r0)
3102 }
3103 return
3104}
3105
3106func GetACP() (acp uint32) {
3107 r0, _, _ := syscall.Syscall(procGetACP.Addr(), 0, 0, 0, 0)
3108 acp = uint32(r0)
3109 return
3110}
3111
3112func MultiByteToWideChar(codePage uint32, dwFlags uint32, str *byte, nstr int32, wchar *uint16, nwchar int32) (nwrite int32, err error) {
3113 r0, _, e1 := syscall.Syscall6(procMultiByteToWideChar.Addr(), 6, uintptr(codePage), uintptr(dwFlags), uintptr(unsafe.Pointer(str)), uintptr(nstr), uintptr(unsafe.Pointer(wchar)), uintptr(nwchar))
3114 nwrite = int32(r0)
3115 if nwrite == 0 {
3116 if e1 != 0 {
3117 err = errnoErr(e1)
3118 } else {
3119 err = syscall.EINVAL
3120 }
3121 }
3122 return
3123}
3124
3125func TranslateName(accName *uint16, accNameFormat uint32, desiredNameFormat uint32, translatedName *uint16, nSize *uint32) (err error) {
3126 r1, _, e1 := syscall.Syscall6(procTranslateNameW.Addr(), 5, uintptr(unsafe.Pointer(accName)), uintptr(accNameFormat), uintptr(desiredNameFormat), uintptr(unsafe.Pointer(translatedName)), uintptr(unsafe.Pointer(nSize)), 0)
3127 if r1&0xff == 0 {
3128 if e1 != 0 {
3129 err = errnoErr(e1)
3130 } else {
3131 err = syscall.EINVAL
3132 }
3133 }
3134 return
3135}
3136
3137func GetUserNameEx(nameFormat uint32, nameBuffre *uint16, nSize *uint32) (err error) {
3138 r1, _, e1 := syscall.Syscall(procGetUserNameExW.Addr(), 3, uintptr(nameFormat), uintptr(unsafe.Pointer(nameBuffre)), uintptr(unsafe.Pointer(nSize)))
3139 if r1&0xff == 0 {
3140 if e1 != 0 {
3141 err = errnoErr(e1)
3142 } else {
3143 err = syscall.EINVAL
3144 }
3145 }
3146 return
3147}
3148
3149func NetUserGetInfo(serverName *uint16, userName *uint16, level uint32, buf **byte) (neterr error) {
3150 r0, _, _ := syscall.Syscall6(procNetUserGetInfo.Addr(), 4, uintptr(unsafe.Pointer(serverName)), uintptr(unsafe.Pointer(userName)), uintptr(level), uintptr(unsafe.Pointer(buf)), 0, 0)
3151 if r0 != 0 {
3152 neterr = syscall.Errno(r0)
3153 }
3154 return
3155}
3156
3157func NetGetJoinInformation(server *uint16, name **uint16, bufType *uint32) (neterr error) {
3158 r0, _, _ := syscall.Syscall(procNetGetJoinInformation.Addr(), 3, uintptr(unsafe.Pointer(server)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(bufType)))
3159 if r0 != 0 {
3160 neterr = syscall.Errno(r0)
3161 }
3162 return
3163}
3164
3165func NetApiBufferFree(buf *byte) (neterr error) {
3166 r0, _, _ := syscall.Syscall(procNetApiBufferFree.Addr(), 1, uintptr(unsafe.Pointer(buf)), 0, 0)
3167 if r0 != 0 {
3168 neterr = syscall.Errno(r0)
3169 }
3170 return
3171}
3172
3173func LookupAccountSid(systemName *uint16, sid *SID, name *uint16, nameLen *uint32, refdDomainName *uint16, refdDomainNameLen *uint32, use *uint32) (err error) {
3174 r1, _, e1 := syscall.Syscall9(procLookupAccountSidW.Addr(), 7, uintptr(unsafe.Pointer(systemName)), uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(nameLen)), uintptr(unsafe.Pointer(refdDomainName)), uintptr(unsafe.Pointer(refdDomainNameLen)), uintptr(unsafe.Pointer(use)), 0, 0)
3175 if r1 == 0 {
3176 if e1 != 0 {
3177 err = errnoErr(e1)
3178 } else {
3179 err = syscall.EINVAL
3180 }
3181 }
3182 return
3183}
3184
3185func LookupAccountName(systemName *uint16, accountName *uint16, sid *SID, sidLen *uint32, refdDomainName *uint16, refdDomainNameLen *uint32, use *uint32) (err error) {
3186 r1, _, e1 := syscall.Syscall9(procLookupAccountNameW.Addr(), 7, uintptr(unsafe.Pointer(systemName)), uintptr(unsafe.Pointer(accountName)), uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(sidLen)), uintptr(unsafe.Pointer(refdDomainName)), uintptr(unsafe.Pointer(refdDomainNameLen)), uintptr(unsafe.Pointer(use)), 0, 0)
3187 if r1 == 0 {
3188 if e1 != 0 {
3189 err = errnoErr(e1)
3190 } else {
3191 err = syscall.EINVAL
3192 }
3193 }
3194 return
3195}
3196
3197func ConvertSidToStringSid(sid *SID, stringSid **uint16) (err error) {
3198 r1, _, e1 := syscall.Syscall(procConvertSidToStringSidW.Addr(), 2, uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(stringSid)), 0)
3199 if r1 == 0 {
3200 if e1 != 0 {
3201 err = errnoErr(e1)
3202 } else {
3203 err = syscall.EINVAL
3204 }
3205 }
3206 return
3207}
3208
3209func ConvertStringSidToSid(stringSid *uint16, sid **SID) (err error) {
3210 r1, _, e1 := syscall.Syscall(procConvertStringSidToSidW.Addr(), 2, uintptr(unsafe.Pointer(stringSid)), uintptr(unsafe.Pointer(sid)), 0)
3211 if r1 == 0 {
3212 if e1 != 0 {
3213 err = errnoErr(e1)
3214 } else {
3215 err = syscall.EINVAL
3216 }
3217 }
3218 return
3219}
3220
3221func GetLengthSid(sid *SID) (len uint32) {
3222 r0, _, _ := syscall.Syscall(procGetLengthSid.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0)
3223 len = uint32(r0)
3224 return
3225}
3226
3227func CopySid(destSidLen uint32, destSid *SID, srcSid *SID) (err error) {
3228 r1, _, e1 := syscall.Syscall(procCopySid.Addr(), 3, uintptr(destSidLen), uintptr(unsafe.Pointer(destSid)), uintptr(unsafe.Pointer(srcSid)))
3229 if r1 == 0 {
3230 if e1 != 0 {
3231 err = errnoErr(e1)
3232 } else {
3233 err = syscall.EINVAL
3234 }
3235 }
3236 return
3237}
3238
3239func AllocateAndInitializeSid(identAuth *SidIdentifierAuthority, subAuth byte, subAuth0 uint32, subAuth1 uint32, subAuth2 uint32, subAuth3 uint32, subAuth4 uint32, subAuth5 uint32, subAuth6 uint32, subAuth7 uint32, sid **SID) (err error) {
3240 r1, _, e1 := syscall.Syscall12(procAllocateAndInitializeSid.Addr(), 11, uintptr(unsafe.Pointer(identAuth)), uintptr(subAuth), uintptr(subAuth0), uintptr(subAuth1), uintptr(subAuth2), uintptr(subAuth3), uintptr(subAuth4), uintptr(subAuth5), uintptr(subAuth6), uintptr(subAuth7), uintptr(unsafe.Pointer(sid)), 0)
3241 if r1 == 0 {
3242 if e1 != 0 {
3243 err = errnoErr(e1)
3244 } else {
3245 err = syscall.EINVAL
3246 }
3247 }
3248 return
3249}
3250
3251func createWellKnownSid(sidType WELL_KNOWN_SID_TYPE, domainSid *SID, sid *SID, sizeSid *uint32) (err error) {
3252 r1, _, e1 := syscall.Syscall6(procCreateWellKnownSid.Addr(), 4, uintptr(sidType), uintptr(unsafe.Pointer(domainSid)), uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(sizeSid)), 0, 0)
3253 if r1 == 0 {
3254 if e1 != 0 {
3255 err = errnoErr(e1)
3256 } else {
3257 err = syscall.EINVAL
3258 }
3259 }
3260 return
3261}
3262
3263func isWellKnownSid(sid *SID, sidType WELL_KNOWN_SID_TYPE) (isWellKnown bool) {
3264 r0, _, _ := syscall.Syscall(procIsWellKnownSid.Addr(), 2, uintptr(unsafe.Pointer(sid)), uintptr(sidType), 0)
3265 isWellKnown = r0 != 0
3266 return
3267}
3268
3269func FreeSid(sid *SID) (err error) {
3270 r1, _, e1 := syscall.Syscall(procFreeSid.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0)
3271 if r1 != 0 {
3272 if e1 != 0 {
3273 err = errnoErr(e1)
3274 } else {
3275 err = syscall.EINVAL
3276 }
3277 }
3278 return
3279}
3280
3281func EqualSid(sid1 *SID, sid2 *SID) (isEqual bool) {
3282 r0, _, _ := syscall.Syscall(procEqualSid.Addr(), 2, uintptr(unsafe.Pointer(sid1)), uintptr(unsafe.Pointer(sid2)), 0)
3283 isEqual = r0 != 0
3284 return
3285}
3286
3287func getSidIdentifierAuthority(sid *SID) (authority *SidIdentifierAuthority) {
3288 r0, _, _ := syscall.Syscall(procGetSidIdentifierAuthority.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0)
3289 authority = (*SidIdentifierAuthority)(unsafe.Pointer(r0))
3290 return
3291}
3292
3293func getSidSubAuthorityCount(sid *SID) (count *uint8) {
3294 r0, _, _ := syscall.Syscall(procGetSidSubAuthorityCount.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0)
3295 count = (*uint8)(unsafe.Pointer(r0))
3296 return
3297}
3298
3299func getSidSubAuthority(sid *SID, index uint32) (subAuthority *uint32) {
3300 r0, _, _ := syscall.Syscall(procGetSidSubAuthority.Addr(), 2, uintptr(unsafe.Pointer(sid)), uintptr(index), 0)
3301 subAuthority = (*uint32)(unsafe.Pointer(r0))
3302 return
3303}
3304
3305func isValidSid(sid *SID) (isValid bool) {
3306 r0, _, _ := syscall.Syscall(procIsValidSid.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0)
3307 isValid = r0 != 0
3308 return
3309}
3310
3311func checkTokenMembership(tokenHandle Token, sidToCheck *SID, isMember *int32) (err error) {
3312 r1, _, e1 := syscall.Syscall(procCheckTokenMembership.Addr(), 3, uintptr(tokenHandle), uintptr(unsafe.Pointer(sidToCheck)), uintptr(unsafe.Pointer(isMember)))
3313 if r1 == 0 {
3314 if e1 != 0 {
3315 err = errnoErr(e1)
3316 } else {
3317 err = syscall.EINVAL
3318 }
3319 }
3320 return
3321}
3322
3323func OpenProcessToken(process Handle, access uint32, token *Token) (err error) {
3324 r1, _, e1 := syscall.Syscall(procOpenProcessToken.Addr(), 3, uintptr(process), uintptr(access), uintptr(unsafe.Pointer(token)))
3325 if r1 == 0 {
3326 if e1 != 0 {
3327 err = errnoErr(e1)
3328 } else {
3329 err = syscall.EINVAL
3330 }
3331 }
3332 return
3333}
3334
3335func OpenThreadToken(thread Handle, access uint32, openAsSelf bool, token *Token) (err error) {
3336 var _p0 uint32
3337 if openAsSelf {
3338 _p0 = 1
3339 } else {
3340 _p0 = 0
3341 }
3342 r1, _, e1 := syscall.Syscall6(procOpenThreadToken.Addr(), 4, uintptr(thread), uintptr(access), uintptr(_p0), uintptr(unsafe.Pointer(token)), 0, 0)
3343 if r1 == 0 {
3344 if e1 != 0 {
3345 err = errnoErr(e1)
3346 } else {
3347 err = syscall.EINVAL
3348 }
3349 }
3350 return
3351}
3352
3353func ImpersonateSelf(impersonationlevel uint32) (err error) {
3354 r1, _, e1 := syscall.Syscall(procImpersonateSelf.Addr(), 1, uintptr(impersonationlevel), 0, 0)
3355 if r1 == 0 {
3356 if e1 != 0 {
3357 err = errnoErr(e1)
3358 } else {
3359 err = syscall.EINVAL
3360 }
3361 }
3362 return
3363}
3364
3365func RevertToSelf() (err error) {
3366 r1, _, e1 := syscall.Syscall(procRevertToSelf.Addr(), 0, 0, 0, 0)
3367 if r1 == 0 {
3368 if e1 != 0 {
3369 err = errnoErr(e1)
3370 } else {
3371 err = syscall.EINVAL
3372 }
3373 }
3374 return
3375}
3376
3377func SetThreadToken(thread *Handle, token Token) (err error) {
3378 r1, _, e1 := syscall.Syscall(procSetThreadToken.Addr(), 2, uintptr(unsafe.Pointer(thread)), uintptr(token), 0)
3379 if r1 == 0 {
3380 if e1 != 0 {
3381 err = errnoErr(e1)
3382 } else {
3383 err = syscall.EINVAL
3384 }
3385 }
3386 return
3387}
3388
3389func LookupPrivilegeValue(systemname *uint16, name *uint16, luid *LUID) (err error) {
3390 r1, _, e1 := syscall.Syscall(procLookupPrivilegeValueW.Addr(), 3, uintptr(unsafe.Pointer(systemname)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(luid)))
3391 if r1 == 0 {
3392 if e1 != 0 {
3393 err = errnoErr(e1)
3394 } else {
3395 err = syscall.EINVAL
3396 }
3397 }
3398 return
3399}
3400
3401func AdjustTokenPrivileges(token Token, disableAllPrivileges bool, newstate *Tokenprivileges, buflen uint32, prevstate *Tokenprivileges, returnlen *uint32) (err error) {
3402 var _p0 uint32
3403 if disableAllPrivileges {
3404 _p0 = 1
3405 } else {
3406 _p0 = 0
3407 }
3408 r1, _, e1 := syscall.Syscall6(procAdjustTokenPrivileges.Addr(), 6, uintptr(token), uintptr(_p0), uintptr(unsafe.Pointer(newstate)), uintptr(buflen), uintptr(unsafe.Pointer(prevstate)), uintptr(unsafe.Pointer(returnlen)))
3409 if r1 == 0 {
3410 if e1 != 0 {
3411 err = errnoErr(e1)
3412 } else {
3413 err = syscall.EINVAL
3414 }
3415 }
3416 return
3417}
3418
3419func AdjustTokenGroups(token Token, resetToDefault bool, newstate *Tokengroups, buflen uint32, prevstate *Tokengroups, returnlen *uint32) (err error) {
3420 var _p0 uint32
3421 if resetToDefault {
3422 _p0 = 1
3423 } else {
3424 _p0 = 0
3425 }
3426 r1, _, e1 := syscall.Syscall6(procAdjustTokenGroups.Addr(), 6, uintptr(token), uintptr(_p0), uintptr(unsafe.Pointer(newstate)), uintptr(buflen), uintptr(unsafe.Pointer(prevstate)), uintptr(unsafe.Pointer(returnlen)))
3427 if r1 == 0 {
3428 if e1 != 0 {
3429 err = errnoErr(e1)
3430 } else {
3431 err = syscall.EINVAL
3432 }
3433 }
3434 return
3435}
3436
3437func GetTokenInformation(token Token, infoClass uint32, info *byte, infoLen uint32, returnedLen *uint32) (err error) {
3438 r1, _, e1 := syscall.Syscall6(procGetTokenInformation.Addr(), 5, uintptr(token), uintptr(infoClass), uintptr(unsafe.Pointer(info)), uintptr(infoLen), uintptr(unsafe.Pointer(returnedLen)), 0)
3439 if r1 == 0 {
3440 if e1 != 0 {
3441 err = errnoErr(e1)
3442 } else {
3443 err = syscall.EINVAL
3444 }
3445 }
3446 return
3447}
3448
3449func SetTokenInformation(token Token, infoClass uint32, info *byte, infoLen uint32) (err error) {
3450 r1, _, e1 := syscall.Syscall6(procSetTokenInformation.Addr(), 4, uintptr(token), uintptr(infoClass), uintptr(unsafe.Pointer(info)), uintptr(infoLen), 0, 0)
3451 if r1 == 0 {
3452 if e1 != 0 {
3453 err = errnoErr(e1)
3454 } else {
3455 err = syscall.EINVAL
3456 }
3457 }
3458 return
3459}
3460
3461func DuplicateTokenEx(existingToken Token, desiredAccess uint32, tokenAttributes *SecurityAttributes, impersonationLevel uint32, tokenType uint32, newToken *Token) (err error) {
3462 r1, _, e1 := syscall.Syscall6(procDuplicateTokenEx.Addr(), 6, uintptr(existingToken), uintptr(desiredAccess), uintptr(unsafe.Pointer(tokenAttributes)), uintptr(impersonationLevel), uintptr(tokenType), uintptr(unsafe.Pointer(newToken)))
3463 if r1 == 0 {
3464 if e1 != 0 {
3465 err = errnoErr(e1)
3466 } else {
3467 err = syscall.EINVAL
3468 }
3469 }
3470 return
3471}
3472
3473func GetUserProfileDirectory(t Token, dir *uint16, dirLen *uint32) (err error) {
3474 r1, _, e1 := syscall.Syscall(procGetUserProfileDirectoryW.Addr(), 3, uintptr(t), uintptr(unsafe.Pointer(dir)), uintptr(unsafe.Pointer(dirLen)))
3475 if r1 == 0 {
3476 if e1 != 0 {
3477 err = errnoErr(e1)
3478 } else {
3479 err = syscall.EINVAL
3480 }
3481 }
3482 return
3483}
3484
3485func getSystemDirectory(dir *uint16, dirLen uint32) (len uint32, err error) {
3486 r0, _, e1 := syscall.Syscall(procGetSystemDirectoryW.Addr(), 2, uintptr(unsafe.Pointer(dir)), uintptr(dirLen), 0)
3487 len = uint32(r0)
3488 if len == 0 {
3489 if e1 != 0 {
3490 err = errnoErr(e1)
3491 } else {
3492 err = syscall.EINVAL
3493 }
3494 }
3495 return
3496}
3497
divyadesai19009132020-03-04 12:58:08 +00003498func getWindowsDirectory(dir *uint16, dirLen uint32) (len uint32, err error) {
3499 r0, _, e1 := syscall.Syscall(procGetWindowsDirectoryW.Addr(), 2, uintptr(unsafe.Pointer(dir)), uintptr(dirLen), 0)
3500 len = uint32(r0)
3501 if len == 0 {
3502 if e1 != 0 {
3503 err = errnoErr(e1)
3504 } else {
3505 err = syscall.EINVAL
3506 }
3507 }
3508 return
3509}
3510
3511func getSystemWindowsDirectory(dir *uint16, dirLen uint32) (len uint32, err error) {
3512 r0, _, e1 := syscall.Syscall(procGetSystemWindowsDirectoryW.Addr(), 2, uintptr(unsafe.Pointer(dir)), uintptr(dirLen), 0)
3513 len = uint32(r0)
3514 if len == 0 {
3515 if e1 != 0 {
3516 err = errnoErr(e1)
3517 } else {
3518 err = syscall.EINVAL
3519 }
3520 }
3521 return
3522}
3523
Zack Williamse940c7a2019-08-21 14:25:39 -07003524func WTSQueryUserToken(session uint32, token *Token) (err error) {
3525 r1, _, e1 := syscall.Syscall(procWTSQueryUserToken.Addr(), 2, uintptr(session), uintptr(unsafe.Pointer(token)), 0)
3526 if r1 == 0 {
3527 if e1 != 0 {
3528 err = errnoErr(e1)
3529 } else {
3530 err = syscall.EINVAL
3531 }
3532 }
3533 return
3534}
3535
3536func WTSEnumerateSessions(handle Handle, reserved uint32, version uint32, sessions **WTS_SESSION_INFO, count *uint32) (err error) {
3537 r1, _, e1 := syscall.Syscall6(procWTSEnumerateSessionsW.Addr(), 5, uintptr(handle), uintptr(reserved), uintptr(version), uintptr(unsafe.Pointer(sessions)), uintptr(unsafe.Pointer(count)), 0)
3538 if r1 == 0 {
3539 if e1 != 0 {
3540 err = errnoErr(e1)
3541 } else {
3542 err = syscall.EINVAL
3543 }
3544 }
3545 return
3546}
3547
3548func WTSFreeMemory(ptr uintptr) {
3549 syscall.Syscall(procWTSFreeMemory.Addr(), 1, uintptr(ptr), 0, 0)
3550 return
3551}
divyadesai19009132020-03-04 12:58:08 +00003552
3553func getSecurityInfo(handle Handle, objectType SE_OBJECT_TYPE, securityInformation SECURITY_INFORMATION, owner **SID, group **SID, dacl **ACL, sacl **ACL, sd **SECURITY_DESCRIPTOR) (ret error) {
3554 r0, _, _ := syscall.Syscall9(procGetSecurityInfo.Addr(), 8, uintptr(handle), uintptr(objectType), uintptr(securityInformation), uintptr(unsafe.Pointer(owner)), uintptr(unsafe.Pointer(group)), uintptr(unsafe.Pointer(dacl)), uintptr(unsafe.Pointer(sacl)), uintptr(unsafe.Pointer(sd)), 0)
3555 if r0 != 0 {
3556 ret = syscall.Errno(r0)
3557 }
3558 return
3559}
3560
3561func SetSecurityInfo(handle Handle, objectType SE_OBJECT_TYPE, securityInformation SECURITY_INFORMATION, owner *SID, group *SID, dacl *ACL, sacl *ACL) {
3562 syscall.Syscall9(procSetSecurityInfo.Addr(), 7, uintptr(handle), uintptr(objectType), uintptr(securityInformation), uintptr(unsafe.Pointer(owner)), uintptr(unsafe.Pointer(group)), uintptr(unsafe.Pointer(dacl)), uintptr(unsafe.Pointer(sacl)), 0, 0)
3563 return
3564}
3565
3566func getNamedSecurityInfo(objectName string, objectType SE_OBJECT_TYPE, securityInformation SECURITY_INFORMATION, owner **SID, group **SID, dacl **ACL, sacl **ACL, sd **SECURITY_DESCRIPTOR) (ret error) {
3567 var _p0 *uint16
3568 _p0, ret = syscall.UTF16PtrFromString(objectName)
3569 if ret != nil {
3570 return
3571 }
3572 return _getNamedSecurityInfo(_p0, objectType, securityInformation, owner, group, dacl, sacl, sd)
3573}
3574
3575func _getNamedSecurityInfo(objectName *uint16, objectType SE_OBJECT_TYPE, securityInformation SECURITY_INFORMATION, owner **SID, group **SID, dacl **ACL, sacl **ACL, sd **SECURITY_DESCRIPTOR) (ret error) {
3576 r0, _, _ := syscall.Syscall9(procGetNamedSecurityInfoW.Addr(), 8, uintptr(unsafe.Pointer(objectName)), uintptr(objectType), uintptr(securityInformation), uintptr(unsafe.Pointer(owner)), uintptr(unsafe.Pointer(group)), uintptr(unsafe.Pointer(dacl)), uintptr(unsafe.Pointer(sacl)), uintptr(unsafe.Pointer(sd)), 0)
3577 if r0 != 0 {
3578 ret = syscall.Errno(r0)
3579 }
3580 return
3581}
3582
3583func SetNamedSecurityInfo(objectName string, objectType SE_OBJECT_TYPE, securityInformation SECURITY_INFORMATION, owner *SID, group *SID, dacl *ACL, sacl *ACL) (ret error) {
3584 var _p0 *uint16
3585 _p0, ret = syscall.UTF16PtrFromString(objectName)
3586 if ret != nil {
3587 return
3588 }
3589 return _SetNamedSecurityInfo(_p0, objectType, securityInformation, owner, group, dacl, sacl)
3590}
3591
3592func _SetNamedSecurityInfo(objectName *uint16, objectType SE_OBJECT_TYPE, securityInformation SECURITY_INFORMATION, owner *SID, group *SID, dacl *ACL, sacl *ACL) (ret error) {
3593 r0, _, _ := syscall.Syscall9(procSetNamedSecurityInfoW.Addr(), 7, uintptr(unsafe.Pointer(objectName)), uintptr(objectType), uintptr(securityInformation), uintptr(unsafe.Pointer(owner)), uintptr(unsafe.Pointer(group)), uintptr(unsafe.Pointer(dacl)), uintptr(unsafe.Pointer(sacl)), 0, 0)
3594 if r0 != 0 {
3595 ret = syscall.Errno(r0)
3596 }
3597 return
3598}
3599
3600func buildSecurityDescriptor(owner *TRUSTEE, group *TRUSTEE, countAccessEntries uint32, accessEntries *EXPLICIT_ACCESS, countAuditEntries uint32, auditEntries *EXPLICIT_ACCESS, oldSecurityDescriptor *SECURITY_DESCRIPTOR, sizeNewSecurityDescriptor *uint32, newSecurityDescriptor **SECURITY_DESCRIPTOR) (ret error) {
3601 r0, _, _ := syscall.Syscall9(procBuildSecurityDescriptorW.Addr(), 9, uintptr(unsafe.Pointer(owner)), uintptr(unsafe.Pointer(group)), uintptr(countAccessEntries), uintptr(unsafe.Pointer(accessEntries)), uintptr(countAuditEntries), uintptr(unsafe.Pointer(auditEntries)), uintptr(unsafe.Pointer(oldSecurityDescriptor)), uintptr(unsafe.Pointer(sizeNewSecurityDescriptor)), uintptr(unsafe.Pointer(newSecurityDescriptor)))
3602 if r0 != 0 {
3603 ret = syscall.Errno(r0)
3604 }
3605 return
3606}
3607
3608func initializeSecurityDescriptor(absoluteSD *SECURITY_DESCRIPTOR, revision uint32) (err error) {
3609 r1, _, e1 := syscall.Syscall(procInitializeSecurityDescriptor.Addr(), 2, uintptr(unsafe.Pointer(absoluteSD)), uintptr(revision), 0)
3610 if r1 == 0 {
3611 if e1 != 0 {
3612 err = errnoErr(e1)
3613 } else {
3614 err = syscall.EINVAL
3615 }
3616 }
3617 return
3618}
3619
3620func getSecurityDescriptorControl(sd *SECURITY_DESCRIPTOR, control *SECURITY_DESCRIPTOR_CONTROL, revision *uint32) (err error) {
3621 r1, _, e1 := syscall.Syscall(procGetSecurityDescriptorControl.Addr(), 3, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(control)), uintptr(unsafe.Pointer(revision)))
3622 if r1 == 0 {
3623 if e1 != 0 {
3624 err = errnoErr(e1)
3625 } else {
3626 err = syscall.EINVAL
3627 }
3628 }
3629 return
3630}
3631
3632func getSecurityDescriptorDacl(sd *SECURITY_DESCRIPTOR, daclPresent *bool, dacl **ACL, daclDefaulted *bool) (err error) {
3633 var _p0 uint32
3634 if *daclPresent {
3635 _p0 = 1
3636 } else {
3637 _p0 = 0
3638 }
3639 var _p1 uint32
3640 if *daclDefaulted {
3641 _p1 = 1
3642 } else {
3643 _p1 = 0
3644 }
3645 r1, _, e1 := syscall.Syscall6(procGetSecurityDescriptorDacl.Addr(), 4, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(&_p0)), uintptr(unsafe.Pointer(dacl)), uintptr(unsafe.Pointer(&_p1)), 0, 0)
3646 *daclPresent = _p0 != 0
3647 *daclDefaulted = _p1 != 0
3648 if r1 == 0 {
3649 if e1 != 0 {
3650 err = errnoErr(e1)
3651 } else {
3652 err = syscall.EINVAL
3653 }
3654 }
3655 return
3656}
3657
3658func getSecurityDescriptorSacl(sd *SECURITY_DESCRIPTOR, saclPresent *bool, sacl **ACL, saclDefaulted *bool) (err error) {
3659 var _p0 uint32
3660 if *saclPresent {
3661 _p0 = 1
3662 } else {
3663 _p0 = 0
3664 }
3665 var _p1 uint32
3666 if *saclDefaulted {
3667 _p1 = 1
3668 } else {
3669 _p1 = 0
3670 }
3671 r1, _, e1 := syscall.Syscall6(procGetSecurityDescriptorSacl.Addr(), 4, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(&_p0)), uintptr(unsafe.Pointer(sacl)), uintptr(unsafe.Pointer(&_p1)), 0, 0)
3672 *saclPresent = _p0 != 0
3673 *saclDefaulted = _p1 != 0
3674 if r1 == 0 {
3675 if e1 != 0 {
3676 err = errnoErr(e1)
3677 } else {
3678 err = syscall.EINVAL
3679 }
3680 }
3681 return
3682}
3683
3684func getSecurityDescriptorOwner(sd *SECURITY_DESCRIPTOR, owner **SID, ownerDefaulted *bool) (err error) {
3685 var _p0 uint32
3686 if *ownerDefaulted {
3687 _p0 = 1
3688 } else {
3689 _p0 = 0
3690 }
3691 r1, _, e1 := syscall.Syscall(procGetSecurityDescriptorOwner.Addr(), 3, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(owner)), uintptr(unsafe.Pointer(&_p0)))
3692 *ownerDefaulted = _p0 != 0
3693 if r1 == 0 {
3694 if e1 != 0 {
3695 err = errnoErr(e1)
3696 } else {
3697 err = syscall.EINVAL
3698 }
3699 }
3700 return
3701}
3702
3703func getSecurityDescriptorGroup(sd *SECURITY_DESCRIPTOR, group **SID, groupDefaulted *bool) (err error) {
3704 var _p0 uint32
3705 if *groupDefaulted {
3706 _p0 = 1
3707 } else {
3708 _p0 = 0
3709 }
3710 r1, _, e1 := syscall.Syscall(procGetSecurityDescriptorGroup.Addr(), 3, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(group)), uintptr(unsafe.Pointer(&_p0)))
3711 *groupDefaulted = _p0 != 0
3712 if r1 == 0 {
3713 if e1 != 0 {
3714 err = errnoErr(e1)
3715 } else {
3716 err = syscall.EINVAL
3717 }
3718 }
3719 return
3720}
3721
3722func getSecurityDescriptorLength(sd *SECURITY_DESCRIPTOR) (len uint32) {
3723 r0, _, _ := syscall.Syscall(procGetSecurityDescriptorLength.Addr(), 1, uintptr(unsafe.Pointer(sd)), 0, 0)
3724 len = uint32(r0)
3725 return
3726}
3727
3728func getSecurityDescriptorRMControl(sd *SECURITY_DESCRIPTOR, rmControl *uint8) (ret error) {
3729 r0, _, _ := syscall.Syscall(procGetSecurityDescriptorRMControl.Addr(), 2, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(rmControl)), 0)
3730 if r0 != 0 {
3731 ret = syscall.Errno(r0)
3732 }
3733 return
3734}
3735
3736func isValidSecurityDescriptor(sd *SECURITY_DESCRIPTOR) (isValid bool) {
3737 r0, _, _ := syscall.Syscall(procIsValidSecurityDescriptor.Addr(), 1, uintptr(unsafe.Pointer(sd)), 0, 0)
3738 isValid = r0 != 0
3739 return
3740}
3741
3742func setSecurityDescriptorControl(sd *SECURITY_DESCRIPTOR, controlBitsOfInterest SECURITY_DESCRIPTOR_CONTROL, controlBitsToSet SECURITY_DESCRIPTOR_CONTROL) (err error) {
3743 r1, _, e1 := syscall.Syscall(procSetSecurityDescriptorControl.Addr(), 3, uintptr(unsafe.Pointer(sd)), uintptr(controlBitsOfInterest), uintptr(controlBitsToSet))
3744 if r1 == 0 {
3745 if e1 != 0 {
3746 err = errnoErr(e1)
3747 } else {
3748 err = syscall.EINVAL
3749 }
3750 }
3751 return
3752}
3753
3754func setSecurityDescriptorDacl(sd *SECURITY_DESCRIPTOR, daclPresent bool, dacl *ACL, daclDefaulted bool) (err error) {
3755 var _p0 uint32
3756 if daclPresent {
3757 _p0 = 1
3758 } else {
3759 _p0 = 0
3760 }
3761 var _p1 uint32
3762 if daclDefaulted {
3763 _p1 = 1
3764 } else {
3765 _p1 = 0
3766 }
3767 r1, _, e1 := syscall.Syscall6(procSetSecurityDescriptorDacl.Addr(), 4, uintptr(unsafe.Pointer(sd)), uintptr(_p0), uintptr(unsafe.Pointer(dacl)), uintptr(_p1), 0, 0)
3768 if r1 == 0 {
3769 if e1 != 0 {
3770 err = errnoErr(e1)
3771 } else {
3772 err = syscall.EINVAL
3773 }
3774 }
3775 return
3776}
3777
3778func setSecurityDescriptorSacl(sd *SECURITY_DESCRIPTOR, saclPresent bool, sacl *ACL, saclDefaulted bool) (err error) {
3779 var _p0 uint32
3780 if saclPresent {
3781 _p0 = 1
3782 } else {
3783 _p0 = 0
3784 }
3785 var _p1 uint32
3786 if saclDefaulted {
3787 _p1 = 1
3788 } else {
3789 _p1 = 0
3790 }
3791 r1, _, e1 := syscall.Syscall6(procSetSecurityDescriptorSacl.Addr(), 4, uintptr(unsafe.Pointer(sd)), uintptr(_p0), uintptr(unsafe.Pointer(sacl)), uintptr(_p1), 0, 0)
3792 if r1 == 0 {
3793 if e1 != 0 {
3794 err = errnoErr(e1)
3795 } else {
3796 err = syscall.EINVAL
3797 }
3798 }
3799 return
3800}
3801
3802func setSecurityDescriptorOwner(sd *SECURITY_DESCRIPTOR, owner *SID, ownerDefaulted bool) (err error) {
3803 var _p0 uint32
3804 if ownerDefaulted {
3805 _p0 = 1
3806 } else {
3807 _p0 = 0
3808 }
3809 r1, _, e1 := syscall.Syscall(procSetSecurityDescriptorOwner.Addr(), 3, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(owner)), uintptr(_p0))
3810 if r1 == 0 {
3811 if e1 != 0 {
3812 err = errnoErr(e1)
3813 } else {
3814 err = syscall.EINVAL
3815 }
3816 }
3817 return
3818}
3819
3820func setSecurityDescriptorGroup(sd *SECURITY_DESCRIPTOR, group *SID, groupDefaulted bool) (err error) {
3821 var _p0 uint32
3822 if groupDefaulted {
3823 _p0 = 1
3824 } else {
3825 _p0 = 0
3826 }
3827 r1, _, e1 := syscall.Syscall(procSetSecurityDescriptorGroup.Addr(), 3, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(group)), uintptr(_p0))
3828 if r1 == 0 {
3829 if e1 != 0 {
3830 err = errnoErr(e1)
3831 } else {
3832 err = syscall.EINVAL
3833 }
3834 }
3835 return
3836}
3837
3838func setSecurityDescriptorRMControl(sd *SECURITY_DESCRIPTOR, rmControl *uint8) {
3839 syscall.Syscall(procSetSecurityDescriptorRMControl.Addr(), 2, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(rmControl)), 0)
3840 return
3841}
3842
3843func convertStringSecurityDescriptorToSecurityDescriptor(str string, revision uint32, sd **SECURITY_DESCRIPTOR, size *uint32) (err error) {
3844 var _p0 *uint16
3845 _p0, err = syscall.UTF16PtrFromString(str)
3846 if err != nil {
3847 return
3848 }
3849 return _convertStringSecurityDescriptorToSecurityDescriptor(_p0, revision, sd, size)
3850}
3851
3852func _convertStringSecurityDescriptorToSecurityDescriptor(str *uint16, revision uint32, sd **SECURITY_DESCRIPTOR, size *uint32) (err error) {
3853 r1, _, e1 := syscall.Syscall6(procConvertStringSecurityDescriptorToSecurityDescriptorW.Addr(), 4, uintptr(unsafe.Pointer(str)), uintptr(revision), uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(size)), 0, 0)
3854 if r1 == 0 {
3855 if e1 != 0 {
3856 err = errnoErr(e1)
3857 } else {
3858 err = syscall.EINVAL
3859 }
3860 }
3861 return
3862}
3863
3864func convertSecurityDescriptorToStringSecurityDescriptor(sd *SECURITY_DESCRIPTOR, revision uint32, securityInformation SECURITY_INFORMATION, str **uint16, strLen *uint32) (err error) {
3865 r1, _, e1 := syscall.Syscall6(procConvertSecurityDescriptorToStringSecurityDescriptorW.Addr(), 5, uintptr(unsafe.Pointer(sd)), uintptr(revision), uintptr(securityInformation), uintptr(unsafe.Pointer(str)), uintptr(unsafe.Pointer(strLen)), 0)
3866 if r1 == 0 {
3867 if e1 != 0 {
3868 err = errnoErr(e1)
3869 } else {
3870 err = syscall.EINVAL
3871 }
3872 }
3873 return
3874}
3875
3876func makeAbsoluteSD(selfRelativeSD *SECURITY_DESCRIPTOR, absoluteSD *SECURITY_DESCRIPTOR, absoluteSDSize *uint32, dacl *ACL, daclSize *uint32, sacl *ACL, saclSize *uint32, owner *SID, ownerSize *uint32, group *SID, groupSize *uint32) (err error) {
3877 r1, _, e1 := syscall.Syscall12(procMakeAbsoluteSD.Addr(), 11, uintptr(unsafe.Pointer(selfRelativeSD)), uintptr(unsafe.Pointer(absoluteSD)), uintptr(unsafe.Pointer(absoluteSDSize)), uintptr(unsafe.Pointer(dacl)), uintptr(unsafe.Pointer(daclSize)), uintptr(unsafe.Pointer(sacl)), uintptr(unsafe.Pointer(saclSize)), uintptr(unsafe.Pointer(owner)), uintptr(unsafe.Pointer(ownerSize)), uintptr(unsafe.Pointer(group)), uintptr(unsafe.Pointer(groupSize)), 0)
3878 if r1 == 0 {
3879 if e1 != 0 {
3880 err = errnoErr(e1)
3881 } else {
3882 err = syscall.EINVAL
3883 }
3884 }
3885 return
3886}
3887
3888func makeSelfRelativeSD(absoluteSD *SECURITY_DESCRIPTOR, selfRelativeSD *SECURITY_DESCRIPTOR, selfRelativeSDSize *uint32) (err error) {
3889 r1, _, e1 := syscall.Syscall(procMakeSelfRelativeSD.Addr(), 3, uintptr(unsafe.Pointer(absoluteSD)), uintptr(unsafe.Pointer(selfRelativeSD)), uintptr(unsafe.Pointer(selfRelativeSDSize)))
3890 if r1 == 0 {
3891 if e1 != 0 {
3892 err = errnoErr(e1)
3893 } else {
3894 err = syscall.EINVAL
3895 }
3896 }
3897 return
3898}
3899
3900func setEntriesInAcl(countExplicitEntries uint32, explicitEntries *EXPLICIT_ACCESS, oldACL *ACL, newACL **ACL) (ret error) {
3901 r0, _, _ := syscall.Syscall6(procSetEntriesInAclW.Addr(), 4, uintptr(countExplicitEntries), uintptr(unsafe.Pointer(explicitEntries)), uintptr(unsafe.Pointer(oldACL)), uintptr(unsafe.Pointer(newACL)), 0, 0)
3902 if r0 != 0 {
3903 ret = syscall.Errno(r0)
3904 }
3905 return
3906}