blob: b28a1934d15389a30c58b57781f6d4ea428b58ea [file] [log] [blame]
Tobias Klauser8014b7b2018-06-14 09:37:16 +02001// Code generated by 'go generate'; DO NOT EDIT.
Rob Pike20acc5c2014-08-11 14:48:46 -07002
Rob Pike8442dd22014-08-11 15:58:26 -07003package windows
Rob Pike20acc5c2014-08-11 14:48:46 -07004
Brad Fitzpatrick3dff6e12016-04-01 04:10:49 +00005import (
6 "syscall"
7 "unsafe"
8)
Rob Pike20acc5c2014-08-11 14:48:46 -07009
Carlos Castillo5b683252015-02-27 04:46:26 -080010var _ unsafe.Pointer
11
Alex Brainmanca83bd22016-12-02 16:54:46 +110012// 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)
Alex Brainman9f70ab92020-10-24 17:55:14 +110020 errERROR_EINVAL error = syscall.EINVAL
Alex Brainmanca83bd22016-12-02 16:54:46 +110021)
22
23// errnoErr returns common boxed Errno values, to prevent
24// allocations at runtime.
25func errnoErr(e syscall.Errno) error {
26 switch e {
27 case 0:
Alex Brainman9f70ab92020-10-24 17:55:14 +110028 return errERROR_EINVAL
Alex Brainmanca83bd22016-12-02 16:54:46 +110029 case errnoERROR_IO_PENDING:
30 return errERROR_IO_PENDING
31 }
32 // TODO: add more here, after collecting data on the common
33 // error values see on Windows. (perhaps when running
34 // all.bat?)
35 return e
36}
37
Rob Pike20acc5c2014-08-11 14:48:46 -070038var (
Alex Brainman042a8f52016-04-06 15:52:57 +100039 modadvapi32 = NewLazySystemDLL("advapi32.dll")
Alex Brainman042a8f52016-04-06 15:52:57 +100040 modcrypt32 = NewLazySystemDLL("crypt32.dll")
Alex Brainman042a8f52016-04-06 15:52:57 +100041 moddnsapi = NewLazySystemDLL("dnsapi.dll")
42 modiphlpapi = NewLazySystemDLL("iphlpapi.dll")
Alex Brainman0aaa2712020-10-11 09:49:28 +110043 modkernel32 = NewLazySystemDLL("kernel32.dll")
44 modmswsock = NewLazySystemDLL("mswsock.dll")
Alex Brainman042a8f52016-04-06 15:52:57 +100045 modnetapi32 = NewLazySystemDLL("netapi32.dll")
Alex Brainman0aaa2712020-10-11 09:49:28 +110046 modntdll = NewLazySystemDLL("ntdll.dll")
47 modole32 = NewLazySystemDLL("ole32.dll")
48 modpsapi = NewLazySystemDLL("psapi.dll")
Jason A. Donenfeldc9906e32020-12-02 23:27:29 +010049 modsechost = NewLazySystemDLL("sechost.dll")
Alex Brainman0aaa2712020-10-11 09:49:28 +110050 modsecur32 = NewLazySystemDLL("secur32.dll")
51 modshell32 = NewLazySystemDLL("shell32.dll")
52 moduser32 = NewLazySystemDLL("user32.dll")
53 moduserenv = NewLazySystemDLL("userenv.dll")
Jason A. Donenfeld07034702021-01-22 17:59:47 +010054 modwintrust = NewLazySystemDLL("wintrust.dll")
Alex Brainman0aaa2712020-10-11 09:49:28 +110055 modws2_32 = NewLazySystemDLL("ws2_32.dll")
Jason A. Donenfeldf91f9b32019-05-13 10:42:08 +020056 modwtsapi32 = NewLazySystemDLL("wtsapi32.dll")
Rob Pike20acc5c2014-08-11 14:48:46 -070057
Alex Brainman0aaa2712020-10-11 09:49:28 +110058 procAdjustTokenGroups = modadvapi32.NewProc("AdjustTokenGroups")
59 procAdjustTokenPrivileges = modadvapi32.NewProc("AdjustTokenPrivileges")
60 procAllocateAndInitializeSid = modadvapi32.NewProc("AllocateAndInitializeSid")
61 procBuildSecurityDescriptorW = modadvapi32.NewProc("BuildSecurityDescriptorW")
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -060062 procChangeServiceConfig2W = modadvapi32.NewProc("ChangeServiceConfig2W")
Alex Brainman0aaa2712020-10-11 09:49:28 +110063 procChangeServiceConfigW = modadvapi32.NewProc("ChangeServiceConfigW")
64 procCheckTokenMembership = modadvapi32.NewProc("CheckTokenMembership")
65 procCloseServiceHandle = modadvapi32.NewProc("CloseServiceHandle")
66 procControlService = modadvapi32.NewProc("ControlService")
67 procConvertSecurityDescriptorToStringSecurityDescriptorW = modadvapi32.NewProc("ConvertSecurityDescriptorToStringSecurityDescriptorW")
68 procConvertSidToStringSidW = modadvapi32.NewProc("ConvertSidToStringSidW")
69 procConvertStringSecurityDescriptorToSecurityDescriptorW = modadvapi32.NewProc("ConvertStringSecurityDescriptorToSecurityDescriptorW")
70 procConvertStringSidToSidW = modadvapi32.NewProc("ConvertStringSidToSidW")
71 procCopySid = modadvapi32.NewProc("CopySid")
72 procCreateServiceW = modadvapi32.NewProc("CreateServiceW")
73 procCreateWellKnownSid = modadvapi32.NewProc("CreateWellKnownSid")
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -060074 procCryptAcquireContextW = modadvapi32.NewProc("CryptAcquireContextW")
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -060075 procCryptGenRandom = modadvapi32.NewProc("CryptGenRandom")
Alex Brainman0aaa2712020-10-11 09:49:28 +110076 procCryptReleaseContext = modadvapi32.NewProc("CryptReleaseContext")
77 procDeleteService = modadvapi32.NewProc("DeleteService")
78 procDeregisterEventSource = modadvapi32.NewProc("DeregisterEventSource")
79 procDuplicateTokenEx = modadvapi32.NewProc("DuplicateTokenEx")
80 procEnumServicesStatusExW = modadvapi32.NewProc("EnumServicesStatusExW")
81 procEqualSid = modadvapi32.NewProc("EqualSid")
82 procFreeSid = modadvapi32.NewProc("FreeSid")
83 procGetLengthSid = modadvapi32.NewProc("GetLengthSid")
84 procGetNamedSecurityInfoW = modadvapi32.NewProc("GetNamedSecurityInfoW")
85 procGetSecurityDescriptorControl = modadvapi32.NewProc("GetSecurityDescriptorControl")
86 procGetSecurityDescriptorDacl = modadvapi32.NewProc("GetSecurityDescriptorDacl")
87 procGetSecurityDescriptorGroup = modadvapi32.NewProc("GetSecurityDescriptorGroup")
88 procGetSecurityDescriptorLength = modadvapi32.NewProc("GetSecurityDescriptorLength")
89 procGetSecurityDescriptorOwner = modadvapi32.NewProc("GetSecurityDescriptorOwner")
90 procGetSecurityDescriptorRMControl = modadvapi32.NewProc("GetSecurityDescriptorRMControl")
91 procGetSecurityDescriptorSacl = modadvapi32.NewProc("GetSecurityDescriptorSacl")
92 procGetSecurityInfo = modadvapi32.NewProc("GetSecurityInfo")
93 procGetSidIdentifierAuthority = modadvapi32.NewProc("GetSidIdentifierAuthority")
94 procGetSidSubAuthority = modadvapi32.NewProc("GetSidSubAuthority")
95 procGetSidSubAuthorityCount = modadvapi32.NewProc("GetSidSubAuthorityCount")
96 procGetTokenInformation = modadvapi32.NewProc("GetTokenInformation")
97 procImpersonateSelf = modadvapi32.NewProc("ImpersonateSelf")
98 procInitializeSecurityDescriptor = modadvapi32.NewProc("InitializeSecurityDescriptor")
99 procInitiateSystemShutdownExW = modadvapi32.NewProc("InitiateSystemShutdownExW")
Jason A. Donenfeldf88b8272020-11-21 10:31:08 +0100100 procIsTokenRestricted = modadvapi32.NewProc("IsTokenRestricted")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100101 procIsValidSecurityDescriptor = modadvapi32.NewProc("IsValidSecurityDescriptor")
102 procIsValidSid = modadvapi32.NewProc("IsValidSid")
103 procIsWellKnownSid = modadvapi32.NewProc("IsWellKnownSid")
104 procLookupAccountNameW = modadvapi32.NewProc("LookupAccountNameW")
105 procLookupAccountSidW = modadvapi32.NewProc("LookupAccountSidW")
106 procLookupPrivilegeValueW = modadvapi32.NewProc("LookupPrivilegeValueW")
107 procMakeAbsoluteSD = modadvapi32.NewProc("MakeAbsoluteSD")
108 procMakeSelfRelativeSD = modadvapi32.NewProc("MakeSelfRelativeSD")
109 procNotifyServiceStatusChangeW = modadvapi32.NewProc("NotifyServiceStatusChangeW")
110 procOpenProcessToken = modadvapi32.NewProc("OpenProcessToken")
111 procOpenSCManagerW = modadvapi32.NewProc("OpenSCManagerW")
112 procOpenServiceW = modadvapi32.NewProc("OpenServiceW")
113 procOpenThreadToken = modadvapi32.NewProc("OpenThreadToken")
114 procQueryServiceConfig2W = modadvapi32.NewProc("QueryServiceConfig2W")
115 procQueryServiceConfigW = modadvapi32.NewProc("QueryServiceConfigW")
116 procQueryServiceLockStatusW = modadvapi32.NewProc("QueryServiceLockStatusW")
117 procQueryServiceStatus = modadvapi32.NewProc("QueryServiceStatus")
118 procQueryServiceStatusEx = modadvapi32.NewProc("QueryServiceStatusEx")
119 procRegCloseKey = modadvapi32.NewProc("RegCloseKey")
120 procRegEnumKeyExW = modadvapi32.NewProc("RegEnumKeyExW")
Josh Bleecher Snyder7e3030f2020-12-10 12:50:29 -0800121 procRegNotifyChangeKeyValue = modadvapi32.NewProc("RegNotifyChangeKeyValue")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100122 procRegOpenKeyExW = modadvapi32.NewProc("RegOpenKeyExW")
123 procRegQueryInfoKeyW = modadvapi32.NewProc("RegQueryInfoKeyW")
124 procRegQueryValueExW = modadvapi32.NewProc("RegQueryValueExW")
125 procRegisterEventSourceW = modadvapi32.NewProc("RegisterEventSourceW")
126 procReportEventW = modadvapi32.NewProc("ReportEventW")
127 procRevertToSelf = modadvapi32.NewProc("RevertToSelf")
128 procSetEntriesInAclW = modadvapi32.NewProc("SetEntriesInAclW")
Jason A. Donenfeld3a5be022020-11-16 17:33:31 +0100129 procSetKernelObjectSecurity = modadvapi32.NewProc("SetKernelObjectSecurity")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100130 procSetNamedSecurityInfoW = modadvapi32.NewProc("SetNamedSecurityInfoW")
131 procSetSecurityDescriptorControl = modadvapi32.NewProc("SetSecurityDescriptorControl")
132 procSetSecurityDescriptorDacl = modadvapi32.NewProc("SetSecurityDescriptorDacl")
133 procSetSecurityDescriptorGroup = modadvapi32.NewProc("SetSecurityDescriptorGroup")
134 procSetSecurityDescriptorOwner = modadvapi32.NewProc("SetSecurityDescriptorOwner")
135 procSetSecurityDescriptorRMControl = modadvapi32.NewProc("SetSecurityDescriptorRMControl")
136 procSetSecurityDescriptorSacl = modadvapi32.NewProc("SetSecurityDescriptorSacl")
137 procSetSecurityInfo = modadvapi32.NewProc("SetSecurityInfo")
138 procSetServiceStatus = modadvapi32.NewProc("SetServiceStatus")
139 procSetThreadToken = modadvapi32.NewProc("SetThreadToken")
140 procSetTokenInformation = modadvapi32.NewProc("SetTokenInformation")
141 procStartServiceCtrlDispatcherW = modadvapi32.NewProc("StartServiceCtrlDispatcherW")
142 procStartServiceW = modadvapi32.NewProc("StartServiceW")
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600143 procCertAddCertificateContextToStore = modcrypt32.NewProc("CertAddCertificateContextToStore")
144 procCertCloseStore = modcrypt32.NewProc("CertCloseStore")
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600145 procCertCreateCertificateContext = modcrypt32.NewProc("CertCreateCertificateContext")
Daniel Kessler80594f22020-11-04 13:11:48 -0800146 procCertDeleteCertificateFromStore = modcrypt32.NewProc("CertDeleteCertificateFromStore")
Boshi LIAN2d187342020-12-31 18:09:48 +0000147 procCertDuplicateCertificateContext = modcrypt32.NewProc("CertDuplicateCertificateContext")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100148 procCertEnumCertificatesInStore = modcrypt32.NewProc("CertEnumCertificatesInStore")
Jason A. Donenfeld4df39782021-01-22 14:23:17 +0100149 procCertFindExtension = modcrypt32.NewProc("CertFindExtension")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100150 procCertFreeCertificateChain = modcrypt32.NewProc("CertFreeCertificateChain")
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600151 procCertFreeCertificateContext = modcrypt32.NewProc("CertFreeCertificateContext")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100152 procCertGetCertificateChain = modcrypt32.NewProc("CertGetCertificateChain")
Jason A. Donenfeld4df39782021-01-22 14:23:17 +0100153 procCertGetNameStringW = modcrypt32.NewProc("CertGetNameStringW")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100154 procCertOpenStore = modcrypt32.NewProc("CertOpenStore")
155 procCertOpenSystemStoreW = modcrypt32.NewProc("CertOpenSystemStoreW")
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600156 procCertVerifyCertificateChainPolicy = modcrypt32.NewProc("CertVerifyCertificateChainPolicy")
Jason A. Donenfeld4df39782021-01-22 14:23:17 +0100157 procCryptDecodeObject = modcrypt32.NewProc("CryptDecodeObject")
158 procCryptQueryObject = modcrypt32.NewProc("CryptQueryObject")
Boshi LIAN2d187342020-12-31 18:09:48 +0000159 procPFXImportCertStore = modcrypt32.NewProc("PFXImportCertStore")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100160 procDnsNameCompare_W = moddnsapi.NewProc("DnsNameCompare_W")
161 procDnsQuery_W = moddnsapi.NewProc("DnsQuery_W")
162 procDnsRecordListFree = moddnsapi.NewProc("DnsRecordListFree")
163 procGetAdaptersAddresses = modiphlpapi.NewProc("GetAdaptersAddresses")
164 procGetAdaptersInfo = modiphlpapi.NewProc("GetAdaptersInfo")
165 procGetIfEntry = modiphlpapi.NewProc("GetIfEntry")
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600166 procAssignProcessToJobObject = modkernel32.NewProc("AssignProcessToJobObject")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100167 procCancelIo = modkernel32.NewProc("CancelIo")
168 procCancelIoEx = modkernel32.NewProc("CancelIoEx")
169 procCloseHandle = modkernel32.NewProc("CloseHandle")
170 procCreateDirectoryW = modkernel32.NewProc("CreateDirectoryW")
171 procCreateEventExW = modkernel32.NewProc("CreateEventExW")
172 procCreateEventW = modkernel32.NewProc("CreateEventW")
173 procCreateFileMappingW = modkernel32.NewProc("CreateFileMappingW")
174 procCreateFileW = modkernel32.NewProc("CreateFileW")
175 procCreateHardLinkW = modkernel32.NewProc("CreateHardLinkW")
176 procCreateIoCompletionPort = modkernel32.NewProc("CreateIoCompletionPort")
177 procCreateJobObjectW = modkernel32.NewProc("CreateJobObjectW")
178 procCreateMutexExW = modkernel32.NewProc("CreateMutexExW")
179 procCreateMutexW = modkernel32.NewProc("CreateMutexW")
180 procCreatePipe = modkernel32.NewProc("CreatePipe")
181 procCreateProcessW = modkernel32.NewProc("CreateProcessW")
182 procCreateSymbolicLinkW = modkernel32.NewProc("CreateSymbolicLinkW")
183 procCreateToolhelp32Snapshot = modkernel32.NewProc("CreateToolhelp32Snapshot")
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600184 procDefineDosDeviceW = modkernel32.NewProc("DefineDosDeviceW")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100185 procDeleteFileW = modkernel32.NewProc("DeleteFileW")
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600186 procDeleteVolumeMountPointW = modkernel32.NewProc("DeleteVolumeMountPointW")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100187 procDeviceIoControl = modkernel32.NewProc("DeviceIoControl")
188 procDuplicateHandle = modkernel32.NewProc("DuplicateHandle")
189 procExitProcess = modkernel32.NewProc("ExitProcess")
190 procFindClose = modkernel32.NewProc("FindClose")
Jason A. Donenfelda8b976e2021-01-22 14:20:47 +0100191 procFindCloseChangeNotification = modkernel32.NewProc("FindCloseChangeNotification")
192 procFindFirstChangeNotificationW = modkernel32.NewProc("FindFirstChangeNotificationW")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100193 procFindFirstFileW = modkernel32.NewProc("FindFirstFileW")
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600194 procFindFirstVolumeMountPointW = modkernel32.NewProc("FindFirstVolumeMountPointW")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100195 procFindFirstVolumeW = modkernel32.NewProc("FindFirstVolumeW")
Jason A. Donenfelda8b976e2021-01-22 14:20:47 +0100196 procFindNextChangeNotification = modkernel32.NewProc("FindNextChangeNotification")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100197 procFindNextFileW = modkernel32.NewProc("FindNextFileW")
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600198 procFindNextVolumeMountPointW = modkernel32.NewProc("FindNextVolumeMountPointW")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100199 procFindNextVolumeW = modkernel32.NewProc("FindNextVolumeW")
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600200 procFindVolumeClose = modkernel32.NewProc("FindVolumeClose")
201 procFindVolumeMountPointClose = modkernel32.NewProc("FindVolumeMountPointClose")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100202 procFlushFileBuffers = modkernel32.NewProc("FlushFileBuffers")
203 procFlushViewOfFile = modkernel32.NewProc("FlushViewOfFile")
204 procFormatMessageW = modkernel32.NewProc("FormatMessageW")
205 procFreeEnvironmentStringsW = modkernel32.NewProc("FreeEnvironmentStringsW")
206 procFreeLibrary = modkernel32.NewProc("FreeLibrary")
207 procGenerateConsoleCtrlEvent = modkernel32.NewProc("GenerateConsoleCtrlEvent")
208 procGetACP = modkernel32.NewProc("GetACP")
209 procGetCommandLineW = modkernel32.NewProc("GetCommandLineW")
210 procGetComputerNameExW = modkernel32.NewProc("GetComputerNameExW")
211 procGetComputerNameW = modkernel32.NewProc("GetComputerNameW")
212 procGetConsoleMode = modkernel32.NewProc("GetConsoleMode")
213 procGetConsoleScreenBufferInfo = modkernel32.NewProc("GetConsoleScreenBufferInfo")
214 procGetCurrentDirectoryW = modkernel32.NewProc("GetCurrentDirectoryW")
215 procGetCurrentProcessId = modkernel32.NewProc("GetCurrentProcessId")
216 procGetCurrentThreadId = modkernel32.NewProc("GetCurrentThreadId")
Takuto Ikutab09406a2019-10-10 18:17:53 +0900217 procGetDiskFreeSpaceExW = modkernel32.NewProc("GetDiskFreeSpaceExW")
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600218 procGetDriveTypeW = modkernel32.NewProc("GetDriveTypeW")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100219 procGetEnvironmentStringsW = modkernel32.NewProc("GetEnvironmentStringsW")
220 procGetEnvironmentVariableW = modkernel32.NewProc("GetEnvironmentVariableW")
221 procGetExitCodeProcess = modkernel32.NewProc("GetExitCodeProcess")
222 procGetFileAttributesExW = modkernel32.NewProc("GetFileAttributesExW")
223 procGetFileAttributesW = modkernel32.NewProc("GetFileAttributesW")
224 procGetFileInformationByHandle = modkernel32.NewProc("GetFileInformationByHandle")
225 procGetFileInformationByHandleEx = modkernel32.NewProc("GetFileInformationByHandleEx")
226 procGetFileType = modkernel32.NewProc("GetFileType")
Meng Zhuo35185872020-10-28 14:35:39 +0800227 procGetFinalPathNameByHandleW = modkernel32.NewProc("GetFinalPathNameByHandleW")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100228 procGetFullPathNameW = modkernel32.NewProc("GetFullPathNameW")
229 procGetLastError = modkernel32.NewProc("GetLastError")
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600230 procGetLogicalDriveStringsW = modkernel32.NewProc("GetLogicalDriveStringsW")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100231 procGetLogicalDrives = modkernel32.NewProc("GetLogicalDrives")
232 procGetLongPathNameW = modkernel32.NewProc("GetLongPathNameW")
233 procGetModuleFileNameW = modkernel32.NewProc("GetModuleFileNameW")
234 procGetModuleHandleExW = modkernel32.NewProc("GetModuleHandleExW")
235 procGetOverlappedResult = modkernel32.NewProc("GetOverlappedResult")
236 procGetPriorityClass = modkernel32.NewProc("GetPriorityClass")
237 procGetProcAddress = modkernel32.NewProc("GetProcAddress")
238 procGetProcessId = modkernel32.NewProc("GetProcessId")
239 procGetProcessPreferredUILanguages = modkernel32.NewProc("GetProcessPreferredUILanguages")
240 procGetProcessShutdownParameters = modkernel32.NewProc("GetProcessShutdownParameters")
241 procGetProcessTimes = modkernel32.NewProc("GetProcessTimes")
242 procGetProcessWorkingSetSizeEx = modkernel32.NewProc("GetProcessWorkingSetSizeEx")
243 procGetQueuedCompletionStatus = modkernel32.NewProc("GetQueuedCompletionStatus")
244 procGetShortPathNameW = modkernel32.NewProc("GetShortPathNameW")
245 procGetStartupInfoW = modkernel32.NewProc("GetStartupInfoW")
246 procGetStdHandle = modkernel32.NewProc("GetStdHandle")
247 procGetSystemDirectoryW = modkernel32.NewProc("GetSystemDirectoryW")
248 procGetSystemPreferredUILanguages = modkernel32.NewProc("GetSystemPreferredUILanguages")
249 procGetSystemTimeAsFileTime = modkernel32.NewProc("GetSystemTimeAsFileTime")
250 procGetSystemTimePreciseAsFileTime = modkernel32.NewProc("GetSystemTimePreciseAsFileTime")
251 procGetSystemWindowsDirectoryW = modkernel32.NewProc("GetSystemWindowsDirectoryW")
252 procGetTempPathW = modkernel32.NewProc("GetTempPathW")
253 procGetThreadPreferredUILanguages = modkernel32.NewProc("GetThreadPreferredUILanguages")
254 procGetTickCount64 = modkernel32.NewProc("GetTickCount64")
255 procGetTimeZoneInformation = modkernel32.NewProc("GetTimeZoneInformation")
256 procGetUserPreferredUILanguages = modkernel32.NewProc("GetUserPreferredUILanguages")
257 procGetVersion = modkernel32.NewProc("GetVersion")
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600258 procGetVolumeInformationByHandleW = modkernel32.NewProc("GetVolumeInformationByHandleW")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100259 procGetVolumeInformationW = modkernel32.NewProc("GetVolumeInformationW")
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600260 procGetVolumeNameForVolumeMountPointW = modkernel32.NewProc("GetVolumeNameForVolumeMountPointW")
261 procGetVolumePathNameW = modkernel32.NewProc("GetVolumePathNameW")
262 procGetVolumePathNamesForVolumeNameW = modkernel32.NewProc("GetVolumePathNamesForVolumeNameW")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100263 procGetWindowsDirectoryW = modkernel32.NewProc("GetWindowsDirectoryW")
264 procIsWow64Process = modkernel32.NewProc("IsWow64Process")
Jason A. Donenfeld12cec1f2020-11-13 15:51:52 +0100265 procIsWow64Process2 = modkernel32.NewProc("IsWow64Process2")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100266 procLoadLibraryExW = modkernel32.NewProc("LoadLibraryExW")
267 procLoadLibraryW = modkernel32.NewProc("LoadLibraryW")
268 procLocalFree = modkernel32.NewProc("LocalFree")
269 procLockFileEx = modkernel32.NewProc("LockFileEx")
270 procMapViewOfFile = modkernel32.NewProc("MapViewOfFile")
271 procMoveFileExW = modkernel32.NewProc("MoveFileExW")
272 procMoveFileW = modkernel32.NewProc("MoveFileW")
273 procMultiByteToWideChar = modkernel32.NewProc("MultiByteToWideChar")
274 procOpenEventW = modkernel32.NewProc("OpenEventW")
275 procOpenMutexW = modkernel32.NewProc("OpenMutexW")
276 procOpenProcess = modkernel32.NewProc("OpenProcess")
277 procOpenThread = modkernel32.NewProc("OpenThread")
278 procPostQueuedCompletionStatus = modkernel32.NewProc("PostQueuedCompletionStatus")
279 procProcess32FirstW = modkernel32.NewProc("Process32FirstW")
280 procProcess32NextW = modkernel32.NewProc("Process32NextW")
281 procProcessIdToSessionId = modkernel32.NewProc("ProcessIdToSessionId")
282 procPulseEvent = modkernel32.NewProc("PulseEvent")
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600283 procQueryDosDeviceW = modkernel32.NewProc("QueryDosDeviceW")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100284 procQueryInformationJobObject = modkernel32.NewProc("QueryInformationJobObject")
285 procReadConsoleW = modkernel32.NewProc("ReadConsoleW")
286 procReadDirectoryChangesW = modkernel32.NewProc("ReadDirectoryChangesW")
287 procReadFile = modkernel32.NewProc("ReadFile")
288 procReleaseMutex = modkernel32.NewProc("ReleaseMutex")
289 procRemoveDirectoryW = modkernel32.NewProc("RemoveDirectoryW")
290 procResetEvent = modkernel32.NewProc("ResetEvent")
291 procResumeThread = modkernel32.NewProc("ResumeThread")
292 procSetConsoleCursorPosition = modkernel32.NewProc("SetConsoleCursorPosition")
293 procSetConsoleMode = modkernel32.NewProc("SetConsoleMode")
294 procSetCurrentDirectoryW = modkernel32.NewProc("SetCurrentDirectoryW")
Jason A. Donenfeld77190672020-11-26 23:54:44 +0100295 procSetDefaultDllDirectories = modkernel32.NewProc("SetDefaultDllDirectories")
296 procSetDllDirectoryW = modkernel32.NewProc("SetDllDirectoryW")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100297 procSetEndOfFile = modkernel32.NewProc("SetEndOfFile")
298 procSetEnvironmentVariableW = modkernel32.NewProc("SetEnvironmentVariableW")
299 procSetErrorMode = modkernel32.NewProc("SetErrorMode")
300 procSetEvent = modkernel32.NewProc("SetEvent")
301 procSetFileAttributesW = modkernel32.NewProc("SetFileAttributesW")
302 procSetFileCompletionNotificationModes = modkernel32.NewProc("SetFileCompletionNotificationModes")
Jason A. Donenfeldd9b008d2020-11-17 10:19:46 +0100303 procSetFileInformationByHandle = modkernel32.NewProc("SetFileInformationByHandle")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100304 procSetFilePointer = modkernel32.NewProc("SetFilePointer")
305 procSetFileTime = modkernel32.NewProc("SetFileTime")
306 procSetHandleInformation = modkernel32.NewProc("SetHandleInformation")
307 procSetInformationJobObject = modkernel32.NewProc("SetInformationJobObject")
308 procSetPriorityClass = modkernel32.NewProc("SetPriorityClass")
309 procSetProcessPriorityBoost = modkernel32.NewProc("SetProcessPriorityBoost")
310 procSetProcessShutdownParameters = modkernel32.NewProc("SetProcessShutdownParameters")
311 procSetProcessWorkingSetSizeEx = modkernel32.NewProc("SetProcessWorkingSetSizeEx")
312 procSetStdHandle = modkernel32.NewProc("SetStdHandle")
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600313 procSetVolumeLabelW = modkernel32.NewProc("SetVolumeLabelW")
314 procSetVolumeMountPointW = modkernel32.NewProc("SetVolumeMountPointW")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100315 procSleepEx = modkernel32.NewProc("SleepEx")
316 procTerminateJobObject = modkernel32.NewProc("TerminateJobObject")
317 procTerminateProcess = modkernel32.NewProc("TerminateProcess")
318 procThread32First = modkernel32.NewProc("Thread32First")
319 procThread32Next = modkernel32.NewProc("Thread32Next")
320 procUnlockFileEx = modkernel32.NewProc("UnlockFileEx")
321 procUnmapViewOfFile = modkernel32.NewProc("UnmapViewOfFile")
322 procVirtualAlloc = modkernel32.NewProc("VirtualAlloc")
323 procVirtualFree = modkernel32.NewProc("VirtualFree")
324 procVirtualLock = modkernel32.NewProc("VirtualLock")
325 procVirtualProtect = modkernel32.NewProc("VirtualProtect")
326 procVirtualUnlock = modkernel32.NewProc("VirtualUnlock")
327 procWaitForMultipleObjects = modkernel32.NewProc("WaitForMultipleObjects")
328 procWaitForSingleObject = modkernel32.NewProc("WaitForSingleObject")
329 procWriteConsoleW = modkernel32.NewProc("WriteConsoleW")
330 procWriteFile = modkernel32.NewProc("WriteFile")
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600331 procAcceptEx = modmswsock.NewProc("AcceptEx")
332 procGetAcceptExSockaddrs = modmswsock.NewProc("GetAcceptExSockaddrs")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100333 procTransmitFile = modmswsock.NewProc("TransmitFile")
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600334 procNetApiBufferFree = modnetapi32.NewProc("NetApiBufferFree")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100335 procNetGetJoinInformation = modnetapi32.NewProc("NetGetJoinInformation")
336 procNetUserGetInfo = modnetapi32.NewProc("NetUserGetInfo")
337 procRtlGetNtVersionNumbers = modntdll.NewProc("RtlGetNtVersionNumbers")
338 procRtlGetVersion = modntdll.NewProc("RtlGetVersion")
339 procCLSIDFromString = modole32.NewProc("CLSIDFromString")
340 procCoCreateGuid = modole32.NewProc("CoCreateGuid")
341 procCoTaskMemFree = modole32.NewProc("CoTaskMemFree")
342 procStringFromGUID2 = modole32.NewProc("StringFromGUID2")
343 procEnumProcesses = modpsapi.NewProc("EnumProcesses")
Jason A. Donenfeldc9906e32020-12-02 23:27:29 +0100344 procSubscribeServiceChangeNotifications = modsechost.NewProc("SubscribeServiceChangeNotifications")
345 procUnsubscribeServiceChangeNotifications = modsechost.NewProc("UnsubscribeServiceChangeNotifications")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100346 procGetUserNameExW = modsecur32.NewProc("GetUserNameExW")
347 procTranslateNameW = modsecur32.NewProc("TranslateNameW")
348 procCommandLineToArgvW = modshell32.NewProc("CommandLineToArgvW")
349 procSHGetKnownFolderPath = modshell32.NewProc("SHGetKnownFolderPath")
350 procShellExecuteW = modshell32.NewProc("ShellExecuteW")
351 procExitWindowsEx = moduser32.NewProc("ExitWindowsEx")
Alex Brainman0df21312021-01-06 18:08:16 +1100352 procGetShellWindow = moduser32.NewProc("GetShellWindow")
353 procGetWindowThreadProcessId = moduser32.NewProc("GetWindowThreadProcessId")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100354 procMessageBoxW = moduser32.NewProc("MessageBoxW")
355 procCreateEnvironmentBlock = moduserenv.NewProc("CreateEnvironmentBlock")
356 procDestroyEnvironmentBlock = moduserenv.NewProc("DestroyEnvironmentBlock")
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600357 procGetUserProfileDirectoryW = moduserenv.NewProc("GetUserProfileDirectoryW")
Jason A. Donenfeld07034702021-01-22 17:59:47 +0100358 procWinVerifyTrustEx = modwintrust.NewProc("WinVerifyTrustEx")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100359 procFreeAddrInfoW = modws2_32.NewProc("FreeAddrInfoW")
360 procGetAddrInfoW = modws2_32.NewProc("GetAddrInfoW")
361 procWSACleanup = modws2_32.NewProc("WSACleanup")
362 procWSAEnumProtocolsW = modws2_32.NewProc("WSAEnumProtocolsW")
363 procWSAIoctl = modws2_32.NewProc("WSAIoctl")
364 procWSARecv = modws2_32.NewProc("WSARecv")
365 procWSARecvFrom = modws2_32.NewProc("WSARecvFrom")
366 procWSASend = modws2_32.NewProc("WSASend")
367 procWSASendTo = modws2_32.NewProc("WSASendTo")
368 procWSAStartup = modws2_32.NewProc("WSAStartup")
369 procbind = modws2_32.NewProc("bind")
370 procclosesocket = modws2_32.NewProc("closesocket")
371 procconnect = modws2_32.NewProc("connect")
372 procgethostbyname = modws2_32.NewProc("gethostbyname")
373 procgetpeername = modws2_32.NewProc("getpeername")
374 procgetprotobyname = modws2_32.NewProc("getprotobyname")
375 procgetservbyname = modws2_32.NewProc("getservbyname")
376 procgetsockname = modws2_32.NewProc("getsockname")
377 procgetsockopt = modws2_32.NewProc("getsockopt")
378 proclisten = modws2_32.NewProc("listen")
379 procntohs = modws2_32.NewProc("ntohs")
380 procrecvfrom = modws2_32.NewProc("recvfrom")
381 procsendto = modws2_32.NewProc("sendto")
382 procsetsockopt = modws2_32.NewProc("setsockopt")
383 procshutdown = modws2_32.NewProc("shutdown")
384 procsocket = modws2_32.NewProc("socket")
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600385 procWTSEnumerateSessionsW = modwtsapi32.NewProc("WTSEnumerateSessionsW")
386 procWTSFreeMemory = modwtsapi32.NewProc("WTSFreeMemory")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100387 procWTSQueryUserToken = modwtsapi32.NewProc("WTSQueryUserToken")
Rob Pike20acc5c2014-08-11 14:48:46 -0700388)
389
Alex Brainman0aaa2712020-10-11 09:49:28 +1100390func AdjustTokenGroups(token Token, resetToDefault bool, newstate *Tokengroups, buflen uint32, prevstate *Tokengroups, returnlen *uint32) (err error) {
Jason A. Donenfeld0c1ff782019-09-18 00:14:46 -0600391 var _p0 uint32
Alex Brainman0aaa2712020-10-11 09:49:28 +1100392 if resetToDefault {
Jason A. Donenfeld0c1ff782019-09-18 00:14:46 -0600393 _p0 = 1
Jason A. Donenfeld0c1ff782019-09-18 00:14:46 -0600394 }
Alex Brainman0aaa2712020-10-11 09:49:28 +1100395 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)))
Jason A. Donenfeld3a4b5fb2019-05-13 11:46:50 +0200396 if r1 == 0 {
Sebastiaan van Stijndfb3f7c2020-10-09 00:24:30 +0000397 err = errnoErr(e1)
Jason A. Donenfeld3a4b5fb2019-05-13 11:46:50 +0200398 }
399 return
400}
401
402func AdjustTokenPrivileges(token Token, disableAllPrivileges bool, newstate *Tokenprivileges, buflen uint32, prevstate *Tokenprivileges, returnlen *uint32) (err error) {
403 var _p0 uint32
404 if disableAllPrivileges {
405 _p0 = 1
Jason A. Donenfeld3a4b5fb2019-05-13 11:46:50 +0200406 }
407 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)))
408 if r1 == 0 {
Sebastiaan van Stijndfb3f7c2020-10-09 00:24:30 +0000409 err = errnoErr(e1)
Jason A. Donenfeld3a4b5fb2019-05-13 11:46:50 +0200410 }
411 return
412}
413
Alex Brainman0aaa2712020-10-11 09:49:28 +1100414func 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) {
415 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)
Jason A. Donenfeldcedb8e12019-05-15 13:59:33 +0200416 if r1 == 0 {
Sebastiaan van Stijndfb3f7c2020-10-09 00:24:30 +0000417 err = errnoErr(e1)
Jason A. Donenfeldcedb8e12019-05-15 13:59:33 +0200418 }
419 return
420}
421
Alex Brainman0aaa2712020-10-11 09:49:28 +1100422func 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) {
423 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)))
424 if r0 != 0 {
425 ret = syscall.Errno(r0)
426 }
427 return
428}
429
430func ChangeServiceConfig2(service Handle, infoLevel uint32, info *byte) (err error) {
431 r1, _, e1 := syscall.Syscall(procChangeServiceConfig2W.Addr(), 3, uintptr(service), uintptr(infoLevel), uintptr(unsafe.Pointer(info)))
Jason A. Donenfeld3a4b5fb2019-05-13 11:46:50 +0200432 if r1 == 0 {
Sebastiaan van Stijndfb3f7c2020-10-09 00:24:30 +0000433 err = errnoErr(e1)
Jason A. Donenfeld3a4b5fb2019-05-13 11:46:50 +0200434 }
435 return
436}
437
Alex Brainman0aaa2712020-10-11 09:49:28 +1100438func 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) {
439 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)
440 if r1 == 0 {
441 err = errnoErr(e1)
442 }
443 return
444}
445
446func checkTokenMembership(tokenHandle Token, sidToCheck *SID, isMember *int32) (err error) {
447 r1, _, e1 := syscall.Syscall(procCheckTokenMembership.Addr(), 3, uintptr(tokenHandle), uintptr(unsafe.Pointer(sidToCheck)), uintptr(unsafe.Pointer(isMember)))
448 if r1 == 0 {
449 err = errnoErr(e1)
450 }
451 return
452}
453
454func CloseServiceHandle(handle Handle) (err error) {
455 r1, _, e1 := syscall.Syscall(procCloseServiceHandle.Addr(), 1, uintptr(handle), 0, 0)
456 if r1 == 0 {
457 err = errnoErr(e1)
458 }
459 return
460}
461
462func ControlService(service Handle, control uint32, status *SERVICE_STATUS) (err error) {
463 r1, _, e1 := syscall.Syscall(procControlService.Addr(), 3, uintptr(service), uintptr(control), uintptr(unsafe.Pointer(status)))
464 if r1 == 0 {
465 err = errnoErr(e1)
466 }
467 return
468}
469
470func convertSecurityDescriptorToStringSecurityDescriptor(sd *SECURITY_DESCRIPTOR, revision uint32, securityInformation SECURITY_INFORMATION, str **uint16, strLen *uint32) (err error) {
471 r1, _, e1 := syscall.Syscall6(procConvertSecurityDescriptorToStringSecurityDescriptorW.Addr(), 5, uintptr(unsafe.Pointer(sd)), uintptr(revision), uintptr(securityInformation), uintptr(unsafe.Pointer(str)), uintptr(unsafe.Pointer(strLen)), 0)
472 if r1 == 0 {
473 err = errnoErr(e1)
474 }
475 return
476}
477
478func ConvertSidToStringSid(sid *SID, stringSid **uint16) (err error) {
479 r1, _, e1 := syscall.Syscall(procConvertSidToStringSidW.Addr(), 2, uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(stringSid)), 0)
480 if r1 == 0 {
481 err = errnoErr(e1)
482 }
483 return
484}
485
486func convertStringSecurityDescriptorToSecurityDescriptor(str string, revision uint32, sd **SECURITY_DESCRIPTOR, size *uint32) (err error) {
487 var _p0 *uint16
488 _p0, err = syscall.UTF16PtrFromString(str)
489 if err != nil {
490 return
491 }
492 return _convertStringSecurityDescriptorToSecurityDescriptor(_p0, revision, sd, size)
493}
494
495func _convertStringSecurityDescriptorToSecurityDescriptor(str *uint16, revision uint32, sd **SECURITY_DESCRIPTOR, size *uint32) (err error) {
496 r1, _, e1 := syscall.Syscall6(procConvertStringSecurityDescriptorToSecurityDescriptorW.Addr(), 4, uintptr(unsafe.Pointer(str)), uintptr(revision), uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(size)), 0, 0)
497 if r1 == 0 {
498 err = errnoErr(e1)
499 }
500 return
501}
502
503func ConvertStringSidToSid(stringSid *uint16, sid **SID) (err error) {
504 r1, _, e1 := syscall.Syscall(procConvertStringSidToSidW.Addr(), 2, uintptr(unsafe.Pointer(stringSid)), uintptr(unsafe.Pointer(sid)), 0)
505 if r1 == 0 {
506 err = errnoErr(e1)
507 }
508 return
509}
510
511func CopySid(destSidLen uint32, destSid *SID, srcSid *SID) (err error) {
512 r1, _, e1 := syscall.Syscall(procCopySid.Addr(), 3, uintptr(destSidLen), uintptr(unsafe.Pointer(destSid)), uintptr(unsafe.Pointer(srcSid)))
513 if r1 == 0 {
514 err = errnoErr(e1)
515 }
516 return
517}
518
519func 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) {
520 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)
521 handle = Handle(r0)
522 if handle == 0 {
523 err = errnoErr(e1)
524 }
525 return
526}
527
528func createWellKnownSid(sidType WELL_KNOWN_SID_TYPE, domainSid *SID, sid *SID, sizeSid *uint32) (err error) {
529 r1, _, e1 := syscall.Syscall6(procCreateWellKnownSid.Addr(), 4, uintptr(sidType), uintptr(unsafe.Pointer(domainSid)), uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(sizeSid)), 0, 0)
530 if r1 == 0 {
531 err = errnoErr(e1)
532 }
533 return
534}
535
536func CryptAcquireContext(provhandle *Handle, container *uint16, provider *uint16, provtype uint32, flags uint32) (err error) {
537 r1, _, e1 := syscall.Syscall6(procCryptAcquireContextW.Addr(), 5, uintptr(unsafe.Pointer(provhandle)), uintptr(unsafe.Pointer(container)), uintptr(unsafe.Pointer(provider)), uintptr(provtype), uintptr(flags), 0)
538 if r1 == 0 {
539 err = errnoErr(e1)
540 }
541 return
542}
543
544func CryptGenRandom(provhandle Handle, buflen uint32, buf *byte) (err error) {
545 r1, _, e1 := syscall.Syscall(procCryptGenRandom.Addr(), 3, uintptr(provhandle), uintptr(buflen), uintptr(unsafe.Pointer(buf)))
546 if r1 == 0 {
547 err = errnoErr(e1)
548 }
549 return
550}
551
552func CryptReleaseContext(provhandle Handle, flags uint32) (err error) {
553 r1, _, e1 := syscall.Syscall(procCryptReleaseContext.Addr(), 2, uintptr(provhandle), uintptr(flags), 0)
554 if r1 == 0 {
555 err = errnoErr(e1)
556 }
557 return
558}
559
560func DeleteService(service Handle) (err error) {
561 r1, _, e1 := syscall.Syscall(procDeleteService.Addr(), 1, uintptr(service), 0, 0)
562 if r1 == 0 {
563 err = errnoErr(e1)
564 }
565 return
566}
567
568func DeregisterEventSource(handle Handle) (err error) {
569 r1, _, e1 := syscall.Syscall(procDeregisterEventSource.Addr(), 1, uintptr(handle), 0, 0)
Jason A. Donenfeld3a4b5fb2019-05-13 11:46:50 +0200570 if r1 == 0 {
Sebastiaan van Stijndfb3f7c2020-10-09 00:24:30 +0000571 err = errnoErr(e1)
Jason A. Donenfeld3a4b5fb2019-05-13 11:46:50 +0200572 }
573 return
574}
575
576func DuplicateTokenEx(existingToken Token, desiredAccess uint32, tokenAttributes *SecurityAttributes, impersonationLevel uint32, tokenType uint32, newToken *Token) (err error) {
577 r1, _, e1 := syscall.Syscall6(procDuplicateTokenEx.Addr(), 6, uintptr(existingToken), uintptr(desiredAccess), uintptr(unsafe.Pointer(tokenAttributes)), uintptr(impersonationLevel), uintptr(tokenType), uintptr(unsafe.Pointer(newToken)))
Rob Pike20acc5c2014-08-11 14:48:46 -0700578 if r1 == 0 {
Sebastiaan van Stijndfb3f7c2020-10-09 00:24:30 +0000579 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -0700580 }
581 return
582}
583
Alex Brainman0aaa2712020-10-11 09:49:28 +1100584func EnumServicesStatusEx(mgr Handle, infoLevel uint32, serviceType uint32, serviceState uint32, services *byte, bufSize uint32, bytesNeeded *uint32, servicesReturned *uint32, resumeHandle *uint32, groupName *uint16) (err error) {
585 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)
Rob Pike20acc5c2014-08-11 14:48:46 -0700586 if r1 == 0 {
Sebastiaan van Stijndfb3f7c2020-10-09 00:24:30 +0000587 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -0700588 }
589 return
590}
Jason A. Donenfeld10058d72019-03-06 18:49:41 +0100591
Alex Brainman0aaa2712020-10-11 09:49:28 +1100592func EqualSid(sid1 *SID, sid2 *SID) (isEqual bool) {
593 r0, _, _ := syscall.Syscall(procEqualSid.Addr(), 2, uintptr(unsafe.Pointer(sid1)), uintptr(unsafe.Pointer(sid2)), 0)
594 isEqual = r0 != 0
595 return
596}
597
598func FreeSid(sid *SID) (err error) {
599 r1, _, e1 := syscall.Syscall(procFreeSid.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0)
600 if r1 != 0 {
601 err = errnoErr(e1)
602 }
603 return
604}
605
606func GetLengthSid(sid *SID) (len uint32) {
607 r0, _, _ := syscall.Syscall(procGetLengthSid.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0)
Jason A. Donenfeld10058d72019-03-06 18:49:41 +0100608 len = uint32(r0)
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600609 return
610}
611
612func getNamedSecurityInfo(objectName string, objectType SE_OBJECT_TYPE, securityInformation SECURITY_INFORMATION, owner **SID, group **SID, dacl **ACL, sacl **ACL, sd **SECURITY_DESCRIPTOR) (ret error) {
613 var _p0 *uint16
614 _p0, ret = syscall.UTF16PtrFromString(objectName)
615 if ret != nil {
616 return
617 }
618 return _getNamedSecurityInfo(_p0, objectType, securityInformation, owner, group, dacl, sacl, sd)
619}
620
621func _getNamedSecurityInfo(objectName *uint16, objectType SE_OBJECT_TYPE, securityInformation SECURITY_INFORMATION, owner **SID, group **SID, dacl **ACL, sacl **ACL, sd **SECURITY_DESCRIPTOR) (ret error) {
622 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)
623 if r0 != 0 {
624 ret = syscall.Errno(r0)
625 }
626 return
627}
628
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600629func getSecurityDescriptorControl(sd *SECURITY_DESCRIPTOR, control *SECURITY_DESCRIPTOR_CONTROL, revision *uint32) (err error) {
630 r1, _, e1 := syscall.Syscall(procGetSecurityDescriptorControl.Addr(), 3, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(control)), uintptr(unsafe.Pointer(revision)))
631 if r1 == 0 {
Sebastiaan van Stijndfb3f7c2020-10-09 00:24:30 +0000632 err = errnoErr(e1)
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600633 }
634 return
635}
636
637func getSecurityDescriptorDacl(sd *SECURITY_DESCRIPTOR, daclPresent *bool, dacl **ACL, daclDefaulted *bool) (err error) {
638 var _p0 uint32
639 if *daclPresent {
640 _p0 = 1
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600641 }
642 var _p1 uint32
643 if *daclDefaulted {
644 _p1 = 1
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600645 }
646 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)
647 *daclPresent = _p0 != 0
648 *daclDefaulted = _p1 != 0
649 if r1 == 0 {
Sebastiaan van Stijndfb3f7c2020-10-09 00:24:30 +0000650 err = errnoErr(e1)
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600651 }
652 return
653}
654
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600655func getSecurityDescriptorGroup(sd *SECURITY_DESCRIPTOR, group **SID, groupDefaulted *bool) (err error) {
656 var _p0 uint32
657 if *groupDefaulted {
658 _p0 = 1
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600659 }
660 r1, _, e1 := syscall.Syscall(procGetSecurityDescriptorGroup.Addr(), 3, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(group)), uintptr(unsafe.Pointer(&_p0)))
661 *groupDefaulted = _p0 != 0
662 if r1 == 0 {
Sebastiaan van Stijndfb3f7c2020-10-09 00:24:30 +0000663 err = errnoErr(e1)
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600664 }
665 return
666}
667
668func getSecurityDescriptorLength(sd *SECURITY_DESCRIPTOR) (len uint32) {
669 r0, _, _ := syscall.Syscall(procGetSecurityDescriptorLength.Addr(), 1, uintptr(unsafe.Pointer(sd)), 0, 0)
670 len = uint32(r0)
671 return
672}
673
Alex Brainman0aaa2712020-10-11 09:49:28 +1100674func getSecurityDescriptorOwner(sd *SECURITY_DESCRIPTOR, owner **SID, ownerDefaulted *bool) (err error) {
675 var _p0 uint32
676 if *ownerDefaulted {
677 _p0 = 1
678 }
679 r1, _, e1 := syscall.Syscall(procGetSecurityDescriptorOwner.Addr(), 3, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(owner)), uintptr(unsafe.Pointer(&_p0)))
680 *ownerDefaulted = _p0 != 0
681 if r1 == 0 {
682 err = errnoErr(e1)
683 }
684 return
685}
686
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600687func getSecurityDescriptorRMControl(sd *SECURITY_DESCRIPTOR, rmControl *uint8) (ret error) {
688 r0, _, _ := syscall.Syscall(procGetSecurityDescriptorRMControl.Addr(), 2, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(rmControl)), 0)
689 if r0 != 0 {
690 ret = syscall.Errno(r0)
691 }
692 return
693}
694
Alex Brainman0aaa2712020-10-11 09:49:28 +1100695func getSecurityDescriptorSacl(sd *SECURITY_DESCRIPTOR, saclPresent *bool, sacl **ACL, saclDefaulted *bool) (err error) {
696 var _p0 uint32
697 if *saclPresent {
698 _p0 = 1
699 }
700 var _p1 uint32
701 if *saclDefaulted {
702 _p1 = 1
703 }
704 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)
705 *saclPresent = _p0 != 0
706 *saclDefaulted = _p1 != 0
707 if r1 == 0 {
708 err = errnoErr(e1)
709 }
710 return
711}
712
713func getSecurityInfo(handle Handle, objectType SE_OBJECT_TYPE, securityInformation SECURITY_INFORMATION, owner **SID, group **SID, dacl **ACL, sacl **ACL, sd **SECURITY_DESCRIPTOR) (ret error) {
714 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)
715 if r0 != 0 {
716 ret = syscall.Errno(r0)
717 }
718 return
719}
720
721func getSidIdentifierAuthority(sid *SID) (authority *SidIdentifierAuthority) {
722 r0, _, _ := syscall.Syscall(procGetSidIdentifierAuthority.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0)
723 authority = (*SidIdentifierAuthority)(unsafe.Pointer(r0))
724 return
725}
726
727func getSidSubAuthority(sid *SID, index uint32) (subAuthority *uint32) {
728 r0, _, _ := syscall.Syscall(procGetSidSubAuthority.Addr(), 2, uintptr(unsafe.Pointer(sid)), uintptr(index), 0)
729 subAuthority = (*uint32)(unsafe.Pointer(r0))
730 return
731}
732
733func getSidSubAuthorityCount(sid *SID) (count *uint8) {
734 r0, _, _ := syscall.Syscall(procGetSidSubAuthorityCount.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0)
735 count = (*uint8)(unsafe.Pointer(r0))
736 return
737}
738
739func GetTokenInformation(token Token, infoClass uint32, info *byte, infoLen uint32, returnedLen *uint32) (err error) {
740 r1, _, e1 := syscall.Syscall6(procGetTokenInformation.Addr(), 5, uintptr(token), uintptr(infoClass), uintptr(unsafe.Pointer(info)), uintptr(infoLen), uintptr(unsafe.Pointer(returnedLen)), 0)
741 if r1 == 0 {
742 err = errnoErr(e1)
743 }
744 return
745}
746
747func ImpersonateSelf(impersonationlevel uint32) (err error) {
748 r1, _, e1 := syscall.Syscall(procImpersonateSelf.Addr(), 1, uintptr(impersonationlevel), 0, 0)
749 if r1 == 0 {
750 err = errnoErr(e1)
751 }
752 return
753}
754
755func initializeSecurityDescriptor(absoluteSD *SECURITY_DESCRIPTOR, revision uint32) (err error) {
756 r1, _, e1 := syscall.Syscall(procInitializeSecurityDescriptor.Addr(), 2, uintptr(unsafe.Pointer(absoluteSD)), uintptr(revision), 0)
757 if r1 == 0 {
758 err = errnoErr(e1)
759 }
760 return
761}
762
763func InitiateSystemShutdownEx(machineName *uint16, message *uint16, timeout uint32, forceAppsClosed bool, rebootAfterShutdown bool, reason uint32) (err error) {
764 var _p0 uint32
765 if forceAppsClosed {
766 _p0 = 1
767 }
768 var _p1 uint32
769 if rebootAfterShutdown {
770 _p1 = 1
771 }
772 r1, _, e1 := syscall.Syscall6(procInitiateSystemShutdownExW.Addr(), 6, uintptr(unsafe.Pointer(machineName)), uintptr(unsafe.Pointer(message)), uintptr(timeout), uintptr(_p0), uintptr(_p1), uintptr(reason))
773 if r1 == 0 {
774 err = errnoErr(e1)
775 }
776 return
777}
778
Jason A. Donenfeldf88b8272020-11-21 10:31:08 +0100779func isTokenRestricted(tokenHandle Token) (ret bool, err error) {
780 r0, _, e1 := syscall.Syscall(procIsTokenRestricted.Addr(), 1, uintptr(tokenHandle), 0, 0)
781 ret = r0 != 0
782 if !ret {
783 err = errnoErr(e1)
784 }
785 return
786}
787
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600788func isValidSecurityDescriptor(sd *SECURITY_DESCRIPTOR) (isValid bool) {
789 r0, _, _ := syscall.Syscall(procIsValidSecurityDescriptor.Addr(), 1, uintptr(unsafe.Pointer(sd)), 0, 0)
790 isValid = r0 != 0
791 return
792}
793
Alex Brainman0aaa2712020-10-11 09:49:28 +1100794func isValidSid(sid *SID) (isValid bool) {
795 r0, _, _ := syscall.Syscall(procIsValidSid.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0)
796 isValid = r0 != 0
797 return
798}
799
800func isWellKnownSid(sid *SID, sidType WELL_KNOWN_SID_TYPE) (isWellKnown bool) {
801 r0, _, _ := syscall.Syscall(procIsWellKnownSid.Addr(), 2, uintptr(unsafe.Pointer(sid)), uintptr(sidType), 0)
802 isWellKnown = r0 != 0
803 return
804}
805
806func LookupAccountName(systemName *uint16, accountName *uint16, sid *SID, sidLen *uint32, refdDomainName *uint16, refdDomainNameLen *uint32, use *uint32) (err error) {
807 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)
808 if r1 == 0 {
809 err = errnoErr(e1)
810 }
811 return
812}
813
814func LookupAccountSid(systemName *uint16, sid *SID, name *uint16, nameLen *uint32, refdDomainName *uint16, refdDomainNameLen *uint32, use *uint32) (err error) {
815 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)
816 if r1 == 0 {
817 err = errnoErr(e1)
818 }
819 return
820}
821
822func LookupPrivilegeValue(systemname *uint16, name *uint16, luid *LUID) (err error) {
823 r1, _, e1 := syscall.Syscall(procLookupPrivilegeValueW.Addr(), 3, uintptr(unsafe.Pointer(systemname)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(luid)))
824 if r1 == 0 {
825 err = errnoErr(e1)
826 }
827 return
828}
829
830func 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) {
831 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)
832 if r1 == 0 {
833 err = errnoErr(e1)
834 }
835 return
836}
837
838func makeSelfRelativeSD(absoluteSD *SECURITY_DESCRIPTOR, selfRelativeSD *SECURITY_DESCRIPTOR, selfRelativeSDSize *uint32) (err error) {
839 r1, _, e1 := syscall.Syscall(procMakeSelfRelativeSD.Addr(), 3, uintptr(unsafe.Pointer(absoluteSD)), uintptr(unsafe.Pointer(selfRelativeSD)), uintptr(unsafe.Pointer(selfRelativeSDSize)))
840 if r1 == 0 {
841 err = errnoErr(e1)
842 }
843 return
844}
845
846func NotifyServiceStatusChange(service Handle, notifyMask uint32, notifier *SERVICE_NOTIFY) (ret error) {
847 r0, _, _ := syscall.Syscall(procNotifyServiceStatusChangeW.Addr(), 3, uintptr(service), uintptr(notifyMask), uintptr(unsafe.Pointer(notifier)))
848 if r0 != 0 {
849 ret = syscall.Errno(r0)
850 }
851 return
852}
853
854func OpenProcessToken(process Handle, access uint32, token *Token) (err error) {
855 r1, _, e1 := syscall.Syscall(procOpenProcessToken.Addr(), 3, uintptr(process), uintptr(access), uintptr(unsafe.Pointer(token)))
856 if r1 == 0 {
857 err = errnoErr(e1)
858 }
859 return
860}
861
862func OpenSCManager(machineName *uint16, databaseName *uint16, access uint32) (handle Handle, err error) {
863 r0, _, e1 := syscall.Syscall(procOpenSCManagerW.Addr(), 3, uintptr(unsafe.Pointer(machineName)), uintptr(unsafe.Pointer(databaseName)), uintptr(access))
864 handle = Handle(r0)
865 if handle == 0 {
866 err = errnoErr(e1)
867 }
868 return
869}
870
871func OpenService(mgr Handle, serviceName *uint16, access uint32) (handle Handle, err error) {
872 r0, _, e1 := syscall.Syscall(procOpenServiceW.Addr(), 3, uintptr(mgr), uintptr(unsafe.Pointer(serviceName)), uintptr(access))
873 handle = Handle(r0)
874 if handle == 0 {
875 err = errnoErr(e1)
876 }
877 return
878}
879
880func OpenThreadToken(thread Handle, access uint32, openAsSelf bool, token *Token) (err error) {
881 var _p0 uint32
882 if openAsSelf {
883 _p0 = 1
884 }
885 r1, _, e1 := syscall.Syscall6(procOpenThreadToken.Addr(), 4, uintptr(thread), uintptr(access), uintptr(_p0), uintptr(unsafe.Pointer(token)), 0, 0)
886 if r1 == 0 {
887 err = errnoErr(e1)
888 }
889 return
890}
891
892func QueryServiceConfig2(service Handle, infoLevel uint32, buff *byte, buffSize uint32, bytesNeeded *uint32) (err error) {
893 r1, _, e1 := syscall.Syscall6(procQueryServiceConfig2W.Addr(), 5, uintptr(service), uintptr(infoLevel), uintptr(unsafe.Pointer(buff)), uintptr(buffSize), uintptr(unsafe.Pointer(bytesNeeded)), 0)
894 if r1 == 0 {
895 err = errnoErr(e1)
896 }
897 return
898}
899
900func QueryServiceConfig(service Handle, serviceConfig *QUERY_SERVICE_CONFIG, bufSize uint32, bytesNeeded *uint32) (err error) {
901 r1, _, e1 := syscall.Syscall6(procQueryServiceConfigW.Addr(), 4, uintptr(service), uintptr(unsafe.Pointer(serviceConfig)), uintptr(bufSize), uintptr(unsafe.Pointer(bytesNeeded)), 0, 0)
902 if r1 == 0 {
903 err = errnoErr(e1)
904 }
905 return
906}
907
908func QueryServiceLockStatus(mgr Handle, lockStatus *QUERY_SERVICE_LOCK_STATUS, bufSize uint32, bytesNeeded *uint32) (err error) {
909 r1, _, e1 := syscall.Syscall6(procQueryServiceLockStatusW.Addr(), 4, uintptr(mgr), uintptr(unsafe.Pointer(lockStatus)), uintptr(bufSize), uintptr(unsafe.Pointer(bytesNeeded)), 0, 0)
910 if r1 == 0 {
911 err = errnoErr(e1)
912 }
913 return
914}
915
916func QueryServiceStatus(service Handle, status *SERVICE_STATUS) (err error) {
917 r1, _, e1 := syscall.Syscall(procQueryServiceStatus.Addr(), 2, uintptr(service), uintptr(unsafe.Pointer(status)), 0)
918 if r1 == 0 {
919 err = errnoErr(e1)
920 }
921 return
922}
923
924func QueryServiceStatusEx(service Handle, infoLevel uint32, buff *byte, buffSize uint32, bytesNeeded *uint32) (err error) {
925 r1, _, e1 := syscall.Syscall6(procQueryServiceStatusEx.Addr(), 5, uintptr(service), uintptr(infoLevel), uintptr(unsafe.Pointer(buff)), uintptr(buffSize), uintptr(unsafe.Pointer(bytesNeeded)), 0)
926 if r1 == 0 {
927 err = errnoErr(e1)
928 }
929 return
930}
931
932func RegCloseKey(key Handle) (regerrno error) {
933 r0, _, _ := syscall.Syscall(procRegCloseKey.Addr(), 1, uintptr(key), 0, 0)
934 if r0 != 0 {
935 regerrno = syscall.Errno(r0)
936 }
937 return
938}
939
940func RegEnumKeyEx(key Handle, index uint32, name *uint16, nameLen *uint32, reserved *uint32, class *uint16, classLen *uint32, lastWriteTime *Filetime) (regerrno error) {
941 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)
942 if r0 != 0 {
943 regerrno = syscall.Errno(r0)
944 }
945 return
946}
947
Josh Bleecher Snyder7e3030f2020-12-10 12:50:29 -0800948func RegNotifyChangeKeyValue(key Handle, watchSubtree bool, notifyFilter uint32, event Handle, asynchronous bool) (regerrno error) {
949 var _p0 uint32
950 if watchSubtree {
951 _p0 = 1
952 }
953 var _p1 uint32
954 if asynchronous {
955 _p1 = 1
956 }
957 r0, _, _ := syscall.Syscall6(procRegNotifyChangeKeyValue.Addr(), 5, uintptr(key), uintptr(_p0), uintptr(notifyFilter), uintptr(event), uintptr(_p1), 0)
958 if r0 != 0 {
959 regerrno = syscall.Errno(r0)
960 }
961 return
962}
963
Alex Brainman0aaa2712020-10-11 09:49:28 +1100964func RegOpenKeyEx(key Handle, subkey *uint16, options uint32, desiredAccess uint32, result *Handle) (regerrno error) {
965 r0, _, _ := syscall.Syscall6(procRegOpenKeyExW.Addr(), 5, uintptr(key), uintptr(unsafe.Pointer(subkey)), uintptr(options), uintptr(desiredAccess), uintptr(unsafe.Pointer(result)), 0)
966 if r0 != 0 {
967 regerrno = syscall.Errno(r0)
968 }
969 return
970}
971
972func 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) {
973 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)))
974 if r0 != 0 {
975 regerrno = syscall.Errno(r0)
976 }
977 return
978}
979
980func RegQueryValueEx(key Handle, name *uint16, reserved *uint32, valtype *uint32, buf *byte, buflen *uint32) (regerrno error) {
981 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)))
982 if r0 != 0 {
983 regerrno = syscall.Errno(r0)
984 }
985 return
986}
987
988func RegisterEventSource(uncServerName *uint16, sourceName *uint16) (handle Handle, err error) {
989 r0, _, e1 := syscall.Syscall(procRegisterEventSourceW.Addr(), 2, uintptr(unsafe.Pointer(uncServerName)), uintptr(unsafe.Pointer(sourceName)), 0)
990 handle = Handle(r0)
991 if handle == 0 {
992 err = errnoErr(e1)
993 }
994 return
995}
996
997func ReportEvent(log Handle, etype uint16, category uint16, eventId uint32, usrSId uintptr, numStrings uint16, dataSize uint32, strings **uint16, rawData *byte) (err error) {
998 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)))
999 if r1 == 0 {
1000 err = errnoErr(e1)
1001 }
1002 return
1003}
1004
1005func RevertToSelf() (err error) {
1006 r1, _, e1 := syscall.Syscall(procRevertToSelf.Addr(), 0, 0, 0, 0)
1007 if r1 == 0 {
1008 err = errnoErr(e1)
1009 }
1010 return
1011}
1012
1013func setEntriesInAcl(countExplicitEntries uint32, explicitEntries *EXPLICIT_ACCESS, oldACL *ACL, newACL **ACL) (ret error) {
1014 r0, _, _ := syscall.Syscall6(procSetEntriesInAclW.Addr(), 4, uintptr(countExplicitEntries), uintptr(unsafe.Pointer(explicitEntries)), uintptr(unsafe.Pointer(oldACL)), uintptr(unsafe.Pointer(newACL)), 0, 0)
1015 if r0 != 0 {
1016 ret = syscall.Errno(r0)
1017 }
1018 return
1019}
1020
Jason A. Donenfeld3a5be022020-11-16 17:33:31 +01001021func SetKernelObjectSecurity(handle Handle, securityInformation SECURITY_INFORMATION, securityDescriptor *SECURITY_DESCRIPTOR) (err error) {
1022 r1, _, e1 := syscall.Syscall(procSetKernelObjectSecurity.Addr(), 3, uintptr(handle), uintptr(securityInformation), uintptr(unsafe.Pointer(securityDescriptor)))
1023 if r1 == 0 {
1024 err = errnoErr(e1)
1025 }
1026 return
1027}
1028
Alex Brainman0aaa2712020-10-11 09:49:28 +11001029func SetNamedSecurityInfo(objectName string, objectType SE_OBJECT_TYPE, securityInformation SECURITY_INFORMATION, owner *SID, group *SID, dacl *ACL, sacl *ACL) (ret error) {
1030 var _p0 *uint16
1031 _p0, ret = syscall.UTF16PtrFromString(objectName)
1032 if ret != nil {
1033 return
1034 }
1035 return _SetNamedSecurityInfo(_p0, objectType, securityInformation, owner, group, dacl, sacl)
1036}
1037
1038func _SetNamedSecurityInfo(objectName *uint16, objectType SE_OBJECT_TYPE, securityInformation SECURITY_INFORMATION, owner *SID, group *SID, dacl *ACL, sacl *ACL) (ret error) {
1039 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)
1040 if r0 != 0 {
1041 ret = syscall.Errno(r0)
1042 }
1043 return
1044}
1045
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -06001046func setSecurityDescriptorControl(sd *SECURITY_DESCRIPTOR, controlBitsOfInterest SECURITY_DESCRIPTOR_CONTROL, controlBitsToSet SECURITY_DESCRIPTOR_CONTROL) (err error) {
1047 r1, _, e1 := syscall.Syscall(procSetSecurityDescriptorControl.Addr(), 3, uintptr(unsafe.Pointer(sd)), uintptr(controlBitsOfInterest), uintptr(controlBitsToSet))
1048 if r1 == 0 {
Sebastiaan van Stijndfb3f7c2020-10-09 00:24:30 +00001049 err = errnoErr(e1)
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -06001050 }
1051 return
1052}
1053
1054func setSecurityDescriptorDacl(sd *SECURITY_DESCRIPTOR, daclPresent bool, dacl *ACL, daclDefaulted bool) (err error) {
1055 var _p0 uint32
1056 if daclPresent {
1057 _p0 = 1
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -06001058 }
1059 var _p1 uint32
1060 if daclDefaulted {
1061 _p1 = 1
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -06001062 }
1063 r1, _, e1 := syscall.Syscall6(procSetSecurityDescriptorDacl.Addr(), 4, uintptr(unsafe.Pointer(sd)), uintptr(_p0), uintptr(unsafe.Pointer(dacl)), uintptr(_p1), 0, 0)
1064 if r1 == 0 {
Sebastiaan van Stijndfb3f7c2020-10-09 00:24:30 +00001065 err = errnoErr(e1)
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -06001066 }
1067 return
1068}
1069
Alex Brainman0aaa2712020-10-11 09:49:28 +11001070func setSecurityDescriptorGroup(sd *SECURITY_DESCRIPTOR, group *SID, groupDefaulted bool) (err error) {
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -06001071 var _p0 uint32
Alex Brainman0aaa2712020-10-11 09:49:28 +11001072 if groupDefaulted {
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -06001073 _p0 = 1
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -06001074 }
Alex Brainman0aaa2712020-10-11 09:49:28 +11001075 r1, _, e1 := syscall.Syscall(procSetSecurityDescriptorGroup.Addr(), 3, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(group)), uintptr(_p0))
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -06001076 if r1 == 0 {
Sebastiaan van Stijndfb3f7c2020-10-09 00:24:30 +00001077 err = errnoErr(e1)
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -06001078 }
1079 return
1080}
1081
1082func setSecurityDescriptorOwner(sd *SECURITY_DESCRIPTOR, owner *SID, ownerDefaulted bool) (err error) {
1083 var _p0 uint32
1084 if ownerDefaulted {
1085 _p0 = 1
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -06001086 }
1087 r1, _, e1 := syscall.Syscall(procSetSecurityDescriptorOwner.Addr(), 3, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(owner)), uintptr(_p0))
1088 if r1 == 0 {
Sebastiaan van Stijndfb3f7c2020-10-09 00:24:30 +00001089 err = errnoErr(e1)
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -06001090 }
1091 return
1092}
1093
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -06001094func setSecurityDescriptorRMControl(sd *SECURITY_DESCRIPTOR, rmControl *uint8) {
1095 syscall.Syscall(procSetSecurityDescriptorRMControl.Addr(), 2, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(rmControl)), 0)
1096 return
1097}
1098
Alex Brainman0aaa2712020-10-11 09:49:28 +11001099func setSecurityDescriptorSacl(sd *SECURITY_DESCRIPTOR, saclPresent bool, sacl *ACL, saclDefaulted bool) (err error) {
1100 var _p0 uint32
1101 if saclPresent {
1102 _p0 = 1
1103 }
1104 var _p1 uint32
1105 if saclDefaulted {
1106 _p1 = 1
1107 }
1108 r1, _, e1 := syscall.Syscall6(procSetSecurityDescriptorSacl.Addr(), 4, uintptr(unsafe.Pointer(sd)), uintptr(_p0), uintptr(unsafe.Pointer(sacl)), uintptr(_p1), 0, 0)
1109 if r1 == 0 {
1110 err = errnoErr(e1)
1111 }
1112 return
1113}
1114
Jason A. Donenfelda8a4db92020-11-16 17:32:51 +01001115func SetSecurityInfo(handle Handle, objectType SE_OBJECT_TYPE, securityInformation SECURITY_INFORMATION, owner *SID, group *SID, dacl *ACL, sacl *ACL) (ret error) {
1116 r0, _, _ := 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)
1117 if r0 != 0 {
1118 ret = syscall.Errno(r0)
1119 }
Alex Brainman0aaa2712020-10-11 09:49:28 +11001120 return
1121}
1122
1123func SetServiceStatus(service Handle, serviceStatus *SERVICE_STATUS) (err error) {
1124 r1, _, e1 := syscall.Syscall(procSetServiceStatus.Addr(), 2, uintptr(service), uintptr(unsafe.Pointer(serviceStatus)), 0)
1125 if r1 == 0 {
1126 err = errnoErr(e1)
1127 }
1128 return
1129}
1130
1131func SetThreadToken(thread *Handle, token Token) (err error) {
1132 r1, _, e1 := syscall.Syscall(procSetThreadToken.Addr(), 2, uintptr(unsafe.Pointer(thread)), uintptr(token), 0)
1133 if r1 == 0 {
1134 err = errnoErr(e1)
1135 }
1136 return
1137}
1138
1139func SetTokenInformation(token Token, infoClass uint32, info *byte, infoLen uint32) (err error) {
1140 r1, _, e1 := syscall.Syscall6(procSetTokenInformation.Addr(), 4, uintptr(token), uintptr(infoClass), uintptr(unsafe.Pointer(info)), uintptr(infoLen), 0, 0)
1141 if r1 == 0 {
1142 err = errnoErr(e1)
1143 }
1144 return
1145}
1146
1147func StartServiceCtrlDispatcher(serviceTable *SERVICE_TABLE_ENTRY) (err error) {
1148 r1, _, e1 := syscall.Syscall(procStartServiceCtrlDispatcherW.Addr(), 1, uintptr(unsafe.Pointer(serviceTable)), 0, 0)
1149 if r1 == 0 {
1150 err = errnoErr(e1)
1151 }
1152 return
1153}
1154
1155func StartService(service Handle, numArgs uint32, argVectors **uint16) (err error) {
1156 r1, _, e1 := syscall.Syscall(procStartServiceW.Addr(), 3, uintptr(service), uintptr(numArgs), uintptr(unsafe.Pointer(argVectors)))
1157 if r1 == 0 {
1158 err = errnoErr(e1)
1159 }
1160 return
1161}
1162
1163func CertAddCertificateContextToStore(store Handle, certContext *CertContext, addDisposition uint32, storeContext **CertContext) (err error) {
1164 r1, _, e1 := syscall.Syscall6(procCertAddCertificateContextToStore.Addr(), 4, uintptr(store), uintptr(unsafe.Pointer(certContext)), uintptr(addDisposition), uintptr(unsafe.Pointer(storeContext)), 0, 0)
1165 if r1 == 0 {
1166 err = errnoErr(e1)
1167 }
1168 return
1169}
1170
1171func CertCloseStore(store Handle, flags uint32) (err error) {
1172 r1, _, e1 := syscall.Syscall(procCertCloseStore.Addr(), 2, uintptr(store), uintptr(flags), 0)
1173 if r1 == 0 {
1174 err = errnoErr(e1)
1175 }
1176 return
1177}
1178
1179func CertCreateCertificateContext(certEncodingType uint32, certEncoded *byte, encodedLen uint32) (context *CertContext, err error) {
1180 r0, _, e1 := syscall.Syscall(procCertCreateCertificateContext.Addr(), 3, uintptr(certEncodingType), uintptr(unsafe.Pointer(certEncoded)), uintptr(encodedLen))
1181 context = (*CertContext)(unsafe.Pointer(r0))
1182 if context == nil {
1183 err = errnoErr(e1)
1184 }
1185 return
1186}
1187
Daniel Kessler80594f22020-11-04 13:11:48 -08001188func CertDeleteCertificateFromStore(certContext *CertContext) (err error) {
1189 r1, _, e1 := syscall.Syscall(procCertDeleteCertificateFromStore.Addr(), 1, uintptr(unsafe.Pointer(certContext)), 0, 0)
1190 if r1 == 0 {
1191 err = errnoErr(e1)
1192 }
1193 return
1194}
1195
Boshi LIAN2d187342020-12-31 18:09:48 +00001196func CertDuplicateCertificateContext(certContext *CertContext) (dupContext *CertContext) {
1197 r0, _, _ := syscall.Syscall(procCertDuplicateCertificateContext.Addr(), 1, uintptr(unsafe.Pointer(certContext)), 0, 0)
1198 dupContext = (*CertContext)(unsafe.Pointer(r0))
1199 return
1200}
1201
Alex Brainman0aaa2712020-10-11 09:49:28 +11001202func CertEnumCertificatesInStore(store Handle, prevContext *CertContext) (context *CertContext, err error) {
1203 r0, _, e1 := syscall.Syscall(procCertEnumCertificatesInStore.Addr(), 2, uintptr(store), uintptr(unsafe.Pointer(prevContext)), 0)
1204 context = (*CertContext)(unsafe.Pointer(r0))
1205 if context == nil {
1206 err = errnoErr(e1)
1207 }
1208 return
1209}
1210
Jason A. Donenfeld4df39782021-01-22 14:23:17 +01001211func CertFindExtension(objId *byte, countExtensions uint32, extensions *CertExtension) (ret *CertExtension) {
1212 r0, _, _ := syscall.Syscall(procCertFindExtension.Addr(), 3, uintptr(unsafe.Pointer(objId)), uintptr(countExtensions), uintptr(unsafe.Pointer(extensions)))
1213 ret = (*CertExtension)(unsafe.Pointer(r0))
1214 return
1215}
1216
Alex Brainman0aaa2712020-10-11 09:49:28 +11001217func CertFreeCertificateChain(ctx *CertChainContext) {
1218 syscall.Syscall(procCertFreeCertificateChain.Addr(), 1, uintptr(unsafe.Pointer(ctx)), 0, 0)
1219 return
1220}
1221
1222func CertFreeCertificateContext(ctx *CertContext) (err error) {
1223 r1, _, e1 := syscall.Syscall(procCertFreeCertificateContext.Addr(), 1, uintptr(unsafe.Pointer(ctx)), 0, 0)
1224 if r1 == 0 {
1225 err = errnoErr(e1)
1226 }
1227 return
1228}
1229
1230func CertGetCertificateChain(engine Handle, leaf *CertContext, time *Filetime, additionalStore Handle, para *CertChainPara, flags uint32, reserved uintptr, chainCtx **CertChainContext) (err error) {
1231 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)
1232 if r1 == 0 {
1233 err = errnoErr(e1)
1234 }
1235 return
1236}
1237
Jason A. Donenfeld4df39782021-01-22 14:23:17 +01001238func CertGetNameString(certContext *CertContext, nameType uint32, flags uint32, typePara unsafe.Pointer, name *uint16, size uint32) (chars uint32) {
1239 r0, _, _ := syscall.Syscall6(procCertGetNameStringW.Addr(), 6, uintptr(unsafe.Pointer(certContext)), uintptr(nameType), uintptr(flags), uintptr(typePara), uintptr(unsafe.Pointer(name)), uintptr(size))
1240 chars = uint32(r0)
1241 return
1242}
1243
Alex Brainman0aaa2712020-10-11 09:49:28 +11001244func CertOpenStore(storeProvider uintptr, msgAndCertEncodingType uint32, cryptProv uintptr, flags uint32, para uintptr) (handle Handle, err error) {
1245 r0, _, e1 := syscall.Syscall6(procCertOpenStore.Addr(), 5, uintptr(storeProvider), uintptr(msgAndCertEncodingType), uintptr(cryptProv), uintptr(flags), uintptr(para), 0)
1246 handle = Handle(r0)
Boshi Lian111129e2020-11-29 13:33:00 +00001247 if handle == 0 {
Alex Brainman0aaa2712020-10-11 09:49:28 +11001248 err = errnoErr(e1)
1249 }
1250 return
1251}
1252
1253func CertOpenSystemStore(hprov Handle, name *uint16) (store Handle, err error) {
1254 r0, _, e1 := syscall.Syscall(procCertOpenSystemStoreW.Addr(), 2, uintptr(hprov), uintptr(unsafe.Pointer(name)), 0)
1255 store = Handle(r0)
1256 if store == 0 {
1257 err = errnoErr(e1)
1258 }
1259 return
1260}
1261
1262func CertVerifyCertificateChainPolicy(policyOID uintptr, chain *CertChainContext, para *CertChainPolicyPara, status *CertChainPolicyStatus) (err error) {
1263 r1, _, e1 := syscall.Syscall6(procCertVerifyCertificateChainPolicy.Addr(), 4, uintptr(policyOID), uintptr(unsafe.Pointer(chain)), uintptr(unsafe.Pointer(para)), uintptr(unsafe.Pointer(status)), 0, 0)
1264 if r1 == 0 {
1265 err = errnoErr(e1)
1266 }
1267 return
1268}
1269
Jason A. Donenfeld4df39782021-01-22 14:23:17 +01001270func CryptDecodeObject(encodingType uint32, structType *byte, encodedBytes *byte, lenEncodedBytes uint32, flags uint32, decoded unsafe.Pointer, decodedLen *uint32) (err error) {
1271 r1, _, e1 := syscall.Syscall9(procCryptDecodeObject.Addr(), 7, uintptr(encodingType), uintptr(unsafe.Pointer(structType)), uintptr(unsafe.Pointer(encodedBytes)), uintptr(lenEncodedBytes), uintptr(flags), uintptr(decoded), uintptr(unsafe.Pointer(decodedLen)), 0, 0)
1272 if r1 == 0 {
1273 err = errnoErr(e1)
1274 }
1275 return
1276}
1277
1278func CryptQueryObject(objectType uint32, object unsafe.Pointer, expectedContentTypeFlags uint32, expectedFormatTypeFlags uint32, flags uint32, msgAndCertEncodingType *uint32, contentType *uint32, formatType *uint32, certStore *Handle, msg *Handle, context *unsafe.Pointer) (err error) {
1279 r1, _, e1 := syscall.Syscall12(procCryptQueryObject.Addr(), 11, uintptr(objectType), uintptr(object), uintptr(expectedContentTypeFlags), uintptr(expectedFormatTypeFlags), uintptr(flags), uintptr(unsafe.Pointer(msgAndCertEncodingType)), uintptr(unsafe.Pointer(contentType)), uintptr(unsafe.Pointer(formatType)), uintptr(unsafe.Pointer(certStore)), uintptr(unsafe.Pointer(msg)), uintptr(unsafe.Pointer(context)), 0)
1280 if r1 == 0 {
1281 err = errnoErr(e1)
1282 }
1283 return
1284}
1285
Boshi LIAN2d187342020-12-31 18:09:48 +00001286func PFXImportCertStore(pfx *CryptDataBlob, password *uint16, flags uint32) (store Handle, err error) {
1287 r0, _, e1 := syscall.Syscall(procPFXImportCertStore.Addr(), 3, uintptr(unsafe.Pointer(pfx)), uintptr(unsafe.Pointer(password)), uintptr(flags))
1288 store = Handle(r0)
1289 if store == 0 {
1290 err = errnoErr(e1)
1291 }
1292 return
1293}
1294
Alex Brainman0aaa2712020-10-11 09:49:28 +11001295func DnsNameCompare(name1 *uint16, name2 *uint16) (same bool) {
1296 r0, _, _ := syscall.Syscall(procDnsNameCompare_W.Addr(), 2, uintptr(unsafe.Pointer(name1)), uintptr(unsafe.Pointer(name2)), 0)
1297 same = r0 != 0
1298 return
1299}
1300
1301func DnsQuery(name string, qtype uint16, options uint32, extra *byte, qrs **DNSRecord, pr *byte) (status error) {
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -06001302 var _p0 *uint16
Alex Brainman0aaa2712020-10-11 09:49:28 +11001303 _p0, status = syscall.UTF16PtrFromString(name)
1304 if status != nil {
1305 return
1306 }
1307 return _DnsQuery(_p0, qtype, options, extra, qrs, pr)
1308}
1309
1310func _DnsQuery(name *uint16, qtype uint16, options uint32, extra *byte, qrs **DNSRecord, pr *byte) (status error) {
1311 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)))
1312 if r0 != 0 {
1313 status = syscall.Errno(r0)
1314 }
1315 return
1316}
1317
1318func DnsRecordListFree(rl *DNSRecord, freetype uint32) {
1319 syscall.Syscall(procDnsRecordListFree.Addr(), 2, uintptr(unsafe.Pointer(rl)), uintptr(freetype), 0)
1320 return
1321}
1322
1323func GetAdaptersAddresses(family uint32, flags uint32, reserved uintptr, adapterAddresses *IpAdapterAddresses, sizePointer *uint32) (errcode error) {
1324 r0, _, _ := syscall.Syscall6(procGetAdaptersAddresses.Addr(), 5, uintptr(family), uintptr(flags), uintptr(reserved), uintptr(unsafe.Pointer(adapterAddresses)), uintptr(unsafe.Pointer(sizePointer)), 0)
1325 if r0 != 0 {
1326 errcode = syscall.Errno(r0)
1327 }
1328 return
1329}
1330
1331func GetAdaptersInfo(ai *IpAdapterInfo, ol *uint32) (errcode error) {
1332 r0, _, _ := syscall.Syscall(procGetAdaptersInfo.Addr(), 2, uintptr(unsafe.Pointer(ai)), uintptr(unsafe.Pointer(ol)), 0)
1333 if r0 != 0 {
1334 errcode = syscall.Errno(r0)
1335 }
1336 return
1337}
1338
1339func GetIfEntry(pIfRow *MibIfRow) (errcode error) {
1340 r0, _, _ := syscall.Syscall(procGetIfEntry.Addr(), 1, uintptr(unsafe.Pointer(pIfRow)), 0, 0)
1341 if r0 != 0 {
1342 errcode = syscall.Errno(r0)
1343 }
1344 return
1345}
1346
1347func AssignProcessToJobObject(job Handle, process Handle) (err error) {
1348 r1, _, e1 := syscall.Syscall(procAssignProcessToJobObject.Addr(), 2, uintptr(job), uintptr(process), 0)
1349 if r1 == 0 {
1350 err = errnoErr(e1)
1351 }
1352 return
1353}
1354
1355func CancelIo(s Handle) (err error) {
1356 r1, _, e1 := syscall.Syscall(procCancelIo.Addr(), 1, uintptr(s), 0, 0)
1357 if r1 == 0 {
1358 err = errnoErr(e1)
1359 }
1360 return
1361}
1362
1363func CancelIoEx(s Handle, o *Overlapped) (err error) {
1364 r1, _, e1 := syscall.Syscall(procCancelIoEx.Addr(), 2, uintptr(s), uintptr(unsafe.Pointer(o)), 0)
1365 if r1 == 0 {
1366 err = errnoErr(e1)
1367 }
1368 return
1369}
1370
1371func CloseHandle(handle Handle) (err error) {
1372 r1, _, e1 := syscall.Syscall(procCloseHandle.Addr(), 1, uintptr(handle), 0, 0)
1373 if r1 == 0 {
1374 err = errnoErr(e1)
1375 }
1376 return
1377}
1378
1379func CreateDirectory(path *uint16, sa *SecurityAttributes) (err error) {
1380 r1, _, e1 := syscall.Syscall(procCreateDirectoryW.Addr(), 2, uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(sa)), 0)
1381 if r1 == 0 {
1382 err = errnoErr(e1)
1383 }
1384 return
1385}
1386
1387func CreateEventEx(eventAttrs *SecurityAttributes, name *uint16, flags uint32, desiredAccess uint32) (handle Handle, err error) {
1388 r0, _, e1 := syscall.Syscall6(procCreateEventExW.Addr(), 4, uintptr(unsafe.Pointer(eventAttrs)), uintptr(unsafe.Pointer(name)), uintptr(flags), uintptr(desiredAccess), 0, 0)
1389 handle = Handle(r0)
1390 if handle == 0 {
1391 err = errnoErr(e1)
1392 }
1393 return
1394}
1395
1396func CreateEvent(eventAttrs *SecurityAttributes, manualReset uint32, initialState uint32, name *uint16) (handle Handle, err error) {
1397 r0, _, e1 := syscall.Syscall6(procCreateEventW.Addr(), 4, uintptr(unsafe.Pointer(eventAttrs)), uintptr(manualReset), uintptr(initialState), uintptr(unsafe.Pointer(name)), 0, 0)
1398 handle = Handle(r0)
1399 if handle == 0 {
1400 err = errnoErr(e1)
1401 }
1402 return
1403}
1404
1405func CreateFileMapping(fhandle Handle, sa *SecurityAttributes, prot uint32, maxSizeHigh uint32, maxSizeLow uint32, name *uint16) (handle Handle, err error) {
1406 r0, _, e1 := syscall.Syscall6(procCreateFileMappingW.Addr(), 6, uintptr(fhandle), uintptr(unsafe.Pointer(sa)), uintptr(prot), uintptr(maxSizeHigh), uintptr(maxSizeLow), uintptr(unsafe.Pointer(name)))
1407 handle = Handle(r0)
1408 if handle == 0 {
1409 err = errnoErr(e1)
1410 }
1411 return
1412}
1413
1414func CreateFile(name *uint16, access uint32, mode uint32, sa *SecurityAttributes, createmode uint32, attrs uint32, templatefile Handle) (handle Handle, err error) {
1415 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)
1416 handle = Handle(r0)
1417 if handle == InvalidHandle {
1418 err = errnoErr(e1)
1419 }
1420 return
1421}
1422
1423func CreateHardLink(filename *uint16, existingfilename *uint16, reserved uintptr) (err error) {
1424 r1, _, e1 := syscall.Syscall(procCreateHardLinkW.Addr(), 3, uintptr(unsafe.Pointer(filename)), uintptr(unsafe.Pointer(existingfilename)), uintptr(reserved))
1425 if r1&0xff == 0 {
1426 err = errnoErr(e1)
1427 }
1428 return
1429}
1430
1431func CreateIoCompletionPort(filehandle Handle, cphandle Handle, key uint32, threadcnt uint32) (handle Handle, err error) {
1432 r0, _, e1 := syscall.Syscall6(procCreateIoCompletionPort.Addr(), 4, uintptr(filehandle), uintptr(cphandle), uintptr(key), uintptr(threadcnt), 0, 0)
1433 handle = Handle(r0)
1434 if handle == 0 {
1435 err = errnoErr(e1)
1436 }
1437 return
1438}
1439
1440func CreateJobObject(jobAttr *SecurityAttributes, name *uint16) (handle Handle, err error) {
1441 r0, _, e1 := syscall.Syscall(procCreateJobObjectW.Addr(), 2, uintptr(unsafe.Pointer(jobAttr)), uintptr(unsafe.Pointer(name)), 0)
1442 handle = Handle(r0)
1443 if handle == 0 {
1444 err = errnoErr(e1)
1445 }
1446 return
1447}
1448
1449func CreateMutexEx(mutexAttrs *SecurityAttributes, name *uint16, flags uint32, desiredAccess uint32) (handle Handle, err error) {
1450 r0, _, e1 := syscall.Syscall6(procCreateMutexExW.Addr(), 4, uintptr(unsafe.Pointer(mutexAttrs)), uintptr(unsafe.Pointer(name)), uintptr(flags), uintptr(desiredAccess), 0, 0)
1451 handle = Handle(r0)
1452 if handle == 0 {
1453 err = errnoErr(e1)
1454 }
1455 return
1456}
1457
1458func CreateMutex(mutexAttrs *SecurityAttributes, initialOwner bool, name *uint16) (handle Handle, err error) {
1459 var _p0 uint32
1460 if initialOwner {
1461 _p0 = 1
1462 }
1463 r0, _, e1 := syscall.Syscall(procCreateMutexW.Addr(), 3, uintptr(unsafe.Pointer(mutexAttrs)), uintptr(_p0), uintptr(unsafe.Pointer(name)))
1464 handle = Handle(r0)
1465 if handle == 0 {
1466 err = errnoErr(e1)
1467 }
1468 return
1469}
1470
1471func CreatePipe(readhandle *Handle, writehandle *Handle, sa *SecurityAttributes, size uint32) (err error) {
1472 r1, _, e1 := syscall.Syscall6(procCreatePipe.Addr(), 4, uintptr(unsafe.Pointer(readhandle)), uintptr(unsafe.Pointer(writehandle)), uintptr(unsafe.Pointer(sa)), uintptr(size), 0, 0)
1473 if r1 == 0 {
1474 err = errnoErr(e1)
1475 }
1476 return
1477}
1478
1479func CreateProcess(appName *uint16, commandLine *uint16, procSecurity *SecurityAttributes, threadSecurity *SecurityAttributes, inheritHandles bool, creationFlags uint32, env *uint16, currentDir *uint16, startupInfo *StartupInfo, outProcInfo *ProcessInformation) (err error) {
1480 var _p0 uint32
1481 if inheritHandles {
1482 _p0 = 1
1483 }
1484 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)
1485 if r1 == 0 {
1486 err = errnoErr(e1)
1487 }
1488 return
1489}
1490
1491func CreateSymbolicLink(symlinkfilename *uint16, targetfilename *uint16, flags uint32) (err error) {
1492 r1, _, e1 := syscall.Syscall(procCreateSymbolicLinkW.Addr(), 3, uintptr(unsafe.Pointer(symlinkfilename)), uintptr(unsafe.Pointer(targetfilename)), uintptr(flags))
1493 if r1&0xff == 0 {
1494 err = errnoErr(e1)
1495 }
1496 return
1497}
1498
1499func CreateToolhelp32Snapshot(flags uint32, processId uint32) (handle Handle, err error) {
1500 r0, _, e1 := syscall.Syscall(procCreateToolhelp32Snapshot.Addr(), 2, uintptr(flags), uintptr(processId), 0)
1501 handle = Handle(r0)
1502 if handle == InvalidHandle {
1503 err = errnoErr(e1)
1504 }
1505 return
1506}
1507
1508func DefineDosDevice(flags uint32, deviceName *uint16, targetPath *uint16) (err error) {
1509 r1, _, e1 := syscall.Syscall(procDefineDosDeviceW.Addr(), 3, uintptr(flags), uintptr(unsafe.Pointer(deviceName)), uintptr(unsafe.Pointer(targetPath)))
1510 if r1 == 0 {
1511 err = errnoErr(e1)
1512 }
1513 return
1514}
1515
1516func DeleteFile(path *uint16) (err error) {
1517 r1, _, e1 := syscall.Syscall(procDeleteFileW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0)
1518 if r1 == 0 {
1519 err = errnoErr(e1)
1520 }
1521 return
1522}
1523
1524func DeleteVolumeMountPoint(volumeMountPoint *uint16) (err error) {
1525 r1, _, e1 := syscall.Syscall(procDeleteVolumeMountPointW.Addr(), 1, uintptr(unsafe.Pointer(volumeMountPoint)), 0, 0)
1526 if r1 == 0 {
1527 err = errnoErr(e1)
1528 }
1529 return
1530}
1531
1532func DeviceIoControl(handle Handle, ioControlCode uint32, inBuffer *byte, inBufferSize uint32, outBuffer *byte, outBufferSize uint32, bytesReturned *uint32, overlapped *Overlapped) (err error) {
1533 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)
1534 if r1 == 0 {
1535 err = errnoErr(e1)
1536 }
1537 return
1538}
1539
1540func DuplicateHandle(hSourceProcessHandle Handle, hSourceHandle Handle, hTargetProcessHandle Handle, lpTargetHandle *Handle, dwDesiredAccess uint32, bInheritHandle bool, dwOptions uint32) (err error) {
1541 var _p0 uint32
1542 if bInheritHandle {
1543 _p0 = 1
1544 }
1545 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)
1546 if r1 == 0 {
1547 err = errnoErr(e1)
1548 }
1549 return
1550}
1551
1552func ExitProcess(exitcode uint32) {
1553 syscall.Syscall(procExitProcess.Addr(), 1, uintptr(exitcode), 0, 0)
1554 return
1555}
1556
1557func FindClose(handle Handle) (err error) {
1558 r1, _, e1 := syscall.Syscall(procFindClose.Addr(), 1, uintptr(handle), 0, 0)
1559 if r1 == 0 {
1560 err = errnoErr(e1)
1561 }
1562 return
1563}
1564
Jason A. Donenfelda8b976e2021-01-22 14:20:47 +01001565func FindCloseChangeNotification(handle Handle) (err error) {
1566 r1, _, e1 := syscall.Syscall(procFindCloseChangeNotification.Addr(), 1, uintptr(handle), 0, 0)
1567 if r1 == 0 {
1568 err = errnoErr(e1)
1569 }
1570 return
1571}
1572
1573func FindFirstChangeNotification(path string, watchSubtree bool, notifyFilter uint32) (handle Handle, err error) {
1574 var _p0 *uint16
1575 _p0, err = syscall.UTF16PtrFromString(path)
1576 if err != nil {
1577 return
1578 }
1579 return _FindFirstChangeNotification(_p0, watchSubtree, notifyFilter)
1580}
1581
1582func _FindFirstChangeNotification(path *uint16, watchSubtree bool, notifyFilter uint32) (handle Handle, err error) {
1583 var _p1 uint32
1584 if watchSubtree {
1585 _p1 = 1
1586 }
1587 r0, _, e1 := syscall.Syscall(procFindFirstChangeNotificationW.Addr(), 3, uintptr(unsafe.Pointer(path)), uintptr(_p1), uintptr(notifyFilter))
1588 handle = Handle(r0)
1589 if handle == InvalidHandle {
1590 err = errnoErr(e1)
1591 }
1592 return
1593}
1594
Alex Brainman0aaa2712020-10-11 09:49:28 +11001595func findFirstFile1(name *uint16, data *win32finddata1) (handle Handle, err error) {
1596 r0, _, e1 := syscall.Syscall(procFindFirstFileW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(data)), 0)
1597 handle = Handle(r0)
1598 if handle == InvalidHandle {
1599 err = errnoErr(e1)
1600 }
1601 return
1602}
1603
1604func FindFirstVolumeMountPoint(rootPathName *uint16, volumeMountPoint *uint16, bufferLength uint32) (handle Handle, err error) {
1605 r0, _, e1 := syscall.Syscall(procFindFirstVolumeMountPointW.Addr(), 3, uintptr(unsafe.Pointer(rootPathName)), uintptr(unsafe.Pointer(volumeMountPoint)), uintptr(bufferLength))
1606 handle = Handle(r0)
1607 if handle == InvalidHandle {
1608 err = errnoErr(e1)
1609 }
1610 return
1611}
1612
1613func FindFirstVolume(volumeName *uint16, bufferLength uint32) (handle Handle, err error) {
1614 r0, _, e1 := syscall.Syscall(procFindFirstVolumeW.Addr(), 2, uintptr(unsafe.Pointer(volumeName)), uintptr(bufferLength), 0)
1615 handle = Handle(r0)
1616 if handle == InvalidHandle {
1617 err = errnoErr(e1)
1618 }
1619 return
1620}
1621
Jason A. Donenfelda8b976e2021-01-22 14:20:47 +01001622func FindNextChangeNotification(handle Handle) (err error) {
1623 r1, _, e1 := syscall.Syscall(procFindNextChangeNotification.Addr(), 1, uintptr(handle), 0, 0)
1624 if r1 == 0 {
1625 err = errnoErr(e1)
1626 }
1627 return
1628}
1629
Alex Brainman0aaa2712020-10-11 09:49:28 +11001630func findNextFile1(handle Handle, data *win32finddata1) (err error) {
1631 r1, _, e1 := syscall.Syscall(procFindNextFileW.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(data)), 0)
1632 if r1 == 0 {
1633 err = errnoErr(e1)
1634 }
1635 return
1636}
1637
1638func FindNextVolumeMountPoint(findVolumeMountPoint Handle, volumeMountPoint *uint16, bufferLength uint32) (err error) {
1639 r1, _, e1 := syscall.Syscall(procFindNextVolumeMountPointW.Addr(), 3, uintptr(findVolumeMountPoint), uintptr(unsafe.Pointer(volumeMountPoint)), uintptr(bufferLength))
1640 if r1 == 0 {
1641 err = errnoErr(e1)
1642 }
1643 return
1644}
1645
1646func FindNextVolume(findVolume Handle, volumeName *uint16, bufferLength uint32) (err error) {
1647 r1, _, e1 := syscall.Syscall(procFindNextVolumeW.Addr(), 3, uintptr(findVolume), uintptr(unsafe.Pointer(volumeName)), uintptr(bufferLength))
1648 if r1 == 0 {
1649 err = errnoErr(e1)
1650 }
1651 return
1652}
1653
1654func FindVolumeClose(findVolume Handle) (err error) {
1655 r1, _, e1 := syscall.Syscall(procFindVolumeClose.Addr(), 1, uintptr(findVolume), 0, 0)
1656 if r1 == 0 {
1657 err = errnoErr(e1)
1658 }
1659 return
1660}
1661
1662func FindVolumeMountPointClose(findVolumeMountPoint Handle) (err error) {
1663 r1, _, e1 := syscall.Syscall(procFindVolumeMountPointClose.Addr(), 1, uintptr(findVolumeMountPoint), 0, 0)
1664 if r1 == 0 {
1665 err = errnoErr(e1)
1666 }
1667 return
1668}
1669
1670func FlushFileBuffers(handle Handle) (err error) {
1671 r1, _, e1 := syscall.Syscall(procFlushFileBuffers.Addr(), 1, uintptr(handle), 0, 0)
1672 if r1 == 0 {
1673 err = errnoErr(e1)
1674 }
1675 return
1676}
1677
1678func FlushViewOfFile(addr uintptr, length uintptr) (err error) {
1679 r1, _, e1 := syscall.Syscall(procFlushViewOfFile.Addr(), 2, uintptr(addr), uintptr(length), 0)
1680 if r1 == 0 {
1681 err = errnoErr(e1)
1682 }
1683 return
1684}
1685
1686func FormatMessage(flags uint32, msgsrc uintptr, msgid uint32, langid uint32, buf []uint16, args *byte) (n uint32, err error) {
1687 var _p0 *uint16
1688 if len(buf) > 0 {
1689 _p0 = &buf[0]
1690 }
1691 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)
1692 n = uint32(r0)
1693 if n == 0 {
1694 err = errnoErr(e1)
1695 }
1696 return
1697}
1698
1699func FreeEnvironmentStrings(envs *uint16) (err error) {
1700 r1, _, e1 := syscall.Syscall(procFreeEnvironmentStringsW.Addr(), 1, uintptr(unsafe.Pointer(envs)), 0, 0)
1701 if r1 == 0 {
1702 err = errnoErr(e1)
1703 }
1704 return
1705}
1706
1707func FreeLibrary(handle Handle) (err error) {
1708 r1, _, e1 := syscall.Syscall(procFreeLibrary.Addr(), 1, uintptr(handle), 0, 0)
1709 if r1 == 0 {
1710 err = errnoErr(e1)
1711 }
1712 return
1713}
1714
1715func GenerateConsoleCtrlEvent(ctrlEvent uint32, processGroupID uint32) (err error) {
1716 r1, _, e1 := syscall.Syscall(procGenerateConsoleCtrlEvent.Addr(), 2, uintptr(ctrlEvent), uintptr(processGroupID), 0)
1717 if r1 == 0 {
1718 err = errnoErr(e1)
1719 }
1720 return
1721}
1722
1723func GetACP() (acp uint32) {
1724 r0, _, _ := syscall.Syscall(procGetACP.Addr(), 0, 0, 0, 0)
1725 acp = uint32(r0)
1726 return
1727}
1728
1729func GetCommandLine() (cmd *uint16) {
1730 r0, _, _ := syscall.Syscall(procGetCommandLineW.Addr(), 0, 0, 0, 0)
1731 cmd = (*uint16)(unsafe.Pointer(r0))
1732 return
1733}
1734
1735func GetComputerNameEx(nametype uint32, buf *uint16, n *uint32) (err error) {
1736 r1, _, e1 := syscall.Syscall(procGetComputerNameExW.Addr(), 3, uintptr(nametype), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(n)))
1737 if r1 == 0 {
1738 err = errnoErr(e1)
1739 }
1740 return
1741}
1742
1743func GetComputerName(buf *uint16, n *uint32) (err error) {
1744 r1, _, e1 := syscall.Syscall(procGetComputerNameW.Addr(), 2, uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(n)), 0)
1745 if r1 == 0 {
1746 err = errnoErr(e1)
1747 }
1748 return
1749}
1750
1751func GetConsoleMode(console Handle, mode *uint32) (err error) {
1752 r1, _, e1 := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(console), uintptr(unsafe.Pointer(mode)), 0)
1753 if r1 == 0 {
1754 err = errnoErr(e1)
1755 }
1756 return
1757}
1758
1759func GetConsoleScreenBufferInfo(console Handle, info *ConsoleScreenBufferInfo) (err error) {
1760 r1, _, e1 := syscall.Syscall(procGetConsoleScreenBufferInfo.Addr(), 2, uintptr(console), uintptr(unsafe.Pointer(info)), 0)
1761 if r1 == 0 {
1762 err = errnoErr(e1)
1763 }
1764 return
1765}
1766
1767func GetCurrentDirectory(buflen uint32, buf *uint16) (n uint32, err error) {
1768 r0, _, e1 := syscall.Syscall(procGetCurrentDirectoryW.Addr(), 2, uintptr(buflen), uintptr(unsafe.Pointer(buf)), 0)
1769 n = uint32(r0)
1770 if n == 0 {
1771 err = errnoErr(e1)
1772 }
1773 return
1774}
1775
1776func GetCurrentProcessId() (pid uint32) {
1777 r0, _, _ := syscall.Syscall(procGetCurrentProcessId.Addr(), 0, 0, 0, 0)
1778 pid = uint32(r0)
1779 return
1780}
1781
1782func GetCurrentThreadId() (id uint32) {
1783 r0, _, _ := syscall.Syscall(procGetCurrentThreadId.Addr(), 0, 0, 0, 0)
1784 id = uint32(r0)
1785 return
1786}
1787
1788func GetDiskFreeSpaceEx(directoryName *uint16, freeBytesAvailableToCaller *uint64, totalNumberOfBytes *uint64, totalNumberOfFreeBytes *uint64) (err error) {
1789 r1, _, e1 := syscall.Syscall6(procGetDiskFreeSpaceExW.Addr(), 4, uintptr(unsafe.Pointer(directoryName)), uintptr(unsafe.Pointer(freeBytesAvailableToCaller)), uintptr(unsafe.Pointer(totalNumberOfBytes)), uintptr(unsafe.Pointer(totalNumberOfFreeBytes)), 0, 0)
1790 if r1 == 0 {
1791 err = errnoErr(e1)
1792 }
1793 return
1794}
1795
1796func GetDriveType(rootPathName *uint16) (driveType uint32) {
1797 r0, _, _ := syscall.Syscall(procGetDriveTypeW.Addr(), 1, uintptr(unsafe.Pointer(rootPathName)), 0, 0)
1798 driveType = uint32(r0)
1799 return
1800}
1801
1802func GetEnvironmentStrings() (envs *uint16, err error) {
1803 r0, _, e1 := syscall.Syscall(procGetEnvironmentStringsW.Addr(), 0, 0, 0, 0)
1804 envs = (*uint16)(unsafe.Pointer(r0))
1805 if envs == nil {
1806 err = errnoErr(e1)
1807 }
1808 return
1809}
1810
1811func GetEnvironmentVariable(name *uint16, buffer *uint16, size uint32) (n uint32, err error) {
1812 r0, _, e1 := syscall.Syscall(procGetEnvironmentVariableW.Addr(), 3, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(buffer)), uintptr(size))
1813 n = uint32(r0)
1814 if n == 0 {
1815 err = errnoErr(e1)
1816 }
1817 return
1818}
1819
1820func GetExitCodeProcess(handle Handle, exitcode *uint32) (err error) {
1821 r1, _, e1 := syscall.Syscall(procGetExitCodeProcess.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(exitcode)), 0)
1822 if r1 == 0 {
1823 err = errnoErr(e1)
1824 }
1825 return
1826}
1827
1828func GetFileAttributesEx(name *uint16, level uint32, info *byte) (err error) {
1829 r1, _, e1 := syscall.Syscall(procGetFileAttributesExW.Addr(), 3, uintptr(unsafe.Pointer(name)), uintptr(level), uintptr(unsafe.Pointer(info)))
1830 if r1 == 0 {
1831 err = errnoErr(e1)
1832 }
1833 return
1834}
1835
1836func GetFileAttributes(name *uint16) (attrs uint32, err error) {
1837 r0, _, e1 := syscall.Syscall(procGetFileAttributesW.Addr(), 1, uintptr(unsafe.Pointer(name)), 0, 0)
1838 attrs = uint32(r0)
1839 if attrs == INVALID_FILE_ATTRIBUTES {
1840 err = errnoErr(e1)
1841 }
1842 return
1843}
1844
1845func GetFileInformationByHandle(handle Handle, data *ByHandleFileInformation) (err error) {
1846 r1, _, e1 := syscall.Syscall(procGetFileInformationByHandle.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(data)), 0)
1847 if r1 == 0 {
1848 err = errnoErr(e1)
1849 }
1850 return
1851}
1852
1853func GetFileInformationByHandleEx(handle Handle, class uint32, outBuffer *byte, outBufferLen uint32) (err error) {
1854 r1, _, e1 := syscall.Syscall6(procGetFileInformationByHandleEx.Addr(), 4, uintptr(handle), uintptr(class), uintptr(unsafe.Pointer(outBuffer)), uintptr(outBufferLen), 0, 0)
1855 if r1 == 0 {
1856 err = errnoErr(e1)
1857 }
1858 return
1859}
1860
1861func GetFileType(filehandle Handle) (n uint32, err error) {
1862 r0, _, e1 := syscall.Syscall(procGetFileType.Addr(), 1, uintptr(filehandle), 0, 0)
1863 n = uint32(r0)
1864 if n == 0 {
1865 err = errnoErr(e1)
1866 }
1867 return
1868}
1869
Jason A. Donenfeldcc9327a2020-11-16 17:45:47 +01001870func GetFinalPathNameByHandle(file Handle, filePath *uint16, filePathSize uint32, flags uint32) (n uint32, err error) {
Meng Zhuo35185872020-10-28 14:35:39 +08001871 r0, _, e1 := syscall.Syscall6(procGetFinalPathNameByHandleW.Addr(), 4, uintptr(file), uintptr(unsafe.Pointer(filePath)), uintptr(filePathSize), uintptr(flags), 0, 0)
1872 n = uint32(r0)
1873 if n == 0 {
1874 err = errnoErr(e1)
1875 }
1876 return
1877}
1878
Alex Brainman0aaa2712020-10-11 09:49:28 +11001879func GetFullPathName(path *uint16, buflen uint32, buf *uint16, fname **uint16) (n uint32, err error) {
1880 r0, _, e1 := syscall.Syscall6(procGetFullPathNameW.Addr(), 4, uintptr(unsafe.Pointer(path)), uintptr(buflen), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(fname)), 0, 0)
1881 n = uint32(r0)
1882 if n == 0 {
1883 err = errnoErr(e1)
1884 }
1885 return
1886}
1887
1888func GetLastError() (lasterr error) {
1889 r0, _, _ := syscall.Syscall(procGetLastError.Addr(), 0, 0, 0, 0)
1890 if r0 != 0 {
1891 lasterr = syscall.Errno(r0)
1892 }
1893 return
1894}
1895
1896func GetLogicalDriveStrings(bufferLength uint32, buffer *uint16) (n uint32, err error) {
1897 r0, _, e1 := syscall.Syscall(procGetLogicalDriveStringsW.Addr(), 2, uintptr(bufferLength), uintptr(unsafe.Pointer(buffer)), 0)
1898 n = uint32(r0)
1899 if n == 0 {
1900 err = errnoErr(e1)
1901 }
1902 return
1903}
1904
1905func GetLogicalDrives() (drivesBitMask uint32, err error) {
1906 r0, _, e1 := syscall.Syscall(procGetLogicalDrives.Addr(), 0, 0, 0, 0)
1907 drivesBitMask = uint32(r0)
1908 if drivesBitMask == 0 {
1909 err = errnoErr(e1)
1910 }
1911 return
1912}
1913
1914func GetLongPathName(path *uint16, buf *uint16, buflen uint32) (n uint32, err error) {
1915 r0, _, e1 := syscall.Syscall(procGetLongPathNameW.Addr(), 3, uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(buf)), uintptr(buflen))
1916 n = uint32(r0)
1917 if n == 0 {
1918 err = errnoErr(e1)
1919 }
1920 return
1921}
1922
1923func GetModuleFileName(module Handle, filename *uint16, size uint32) (n uint32, err error) {
1924 r0, _, e1 := syscall.Syscall(procGetModuleFileNameW.Addr(), 3, uintptr(module), uintptr(unsafe.Pointer(filename)), uintptr(size))
1925 n = uint32(r0)
1926 if n == 0 {
1927 err = errnoErr(e1)
1928 }
1929 return
1930}
1931
1932func GetModuleHandleEx(flags uint32, moduleName *uint16, module *Handle) (err error) {
1933 r1, _, e1 := syscall.Syscall(procGetModuleHandleExW.Addr(), 3, uintptr(flags), uintptr(unsafe.Pointer(moduleName)), uintptr(unsafe.Pointer(module)))
1934 if r1 == 0 {
1935 err = errnoErr(e1)
1936 }
1937 return
1938}
1939
1940func GetOverlappedResult(handle Handle, overlapped *Overlapped, done *uint32, wait bool) (err error) {
1941 var _p0 uint32
1942 if wait {
1943 _p0 = 1
1944 }
1945 r1, _, e1 := syscall.Syscall6(procGetOverlappedResult.Addr(), 4, uintptr(handle), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(done)), uintptr(_p0), 0, 0)
1946 if r1 == 0 {
1947 err = errnoErr(e1)
1948 }
1949 return
1950}
1951
1952func GetPriorityClass(process Handle) (ret uint32, err error) {
1953 r0, _, e1 := syscall.Syscall(procGetPriorityClass.Addr(), 1, uintptr(process), 0, 0)
1954 ret = uint32(r0)
1955 if ret == 0 {
1956 err = errnoErr(e1)
1957 }
1958 return
1959}
1960
1961func GetProcAddress(module Handle, procname string) (proc uintptr, err error) {
1962 var _p0 *byte
1963 _p0, err = syscall.BytePtrFromString(procname)
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -06001964 if err != nil {
1965 return
1966 }
Alex Brainman0aaa2712020-10-11 09:49:28 +11001967 return _GetProcAddress(module, _p0)
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -06001968}
1969
Alex Brainman0aaa2712020-10-11 09:49:28 +11001970func _GetProcAddress(module Handle, procname *byte) (proc uintptr, err error) {
1971 r0, _, e1 := syscall.Syscall(procGetProcAddress.Addr(), 2, uintptr(module), uintptr(unsafe.Pointer(procname)), 0)
1972 proc = uintptr(r0)
1973 if proc == 0 {
1974 err = errnoErr(e1)
1975 }
1976 return
1977}
1978
1979func GetProcessId(process Handle) (id uint32, err error) {
1980 r0, _, e1 := syscall.Syscall(procGetProcessId.Addr(), 1, uintptr(process), 0, 0)
1981 id = uint32(r0)
1982 if id == 0 {
1983 err = errnoErr(e1)
1984 }
1985 return
1986}
1987
1988func getProcessPreferredUILanguages(flags uint32, numLanguages *uint32, buf *uint16, bufSize *uint32) (err error) {
1989 r1, _, e1 := syscall.Syscall6(procGetProcessPreferredUILanguages.Addr(), 4, uintptr(flags), uintptr(unsafe.Pointer(numLanguages)), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(bufSize)), 0, 0)
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -06001990 if r1 == 0 {
Sebastiaan van Stijndfb3f7c2020-10-09 00:24:30 +00001991 err = errnoErr(e1)
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -06001992 }
1993 return
1994}
1995
Alex Brainman0aaa2712020-10-11 09:49:28 +11001996func GetProcessShutdownParameters(level *uint32, flags *uint32) (err error) {
1997 r1, _, e1 := syscall.Syscall(procGetProcessShutdownParameters.Addr(), 2, uintptr(unsafe.Pointer(level)), uintptr(unsafe.Pointer(flags)), 0)
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -06001998 if r1 == 0 {
Sebastiaan van Stijndfb3f7c2020-10-09 00:24:30 +00001999 err = errnoErr(e1)
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -06002000 }
2001 return
2002}
2003
Alex Brainman0aaa2712020-10-11 09:49:28 +11002004func GetProcessTimes(handle Handle, creationTime *Filetime, exitTime *Filetime, kernelTime *Filetime, userTime *Filetime) (err error) {
2005 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)
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -06002006 if r1 == 0 {
Sebastiaan van Stijndfb3f7c2020-10-09 00:24:30 +00002007 err = errnoErr(e1)
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -06002008 }
2009 return
2010}
2011
Alex Brainman0aaa2712020-10-11 09:49:28 +11002012func GetProcessWorkingSetSizeEx(hProcess Handle, lpMinimumWorkingSetSize *uintptr, lpMaximumWorkingSetSize *uintptr, flags *uint32) {
2013 syscall.Syscall6(procGetProcessWorkingSetSizeEx.Addr(), 4, uintptr(hProcess), uintptr(unsafe.Pointer(lpMinimumWorkingSetSize)), uintptr(unsafe.Pointer(lpMaximumWorkingSetSize)), uintptr(unsafe.Pointer(flags)), 0, 0)
2014 return
2015}
2016
2017func GetQueuedCompletionStatus(cphandle Handle, qty *uint32, key *uint32, overlapped **Overlapped, timeout uint32) (err error) {
2018 r1, _, e1 := syscall.Syscall6(procGetQueuedCompletionStatus.Addr(), 5, uintptr(cphandle), uintptr(unsafe.Pointer(qty)), uintptr(unsafe.Pointer(key)), uintptr(unsafe.Pointer(overlapped)), uintptr(timeout), 0)
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -06002019 if r1 == 0 {
Sebastiaan van Stijndfb3f7c2020-10-09 00:24:30 +00002020 err = errnoErr(e1)
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -06002021 }
2022 return
2023}
2024
Alex Brainman0aaa2712020-10-11 09:49:28 +11002025func GetShortPathName(longpath *uint16, shortpath *uint16, buflen uint32) (n uint32, err error) {
2026 r0, _, e1 := syscall.Syscall(procGetShortPathNameW.Addr(), 3, uintptr(unsafe.Pointer(longpath)), uintptr(unsafe.Pointer(shortpath)), uintptr(buflen))
2027 n = uint32(r0)
2028 if n == 0 {
2029 err = errnoErr(e1)
2030 }
2031 return
2032}
2033
2034func GetStartupInfo(startupInfo *StartupInfo) (err error) {
2035 r1, _, e1 := syscall.Syscall(procGetStartupInfoW.Addr(), 1, uintptr(unsafe.Pointer(startupInfo)), 0, 0)
2036 if r1 == 0 {
2037 err = errnoErr(e1)
2038 }
2039 return
2040}
2041
2042func GetStdHandle(stdhandle uint32) (handle Handle, err error) {
2043 r0, _, e1 := syscall.Syscall(procGetStdHandle.Addr(), 1, uintptr(stdhandle), 0, 0)
2044 handle = Handle(r0)
2045 if handle == InvalidHandle {
2046 err = errnoErr(e1)
2047 }
2048 return
2049}
2050
2051func getSystemDirectory(dir *uint16, dirLen uint32) (len uint32, err error) {
2052 r0, _, e1 := syscall.Syscall(procGetSystemDirectoryW.Addr(), 2, uintptr(unsafe.Pointer(dir)), uintptr(dirLen), 0)
2053 len = uint32(r0)
2054 if len == 0 {
2055 err = errnoErr(e1)
2056 }
2057 return
2058}
2059
2060func getSystemPreferredUILanguages(flags uint32, numLanguages *uint32, buf *uint16, bufSize *uint32) (err error) {
2061 r1, _, e1 := syscall.Syscall6(procGetSystemPreferredUILanguages.Addr(), 4, uintptr(flags), uintptr(unsafe.Pointer(numLanguages)), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(bufSize)), 0, 0)
2062 if r1 == 0 {
2063 err = errnoErr(e1)
2064 }
2065 return
2066}
2067
2068func GetSystemTimeAsFileTime(time *Filetime) {
2069 syscall.Syscall(procGetSystemTimeAsFileTime.Addr(), 1, uintptr(unsafe.Pointer(time)), 0, 0)
2070 return
2071}
2072
2073func GetSystemTimePreciseAsFileTime(time *Filetime) {
2074 syscall.Syscall(procGetSystemTimePreciseAsFileTime.Addr(), 1, uintptr(unsafe.Pointer(time)), 0, 0)
2075 return
2076}
2077
2078func getSystemWindowsDirectory(dir *uint16, dirLen uint32) (len uint32, err error) {
2079 r0, _, e1 := syscall.Syscall(procGetSystemWindowsDirectoryW.Addr(), 2, uintptr(unsafe.Pointer(dir)), uintptr(dirLen), 0)
2080 len = uint32(r0)
2081 if len == 0 {
2082 err = errnoErr(e1)
2083 }
2084 return
2085}
2086
2087func GetTempPath(buflen uint32, buf *uint16) (n uint32, err error) {
2088 r0, _, e1 := syscall.Syscall(procGetTempPathW.Addr(), 2, uintptr(buflen), uintptr(unsafe.Pointer(buf)), 0)
2089 n = uint32(r0)
2090 if n == 0 {
2091 err = errnoErr(e1)
2092 }
2093 return
2094}
2095
2096func getThreadPreferredUILanguages(flags uint32, numLanguages *uint32, buf *uint16, bufSize *uint32) (err error) {
2097 r1, _, e1 := syscall.Syscall6(procGetThreadPreferredUILanguages.Addr(), 4, uintptr(flags), uintptr(unsafe.Pointer(numLanguages)), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(bufSize)), 0, 0)
2098 if r1 == 0 {
2099 err = errnoErr(e1)
2100 }
2101 return
2102}
2103
2104func getTickCount64() (ms uint64) {
2105 r0, _, _ := syscall.Syscall(procGetTickCount64.Addr(), 0, 0, 0, 0)
2106 ms = uint64(r0)
2107 return
2108}
2109
2110func GetTimeZoneInformation(tzi *Timezoneinformation) (rc uint32, err error) {
2111 r0, _, e1 := syscall.Syscall(procGetTimeZoneInformation.Addr(), 1, uintptr(unsafe.Pointer(tzi)), 0, 0)
2112 rc = uint32(r0)
2113 if rc == 0xffffffff {
2114 err = errnoErr(e1)
2115 }
2116 return
2117}
2118
2119func getUserPreferredUILanguages(flags uint32, numLanguages *uint32, buf *uint16, bufSize *uint32) (err error) {
2120 r1, _, e1 := syscall.Syscall6(procGetUserPreferredUILanguages.Addr(), 4, uintptr(flags), uintptr(unsafe.Pointer(numLanguages)), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(bufSize)), 0, 0)
2121 if r1 == 0 {
2122 err = errnoErr(e1)
2123 }
2124 return
2125}
2126
2127func GetVersion() (ver uint32, err error) {
2128 r0, _, e1 := syscall.Syscall(procGetVersion.Addr(), 0, 0, 0, 0)
2129 ver = uint32(r0)
2130 if ver == 0 {
2131 err = errnoErr(e1)
2132 }
2133 return
2134}
2135
2136func GetVolumeInformationByHandle(file Handle, volumeNameBuffer *uint16, volumeNameSize uint32, volumeNameSerialNumber *uint32, maximumComponentLength *uint32, fileSystemFlags *uint32, fileSystemNameBuffer *uint16, fileSystemNameSize uint32) (err error) {
2137 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)
2138 if r1 == 0 {
2139 err = errnoErr(e1)
2140 }
2141 return
2142}
2143
2144func GetVolumeInformation(rootPathName *uint16, volumeNameBuffer *uint16, volumeNameSize uint32, volumeNameSerialNumber *uint32, maximumComponentLength *uint32, fileSystemFlags *uint32, fileSystemNameBuffer *uint16, fileSystemNameSize uint32) (err error) {
2145 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)
2146 if r1 == 0 {
2147 err = errnoErr(e1)
2148 }
2149 return
2150}
2151
2152func GetVolumeNameForVolumeMountPoint(volumeMountPoint *uint16, volumeName *uint16, bufferlength uint32) (err error) {
2153 r1, _, e1 := syscall.Syscall(procGetVolumeNameForVolumeMountPointW.Addr(), 3, uintptr(unsafe.Pointer(volumeMountPoint)), uintptr(unsafe.Pointer(volumeName)), uintptr(bufferlength))
2154 if r1 == 0 {
2155 err = errnoErr(e1)
2156 }
2157 return
2158}
2159
2160func GetVolumePathName(fileName *uint16, volumePathName *uint16, bufferLength uint32) (err error) {
2161 r1, _, e1 := syscall.Syscall(procGetVolumePathNameW.Addr(), 3, uintptr(unsafe.Pointer(fileName)), uintptr(unsafe.Pointer(volumePathName)), uintptr(bufferLength))
2162 if r1 == 0 {
2163 err = errnoErr(e1)
2164 }
2165 return
2166}
2167
2168func GetVolumePathNamesForVolumeName(volumeName *uint16, volumePathNames *uint16, bufferLength uint32, returnLength *uint32) (err error) {
2169 r1, _, e1 := syscall.Syscall6(procGetVolumePathNamesForVolumeNameW.Addr(), 4, uintptr(unsafe.Pointer(volumeName)), uintptr(unsafe.Pointer(volumePathNames)), uintptr(bufferLength), uintptr(unsafe.Pointer(returnLength)), 0, 0)
2170 if r1 == 0 {
2171 err = errnoErr(e1)
2172 }
2173 return
2174}
2175
2176func getWindowsDirectory(dir *uint16, dirLen uint32) (len uint32, err error) {
2177 r0, _, e1 := syscall.Syscall(procGetWindowsDirectoryW.Addr(), 2, uintptr(unsafe.Pointer(dir)), uintptr(dirLen), 0)
2178 len = uint32(r0)
2179 if len == 0 {
2180 err = errnoErr(e1)
2181 }
2182 return
2183}
2184
2185func IsWow64Process(handle Handle, isWow64 *bool) (err error) {
2186 var _p0 uint32
2187 if *isWow64 {
2188 _p0 = 1
2189 }
2190 r1, _, e1 := syscall.Syscall(procIsWow64Process.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(&_p0)), 0)
2191 *isWow64 = _p0 != 0
2192 if r1 == 0 {
2193 err = errnoErr(e1)
2194 }
2195 return
2196}
2197
Jason A. Donenfeld12cec1f2020-11-13 15:51:52 +01002198func IsWow64Process2(handle Handle, processMachine *uint16, nativeMachine *uint16) (err error) {
2199 err = procIsWow64Process2.Find()
2200 if err != nil {
2201 return
2202 }
2203 r1, _, e1 := syscall.Syscall(procIsWow64Process2.Addr(), 3, uintptr(handle), uintptr(unsafe.Pointer(processMachine)), uintptr(unsafe.Pointer(nativeMachine)))
2204 if r1 == 0 {
2205 err = errnoErr(e1)
2206 }
2207 return
2208}
2209
Alex Brainman0aaa2712020-10-11 09:49:28 +11002210func LoadLibraryEx(libname string, zero Handle, flags uintptr) (handle Handle, err error) {
2211 var _p0 *uint16
2212 _p0, err = syscall.UTF16PtrFromString(libname)
2213 if err != nil {
2214 return
2215 }
2216 return _LoadLibraryEx(_p0, zero, flags)
2217}
2218
2219func _LoadLibraryEx(libname *uint16, zero Handle, flags uintptr) (handle Handle, err error) {
2220 r0, _, e1 := syscall.Syscall(procLoadLibraryExW.Addr(), 3, uintptr(unsafe.Pointer(libname)), uintptr(zero), uintptr(flags))
2221 handle = Handle(r0)
2222 if handle == 0 {
2223 err = errnoErr(e1)
2224 }
2225 return
2226}
2227
2228func LoadLibrary(libname string) (handle Handle, err error) {
2229 var _p0 *uint16
2230 _p0, err = syscall.UTF16PtrFromString(libname)
2231 if err != nil {
2232 return
2233 }
2234 return _LoadLibrary(_p0)
2235}
2236
2237func _LoadLibrary(libname *uint16) (handle Handle, err error) {
2238 r0, _, e1 := syscall.Syscall(procLoadLibraryW.Addr(), 1, uintptr(unsafe.Pointer(libname)), 0, 0)
2239 handle = Handle(r0)
2240 if handle == 0 {
2241 err = errnoErr(e1)
2242 }
2243 return
2244}
2245
2246func LocalFree(hmem Handle) (handle Handle, err error) {
2247 r0, _, e1 := syscall.Syscall(procLocalFree.Addr(), 1, uintptr(hmem), 0, 0)
2248 handle = Handle(r0)
2249 if handle != 0 {
2250 err = errnoErr(e1)
2251 }
2252 return
2253}
2254
2255func LockFileEx(file Handle, flags uint32, reserved uint32, bytesLow uint32, bytesHigh uint32, overlapped *Overlapped) (err error) {
2256 r1, _, e1 := syscall.Syscall6(procLockFileEx.Addr(), 6, uintptr(file), uintptr(flags), uintptr(reserved), uintptr(bytesLow), uintptr(bytesHigh), uintptr(unsafe.Pointer(overlapped)))
2257 if r1 == 0 {
2258 err = errnoErr(e1)
2259 }
2260 return
2261}
2262
2263func MapViewOfFile(handle Handle, access uint32, offsetHigh uint32, offsetLow uint32, length uintptr) (addr uintptr, err error) {
2264 r0, _, e1 := syscall.Syscall6(procMapViewOfFile.Addr(), 5, uintptr(handle), uintptr(access), uintptr(offsetHigh), uintptr(offsetLow), uintptr(length), 0)
2265 addr = uintptr(r0)
2266 if addr == 0 {
2267 err = errnoErr(e1)
2268 }
2269 return
2270}
2271
2272func MoveFileEx(from *uint16, to *uint16, flags uint32) (err error) {
2273 r1, _, e1 := syscall.Syscall(procMoveFileExW.Addr(), 3, uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(to)), uintptr(flags))
2274 if r1 == 0 {
2275 err = errnoErr(e1)
2276 }
2277 return
2278}
2279
2280func MoveFile(from *uint16, to *uint16) (err error) {
2281 r1, _, e1 := syscall.Syscall(procMoveFileW.Addr(), 2, uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(to)), 0)
2282 if r1 == 0 {
2283 err = errnoErr(e1)
2284 }
2285 return
2286}
2287
2288func MultiByteToWideChar(codePage uint32, dwFlags uint32, str *byte, nstr int32, wchar *uint16, nwchar int32) (nwrite int32, err error) {
2289 r0, _, e1 := syscall.Syscall6(procMultiByteToWideChar.Addr(), 6, uintptr(codePage), uintptr(dwFlags), uintptr(unsafe.Pointer(str)), uintptr(nstr), uintptr(unsafe.Pointer(wchar)), uintptr(nwchar))
2290 nwrite = int32(r0)
2291 if nwrite == 0 {
2292 err = errnoErr(e1)
2293 }
2294 return
2295}
2296
2297func OpenEvent(desiredAccess uint32, inheritHandle bool, name *uint16) (handle Handle, err error) {
2298 var _p0 uint32
2299 if inheritHandle {
2300 _p0 = 1
2301 }
2302 r0, _, e1 := syscall.Syscall(procOpenEventW.Addr(), 3, uintptr(desiredAccess), uintptr(_p0), uintptr(unsafe.Pointer(name)))
2303 handle = Handle(r0)
2304 if handle == 0 {
2305 err = errnoErr(e1)
2306 }
2307 return
2308}
2309
2310func OpenMutex(desiredAccess uint32, inheritHandle bool, name *uint16) (handle Handle, err error) {
2311 var _p0 uint32
2312 if inheritHandle {
2313 _p0 = 1
2314 }
2315 r0, _, e1 := syscall.Syscall(procOpenMutexW.Addr(), 3, uintptr(desiredAccess), uintptr(_p0), uintptr(unsafe.Pointer(name)))
2316 handle = Handle(r0)
2317 if handle == 0 {
2318 err = errnoErr(e1)
2319 }
2320 return
2321}
2322
2323func OpenProcess(desiredAccess uint32, inheritHandle bool, processId uint32) (handle Handle, err error) {
2324 var _p0 uint32
2325 if inheritHandle {
2326 _p0 = 1
2327 }
2328 r0, _, e1 := syscall.Syscall(procOpenProcess.Addr(), 3, uintptr(desiredAccess), uintptr(_p0), uintptr(processId))
2329 handle = Handle(r0)
2330 if handle == 0 {
2331 err = errnoErr(e1)
2332 }
2333 return
2334}
2335
2336func OpenThread(desiredAccess uint32, inheritHandle bool, threadId uint32) (handle Handle, err error) {
2337 var _p0 uint32
2338 if inheritHandle {
2339 _p0 = 1
2340 }
2341 r0, _, e1 := syscall.Syscall(procOpenThread.Addr(), 3, uintptr(desiredAccess), uintptr(_p0), uintptr(threadId))
2342 handle = Handle(r0)
2343 if handle == 0 {
2344 err = errnoErr(e1)
2345 }
2346 return
2347}
2348
2349func PostQueuedCompletionStatus(cphandle Handle, qty uint32, key uint32, overlapped *Overlapped) (err error) {
2350 r1, _, e1 := syscall.Syscall6(procPostQueuedCompletionStatus.Addr(), 4, uintptr(cphandle), uintptr(qty), uintptr(key), uintptr(unsafe.Pointer(overlapped)), 0, 0)
2351 if r1 == 0 {
2352 err = errnoErr(e1)
2353 }
2354 return
2355}
2356
2357func Process32First(snapshot Handle, procEntry *ProcessEntry32) (err error) {
2358 r1, _, e1 := syscall.Syscall(procProcess32FirstW.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(procEntry)), 0)
2359 if r1 == 0 {
2360 err = errnoErr(e1)
2361 }
2362 return
2363}
2364
2365func Process32Next(snapshot Handle, procEntry *ProcessEntry32) (err error) {
2366 r1, _, e1 := syscall.Syscall(procProcess32NextW.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(procEntry)), 0)
2367 if r1 == 0 {
2368 err = errnoErr(e1)
2369 }
2370 return
2371}
2372
2373func ProcessIdToSessionId(pid uint32, sessionid *uint32) (err error) {
2374 r1, _, e1 := syscall.Syscall(procProcessIdToSessionId.Addr(), 2, uintptr(pid), uintptr(unsafe.Pointer(sessionid)), 0)
2375 if r1 == 0 {
2376 err = errnoErr(e1)
2377 }
2378 return
2379}
2380
2381func PulseEvent(event Handle) (err error) {
2382 r1, _, e1 := syscall.Syscall(procPulseEvent.Addr(), 1, uintptr(event), 0, 0)
2383 if r1 == 0 {
2384 err = errnoErr(e1)
2385 }
2386 return
2387}
2388
2389func QueryDosDevice(deviceName *uint16, targetPath *uint16, max uint32) (n uint32, err error) {
2390 r0, _, e1 := syscall.Syscall(procQueryDosDeviceW.Addr(), 3, uintptr(unsafe.Pointer(deviceName)), uintptr(unsafe.Pointer(targetPath)), uintptr(max))
2391 n = uint32(r0)
2392 if n == 0 {
2393 err = errnoErr(e1)
2394 }
2395 return
2396}
2397
2398func QueryInformationJobObject(job Handle, JobObjectInformationClass int32, JobObjectInformation uintptr, JobObjectInformationLength uint32, retlen *uint32) (err error) {
2399 r1, _, e1 := syscall.Syscall6(procQueryInformationJobObject.Addr(), 5, uintptr(job), uintptr(JobObjectInformationClass), uintptr(JobObjectInformation), uintptr(JobObjectInformationLength), uintptr(unsafe.Pointer(retlen)), 0)
2400 if r1 == 0 {
2401 err = errnoErr(e1)
2402 }
2403 return
2404}
2405
2406func ReadConsole(console Handle, buf *uint16, toread uint32, read *uint32, inputControl *byte) (err error) {
2407 r1, _, e1 := syscall.Syscall6(procReadConsoleW.Addr(), 5, uintptr(console), uintptr(unsafe.Pointer(buf)), uintptr(toread), uintptr(unsafe.Pointer(read)), uintptr(unsafe.Pointer(inputControl)), 0)
2408 if r1 == 0 {
2409 err = errnoErr(e1)
2410 }
2411 return
2412}
2413
2414func ReadDirectoryChanges(handle Handle, buf *byte, buflen uint32, watchSubTree bool, mask uint32, retlen *uint32, overlapped *Overlapped, completionRoutine uintptr) (err error) {
2415 var _p0 uint32
2416 if watchSubTree {
2417 _p0 = 1
2418 }
2419 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)
2420 if r1 == 0 {
2421 err = errnoErr(e1)
2422 }
2423 return
2424}
2425
2426func ReadFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) (err error) {
2427 var _p0 *byte
2428 if len(buf) > 0 {
2429 _p0 = &buf[0]
2430 }
2431 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)
2432 if r1 == 0 {
2433 err = errnoErr(e1)
2434 }
2435 return
2436}
2437
2438func ReleaseMutex(mutex Handle) (err error) {
2439 r1, _, e1 := syscall.Syscall(procReleaseMutex.Addr(), 1, uintptr(mutex), 0, 0)
2440 if r1 == 0 {
2441 err = errnoErr(e1)
2442 }
2443 return
2444}
2445
2446func RemoveDirectory(path *uint16) (err error) {
2447 r1, _, e1 := syscall.Syscall(procRemoveDirectoryW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0)
2448 if r1 == 0 {
2449 err = errnoErr(e1)
2450 }
2451 return
2452}
2453
2454func ResetEvent(event Handle) (err error) {
2455 r1, _, e1 := syscall.Syscall(procResetEvent.Addr(), 1, uintptr(event), 0, 0)
2456 if r1 == 0 {
2457 err = errnoErr(e1)
2458 }
2459 return
2460}
2461
2462func ResumeThread(thread Handle) (ret uint32, err error) {
2463 r0, _, e1 := syscall.Syscall(procResumeThread.Addr(), 1, uintptr(thread), 0, 0)
2464 ret = uint32(r0)
2465 if ret == 0xffffffff {
2466 err = errnoErr(e1)
2467 }
2468 return
2469}
2470
Jason A. Donenfeld35f3e6c2020-11-10 11:04:08 +01002471func setConsoleCursorPosition(console Handle, position uint32) (err error) {
2472 r1, _, e1 := syscall.Syscall(procSetConsoleCursorPosition.Addr(), 2, uintptr(console), uintptr(position), 0)
Alex Brainman0aaa2712020-10-11 09:49:28 +11002473 if r1 == 0 {
2474 err = errnoErr(e1)
2475 }
2476 return
2477}
2478
2479func SetConsoleMode(console Handle, mode uint32) (err error) {
2480 r1, _, e1 := syscall.Syscall(procSetConsoleMode.Addr(), 2, uintptr(console), uintptr(mode), 0)
2481 if r1 == 0 {
2482 err = errnoErr(e1)
2483 }
2484 return
2485}
2486
2487func SetCurrentDirectory(path *uint16) (err error) {
2488 r1, _, e1 := syscall.Syscall(procSetCurrentDirectoryW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0)
2489 if r1 == 0 {
2490 err = errnoErr(e1)
2491 }
2492 return
2493}
2494
Jason A. Donenfeld77190672020-11-26 23:54:44 +01002495func SetDefaultDllDirectories(directoryFlags uint32) (err error) {
2496 r1, _, e1 := syscall.Syscall(procSetDefaultDllDirectories.Addr(), 1, uintptr(directoryFlags), 0, 0)
2497 if r1 == 0 {
2498 err = errnoErr(e1)
2499 }
2500 return
2501}
2502
2503func SetDllDirectory(path string) (err error) {
2504 var _p0 *uint16
2505 _p0, err = syscall.UTF16PtrFromString(path)
2506 if err != nil {
2507 return
2508 }
2509 return _SetDllDirectory(_p0)
2510}
2511
2512func _SetDllDirectory(path *uint16) (err error) {
2513 r1, _, e1 := syscall.Syscall(procSetDllDirectoryW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0)
2514 if r1 == 0 {
2515 err = errnoErr(e1)
2516 }
2517 return
2518}
2519
Alex Brainman0aaa2712020-10-11 09:49:28 +11002520func SetEndOfFile(handle Handle) (err error) {
2521 r1, _, e1 := syscall.Syscall(procSetEndOfFile.Addr(), 1, uintptr(handle), 0, 0)
2522 if r1 == 0 {
2523 err = errnoErr(e1)
2524 }
2525 return
2526}
2527
2528func SetEnvironmentVariable(name *uint16, value *uint16) (err error) {
2529 r1, _, e1 := syscall.Syscall(procSetEnvironmentVariableW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(value)), 0)
2530 if r1 == 0 {
2531 err = errnoErr(e1)
2532 }
2533 return
2534}
2535
2536func SetErrorMode(mode uint32) (ret uint32) {
2537 r0, _, _ := syscall.Syscall(procSetErrorMode.Addr(), 1, uintptr(mode), 0, 0)
2538 ret = uint32(r0)
2539 return
2540}
2541
2542func SetEvent(event Handle) (err error) {
2543 r1, _, e1 := syscall.Syscall(procSetEvent.Addr(), 1, uintptr(event), 0, 0)
2544 if r1 == 0 {
2545 err = errnoErr(e1)
2546 }
2547 return
2548}
2549
2550func SetFileAttributes(name *uint16, attrs uint32) (err error) {
2551 r1, _, e1 := syscall.Syscall(procSetFileAttributesW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(attrs), 0)
2552 if r1 == 0 {
2553 err = errnoErr(e1)
2554 }
2555 return
2556}
2557
2558func SetFileCompletionNotificationModes(handle Handle, flags uint8) (err error) {
2559 r1, _, e1 := syscall.Syscall(procSetFileCompletionNotificationModes.Addr(), 2, uintptr(handle), uintptr(flags), 0)
2560 if r1 == 0 {
2561 err = errnoErr(e1)
2562 }
2563 return
2564}
2565
Jason A. Donenfeldd9b008d2020-11-17 10:19:46 +01002566func SetFileInformationByHandle(handle Handle, class uint32, inBuffer *byte, inBufferLen uint32) (err error) {
2567 r1, _, e1 := syscall.Syscall6(procSetFileInformationByHandle.Addr(), 4, uintptr(handle), uintptr(class), uintptr(unsafe.Pointer(inBuffer)), uintptr(inBufferLen), 0, 0)
2568 if r1 == 0 {
2569 err = errnoErr(e1)
2570 }
2571 return
2572}
2573
Alex Brainman0aaa2712020-10-11 09:49:28 +11002574func SetFilePointer(handle Handle, lowoffset int32, highoffsetptr *int32, whence uint32) (newlowoffset uint32, err error) {
2575 r0, _, e1 := syscall.Syscall6(procSetFilePointer.Addr(), 4, uintptr(handle), uintptr(lowoffset), uintptr(unsafe.Pointer(highoffsetptr)), uintptr(whence), 0, 0)
2576 newlowoffset = uint32(r0)
2577 if newlowoffset == 0xffffffff {
2578 err = errnoErr(e1)
2579 }
2580 return
2581}
2582
2583func SetFileTime(handle Handle, ctime *Filetime, atime *Filetime, wtime *Filetime) (err error) {
2584 r1, _, e1 := syscall.Syscall6(procSetFileTime.Addr(), 4, uintptr(handle), uintptr(unsafe.Pointer(ctime)), uintptr(unsafe.Pointer(atime)), uintptr(unsafe.Pointer(wtime)), 0, 0)
2585 if r1 == 0 {
2586 err = errnoErr(e1)
2587 }
2588 return
2589}
2590
2591func SetHandleInformation(handle Handle, mask uint32, flags uint32) (err error) {
2592 r1, _, e1 := syscall.Syscall(procSetHandleInformation.Addr(), 3, uintptr(handle), uintptr(mask), uintptr(flags))
2593 if r1 == 0 {
2594 err = errnoErr(e1)
2595 }
2596 return
2597}
2598
2599func SetInformationJobObject(job Handle, JobObjectInformationClass uint32, JobObjectInformation uintptr, JobObjectInformationLength uint32) (ret int, err error) {
2600 r0, _, e1 := syscall.Syscall6(procSetInformationJobObject.Addr(), 4, uintptr(job), uintptr(JobObjectInformationClass), uintptr(JobObjectInformation), uintptr(JobObjectInformationLength), 0, 0)
2601 ret = int(r0)
2602 if ret == 0 {
2603 err = errnoErr(e1)
2604 }
2605 return
2606}
2607
2608func SetPriorityClass(process Handle, priorityClass uint32) (err error) {
2609 r1, _, e1 := syscall.Syscall(procSetPriorityClass.Addr(), 2, uintptr(process), uintptr(priorityClass), 0)
2610 if r1 == 0 {
2611 err = errnoErr(e1)
2612 }
2613 return
2614}
2615
2616func SetProcessPriorityBoost(process Handle, disable bool) (err error) {
2617 var _p0 uint32
2618 if disable {
2619 _p0 = 1
2620 }
2621 r1, _, e1 := syscall.Syscall(procSetProcessPriorityBoost.Addr(), 2, uintptr(process), uintptr(_p0), 0)
2622 if r1 == 0 {
2623 err = errnoErr(e1)
2624 }
2625 return
2626}
2627
2628func SetProcessShutdownParameters(level uint32, flags uint32) (err error) {
2629 r1, _, e1 := syscall.Syscall(procSetProcessShutdownParameters.Addr(), 2, uintptr(level), uintptr(flags), 0)
2630 if r1 == 0 {
2631 err = errnoErr(e1)
2632 }
2633 return
2634}
2635
2636func SetProcessWorkingSetSizeEx(hProcess Handle, dwMinimumWorkingSetSize uintptr, dwMaximumWorkingSetSize uintptr, flags uint32) (err error) {
2637 r1, _, e1 := syscall.Syscall6(procSetProcessWorkingSetSizeEx.Addr(), 4, uintptr(hProcess), uintptr(dwMinimumWorkingSetSize), uintptr(dwMaximumWorkingSetSize), uintptr(flags), 0, 0)
2638 if r1 == 0 {
2639 err = errnoErr(e1)
2640 }
2641 return
2642}
2643
2644func SetStdHandle(stdhandle uint32, handle Handle) (err error) {
2645 r1, _, e1 := syscall.Syscall(procSetStdHandle.Addr(), 2, uintptr(stdhandle), uintptr(handle), 0)
2646 if r1 == 0 {
2647 err = errnoErr(e1)
2648 }
2649 return
2650}
2651
2652func SetVolumeLabel(rootPathName *uint16, volumeName *uint16) (err error) {
2653 r1, _, e1 := syscall.Syscall(procSetVolumeLabelW.Addr(), 2, uintptr(unsafe.Pointer(rootPathName)), uintptr(unsafe.Pointer(volumeName)), 0)
2654 if r1 == 0 {
2655 err = errnoErr(e1)
2656 }
2657 return
2658}
2659
2660func SetVolumeMountPoint(volumeMountPoint *uint16, volumeName *uint16) (err error) {
2661 r1, _, e1 := syscall.Syscall(procSetVolumeMountPointW.Addr(), 2, uintptr(unsafe.Pointer(volumeMountPoint)), uintptr(unsafe.Pointer(volumeName)), 0)
2662 if r1 == 0 {
2663 err = errnoErr(e1)
2664 }
2665 return
2666}
2667
2668func SleepEx(milliseconds uint32, alertable bool) (ret uint32) {
2669 var _p0 uint32
2670 if alertable {
2671 _p0 = 1
2672 }
2673 r0, _, _ := syscall.Syscall(procSleepEx.Addr(), 2, uintptr(milliseconds), uintptr(_p0), 0)
2674 ret = uint32(r0)
2675 return
2676}
2677
2678func TerminateJobObject(job Handle, exitCode uint32) (err error) {
2679 r1, _, e1 := syscall.Syscall(procTerminateJobObject.Addr(), 2, uintptr(job), uintptr(exitCode), 0)
2680 if r1 == 0 {
2681 err = errnoErr(e1)
2682 }
2683 return
2684}
2685
2686func TerminateProcess(handle Handle, exitcode uint32) (err error) {
2687 r1, _, e1 := syscall.Syscall(procTerminateProcess.Addr(), 2, uintptr(handle), uintptr(exitcode), 0)
2688 if r1 == 0 {
2689 err = errnoErr(e1)
2690 }
2691 return
2692}
2693
2694func Thread32First(snapshot Handle, threadEntry *ThreadEntry32) (err error) {
2695 r1, _, e1 := syscall.Syscall(procThread32First.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(threadEntry)), 0)
2696 if r1 == 0 {
2697 err = errnoErr(e1)
2698 }
2699 return
2700}
2701
2702func Thread32Next(snapshot Handle, threadEntry *ThreadEntry32) (err error) {
2703 r1, _, e1 := syscall.Syscall(procThread32Next.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(threadEntry)), 0)
2704 if r1 == 0 {
2705 err = errnoErr(e1)
2706 }
2707 return
2708}
2709
2710func UnlockFileEx(file Handle, reserved uint32, bytesLow uint32, bytesHigh uint32, overlapped *Overlapped) (err error) {
2711 r1, _, e1 := syscall.Syscall6(procUnlockFileEx.Addr(), 5, uintptr(file), uintptr(reserved), uintptr(bytesLow), uintptr(bytesHigh), uintptr(unsafe.Pointer(overlapped)), 0)
2712 if r1 == 0 {
2713 err = errnoErr(e1)
2714 }
2715 return
2716}
2717
2718func UnmapViewOfFile(addr uintptr) (err error) {
2719 r1, _, e1 := syscall.Syscall(procUnmapViewOfFile.Addr(), 1, uintptr(addr), 0, 0)
2720 if r1 == 0 {
2721 err = errnoErr(e1)
2722 }
2723 return
2724}
2725
2726func VirtualAlloc(address uintptr, size uintptr, alloctype uint32, protect uint32) (value uintptr, err error) {
2727 r0, _, e1 := syscall.Syscall6(procVirtualAlloc.Addr(), 4, uintptr(address), uintptr(size), uintptr(alloctype), uintptr(protect), 0, 0)
2728 value = uintptr(r0)
2729 if value == 0 {
2730 err = errnoErr(e1)
2731 }
2732 return
2733}
2734
2735func VirtualFree(address uintptr, size uintptr, freetype uint32) (err error) {
2736 r1, _, e1 := syscall.Syscall(procVirtualFree.Addr(), 3, uintptr(address), uintptr(size), uintptr(freetype))
2737 if r1 == 0 {
2738 err = errnoErr(e1)
2739 }
2740 return
2741}
2742
2743func VirtualLock(addr uintptr, length uintptr) (err error) {
2744 r1, _, e1 := syscall.Syscall(procVirtualLock.Addr(), 2, uintptr(addr), uintptr(length), 0)
2745 if r1 == 0 {
2746 err = errnoErr(e1)
2747 }
2748 return
2749}
2750
2751func VirtualProtect(address uintptr, size uintptr, newprotect uint32, oldprotect *uint32) (err error) {
2752 r1, _, e1 := syscall.Syscall6(procVirtualProtect.Addr(), 4, uintptr(address), uintptr(size), uintptr(newprotect), uintptr(unsafe.Pointer(oldprotect)), 0, 0)
2753 if r1 == 0 {
2754 err = errnoErr(e1)
2755 }
2756 return
2757}
2758
2759func VirtualUnlock(addr uintptr, length uintptr) (err error) {
2760 r1, _, e1 := syscall.Syscall(procVirtualUnlock.Addr(), 2, uintptr(addr), uintptr(length), 0)
2761 if r1 == 0 {
2762 err = errnoErr(e1)
2763 }
2764 return
2765}
2766
2767func waitForMultipleObjects(count uint32, handles uintptr, waitAll bool, waitMilliseconds uint32) (event uint32, err error) {
2768 var _p0 uint32
2769 if waitAll {
2770 _p0 = 1
2771 }
2772 r0, _, e1 := syscall.Syscall6(procWaitForMultipleObjects.Addr(), 4, uintptr(count), uintptr(handles), uintptr(_p0), uintptr(waitMilliseconds), 0, 0)
2773 event = uint32(r0)
2774 if event == 0xffffffff {
2775 err = errnoErr(e1)
2776 }
2777 return
2778}
2779
2780func WaitForSingleObject(handle Handle, waitMilliseconds uint32) (event uint32, err error) {
2781 r0, _, e1 := syscall.Syscall(procWaitForSingleObject.Addr(), 2, uintptr(handle), uintptr(waitMilliseconds), 0)
2782 event = uint32(r0)
2783 if event == 0xffffffff {
2784 err = errnoErr(e1)
2785 }
2786 return
2787}
2788
2789func WriteConsole(console Handle, buf *uint16, towrite uint32, written *uint32, reserved *byte) (err error) {
2790 r1, _, e1 := syscall.Syscall6(procWriteConsoleW.Addr(), 5, uintptr(console), uintptr(unsafe.Pointer(buf)), uintptr(towrite), uintptr(unsafe.Pointer(written)), uintptr(unsafe.Pointer(reserved)), 0)
2791 if r1 == 0 {
2792 err = errnoErr(e1)
2793 }
2794 return
2795}
2796
2797func WriteFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) (err error) {
2798 var _p0 *byte
2799 if len(buf) > 0 {
2800 _p0 = &buf[0]
2801 }
2802 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)
2803 if r1 == 0 {
2804 err = errnoErr(e1)
2805 }
2806 return
2807}
2808
2809func AcceptEx(ls Handle, as Handle, buf *byte, rxdatalen uint32, laddrlen uint32, raddrlen uint32, recvd *uint32, overlapped *Overlapped) (err error) {
2810 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)
2811 if r1 == 0 {
2812 err = errnoErr(e1)
2813 }
2814 return
2815}
2816
2817func GetAcceptExSockaddrs(buf *byte, rxdatalen uint32, laddrlen uint32, raddrlen uint32, lrsa **RawSockaddrAny, lrsalen *int32, rrsa **RawSockaddrAny, rrsalen *int32) {
2818 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)
2819 return
2820}
2821
2822func TransmitFile(s Handle, handle Handle, bytesToWrite uint32, bytsPerSend uint32, overlapped *Overlapped, transmitFileBuf *TransmitFileBuffers, flags uint32) (err error) {
2823 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)
2824 if r1 == 0 {
2825 err = errnoErr(e1)
2826 }
2827 return
2828}
2829
2830func NetApiBufferFree(buf *byte) (neterr error) {
2831 r0, _, _ := syscall.Syscall(procNetApiBufferFree.Addr(), 1, uintptr(unsafe.Pointer(buf)), 0, 0)
2832 if r0 != 0 {
2833 neterr = syscall.Errno(r0)
2834 }
2835 return
2836}
2837
2838func NetGetJoinInformation(server *uint16, name **uint16, bufType *uint32) (neterr error) {
2839 r0, _, _ := syscall.Syscall(procNetGetJoinInformation.Addr(), 3, uintptr(unsafe.Pointer(server)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(bufType)))
2840 if r0 != 0 {
2841 neterr = syscall.Errno(r0)
2842 }
2843 return
2844}
2845
2846func NetUserGetInfo(serverName *uint16, userName *uint16, level uint32, buf **byte) (neterr error) {
2847 r0, _, _ := syscall.Syscall6(procNetUserGetInfo.Addr(), 4, uintptr(unsafe.Pointer(serverName)), uintptr(unsafe.Pointer(userName)), uintptr(level), uintptr(unsafe.Pointer(buf)), 0, 0)
2848 if r0 != 0 {
2849 neterr = syscall.Errno(r0)
2850 }
2851 return
2852}
2853
2854func rtlGetNtVersionNumbers(majorVersion *uint32, minorVersion *uint32, buildNumber *uint32) {
2855 syscall.Syscall(procRtlGetNtVersionNumbers.Addr(), 3, uintptr(unsafe.Pointer(majorVersion)), uintptr(unsafe.Pointer(minorVersion)), uintptr(unsafe.Pointer(buildNumber)))
2856 return
2857}
2858
2859func rtlGetVersion(info *OsVersionInfoEx) (ret error) {
2860 r0, _, _ := syscall.Syscall(procRtlGetVersion.Addr(), 1, uintptr(unsafe.Pointer(info)), 0, 0)
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -06002861 if r0 != 0 {
2862 ret = syscall.Errno(r0)
2863 }
2864 return
2865}
Alex Brainman0aaa2712020-10-11 09:49:28 +11002866
2867func clsidFromString(lpsz *uint16, pclsid *GUID) (ret error) {
2868 r0, _, _ := syscall.Syscall(procCLSIDFromString.Addr(), 2, uintptr(unsafe.Pointer(lpsz)), uintptr(unsafe.Pointer(pclsid)), 0)
2869 if r0 != 0 {
2870 ret = syscall.Errno(r0)
2871 }
2872 return
2873}
2874
2875func coCreateGuid(pguid *GUID) (ret error) {
2876 r0, _, _ := syscall.Syscall(procCoCreateGuid.Addr(), 1, uintptr(unsafe.Pointer(pguid)), 0, 0)
2877 if r0 != 0 {
2878 ret = syscall.Errno(r0)
2879 }
2880 return
2881}
2882
2883func CoTaskMemFree(address unsafe.Pointer) {
2884 syscall.Syscall(procCoTaskMemFree.Addr(), 1, uintptr(address), 0, 0)
2885 return
2886}
2887
2888func stringFromGUID2(rguid *GUID, lpsz *uint16, cchMax int32) (chars int32) {
2889 r0, _, _ := syscall.Syscall(procStringFromGUID2.Addr(), 3, uintptr(unsafe.Pointer(rguid)), uintptr(unsafe.Pointer(lpsz)), uintptr(cchMax))
2890 chars = int32(r0)
2891 return
2892}
2893
2894func EnumProcesses(processIds []uint32, bytesReturned *uint32) (err error) {
2895 var _p0 *uint32
2896 if len(processIds) > 0 {
2897 _p0 = &processIds[0]
2898 }
2899 r1, _, e1 := syscall.Syscall(procEnumProcesses.Addr(), 3, uintptr(unsafe.Pointer(_p0)), uintptr(len(processIds)), uintptr(unsafe.Pointer(bytesReturned)))
2900 if r1 == 0 {
2901 err = errnoErr(e1)
2902 }
2903 return
2904}
2905
Jason A. Donenfeldc9906e32020-12-02 23:27:29 +01002906func SubscribeServiceChangeNotifications(service Handle, eventType uint32, callback uintptr, callbackCtx uintptr, subscription *uintptr) (ret error) {
2907 ret = procSubscribeServiceChangeNotifications.Find()
2908 if ret != nil {
2909 return
2910 }
2911 r0, _, _ := syscall.Syscall6(procSubscribeServiceChangeNotifications.Addr(), 5, uintptr(service), uintptr(eventType), uintptr(callback), uintptr(callbackCtx), uintptr(unsafe.Pointer(subscription)), 0)
2912 if r0 != 0 {
2913 ret = syscall.Errno(r0)
2914 }
2915 return
2916}
2917
2918func UnsubscribeServiceChangeNotifications(subscription uintptr) (err error) {
2919 err = procUnsubscribeServiceChangeNotifications.Find()
2920 if err != nil {
2921 return
2922 }
2923 syscall.Syscall(procUnsubscribeServiceChangeNotifications.Addr(), 1, uintptr(subscription), 0, 0)
2924 return
2925}
2926
Alex Brainman0aaa2712020-10-11 09:49:28 +11002927func GetUserNameEx(nameFormat uint32, nameBuffre *uint16, nSize *uint32) (err error) {
2928 r1, _, e1 := syscall.Syscall(procGetUserNameExW.Addr(), 3, uintptr(nameFormat), uintptr(unsafe.Pointer(nameBuffre)), uintptr(unsafe.Pointer(nSize)))
2929 if r1&0xff == 0 {
2930 err = errnoErr(e1)
2931 }
2932 return
2933}
2934
2935func TranslateName(accName *uint16, accNameFormat uint32, desiredNameFormat uint32, translatedName *uint16, nSize *uint32) (err error) {
2936 r1, _, e1 := syscall.Syscall6(procTranslateNameW.Addr(), 5, uintptr(unsafe.Pointer(accName)), uintptr(accNameFormat), uintptr(desiredNameFormat), uintptr(unsafe.Pointer(translatedName)), uintptr(unsafe.Pointer(nSize)), 0)
2937 if r1&0xff == 0 {
2938 err = errnoErr(e1)
2939 }
2940 return
2941}
2942
2943func CommandLineToArgv(cmd *uint16, argc *int32) (argv *[8192]*[8192]uint16, err error) {
2944 r0, _, e1 := syscall.Syscall(procCommandLineToArgvW.Addr(), 2, uintptr(unsafe.Pointer(cmd)), uintptr(unsafe.Pointer(argc)), 0)
2945 argv = (*[8192]*[8192]uint16)(unsafe.Pointer(r0))
2946 if argv == nil {
2947 err = errnoErr(e1)
2948 }
2949 return
2950}
2951
2952func shGetKnownFolderPath(id *KNOWNFOLDERID, flags uint32, token Token, path **uint16) (ret error) {
2953 r0, _, _ := syscall.Syscall6(procSHGetKnownFolderPath.Addr(), 4, uintptr(unsafe.Pointer(id)), uintptr(flags), uintptr(token), uintptr(unsafe.Pointer(path)), 0, 0)
2954 if r0 != 0 {
2955 ret = syscall.Errno(r0)
2956 }
2957 return
2958}
2959
2960func ShellExecute(hwnd Handle, verb *uint16, file *uint16, args *uint16, cwd *uint16, showCmd int32) (err error) {
2961 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))
2962 if r1 <= 32 {
2963 err = errnoErr(e1)
2964 }
2965 return
2966}
2967
2968func ExitWindowsEx(flags uint32, reason uint32) (err error) {
2969 r1, _, e1 := syscall.Syscall(procExitWindowsEx.Addr(), 2, uintptr(flags), uintptr(reason), 0)
2970 if r1 == 0 {
2971 err = errnoErr(e1)
2972 }
2973 return
2974}
2975
Alex Brainman59c308d2021-01-11 16:46:25 +11002976func GetShellWindow() (shellWindow HWND) {
Alex Brainman0df21312021-01-06 18:08:16 +11002977 r0, _, _ := syscall.Syscall(procGetShellWindow.Addr(), 0, 0, 0, 0)
Alex Brainman59c308d2021-01-11 16:46:25 +11002978 shellWindow = HWND(r0)
Alex Brainman0df21312021-01-06 18:08:16 +11002979 return
2980}
2981
Jason A. Donenfeld04d74652021-01-21 15:17:19 +01002982func GetWindowThreadProcessId(hwnd HWND, pid *uint32) (tid uint32, err error) {
2983 r0, _, e1 := syscall.Syscall(procGetWindowThreadProcessId.Addr(), 2, uintptr(hwnd), uintptr(unsafe.Pointer(pid)), 0)
Alex Brainman0df21312021-01-06 18:08:16 +11002984 tid = uint32(r0)
Jason A. Donenfeld04d74652021-01-21 15:17:19 +01002985 if tid == 0 {
2986 err = errnoErr(e1)
2987 }
Alex Brainman0df21312021-01-06 18:08:16 +11002988 return
2989}
2990
Alex Brainman59c308d2021-01-11 16:46:25 +11002991func MessageBox(hwnd HWND, text *uint16, caption *uint16, boxtype uint32) (ret int32, err error) {
Alex Brainman0aaa2712020-10-11 09:49:28 +11002992 r0, _, e1 := syscall.Syscall6(procMessageBoxW.Addr(), 4, uintptr(hwnd), uintptr(unsafe.Pointer(text)), uintptr(unsafe.Pointer(caption)), uintptr(boxtype), 0, 0)
2993 ret = int32(r0)
2994 if ret == 0 {
2995 err = errnoErr(e1)
2996 }
2997 return
2998}
2999
3000func CreateEnvironmentBlock(block **uint16, token Token, inheritExisting bool) (err error) {
3001 var _p0 uint32
3002 if inheritExisting {
3003 _p0 = 1
3004 }
3005 r1, _, e1 := syscall.Syscall(procCreateEnvironmentBlock.Addr(), 3, uintptr(unsafe.Pointer(block)), uintptr(token), uintptr(_p0))
3006 if r1 == 0 {
3007 err = errnoErr(e1)
3008 }
3009 return
3010}
3011
3012func DestroyEnvironmentBlock(block *uint16) (err error) {
3013 r1, _, e1 := syscall.Syscall(procDestroyEnvironmentBlock.Addr(), 1, uintptr(unsafe.Pointer(block)), 0, 0)
3014 if r1 == 0 {
3015 err = errnoErr(e1)
3016 }
3017 return
3018}
3019
3020func GetUserProfileDirectory(t Token, dir *uint16, dirLen *uint32) (err error) {
3021 r1, _, e1 := syscall.Syscall(procGetUserProfileDirectoryW.Addr(), 3, uintptr(t), uintptr(unsafe.Pointer(dir)), uintptr(unsafe.Pointer(dirLen)))
3022 if r1 == 0 {
3023 err = errnoErr(e1)
3024 }
3025 return
3026}
3027
Jason A. Donenfeld07034702021-01-22 17:59:47 +01003028func WinVerifyTrustEx(hwnd HWND, actionId *GUID, data *WinTrustData) (ret error) {
3029 r0, _, _ := syscall.Syscall(procWinVerifyTrustEx.Addr(), 3, uintptr(hwnd), uintptr(unsafe.Pointer(actionId)), uintptr(unsafe.Pointer(data)))
3030 if r0 != 0 {
3031 ret = syscall.Errno(r0)
3032 }
3033 return
3034}
3035
Alex Brainman0aaa2712020-10-11 09:49:28 +11003036func FreeAddrInfoW(addrinfo *AddrinfoW) {
3037 syscall.Syscall(procFreeAddrInfoW.Addr(), 1, uintptr(unsafe.Pointer(addrinfo)), 0, 0)
3038 return
3039}
3040
3041func GetAddrInfoW(nodename *uint16, servicename *uint16, hints *AddrinfoW, result **AddrinfoW) (sockerr error) {
3042 r0, _, _ := syscall.Syscall6(procGetAddrInfoW.Addr(), 4, uintptr(unsafe.Pointer(nodename)), uintptr(unsafe.Pointer(servicename)), uintptr(unsafe.Pointer(hints)), uintptr(unsafe.Pointer(result)), 0, 0)
3043 if r0 != 0 {
3044 sockerr = syscall.Errno(r0)
3045 }
3046 return
3047}
3048
3049func WSACleanup() (err error) {
3050 r1, _, e1 := syscall.Syscall(procWSACleanup.Addr(), 0, 0, 0, 0)
3051 if r1 == socket_error {
3052 err = errnoErr(e1)
3053 }
3054 return
3055}
3056
3057func WSAEnumProtocols(protocols *int32, protocolBuffer *WSAProtocolInfo, bufferLength *uint32) (n int32, err error) {
3058 r0, _, e1 := syscall.Syscall(procWSAEnumProtocolsW.Addr(), 3, uintptr(unsafe.Pointer(protocols)), uintptr(unsafe.Pointer(protocolBuffer)), uintptr(unsafe.Pointer(bufferLength)))
3059 n = int32(r0)
3060 if n == -1 {
3061 err = errnoErr(e1)
3062 }
3063 return
3064}
3065
3066func WSAIoctl(s Handle, iocc uint32, inbuf *byte, cbif uint32, outbuf *byte, cbob uint32, cbbr *uint32, overlapped *Overlapped, completionRoutine uintptr) (err error) {
3067 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))
3068 if r1 == socket_error {
3069 err = errnoErr(e1)
3070 }
3071 return
3072}
3073
3074func WSARecv(s Handle, bufs *WSABuf, bufcnt uint32, recvd *uint32, flags *uint32, overlapped *Overlapped, croutine *byte) (err error) {
3075 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)
3076 if r1 == socket_error {
3077 err = errnoErr(e1)
3078 }
3079 return
3080}
3081
3082func WSARecvFrom(s Handle, bufs *WSABuf, bufcnt uint32, recvd *uint32, flags *uint32, from *RawSockaddrAny, fromlen *int32, overlapped *Overlapped, croutine *byte) (err error) {
3083 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)))
3084 if r1 == socket_error {
3085 err = errnoErr(e1)
3086 }
3087 return
3088}
3089
3090func WSASend(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, overlapped *Overlapped, croutine *byte) (err error) {
3091 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)
3092 if r1 == socket_error {
3093 err = errnoErr(e1)
3094 }
3095 return
3096}
3097
3098func WSASendTo(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, to *RawSockaddrAny, tolen int32, overlapped *Overlapped, croutine *byte) (err error) {
3099 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)))
3100 if r1 == socket_error {
3101 err = errnoErr(e1)
3102 }
3103 return
3104}
3105
3106func WSAStartup(verreq uint32, data *WSAData) (sockerr error) {
3107 r0, _, _ := syscall.Syscall(procWSAStartup.Addr(), 2, uintptr(verreq), uintptr(unsafe.Pointer(data)), 0)
3108 if r0 != 0 {
3109 sockerr = syscall.Errno(r0)
3110 }
3111 return
3112}
3113
3114func bind(s Handle, name unsafe.Pointer, namelen int32) (err error) {
3115 r1, _, e1 := syscall.Syscall(procbind.Addr(), 3, uintptr(s), uintptr(name), uintptr(namelen))
3116 if r1 == socket_error {
3117 err = errnoErr(e1)
3118 }
3119 return
3120}
3121
3122func Closesocket(s Handle) (err error) {
3123 r1, _, e1 := syscall.Syscall(procclosesocket.Addr(), 1, uintptr(s), 0, 0)
3124 if r1 == socket_error {
3125 err = errnoErr(e1)
3126 }
3127 return
3128}
3129
3130func connect(s Handle, name unsafe.Pointer, namelen int32) (err error) {
3131 r1, _, e1 := syscall.Syscall(procconnect.Addr(), 3, uintptr(s), uintptr(name), uintptr(namelen))
3132 if r1 == socket_error {
3133 err = errnoErr(e1)
3134 }
3135 return
3136}
3137
3138func GetHostByName(name string) (h *Hostent, err error) {
3139 var _p0 *byte
3140 _p0, err = syscall.BytePtrFromString(name)
3141 if err != nil {
3142 return
3143 }
3144 return _GetHostByName(_p0)
3145}
3146
3147func _GetHostByName(name *byte) (h *Hostent, err error) {
3148 r0, _, e1 := syscall.Syscall(procgethostbyname.Addr(), 1, uintptr(unsafe.Pointer(name)), 0, 0)
3149 h = (*Hostent)(unsafe.Pointer(r0))
3150 if h == nil {
3151 err = errnoErr(e1)
3152 }
3153 return
3154}
3155
3156func getpeername(s Handle, rsa *RawSockaddrAny, addrlen *int32) (err error) {
3157 r1, _, e1 := syscall.Syscall(procgetpeername.Addr(), 3, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
3158 if r1 == socket_error {
3159 err = errnoErr(e1)
3160 }
3161 return
3162}
3163
3164func GetProtoByName(name string) (p *Protoent, err error) {
3165 var _p0 *byte
3166 _p0, err = syscall.BytePtrFromString(name)
3167 if err != nil {
3168 return
3169 }
3170 return _GetProtoByName(_p0)
3171}
3172
3173func _GetProtoByName(name *byte) (p *Protoent, err error) {
3174 r0, _, e1 := syscall.Syscall(procgetprotobyname.Addr(), 1, uintptr(unsafe.Pointer(name)), 0, 0)
3175 p = (*Protoent)(unsafe.Pointer(r0))
3176 if p == nil {
3177 err = errnoErr(e1)
3178 }
3179 return
3180}
3181
3182func GetServByName(name string, proto string) (s *Servent, err error) {
3183 var _p0 *byte
3184 _p0, err = syscall.BytePtrFromString(name)
3185 if err != nil {
3186 return
3187 }
3188 var _p1 *byte
3189 _p1, err = syscall.BytePtrFromString(proto)
3190 if err != nil {
3191 return
3192 }
3193 return _GetServByName(_p0, _p1)
3194}
3195
3196func _GetServByName(name *byte, proto *byte) (s *Servent, err error) {
3197 r0, _, e1 := syscall.Syscall(procgetservbyname.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(proto)), 0)
3198 s = (*Servent)(unsafe.Pointer(r0))
3199 if s == nil {
3200 err = errnoErr(e1)
3201 }
3202 return
3203}
3204
3205func getsockname(s Handle, rsa *RawSockaddrAny, addrlen *int32) (err error) {
3206 r1, _, e1 := syscall.Syscall(procgetsockname.Addr(), 3, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
3207 if r1 == socket_error {
3208 err = errnoErr(e1)
3209 }
3210 return
3211}
3212
3213func Getsockopt(s Handle, level int32, optname int32, optval *byte, optlen *int32) (err error) {
3214 r1, _, e1 := syscall.Syscall6(procgetsockopt.Addr(), 5, uintptr(s), uintptr(level), uintptr(optname), uintptr(unsafe.Pointer(optval)), uintptr(unsafe.Pointer(optlen)), 0)
3215 if r1 == socket_error {
3216 err = errnoErr(e1)
3217 }
3218 return
3219}
3220
3221func listen(s Handle, backlog int32) (err error) {
3222 r1, _, e1 := syscall.Syscall(proclisten.Addr(), 2, uintptr(s), uintptr(backlog), 0)
3223 if r1 == socket_error {
3224 err = errnoErr(e1)
3225 }
3226 return
3227}
3228
3229func Ntohs(netshort uint16) (u uint16) {
3230 r0, _, _ := syscall.Syscall(procntohs.Addr(), 1, uintptr(netshort), 0, 0)
3231 u = uint16(r0)
3232 return
3233}
3234
3235func recvfrom(s Handle, buf []byte, flags int32, from *RawSockaddrAny, fromlen *int32) (n int32, err error) {
3236 var _p0 *byte
3237 if len(buf) > 0 {
3238 _p0 = &buf[0]
3239 }
3240 r0, _, e1 := syscall.Syscall6(procrecvfrom.Addr(), 6, uintptr(s), uintptr(unsafe.Pointer(_p0)), uintptr(len(buf)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)))
3241 n = int32(r0)
3242 if n == -1 {
3243 err = errnoErr(e1)
3244 }
3245 return
3246}
3247
3248func sendto(s Handle, buf []byte, flags int32, to unsafe.Pointer, tolen int32) (err error) {
3249 var _p0 *byte
3250 if len(buf) > 0 {
3251 _p0 = &buf[0]
3252 }
3253 r1, _, e1 := syscall.Syscall6(procsendto.Addr(), 6, uintptr(s), uintptr(unsafe.Pointer(_p0)), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(tolen))
3254 if r1 == socket_error {
3255 err = errnoErr(e1)
3256 }
3257 return
3258}
3259
3260func Setsockopt(s Handle, level int32, optname int32, optval *byte, optlen int32) (err error) {
3261 r1, _, e1 := syscall.Syscall6(procsetsockopt.Addr(), 5, uintptr(s), uintptr(level), uintptr(optname), uintptr(unsafe.Pointer(optval)), uintptr(optlen), 0)
3262 if r1 == socket_error {
3263 err = errnoErr(e1)
3264 }
3265 return
3266}
3267
3268func shutdown(s Handle, how int32) (err error) {
3269 r1, _, e1 := syscall.Syscall(procshutdown.Addr(), 2, uintptr(s), uintptr(how), 0)
3270 if r1 == socket_error {
3271 err = errnoErr(e1)
3272 }
3273 return
3274}
3275
3276func socket(af int32, typ int32, protocol int32) (handle Handle, err error) {
3277 r0, _, e1 := syscall.Syscall(procsocket.Addr(), 3, uintptr(af), uintptr(typ), uintptr(protocol))
3278 handle = Handle(r0)
3279 if handle == InvalidHandle {
3280 err = errnoErr(e1)
3281 }
3282 return
3283}
3284
3285func WTSEnumerateSessions(handle Handle, reserved uint32, version uint32, sessions **WTS_SESSION_INFO, count *uint32) (err error) {
3286 r1, _, e1 := syscall.Syscall6(procWTSEnumerateSessionsW.Addr(), 5, uintptr(handle), uintptr(reserved), uintptr(version), uintptr(unsafe.Pointer(sessions)), uintptr(unsafe.Pointer(count)), 0)
3287 if r1 == 0 {
3288 err = errnoErr(e1)
3289 }
3290 return
3291}
3292
3293func WTSFreeMemory(ptr uintptr) {
3294 syscall.Syscall(procWTSFreeMemory.Addr(), 1, uintptr(ptr), 0, 0)
3295 return
3296}
3297
3298func WTSQueryUserToken(session uint32, token *Token) (err error) {
3299 r1, _, e1 := syscall.Syscall(procWTSQueryUserToken.Addr(), 2, uintptr(session), uintptr(unsafe.Pointer(token)), 0)
3300 if r1 == 0 {
3301 err = errnoErr(e1)
3302 }
3303 return
3304}