blob: 5c6035ddfa923580803e21170845eda63e4c113b [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 (
Jason A. Donenfeldfe613092021-10-27 15:23:03 +020039 modCfgMgr32 = NewLazySystemDLL("CfgMgr32.dll")
Alex Brainman042a8f52016-04-06 15:52:57 +100040 modadvapi32 = NewLazySystemDLL("advapi32.dll")
Alex Brainman042a8f52016-04-06 15:52:57 +100041 modcrypt32 = NewLazySystemDLL("crypt32.dll")
Alex Brainman042a8f52016-04-06 15:52:57 +100042 moddnsapi = NewLazySystemDLL("dnsapi.dll")
Michael Lellifb04ddd2022-09-17 22:48:29 +000043 moddwmapi = NewLazySystemDLL("dwmapi.dll")
Alex Brainman042a8f52016-04-06 15:52:57 +100044 modiphlpapi = NewLazySystemDLL("iphlpapi.dll")
Alex Brainman0aaa2712020-10-11 09:49:28 +110045 modkernel32 = NewLazySystemDLL("kernel32.dll")
46 modmswsock = NewLazySystemDLL("mswsock.dll")
Alex Brainman042a8f52016-04-06 15:52:57 +100047 modnetapi32 = NewLazySystemDLL("netapi32.dll")
Alex Brainman0aaa2712020-10-11 09:49:28 +110048 modntdll = NewLazySystemDLL("ntdll.dll")
49 modole32 = NewLazySystemDLL("ole32.dll")
50 modpsapi = NewLazySystemDLL("psapi.dll")
Jason A. Donenfeldc9906e32020-12-02 23:27:29 +010051 modsechost = NewLazySystemDLL("sechost.dll")
Alex Brainman0aaa2712020-10-11 09:49:28 +110052 modsecur32 = NewLazySystemDLL("secur32.dll")
Jason A. Donenfeldfe613092021-10-27 15:23:03 +020053 modsetupapi = NewLazySystemDLL("setupapi.dll")
Alex Brainman0aaa2712020-10-11 09:49:28 +110054 modshell32 = NewLazySystemDLL("shell32.dll")
55 moduser32 = NewLazySystemDLL("user32.dll")
56 moduserenv = NewLazySystemDLL("userenv.dll")
Jason A. Donenfeld153b1542021-10-19 17:25:37 -060057 modversion = NewLazySystemDLL("version.dll")
qmuntal60ecf132023-08-04 11:50:46 +020058 modwinmm = NewLazySystemDLL("winmm.dll")
Jason A. Donenfeld07034702021-01-22 17:59:47 +010059 modwintrust = NewLazySystemDLL("wintrust.dll")
Alex Brainman0aaa2712020-10-11 09:49:28 +110060 modws2_32 = NewLazySystemDLL("ws2_32.dll")
Jason A. Donenfeldf91f9b32019-05-13 10:42:08 +020061 modwtsapi32 = NewLazySystemDLL("wtsapi32.dll")
Rob Pike20acc5c2014-08-11 14:48:46 -070062
Jason A. Donenfeldfe613092021-10-27 15:23:03 +020063 procCM_Get_DevNode_Status = modCfgMgr32.NewProc("CM_Get_DevNode_Status")
64 procCM_Get_Device_Interface_ListW = modCfgMgr32.NewProc("CM_Get_Device_Interface_ListW")
65 procCM_Get_Device_Interface_List_SizeW = modCfgMgr32.NewProc("CM_Get_Device_Interface_List_SizeW")
66 procCM_MapCrToWin32Err = modCfgMgr32.NewProc("CM_MapCrToWin32Err")
Alex Brainman0aaa2712020-10-11 09:49:28 +110067 procAdjustTokenGroups = modadvapi32.NewProc("AdjustTokenGroups")
68 procAdjustTokenPrivileges = modadvapi32.NewProc("AdjustTokenPrivileges")
69 procAllocateAndInitializeSid = modadvapi32.NewProc("AllocateAndInitializeSid")
70 procBuildSecurityDescriptorW = modadvapi32.NewProc("BuildSecurityDescriptorW")
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -060071 procChangeServiceConfig2W = modadvapi32.NewProc("ChangeServiceConfig2W")
Alex Brainman0aaa2712020-10-11 09:49:28 +110072 procChangeServiceConfigW = modadvapi32.NewProc("ChangeServiceConfigW")
73 procCheckTokenMembership = modadvapi32.NewProc("CheckTokenMembership")
74 procCloseServiceHandle = modadvapi32.NewProc("CloseServiceHandle")
75 procControlService = modadvapi32.NewProc("ControlService")
76 procConvertSecurityDescriptorToStringSecurityDescriptorW = modadvapi32.NewProc("ConvertSecurityDescriptorToStringSecurityDescriptorW")
77 procConvertSidToStringSidW = modadvapi32.NewProc("ConvertSidToStringSidW")
78 procConvertStringSecurityDescriptorToSecurityDescriptorW = modadvapi32.NewProc("ConvertStringSecurityDescriptorToSecurityDescriptorW")
79 procConvertStringSidToSidW = modadvapi32.NewProc("ConvertStringSidToSidW")
80 procCopySid = modadvapi32.NewProc("CopySid")
Jason A. Donenfeld7ecdf8e2021-05-31 18:59:41 +020081 procCreateProcessAsUserW = modadvapi32.NewProc("CreateProcessAsUserW")
Alex Brainman0aaa2712020-10-11 09:49:28 +110082 procCreateServiceW = modadvapi32.NewProc("CreateServiceW")
83 procCreateWellKnownSid = modadvapi32.NewProc("CreateWellKnownSid")
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -060084 procCryptAcquireContextW = modadvapi32.NewProc("CryptAcquireContextW")
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -060085 procCryptGenRandom = modadvapi32.NewProc("CryptGenRandom")
Alex Brainman0aaa2712020-10-11 09:49:28 +110086 procCryptReleaseContext = modadvapi32.NewProc("CryptReleaseContext")
87 procDeleteService = modadvapi32.NewProc("DeleteService")
88 procDeregisterEventSource = modadvapi32.NewProc("DeregisterEventSource")
89 procDuplicateTokenEx = modadvapi32.NewProc("DuplicateTokenEx")
Sebastian Sotodbd8f992022-11-18 10:22:56 -050090 procEnumDependentServicesW = modadvapi32.NewProc("EnumDependentServicesW")
Alex Brainman0aaa2712020-10-11 09:49:28 +110091 procEnumServicesStatusExW = modadvapi32.NewProc("EnumServicesStatusExW")
92 procEqualSid = modadvapi32.NewProc("EqualSid")
93 procFreeSid = modadvapi32.NewProc("FreeSid")
94 procGetLengthSid = modadvapi32.NewProc("GetLengthSid")
95 procGetNamedSecurityInfoW = modadvapi32.NewProc("GetNamedSecurityInfoW")
96 procGetSecurityDescriptorControl = modadvapi32.NewProc("GetSecurityDescriptorControl")
97 procGetSecurityDescriptorDacl = modadvapi32.NewProc("GetSecurityDescriptorDacl")
98 procGetSecurityDescriptorGroup = modadvapi32.NewProc("GetSecurityDescriptorGroup")
99 procGetSecurityDescriptorLength = modadvapi32.NewProc("GetSecurityDescriptorLength")
100 procGetSecurityDescriptorOwner = modadvapi32.NewProc("GetSecurityDescriptorOwner")
101 procGetSecurityDescriptorRMControl = modadvapi32.NewProc("GetSecurityDescriptorRMControl")
102 procGetSecurityDescriptorSacl = modadvapi32.NewProc("GetSecurityDescriptorSacl")
103 procGetSecurityInfo = modadvapi32.NewProc("GetSecurityInfo")
104 procGetSidIdentifierAuthority = modadvapi32.NewProc("GetSidIdentifierAuthority")
105 procGetSidSubAuthority = modadvapi32.NewProc("GetSidSubAuthority")
106 procGetSidSubAuthorityCount = modadvapi32.NewProc("GetSidSubAuthorityCount")
107 procGetTokenInformation = modadvapi32.NewProc("GetTokenInformation")
108 procImpersonateSelf = modadvapi32.NewProc("ImpersonateSelf")
109 procInitializeSecurityDescriptor = modadvapi32.NewProc("InitializeSecurityDescriptor")
110 procInitiateSystemShutdownExW = modadvapi32.NewProc("InitiateSystemShutdownExW")
Jason A. Donenfeldf88b8272020-11-21 10:31:08 +0100111 procIsTokenRestricted = modadvapi32.NewProc("IsTokenRestricted")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100112 procIsValidSecurityDescriptor = modadvapi32.NewProc("IsValidSecurityDescriptor")
113 procIsValidSid = modadvapi32.NewProc("IsValidSid")
114 procIsWellKnownSid = modadvapi32.NewProc("IsWellKnownSid")
115 procLookupAccountNameW = modadvapi32.NewProc("LookupAccountNameW")
116 procLookupAccountSidW = modadvapi32.NewProc("LookupAccountSidW")
117 procLookupPrivilegeValueW = modadvapi32.NewProc("LookupPrivilegeValueW")
118 procMakeAbsoluteSD = modadvapi32.NewProc("MakeAbsoluteSD")
119 procMakeSelfRelativeSD = modadvapi32.NewProc("MakeSelfRelativeSD")
120 procNotifyServiceStatusChangeW = modadvapi32.NewProc("NotifyServiceStatusChangeW")
121 procOpenProcessToken = modadvapi32.NewProc("OpenProcessToken")
122 procOpenSCManagerW = modadvapi32.NewProc("OpenSCManagerW")
123 procOpenServiceW = modadvapi32.NewProc("OpenServiceW")
124 procOpenThreadToken = modadvapi32.NewProc("OpenThreadToken")
125 procQueryServiceConfig2W = modadvapi32.NewProc("QueryServiceConfig2W")
126 procQueryServiceConfigW = modadvapi32.NewProc("QueryServiceConfigW")
Jason A. Donenfeld6e787282021-10-25 14:45:05 +0200127 procQueryServiceDynamicInformation = modadvapi32.NewProc("QueryServiceDynamicInformation")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100128 procQueryServiceLockStatusW = modadvapi32.NewProc("QueryServiceLockStatusW")
129 procQueryServiceStatus = modadvapi32.NewProc("QueryServiceStatus")
130 procQueryServiceStatusEx = modadvapi32.NewProc("QueryServiceStatusEx")
131 procRegCloseKey = modadvapi32.NewProc("RegCloseKey")
132 procRegEnumKeyExW = modadvapi32.NewProc("RegEnumKeyExW")
Josh Bleecher Snyder7e3030f2020-12-10 12:50:29 -0800133 procRegNotifyChangeKeyValue = modadvapi32.NewProc("RegNotifyChangeKeyValue")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100134 procRegOpenKeyExW = modadvapi32.NewProc("RegOpenKeyExW")
135 procRegQueryInfoKeyW = modadvapi32.NewProc("RegQueryInfoKeyW")
136 procRegQueryValueExW = modadvapi32.NewProc("RegQueryValueExW")
137 procRegisterEventSourceW = modadvapi32.NewProc("RegisterEventSourceW")
Jason A. Donenfeld0ec99a62021-06-22 16:38:31 +0200138 procRegisterServiceCtrlHandlerExW = modadvapi32.NewProc("RegisterServiceCtrlHandlerExW")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100139 procReportEventW = modadvapi32.NewProc("ReportEventW")
140 procRevertToSelf = modadvapi32.NewProc("RevertToSelf")
141 procSetEntriesInAclW = modadvapi32.NewProc("SetEntriesInAclW")
Jason A. Donenfeld3a5be022020-11-16 17:33:31 +0100142 procSetKernelObjectSecurity = modadvapi32.NewProc("SetKernelObjectSecurity")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100143 procSetNamedSecurityInfoW = modadvapi32.NewProc("SetNamedSecurityInfoW")
144 procSetSecurityDescriptorControl = modadvapi32.NewProc("SetSecurityDescriptorControl")
145 procSetSecurityDescriptorDacl = modadvapi32.NewProc("SetSecurityDescriptorDacl")
146 procSetSecurityDescriptorGroup = modadvapi32.NewProc("SetSecurityDescriptorGroup")
147 procSetSecurityDescriptorOwner = modadvapi32.NewProc("SetSecurityDescriptorOwner")
148 procSetSecurityDescriptorRMControl = modadvapi32.NewProc("SetSecurityDescriptorRMControl")
149 procSetSecurityDescriptorSacl = modadvapi32.NewProc("SetSecurityDescriptorSacl")
150 procSetSecurityInfo = modadvapi32.NewProc("SetSecurityInfo")
151 procSetServiceStatus = modadvapi32.NewProc("SetServiceStatus")
152 procSetThreadToken = modadvapi32.NewProc("SetThreadToken")
153 procSetTokenInformation = modadvapi32.NewProc("SetTokenInformation")
154 procStartServiceCtrlDispatcherW = modadvapi32.NewProc("StartServiceCtrlDispatcherW")
155 procStartServiceW = modadvapi32.NewProc("StartServiceW")
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600156 procCertAddCertificateContextToStore = modcrypt32.NewProc("CertAddCertificateContextToStore")
157 procCertCloseStore = modcrypt32.NewProc("CertCloseStore")
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600158 procCertCreateCertificateContext = modcrypt32.NewProc("CertCreateCertificateContext")
Daniel Kessler80594f22020-11-04 13:11:48 -0800159 procCertDeleteCertificateFromStore = modcrypt32.NewProc("CertDeleteCertificateFromStore")
Boshi LIAN2d187342020-12-31 18:09:48 +0000160 procCertDuplicateCertificateContext = modcrypt32.NewProc("CertDuplicateCertificateContext")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100161 procCertEnumCertificatesInStore = modcrypt32.NewProc("CertEnumCertificatesInStore")
Boshi LIAN3351caf2021-02-12 18:49:36 +0000162 procCertFindCertificateInStore = modcrypt32.NewProc("CertFindCertificateInStore")
163 procCertFindChainInStore = modcrypt32.NewProc("CertFindChainInStore")
Jason A. Donenfeld4df39782021-01-22 14:23:17 +0100164 procCertFindExtension = modcrypt32.NewProc("CertFindExtension")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100165 procCertFreeCertificateChain = modcrypt32.NewProc("CertFreeCertificateChain")
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600166 procCertFreeCertificateContext = modcrypt32.NewProc("CertFreeCertificateContext")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100167 procCertGetCertificateChain = modcrypt32.NewProc("CertGetCertificateChain")
Jason A. Donenfeld4df39782021-01-22 14:23:17 +0100168 procCertGetNameStringW = modcrypt32.NewProc("CertGetNameStringW")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100169 procCertOpenStore = modcrypt32.NewProc("CertOpenStore")
170 procCertOpenSystemStoreW = modcrypt32.NewProc("CertOpenSystemStoreW")
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600171 procCertVerifyCertificateChainPolicy = modcrypt32.NewProc("CertVerifyCertificateChainPolicy")
Boshi LIAN3351caf2021-02-12 18:49:36 +0000172 procCryptAcquireCertificatePrivateKey = modcrypt32.NewProc("CryptAcquireCertificatePrivateKey")
Jason A. Donenfeld4df39782021-01-22 14:23:17 +0100173 procCryptDecodeObject = modcrypt32.NewProc("CryptDecodeObject")
Jason A. Donenfeld1d476972021-01-22 18:27:41 +0100174 procCryptProtectData = modcrypt32.NewProc("CryptProtectData")
Jason A. Donenfeld4df39782021-01-22 14:23:17 +0100175 procCryptQueryObject = modcrypt32.NewProc("CryptQueryObject")
Jason A. Donenfeld1d476972021-01-22 18:27:41 +0100176 procCryptUnprotectData = modcrypt32.NewProc("CryptUnprotectData")
Boshi LIAN2d187342020-12-31 18:09:48 +0000177 procPFXImportCertStore = modcrypt32.NewProc("PFXImportCertStore")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100178 procDnsNameCompare_W = moddnsapi.NewProc("DnsNameCompare_W")
179 procDnsQuery_W = moddnsapi.NewProc("DnsQuery_W")
180 procDnsRecordListFree = moddnsapi.NewProc("DnsRecordListFree")
Michael Lellifb04ddd2022-09-17 22:48:29 +0000181 procDwmGetWindowAttribute = moddwmapi.NewProc("DwmGetWindowAttribute")
182 procDwmSetWindowAttribute = moddwmapi.NewProc("DwmSetWindowAttribute")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100183 procGetAdaptersAddresses = modiphlpapi.NewProc("GetAdaptersAddresses")
184 procGetAdaptersInfo = modiphlpapi.NewProc("GetAdaptersInfo")
Dan Kortschak179beb02022-06-24 17:17:25 +0930185 procGetBestInterfaceEx = modiphlpapi.NewProc("GetBestInterfaceEx")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100186 procGetIfEntry = modiphlpapi.NewProc("GetIfEntry")
Roland Shoemaker11eadc02023-11-08 11:08:03 -0800187 procAddDllDirectory = modkernel32.NewProc("AddDllDirectory")
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600188 procAssignProcessToJobObject = modkernel32.NewProc("AssignProcessToJobObject")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100189 procCancelIo = modkernel32.NewProc("CancelIo")
190 procCancelIoEx = modkernel32.NewProc("CancelIoEx")
Tom Payne1a50d972024-03-31 22:00:41 +0000191 procClearCommBreak = modkernel32.NewProc("ClearCommBreak")
192 procClearCommError = modkernel32.NewProc("ClearCommError")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100193 procCloseHandle = modkernel32.NewProc("CloseHandle")
Ayman Bagabas71c9d872023-09-26 15:53:15 +0000194 procClosePseudoConsole = modkernel32.NewProc("ClosePseudoConsole")
Jason A. Donenfeld7b4935e2021-03-03 14:05:15 +0100195 procConnectNamedPipe = modkernel32.NewProc("ConnectNamedPipe")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100196 procCreateDirectoryW = modkernel32.NewProc("CreateDirectoryW")
197 procCreateEventExW = modkernel32.NewProc("CreateEventExW")
198 procCreateEventW = modkernel32.NewProc("CreateEventW")
199 procCreateFileMappingW = modkernel32.NewProc("CreateFileMappingW")
200 procCreateFileW = modkernel32.NewProc("CreateFileW")
201 procCreateHardLinkW = modkernel32.NewProc("CreateHardLinkW")
202 procCreateIoCompletionPort = modkernel32.NewProc("CreateIoCompletionPort")
203 procCreateJobObjectW = modkernel32.NewProc("CreateJobObjectW")
204 procCreateMutexExW = modkernel32.NewProc("CreateMutexExW")
205 procCreateMutexW = modkernel32.NewProc("CreateMutexW")
Jason A. Donenfeld7b4935e2021-03-03 14:05:15 +0100206 procCreateNamedPipeW = modkernel32.NewProc("CreateNamedPipeW")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100207 procCreatePipe = modkernel32.NewProc("CreatePipe")
208 procCreateProcessW = modkernel32.NewProc("CreateProcessW")
Ayman Bagabas71c9d872023-09-26 15:53:15 +0000209 procCreatePseudoConsole = modkernel32.NewProc("CreatePseudoConsole")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100210 procCreateSymbolicLinkW = modkernel32.NewProc("CreateSymbolicLinkW")
211 procCreateToolhelp32Snapshot = modkernel32.NewProc("CreateToolhelp32Snapshot")
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600212 procDefineDosDeviceW = modkernel32.NewProc("DefineDosDeviceW")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100213 procDeleteFileW = modkernel32.NewProc("DeleteFileW")
Jason A. Donenfeldf36f7822021-02-01 00:16:53 +0100214 procDeleteProcThreadAttributeList = modkernel32.NewProc("DeleteProcThreadAttributeList")
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600215 procDeleteVolumeMountPointW = modkernel32.NewProc("DeleteVolumeMountPointW")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100216 procDeviceIoControl = modkernel32.NewProc("DeviceIoControl")
Peter Hoogendijk95f07ec2024-03-10 14:49:55 +0100217 procDisconnectNamedPipe = modkernel32.NewProc("DisconnectNamedPipe")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100218 procDuplicateHandle = modkernel32.NewProc("DuplicateHandle")
Tom Payne1a50d972024-03-31 22:00:41 +0000219 procEscapeCommFunction = modkernel32.NewProc("EscapeCommFunction")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100220 procExitProcess = modkernel32.NewProc("ExitProcess")
Jason A. Donenfeldfe613092021-10-27 15:23:03 +0200221 procExpandEnvironmentStringsW = modkernel32.NewProc("ExpandEnvironmentStringsW")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100222 procFindClose = modkernel32.NewProc("FindClose")
Jason A. Donenfelda8b976e2021-01-22 14:20:47 +0100223 procFindCloseChangeNotification = modkernel32.NewProc("FindCloseChangeNotification")
224 procFindFirstChangeNotificationW = modkernel32.NewProc("FindFirstChangeNotificationW")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100225 procFindFirstFileW = modkernel32.NewProc("FindFirstFileW")
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600226 procFindFirstVolumeMountPointW = modkernel32.NewProc("FindFirstVolumeMountPointW")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100227 procFindFirstVolumeW = modkernel32.NewProc("FindFirstVolumeW")
Jason A. Donenfelda8b976e2021-01-22 14:20:47 +0100228 procFindNextChangeNotification = modkernel32.NewProc("FindNextChangeNotification")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100229 procFindNextFileW = modkernel32.NewProc("FindNextFileW")
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600230 procFindNextVolumeMountPointW = modkernel32.NewProc("FindNextVolumeMountPointW")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100231 procFindNextVolumeW = modkernel32.NewProc("FindNextVolumeW")
Jason A. Donenfeldf9bc61c2021-03-03 15:00:01 +0100232 procFindResourceW = modkernel32.NewProc("FindResourceW")
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600233 procFindVolumeClose = modkernel32.NewProc("FindVolumeClose")
234 procFindVolumeMountPointClose = modkernel32.NewProc("FindVolumeMountPointClose")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100235 procFlushFileBuffers = modkernel32.NewProc("FlushFileBuffers")
236 procFlushViewOfFile = modkernel32.NewProc("FlushViewOfFile")
237 procFormatMessageW = modkernel32.NewProc("FormatMessageW")
238 procFreeEnvironmentStringsW = modkernel32.NewProc("FreeEnvironmentStringsW")
239 procFreeLibrary = modkernel32.NewProc("FreeLibrary")
240 procGenerateConsoleCtrlEvent = modkernel32.NewProc("GenerateConsoleCtrlEvent")
241 procGetACP = modkernel32.NewProc("GetACP")
Tobias Klauser5a964db2022-01-05 12:16:54 +0100242 procGetActiveProcessorCount = modkernel32.NewProc("GetActiveProcessorCount")
Tom Payne1a50d972024-03-31 22:00:41 +0000243 procGetCommModemStatus = modkernel32.NewProc("GetCommModemStatus")
244 procGetCommState = modkernel32.NewProc("GetCommState")
Tobias Kohlbau479acdf2021-02-06 08:58:28 +0100245 procGetCommTimeouts = modkernel32.NewProc("GetCommTimeouts")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100246 procGetCommandLineW = modkernel32.NewProc("GetCommandLineW")
247 procGetComputerNameExW = modkernel32.NewProc("GetComputerNameExW")
248 procGetComputerNameW = modkernel32.NewProc("GetComputerNameW")
249 procGetConsoleMode = modkernel32.NewProc("GetConsoleMode")
250 procGetConsoleScreenBufferInfo = modkernel32.NewProc("GetConsoleScreenBufferInfo")
251 procGetCurrentDirectoryW = modkernel32.NewProc("GetCurrentDirectoryW")
252 procGetCurrentProcessId = modkernel32.NewProc("GetCurrentProcessId")
253 procGetCurrentThreadId = modkernel32.NewProc("GetCurrentThreadId")
Takuto Ikutab09406a2019-10-10 18:17:53 +0900254 procGetDiskFreeSpaceExW = modkernel32.NewProc("GetDiskFreeSpaceExW")
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600255 procGetDriveTypeW = modkernel32.NewProc("GetDriveTypeW")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100256 procGetEnvironmentStringsW = modkernel32.NewProc("GetEnvironmentStringsW")
257 procGetEnvironmentVariableW = modkernel32.NewProc("GetEnvironmentVariableW")
258 procGetExitCodeProcess = modkernel32.NewProc("GetExitCodeProcess")
259 procGetFileAttributesExW = modkernel32.NewProc("GetFileAttributesExW")
260 procGetFileAttributesW = modkernel32.NewProc("GetFileAttributesW")
261 procGetFileInformationByHandle = modkernel32.NewProc("GetFileInformationByHandle")
262 procGetFileInformationByHandleEx = modkernel32.NewProc("GetFileInformationByHandleEx")
AN Long8ccaaf02023-09-13 14:24:41 +0000263 procGetFileTime = modkernel32.NewProc("GetFileTime")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100264 procGetFileType = modkernel32.NewProc("GetFileType")
Meng Zhuo35185872020-10-28 14:35:39 +0800265 procGetFinalPathNameByHandleW = modkernel32.NewProc("GetFinalPathNameByHandleW")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100266 procGetFullPathNameW = modkernel32.NewProc("GetFullPathNameW")
Johan Jansson3ca3b182022-10-23 12:59:07 +0300267 procGetLargePageMinimum = modkernel32.NewProc("GetLargePageMinimum")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100268 procGetLastError = modkernel32.NewProc("GetLastError")
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600269 procGetLogicalDriveStringsW = modkernel32.NewProc("GetLogicalDriveStringsW")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100270 procGetLogicalDrives = modkernel32.NewProc("GetLogicalDrives")
271 procGetLongPathNameW = modkernel32.NewProc("GetLongPathNameW")
Tobias Klauser5a964db2022-01-05 12:16:54 +0100272 procGetMaximumProcessorCount = modkernel32.NewProc("GetMaximumProcessorCount")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100273 procGetModuleFileNameW = modkernel32.NewProc("GetModuleFileNameW")
274 procGetModuleHandleExW = modkernel32.NewProc("GetModuleHandleExW")
Jason A. Donenfeld7b4935e2021-03-03 14:05:15 +0100275 procGetNamedPipeHandleStateW = modkernel32.NewProc("GetNamedPipeHandleStateW")
276 procGetNamedPipeInfo = modkernel32.NewProc("GetNamedPipeInfo")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100277 procGetOverlappedResult = modkernel32.NewProc("GetOverlappedResult")
278 procGetPriorityClass = modkernel32.NewProc("GetPriorityClass")
279 procGetProcAddress = modkernel32.NewProc("GetProcAddress")
280 procGetProcessId = modkernel32.NewProc("GetProcessId")
281 procGetProcessPreferredUILanguages = modkernel32.NewProc("GetProcessPreferredUILanguages")
282 procGetProcessShutdownParameters = modkernel32.NewProc("GetProcessShutdownParameters")
283 procGetProcessTimes = modkernel32.NewProc("GetProcessTimes")
284 procGetProcessWorkingSetSizeEx = modkernel32.NewProc("GetProcessWorkingSetSizeEx")
285 procGetQueuedCompletionStatus = modkernel32.NewProc("GetQueuedCompletionStatus")
286 procGetShortPathNameW = modkernel32.NewProc("GetShortPathNameW")
287 procGetStartupInfoW = modkernel32.NewProc("GetStartupInfoW")
288 procGetStdHandle = modkernel32.NewProc("GetStdHandle")
289 procGetSystemDirectoryW = modkernel32.NewProc("GetSystemDirectoryW")
290 procGetSystemPreferredUILanguages = modkernel32.NewProc("GetSystemPreferredUILanguages")
291 procGetSystemTimeAsFileTime = modkernel32.NewProc("GetSystemTimeAsFileTime")
292 procGetSystemTimePreciseAsFileTime = modkernel32.NewProc("GetSystemTimePreciseAsFileTime")
293 procGetSystemWindowsDirectoryW = modkernel32.NewProc("GetSystemWindowsDirectoryW")
294 procGetTempPathW = modkernel32.NewProc("GetTempPathW")
295 procGetThreadPreferredUILanguages = modkernel32.NewProc("GetThreadPreferredUILanguages")
296 procGetTickCount64 = modkernel32.NewProc("GetTickCount64")
297 procGetTimeZoneInformation = modkernel32.NewProc("GetTimeZoneInformation")
298 procGetUserPreferredUILanguages = modkernel32.NewProc("GetUserPreferredUILanguages")
299 procGetVersion = modkernel32.NewProc("GetVersion")
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600300 procGetVolumeInformationByHandleW = modkernel32.NewProc("GetVolumeInformationByHandleW")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100301 procGetVolumeInformationW = modkernel32.NewProc("GetVolumeInformationW")
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600302 procGetVolumeNameForVolumeMountPointW = modkernel32.NewProc("GetVolumeNameForVolumeMountPointW")
303 procGetVolumePathNameW = modkernel32.NewProc("GetVolumePathNameW")
304 procGetVolumePathNamesForVolumeNameW = modkernel32.NewProc("GetVolumePathNamesForVolumeNameW")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100305 procGetWindowsDirectoryW = modkernel32.NewProc("GetWindowsDirectoryW")
Jason A. Donenfeldf36f7822021-02-01 00:16:53 +0100306 procInitializeProcThreadAttributeList = modkernel32.NewProc("InitializeProcThreadAttributeList")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100307 procIsWow64Process = modkernel32.NewProc("IsWow64Process")
Jason A. Donenfeld12cec1f2020-11-13 15:51:52 +0100308 procIsWow64Process2 = modkernel32.NewProc("IsWow64Process2")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100309 procLoadLibraryExW = modkernel32.NewProc("LoadLibraryExW")
310 procLoadLibraryW = modkernel32.NewProc("LoadLibraryW")
Jason A. Donenfeldf9bc61c2021-03-03 15:00:01 +0100311 procLoadResource = modkernel32.NewProc("LoadResource")
Jason A. Donenfeld7b4935e2021-03-03 14:05:15 +0100312 procLocalAlloc = modkernel32.NewProc("LocalAlloc")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100313 procLocalFree = modkernel32.NewProc("LocalFree")
314 procLockFileEx = modkernel32.NewProc("LockFileEx")
Jason A. Donenfeldf9bc61c2021-03-03 15:00:01 +0100315 procLockResource = modkernel32.NewProc("LockResource")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100316 procMapViewOfFile = modkernel32.NewProc("MapViewOfFile")
Tobias Klauser94396e42021-12-03 19:58:53 +0100317 procModule32FirstW = modkernel32.NewProc("Module32FirstW")
318 procModule32NextW = modkernel32.NewProc("Module32NextW")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100319 procMoveFileExW = modkernel32.NewProc("MoveFileExW")
320 procMoveFileW = modkernel32.NewProc("MoveFileW")
321 procMultiByteToWideChar = modkernel32.NewProc("MultiByteToWideChar")
322 procOpenEventW = modkernel32.NewProc("OpenEventW")
323 procOpenMutexW = modkernel32.NewProc("OpenMutexW")
324 procOpenProcess = modkernel32.NewProc("OpenProcess")
325 procOpenThread = modkernel32.NewProc("OpenThread")
326 procPostQueuedCompletionStatus = modkernel32.NewProc("PostQueuedCompletionStatus")
327 procProcess32FirstW = modkernel32.NewProc("Process32FirstW")
328 procProcess32NextW = modkernel32.NewProc("Process32NextW")
329 procProcessIdToSessionId = modkernel32.NewProc("ProcessIdToSessionId")
330 procPulseEvent = modkernel32.NewProc("PulseEvent")
Tom Payne1a50d972024-03-31 22:00:41 +0000331 procPurgeComm = modkernel32.NewProc("PurgeComm")
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600332 procQueryDosDeviceW = modkernel32.NewProc("QueryDosDeviceW")
Jason A. Donenfeld61f932b2021-03-04 12:14:53 -0700333 procQueryFullProcessImageNameW = modkernel32.NewProc("QueryFullProcessImageNameW")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100334 procQueryInformationJobObject = modkernel32.NewProc("QueryInformationJobObject")
335 procReadConsoleW = modkernel32.NewProc("ReadConsoleW")
336 procReadDirectoryChangesW = modkernel32.NewProc("ReadDirectoryChangesW")
337 procReadFile = modkernel32.NewProc("ReadFile")
Weilu Jiad3039522021-10-05 07:50:15 +0000338 procReadProcessMemory = modkernel32.NewProc("ReadProcessMemory")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100339 procReleaseMutex = modkernel32.NewProc("ReleaseMutex")
340 procRemoveDirectoryW = modkernel32.NewProc("RemoveDirectoryW")
Roland Shoemaker11eadc02023-11-08 11:08:03 -0800341 procRemoveDllDirectory = modkernel32.NewProc("RemoveDllDirectory")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100342 procResetEvent = modkernel32.NewProc("ResetEvent")
Ayman Bagabas71c9d872023-09-26 15:53:15 +0000343 procResizePseudoConsole = modkernel32.NewProc("ResizePseudoConsole")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100344 procResumeThread = modkernel32.NewProc("ResumeThread")
Tom Payne1a50d972024-03-31 22:00:41 +0000345 procSetCommBreak = modkernel32.NewProc("SetCommBreak")
346 procSetCommMask = modkernel32.NewProc("SetCommMask")
347 procSetCommState = modkernel32.NewProc("SetCommState")
Tobias Kohlbau479acdf2021-02-06 08:58:28 +0100348 procSetCommTimeouts = modkernel32.NewProc("SetCommTimeouts")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100349 procSetConsoleCursorPosition = modkernel32.NewProc("SetConsoleCursorPosition")
350 procSetConsoleMode = modkernel32.NewProc("SetConsoleMode")
351 procSetCurrentDirectoryW = modkernel32.NewProc("SetCurrentDirectoryW")
Jason A. Donenfeld77190672020-11-26 23:54:44 +0100352 procSetDefaultDllDirectories = modkernel32.NewProc("SetDefaultDllDirectories")
353 procSetDllDirectoryW = modkernel32.NewProc("SetDllDirectoryW")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100354 procSetEndOfFile = modkernel32.NewProc("SetEndOfFile")
355 procSetEnvironmentVariableW = modkernel32.NewProc("SetEnvironmentVariableW")
356 procSetErrorMode = modkernel32.NewProc("SetErrorMode")
357 procSetEvent = modkernel32.NewProc("SetEvent")
358 procSetFileAttributesW = modkernel32.NewProc("SetFileAttributesW")
359 procSetFileCompletionNotificationModes = modkernel32.NewProc("SetFileCompletionNotificationModes")
Jason A. Donenfeldd9b008d2020-11-17 10:19:46 +0100360 procSetFileInformationByHandle = modkernel32.NewProc("SetFileInformationByHandle")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100361 procSetFilePointer = modkernel32.NewProc("SetFilePointer")
362 procSetFileTime = modkernel32.NewProc("SetFileTime")
Peter Hoogendijk95f07ec2024-03-10 14:49:55 +0100363 procSetFileValidData = modkernel32.NewProc("SetFileValidData")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100364 procSetHandleInformation = modkernel32.NewProc("SetHandleInformation")
365 procSetInformationJobObject = modkernel32.NewProc("SetInformationJobObject")
Jason A. Donenfeld94ec62e2021-03-05 09:45:33 -0700366 procSetNamedPipeHandleState = modkernel32.NewProc("SetNamedPipeHandleState")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100367 procSetPriorityClass = modkernel32.NewProc("SetPriorityClass")
368 procSetProcessPriorityBoost = modkernel32.NewProc("SetProcessPriorityBoost")
369 procSetProcessShutdownParameters = modkernel32.NewProc("SetProcessShutdownParameters")
370 procSetProcessWorkingSetSizeEx = modkernel32.NewProc("SetProcessWorkingSetSizeEx")
371 procSetStdHandle = modkernel32.NewProc("SetStdHandle")
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600372 procSetVolumeLabelW = modkernel32.NewProc("SetVolumeLabelW")
373 procSetVolumeMountPointW = modkernel32.NewProc("SetVolumeMountPointW")
Tom Payne1a50d972024-03-31 22:00:41 +0000374 procSetupComm = modkernel32.NewProc("SetupComm")
Jason A. Donenfeldf9bc61c2021-03-03 15:00:01 +0100375 procSizeofResource = modkernel32.NewProc("SizeofResource")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100376 procSleepEx = modkernel32.NewProc("SleepEx")
377 procTerminateJobObject = modkernel32.NewProc("TerminateJobObject")
378 procTerminateProcess = modkernel32.NewProc("TerminateProcess")
379 procThread32First = modkernel32.NewProc("Thread32First")
380 procThread32Next = modkernel32.NewProc("Thread32Next")
381 procUnlockFileEx = modkernel32.NewProc("UnlockFileEx")
382 procUnmapViewOfFile = modkernel32.NewProc("UnmapViewOfFile")
Jason A. Donenfeldf36f7822021-02-01 00:16:53 +0100383 procUpdateProcThreadAttribute = modkernel32.NewProc("UpdateProcThreadAttribute")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100384 procVirtualAlloc = modkernel32.NewProc("VirtualAlloc")
385 procVirtualFree = modkernel32.NewProc("VirtualFree")
386 procVirtualLock = modkernel32.NewProc("VirtualLock")
387 procVirtualProtect = modkernel32.NewProc("VirtualProtect")
Weilu Jiad3039522021-10-05 07:50:15 +0000388 procVirtualProtectEx = modkernel32.NewProc("VirtualProtectEx")
389 procVirtualQuery = modkernel32.NewProc("VirtualQuery")
390 procVirtualQueryEx = modkernel32.NewProc("VirtualQueryEx")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100391 procVirtualUnlock = modkernel32.NewProc("VirtualUnlock")
David Crawshaw44f02d92021-06-30 06:31:16 -0700392 procWTSGetActiveConsoleSessionId = modkernel32.NewProc("WTSGetActiveConsoleSessionId")
Tom Payne1a50d972024-03-31 22:00:41 +0000393 procWaitCommEvent = modkernel32.NewProc("WaitCommEvent")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100394 procWaitForMultipleObjects = modkernel32.NewProc("WaitForMultipleObjects")
395 procWaitForSingleObject = modkernel32.NewProc("WaitForSingleObject")
396 procWriteConsoleW = modkernel32.NewProc("WriteConsoleW")
397 procWriteFile = modkernel32.NewProc("WriteFile")
Weilu Jiad3039522021-10-05 07:50:15 +0000398 procWriteProcessMemory = modkernel32.NewProc("WriteProcessMemory")
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600399 procAcceptEx = modmswsock.NewProc("AcceptEx")
400 procGetAcceptExSockaddrs = modmswsock.NewProc("GetAcceptExSockaddrs")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100401 procTransmitFile = modmswsock.NewProc("TransmitFile")
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600402 procNetApiBufferFree = modnetapi32.NewProc("NetApiBufferFree")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100403 procNetGetJoinInformation = modnetapi32.NewProc("NetGetJoinInformation")
404 procNetUserGetInfo = modnetapi32.NewProc("NetUserGetInfo")
Jason A. Donenfeld1243437a82021-03-03 13:10:42 +0100405 procNtCreateFile = modntdll.NewProc("NtCreateFile")
406 procNtCreateNamedPipeFile = modntdll.NewProc("NtCreateNamedPipeFile")
407 procNtQueryInformationProcess = modntdll.NewProc("NtQueryInformationProcess")
Jason A. Donenfeld153b1542021-10-19 17:25:37 -0600408 procNtQuerySystemInformation = modntdll.NewProc("NtQuerySystemInformation")
Takuto Ikutac1bf0bb2021-10-29 17:43:04 +0900409 procNtSetInformationFile = modntdll.NewProc("NtSetInformationFile")
Jason A. Donenfeld1243437a82021-03-03 13:10:42 +0100410 procNtSetInformationProcess = modntdll.NewProc("NtSetInformationProcess")
Jason A. Donenfeld153b1542021-10-19 17:25:37 -0600411 procNtSetSystemInformation = modntdll.NewProc("NtSetSystemInformation")
Jason A. Donenfeld9d617382021-10-20 11:31:38 -0600412 procRtlAddFunctionTable = modntdll.NewProc("RtlAddFunctionTable")
Jason A. Donenfeld1243437a82021-03-03 13:10:42 +0100413 procRtlDefaultNpAcl = modntdll.NewProc("RtlDefaultNpAcl")
Jason A. Donenfeld9d617382021-10-20 11:31:38 -0600414 procRtlDeleteFunctionTable = modntdll.NewProc("RtlDeleteFunctionTable")
Jason A. Donenfeld1243437a82021-03-03 13:10:42 +0100415 procRtlDosPathNameToNtPathName_U_WithStatus = modntdll.NewProc("RtlDosPathNameToNtPathName_U_WithStatus")
416 procRtlDosPathNameToRelativeNtPathName_U_WithStatus = modntdll.NewProc("RtlDosPathNameToRelativeNtPathName_U_WithStatus")
417 procRtlGetCurrentPeb = modntdll.NewProc("RtlGetCurrentPeb")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100418 procRtlGetNtVersionNumbers = modntdll.NewProc("RtlGetNtVersionNumbers")
419 procRtlGetVersion = modntdll.NewProc("RtlGetVersion")
Jason A. Donenfeld5cdee2b2021-03-05 08:28:14 -0700420 procRtlInitString = modntdll.NewProc("RtlInitString")
Jason A. Donenfeld1243437a82021-03-03 13:10:42 +0100421 procRtlInitUnicodeString = modntdll.NewProc("RtlInitUnicodeString")
Jason A. Donenfeldafaa3652021-03-03 12:07:20 +0100422 procRtlNtStatusToDosErrorNoTeb = modntdll.NewProc("RtlNtStatusToDosErrorNoTeb")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100423 procCLSIDFromString = modole32.NewProc("CLSIDFromString")
424 procCoCreateGuid = modole32.NewProc("CoCreateGuid")
Jason A. Donenfeld0d6cb8b2021-03-03 23:50:28 +0100425 procCoGetObject = modole32.NewProc("CoGetObject")
426 procCoInitializeEx = modole32.NewProc("CoInitializeEx")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100427 procCoTaskMemFree = modole32.NewProc("CoTaskMemFree")
Jason A. Donenfeld0d6cb8b2021-03-03 23:50:28 +0100428 procCoUninitialize = modole32.NewProc("CoUninitialize")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100429 procStringFromGUID2 = modole32.NewProc("StringFromGUID2")
Weilu Jia92d5a992021-09-20 22:56:04 +0000430 procEnumProcessModules = modpsapi.NewProc("EnumProcessModules")
431 procEnumProcessModulesEx = modpsapi.NewProc("EnumProcessModulesEx")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100432 procEnumProcesses = modpsapi.NewProc("EnumProcesses")
Weilu Jia92d5a992021-09-20 22:56:04 +0000433 procGetModuleBaseNameW = modpsapi.NewProc("GetModuleBaseNameW")
434 procGetModuleFileNameExW = modpsapi.NewProc("GetModuleFileNameExW")
435 procGetModuleInformation = modpsapi.NewProc("GetModuleInformation")
awaw fumin1609e552022-07-29 01:46:33 +0000436 procQueryWorkingSetEx = modpsapi.NewProc("QueryWorkingSetEx")
Jason A. Donenfeldc9906e32020-12-02 23:27:29 +0100437 procSubscribeServiceChangeNotifications = modsechost.NewProc("SubscribeServiceChangeNotifications")
438 procUnsubscribeServiceChangeNotifications = modsechost.NewProc("UnsubscribeServiceChangeNotifications")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100439 procGetUserNameExW = modsecur32.NewProc("GetUserNameExW")
440 procTranslateNameW = modsecur32.NewProc("TranslateNameW")
Jason A. Donenfeldfe613092021-10-27 15:23:03 +0200441 procSetupDiBuildDriverInfoList = modsetupapi.NewProc("SetupDiBuildDriverInfoList")
442 procSetupDiCallClassInstaller = modsetupapi.NewProc("SetupDiCallClassInstaller")
443 procSetupDiCancelDriverInfoSearch = modsetupapi.NewProc("SetupDiCancelDriverInfoSearch")
444 procSetupDiClassGuidsFromNameExW = modsetupapi.NewProc("SetupDiClassGuidsFromNameExW")
445 procSetupDiClassNameFromGuidExW = modsetupapi.NewProc("SetupDiClassNameFromGuidExW")
446 procSetupDiCreateDeviceInfoListExW = modsetupapi.NewProc("SetupDiCreateDeviceInfoListExW")
447 procSetupDiCreateDeviceInfoW = modsetupapi.NewProc("SetupDiCreateDeviceInfoW")
448 procSetupDiDestroyDeviceInfoList = modsetupapi.NewProc("SetupDiDestroyDeviceInfoList")
449 procSetupDiDestroyDriverInfoList = modsetupapi.NewProc("SetupDiDestroyDriverInfoList")
450 procSetupDiEnumDeviceInfo = modsetupapi.NewProc("SetupDiEnumDeviceInfo")
451 procSetupDiEnumDriverInfoW = modsetupapi.NewProc("SetupDiEnumDriverInfoW")
452 procSetupDiGetClassDevsExW = modsetupapi.NewProc("SetupDiGetClassDevsExW")
453 procSetupDiGetClassInstallParamsW = modsetupapi.NewProc("SetupDiGetClassInstallParamsW")
454 procSetupDiGetDeviceInfoListDetailW = modsetupapi.NewProc("SetupDiGetDeviceInfoListDetailW")
455 procSetupDiGetDeviceInstallParamsW = modsetupapi.NewProc("SetupDiGetDeviceInstallParamsW")
456 procSetupDiGetDeviceInstanceIdW = modsetupapi.NewProc("SetupDiGetDeviceInstanceIdW")
457 procSetupDiGetDevicePropertyW = modsetupapi.NewProc("SetupDiGetDevicePropertyW")
458 procSetupDiGetDeviceRegistryPropertyW = modsetupapi.NewProc("SetupDiGetDeviceRegistryPropertyW")
459 procSetupDiGetDriverInfoDetailW = modsetupapi.NewProc("SetupDiGetDriverInfoDetailW")
460 procSetupDiGetSelectedDevice = modsetupapi.NewProc("SetupDiGetSelectedDevice")
461 procSetupDiGetSelectedDriverW = modsetupapi.NewProc("SetupDiGetSelectedDriverW")
462 procSetupDiOpenDevRegKey = modsetupapi.NewProc("SetupDiOpenDevRegKey")
463 procSetupDiSetClassInstallParamsW = modsetupapi.NewProc("SetupDiSetClassInstallParamsW")
464 procSetupDiSetDeviceInstallParamsW = modsetupapi.NewProc("SetupDiSetDeviceInstallParamsW")
465 procSetupDiSetDeviceRegistryPropertyW = modsetupapi.NewProc("SetupDiSetDeviceRegistryPropertyW")
466 procSetupDiSetSelectedDevice = modsetupapi.NewProc("SetupDiSetSelectedDevice")
467 procSetupDiSetSelectedDriverW = modsetupapi.NewProc("SetupDiSetSelectedDriverW")
468 procSetupUninstallOEMInfW = modsetupapi.NewProc("SetupUninstallOEMInfW")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100469 procCommandLineToArgvW = modshell32.NewProc("CommandLineToArgvW")
470 procSHGetKnownFolderPath = modshell32.NewProc("SHGetKnownFolderPath")
471 procShellExecuteW = modshell32.NewProc("ShellExecuteW")
Michael Lelli3275c402022-09-12 22:13:50 +0000472 procEnumChildWindows = moduser32.NewProc("EnumChildWindows")
473 procEnumWindows = moduser32.NewProc("EnumWindows")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100474 procExitWindowsEx = moduser32.NewProc("ExitWindowsEx")
Michael Lelli3275c402022-09-12 22:13:50 +0000475 procGetClassNameW = moduser32.NewProc("GetClassNameW")
476 procGetDesktopWindow = moduser32.NewProc("GetDesktopWindow")
477 procGetForegroundWindow = moduser32.NewProc("GetForegroundWindow")
478 procGetGUIThreadInfo = moduser32.NewProc("GetGUIThreadInfo")
Alex Brainman0df21312021-01-06 18:08:16 +1100479 procGetShellWindow = moduser32.NewProc("GetShellWindow")
480 procGetWindowThreadProcessId = moduser32.NewProc("GetWindowThreadProcessId")
Michael Lelli3275c402022-09-12 22:13:50 +0000481 procIsWindow = moduser32.NewProc("IsWindow")
482 procIsWindowUnicode = moduser32.NewProc("IsWindowUnicode")
483 procIsWindowVisible = moduser32.NewProc("IsWindowVisible")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100484 procMessageBoxW = moduser32.NewProc("MessageBoxW")
485 procCreateEnvironmentBlock = moduserenv.NewProc("CreateEnvironmentBlock")
486 procDestroyEnvironmentBlock = moduserenv.NewProc("DestroyEnvironmentBlock")
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600487 procGetUserProfileDirectoryW = moduserenv.NewProc("GetUserProfileDirectoryW")
Jason A. Donenfeld153b1542021-10-19 17:25:37 -0600488 procGetFileVersionInfoSizeW = modversion.NewProc("GetFileVersionInfoSizeW")
489 procGetFileVersionInfoW = modversion.NewProc("GetFileVersionInfoW")
490 procVerQueryValueW = modversion.NewProc("VerQueryValueW")
qmuntal60ecf132023-08-04 11:50:46 +0200491 proctimeBeginPeriod = modwinmm.NewProc("timeBeginPeriod")
492 proctimeEndPeriod = modwinmm.NewProc("timeEndPeriod")
Jason A. Donenfeld07034702021-01-22 17:59:47 +0100493 procWinVerifyTrustEx = modwintrust.NewProc("WinVerifyTrustEx")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100494 procFreeAddrInfoW = modws2_32.NewProc("FreeAddrInfoW")
495 procGetAddrInfoW = modws2_32.NewProc("GetAddrInfoW")
496 procWSACleanup = modws2_32.NewProc("WSACleanup")
497 procWSAEnumProtocolsW = modws2_32.NewProc("WSAEnumProtocolsW")
Jason A. Donenfeld7b4935e2021-03-03 14:05:15 +0100498 procWSAGetOverlappedResult = modws2_32.NewProc("WSAGetOverlappedResult")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100499 procWSAIoctl = modws2_32.NewProc("WSAIoctl")
PumpkinSeed4fee21c2022-08-15 10:39:57 +0200500 procWSALookupServiceBeginW = modws2_32.NewProc("WSALookupServiceBeginW")
501 procWSALookupServiceEnd = modws2_32.NewProc("WSALookupServiceEnd")
502 procWSALookupServiceNextW = modws2_32.NewProc("WSALookupServiceNextW")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100503 procWSARecv = modws2_32.NewProc("WSARecv")
504 procWSARecvFrom = modws2_32.NewProc("WSARecvFrom")
505 procWSASend = modws2_32.NewProc("WSASend")
506 procWSASendTo = modws2_32.NewProc("WSASendTo")
Jason A. Donenfeldeede4232021-02-23 13:44:32 +0100507 procWSASocketW = modws2_32.NewProc("WSASocketW")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100508 procWSAStartup = modws2_32.NewProc("WSAStartup")
509 procbind = modws2_32.NewProc("bind")
510 procclosesocket = modws2_32.NewProc("closesocket")
511 procconnect = modws2_32.NewProc("connect")
512 procgethostbyname = modws2_32.NewProc("gethostbyname")
513 procgetpeername = modws2_32.NewProc("getpeername")
514 procgetprotobyname = modws2_32.NewProc("getprotobyname")
515 procgetservbyname = modws2_32.NewProc("getservbyname")
516 procgetsockname = modws2_32.NewProc("getsockname")
517 procgetsockopt = modws2_32.NewProc("getsockopt")
518 proclisten = modws2_32.NewProc("listen")
519 procntohs = modws2_32.NewProc("ntohs")
520 procrecvfrom = modws2_32.NewProc("recvfrom")
521 procsendto = modws2_32.NewProc("sendto")
522 procsetsockopt = modws2_32.NewProc("setsockopt")
523 procshutdown = modws2_32.NewProc("shutdown")
524 procsocket = modws2_32.NewProc("socket")
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600525 procWTSEnumerateSessionsW = modwtsapi32.NewProc("WTSEnumerateSessionsW")
526 procWTSFreeMemory = modwtsapi32.NewProc("WTSFreeMemory")
Alex Brainman0aaa2712020-10-11 09:49:28 +1100527 procWTSQueryUserToken = modwtsapi32.NewProc("WTSQueryUserToken")
Rob Pike20acc5c2014-08-11 14:48:46 -0700528)
529
Jason A. Donenfeldfe613092021-10-27 15:23:03 +0200530func cm_Get_DevNode_Status(status *uint32, problemNumber *uint32, devInst DEVINST, flags uint32) (ret CONFIGRET) {
531 r0, _, _ := syscall.Syscall6(procCM_Get_DevNode_Status.Addr(), 4, uintptr(unsafe.Pointer(status)), uintptr(unsafe.Pointer(problemNumber)), uintptr(devInst), uintptr(flags), 0, 0)
532 ret = CONFIGRET(r0)
533 return
534}
535
536func cm_Get_Device_Interface_List(interfaceClass *GUID, deviceID *uint16, buffer *uint16, bufferLen uint32, flags uint32) (ret CONFIGRET) {
537 r0, _, _ := syscall.Syscall6(procCM_Get_Device_Interface_ListW.Addr(), 5, uintptr(unsafe.Pointer(interfaceClass)), uintptr(unsafe.Pointer(deviceID)), uintptr(unsafe.Pointer(buffer)), uintptr(bufferLen), uintptr(flags), 0)
538 ret = CONFIGRET(r0)
539 return
540}
541
542func cm_Get_Device_Interface_List_Size(len *uint32, interfaceClass *GUID, deviceID *uint16, flags uint32) (ret CONFIGRET) {
543 r0, _, _ := syscall.Syscall6(procCM_Get_Device_Interface_List_SizeW.Addr(), 4, uintptr(unsafe.Pointer(len)), uintptr(unsafe.Pointer(interfaceClass)), uintptr(unsafe.Pointer(deviceID)), uintptr(flags), 0, 0)
544 ret = CONFIGRET(r0)
545 return
546}
547
548func cm_MapCrToWin32Err(configRet CONFIGRET, defaultWin32Error Errno) (ret Errno) {
549 r0, _, _ := syscall.Syscall(procCM_MapCrToWin32Err.Addr(), 2, uintptr(configRet), uintptr(defaultWin32Error), 0)
550 ret = Errno(r0)
551 return
552}
553
Alex Brainman0aaa2712020-10-11 09:49:28 +1100554func AdjustTokenGroups(token Token, resetToDefault bool, newstate *Tokengroups, buflen uint32, prevstate *Tokengroups, returnlen *uint32) (err error) {
Jason A. Donenfeld0c1ff782019-09-18 00:14:46 -0600555 var _p0 uint32
Alex Brainman0aaa2712020-10-11 09:49:28 +1100556 if resetToDefault {
Jason A. Donenfeld0c1ff782019-09-18 00:14:46 -0600557 _p0 = 1
Jason A. Donenfeld0c1ff782019-09-18 00:14:46 -0600558 }
Alex Brainman0aaa2712020-10-11 09:49:28 +1100559 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 +0200560 if r1 == 0 {
Sebastiaan van Stijndfb3f7c2020-10-09 00:24:30 +0000561 err = errnoErr(e1)
Jason A. Donenfeld3a4b5fb2019-05-13 11:46:50 +0200562 }
563 return
564}
565
566func AdjustTokenPrivileges(token Token, disableAllPrivileges bool, newstate *Tokenprivileges, buflen uint32, prevstate *Tokenprivileges, returnlen *uint32) (err error) {
567 var _p0 uint32
568 if disableAllPrivileges {
569 _p0 = 1
Jason A. Donenfeld3a4b5fb2019-05-13 11:46:50 +0200570 }
571 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)))
572 if r1 == 0 {
Sebastiaan van Stijndfb3f7c2020-10-09 00:24:30 +0000573 err = errnoErr(e1)
Jason A. Donenfeld3a4b5fb2019-05-13 11:46:50 +0200574 }
575 return
576}
577
Alex Brainman0aaa2712020-10-11 09:49:28 +1100578func 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) {
579 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 +0200580 if r1 == 0 {
Sebastiaan van Stijndfb3f7c2020-10-09 00:24:30 +0000581 err = errnoErr(e1)
Jason A. Donenfeldcedb8e12019-05-15 13:59:33 +0200582 }
583 return
584}
585
Alex Brainman0aaa2712020-10-11 09:49:28 +1100586func 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) {
587 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)))
588 if r0 != 0 {
589 ret = syscall.Errno(r0)
590 }
591 return
592}
593
594func ChangeServiceConfig2(service Handle, infoLevel uint32, info *byte) (err error) {
595 r1, _, e1 := syscall.Syscall(procChangeServiceConfig2W.Addr(), 3, uintptr(service), uintptr(infoLevel), uintptr(unsafe.Pointer(info)))
Jason A. Donenfeld3a4b5fb2019-05-13 11:46:50 +0200596 if r1 == 0 {
Sebastiaan van Stijndfb3f7c2020-10-09 00:24:30 +0000597 err = errnoErr(e1)
Jason A. Donenfeld3a4b5fb2019-05-13 11:46:50 +0200598 }
599 return
600}
601
Alex Brainman0aaa2712020-10-11 09:49:28 +1100602func 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) {
603 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)
604 if r1 == 0 {
605 err = errnoErr(e1)
606 }
607 return
608}
609
610func checkTokenMembership(tokenHandle Token, sidToCheck *SID, isMember *int32) (err error) {
611 r1, _, e1 := syscall.Syscall(procCheckTokenMembership.Addr(), 3, uintptr(tokenHandle), uintptr(unsafe.Pointer(sidToCheck)), uintptr(unsafe.Pointer(isMember)))
612 if r1 == 0 {
613 err = errnoErr(e1)
614 }
615 return
616}
617
618func CloseServiceHandle(handle Handle) (err error) {
619 r1, _, e1 := syscall.Syscall(procCloseServiceHandle.Addr(), 1, uintptr(handle), 0, 0)
620 if r1 == 0 {
621 err = errnoErr(e1)
622 }
623 return
624}
625
626func ControlService(service Handle, control uint32, status *SERVICE_STATUS) (err error) {
627 r1, _, e1 := syscall.Syscall(procControlService.Addr(), 3, uintptr(service), uintptr(control), uintptr(unsafe.Pointer(status)))
628 if r1 == 0 {
629 err = errnoErr(e1)
630 }
631 return
632}
633
634func convertSecurityDescriptorToStringSecurityDescriptor(sd *SECURITY_DESCRIPTOR, revision uint32, securityInformation SECURITY_INFORMATION, str **uint16, strLen *uint32) (err error) {
635 r1, _, e1 := syscall.Syscall6(procConvertSecurityDescriptorToStringSecurityDescriptorW.Addr(), 5, uintptr(unsafe.Pointer(sd)), uintptr(revision), uintptr(securityInformation), uintptr(unsafe.Pointer(str)), uintptr(unsafe.Pointer(strLen)), 0)
636 if r1 == 0 {
637 err = errnoErr(e1)
638 }
639 return
640}
641
642func ConvertSidToStringSid(sid *SID, stringSid **uint16) (err error) {
643 r1, _, e1 := syscall.Syscall(procConvertSidToStringSidW.Addr(), 2, uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(stringSid)), 0)
644 if r1 == 0 {
645 err = errnoErr(e1)
646 }
647 return
648}
649
650func convertStringSecurityDescriptorToSecurityDescriptor(str string, revision uint32, sd **SECURITY_DESCRIPTOR, size *uint32) (err error) {
651 var _p0 *uint16
652 _p0, err = syscall.UTF16PtrFromString(str)
653 if err != nil {
654 return
655 }
656 return _convertStringSecurityDescriptorToSecurityDescriptor(_p0, revision, sd, size)
657}
658
659func _convertStringSecurityDescriptorToSecurityDescriptor(str *uint16, revision uint32, sd **SECURITY_DESCRIPTOR, size *uint32) (err error) {
660 r1, _, e1 := syscall.Syscall6(procConvertStringSecurityDescriptorToSecurityDescriptorW.Addr(), 4, uintptr(unsafe.Pointer(str)), uintptr(revision), uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(size)), 0, 0)
661 if r1 == 0 {
662 err = errnoErr(e1)
663 }
664 return
665}
666
667func ConvertStringSidToSid(stringSid *uint16, sid **SID) (err error) {
668 r1, _, e1 := syscall.Syscall(procConvertStringSidToSidW.Addr(), 2, uintptr(unsafe.Pointer(stringSid)), uintptr(unsafe.Pointer(sid)), 0)
669 if r1 == 0 {
670 err = errnoErr(e1)
671 }
672 return
673}
674
675func CopySid(destSidLen uint32, destSid *SID, srcSid *SID) (err error) {
676 r1, _, e1 := syscall.Syscall(procCopySid.Addr(), 3, uintptr(destSidLen), uintptr(unsafe.Pointer(destSid)), uintptr(unsafe.Pointer(srcSid)))
677 if r1 == 0 {
678 err = errnoErr(e1)
679 }
680 return
681}
682
Jason A. Donenfeld7ecdf8e2021-05-31 18:59:41 +0200683func CreateProcessAsUser(token Token, appName *uint16, commandLine *uint16, procSecurity *SecurityAttributes, threadSecurity *SecurityAttributes, inheritHandles bool, creationFlags uint32, env *uint16, currentDir *uint16, startupInfo *StartupInfo, outProcInfo *ProcessInformation) (err error) {
684 var _p0 uint32
685 if inheritHandles {
686 _p0 = 1
687 }
688 r1, _, e1 := syscall.Syscall12(procCreateProcessAsUserW.Addr(), 11, uintptr(token), 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)
689 if r1 == 0 {
690 err = errnoErr(e1)
691 }
692 return
693}
694
Alex Brainman0aaa2712020-10-11 09:49:28 +1100695func 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) {
696 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)
697 handle = Handle(r0)
698 if handle == 0 {
699 err = errnoErr(e1)
700 }
701 return
702}
703
704func createWellKnownSid(sidType WELL_KNOWN_SID_TYPE, domainSid *SID, sid *SID, sizeSid *uint32) (err error) {
705 r1, _, e1 := syscall.Syscall6(procCreateWellKnownSid.Addr(), 4, uintptr(sidType), uintptr(unsafe.Pointer(domainSid)), uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(sizeSid)), 0, 0)
706 if r1 == 0 {
707 err = errnoErr(e1)
708 }
709 return
710}
711
712func CryptAcquireContext(provhandle *Handle, container *uint16, provider *uint16, provtype uint32, flags uint32) (err error) {
713 r1, _, e1 := syscall.Syscall6(procCryptAcquireContextW.Addr(), 5, uintptr(unsafe.Pointer(provhandle)), uintptr(unsafe.Pointer(container)), uintptr(unsafe.Pointer(provider)), uintptr(provtype), uintptr(flags), 0)
714 if r1 == 0 {
715 err = errnoErr(e1)
716 }
717 return
718}
719
720func CryptGenRandom(provhandle Handle, buflen uint32, buf *byte) (err error) {
721 r1, _, e1 := syscall.Syscall(procCryptGenRandom.Addr(), 3, uintptr(provhandle), uintptr(buflen), uintptr(unsafe.Pointer(buf)))
722 if r1 == 0 {
723 err = errnoErr(e1)
724 }
725 return
726}
727
728func CryptReleaseContext(provhandle Handle, flags uint32) (err error) {
729 r1, _, e1 := syscall.Syscall(procCryptReleaseContext.Addr(), 2, uintptr(provhandle), uintptr(flags), 0)
730 if r1 == 0 {
731 err = errnoErr(e1)
732 }
733 return
734}
735
736func DeleteService(service Handle) (err error) {
737 r1, _, e1 := syscall.Syscall(procDeleteService.Addr(), 1, uintptr(service), 0, 0)
738 if r1 == 0 {
739 err = errnoErr(e1)
740 }
741 return
742}
743
744func DeregisterEventSource(handle Handle) (err error) {
745 r1, _, e1 := syscall.Syscall(procDeregisterEventSource.Addr(), 1, uintptr(handle), 0, 0)
Jason A. Donenfeld3a4b5fb2019-05-13 11:46:50 +0200746 if r1 == 0 {
Sebastiaan van Stijndfb3f7c2020-10-09 00:24:30 +0000747 err = errnoErr(e1)
Jason A. Donenfeld3a4b5fb2019-05-13 11:46:50 +0200748 }
749 return
750}
751
752func DuplicateTokenEx(existingToken Token, desiredAccess uint32, tokenAttributes *SecurityAttributes, impersonationLevel uint32, tokenType uint32, newToken *Token) (err error) {
753 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 -0700754 if r1 == 0 {
Sebastiaan van Stijndfb3f7c2020-10-09 00:24:30 +0000755 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -0700756 }
757 return
758}
759
Sebastian Sotodbd8f992022-11-18 10:22:56 -0500760func EnumDependentServices(service Handle, activityState uint32, services *ENUM_SERVICE_STATUS, buffSize uint32, bytesNeeded *uint32, servicesReturned *uint32) (err error) {
761 r1, _, e1 := syscall.Syscall6(procEnumDependentServicesW.Addr(), 6, uintptr(service), uintptr(activityState), uintptr(unsafe.Pointer(services)), uintptr(buffSize), uintptr(unsafe.Pointer(bytesNeeded)), uintptr(unsafe.Pointer(servicesReturned)))
762 if r1 == 0 {
763 err = errnoErr(e1)
764 }
765 return
766}
767
Alex Brainman0aaa2712020-10-11 09:49:28 +1100768func EnumServicesStatusEx(mgr Handle, infoLevel uint32, serviceType uint32, serviceState uint32, services *byte, bufSize uint32, bytesNeeded *uint32, servicesReturned *uint32, resumeHandle *uint32, groupName *uint16) (err error) {
769 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 -0700770 if r1 == 0 {
Sebastiaan van Stijndfb3f7c2020-10-09 00:24:30 +0000771 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -0700772 }
773 return
774}
Jason A. Donenfeld10058d72019-03-06 18:49:41 +0100775
Alex Brainman0aaa2712020-10-11 09:49:28 +1100776func EqualSid(sid1 *SID, sid2 *SID) (isEqual bool) {
777 r0, _, _ := syscall.Syscall(procEqualSid.Addr(), 2, uintptr(unsafe.Pointer(sid1)), uintptr(unsafe.Pointer(sid2)), 0)
778 isEqual = r0 != 0
779 return
780}
781
782func FreeSid(sid *SID) (err error) {
783 r1, _, e1 := syscall.Syscall(procFreeSid.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0)
784 if r1 != 0 {
785 err = errnoErr(e1)
786 }
787 return
788}
789
790func GetLengthSid(sid *SID) (len uint32) {
791 r0, _, _ := syscall.Syscall(procGetLengthSid.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0)
Jason A. Donenfeld10058d72019-03-06 18:49:41 +0100792 len = uint32(r0)
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600793 return
794}
795
796func getNamedSecurityInfo(objectName string, objectType SE_OBJECT_TYPE, securityInformation SECURITY_INFORMATION, owner **SID, group **SID, dacl **ACL, sacl **ACL, sd **SECURITY_DESCRIPTOR) (ret error) {
797 var _p0 *uint16
798 _p0, ret = syscall.UTF16PtrFromString(objectName)
799 if ret != nil {
800 return
801 }
802 return _getNamedSecurityInfo(_p0, objectType, securityInformation, owner, group, dacl, sacl, sd)
803}
804
805func _getNamedSecurityInfo(objectName *uint16, objectType SE_OBJECT_TYPE, securityInformation SECURITY_INFORMATION, owner **SID, group **SID, dacl **ACL, sacl **ACL, sd **SECURITY_DESCRIPTOR) (ret error) {
806 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)
807 if r0 != 0 {
808 ret = syscall.Errno(r0)
809 }
810 return
811}
812
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600813func getSecurityDescriptorControl(sd *SECURITY_DESCRIPTOR, control *SECURITY_DESCRIPTOR_CONTROL, revision *uint32) (err error) {
814 r1, _, e1 := syscall.Syscall(procGetSecurityDescriptorControl.Addr(), 3, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(control)), uintptr(unsafe.Pointer(revision)))
815 if r1 == 0 {
Sebastiaan van Stijndfb3f7c2020-10-09 00:24:30 +0000816 err = errnoErr(e1)
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600817 }
818 return
819}
820
821func getSecurityDescriptorDacl(sd *SECURITY_DESCRIPTOR, daclPresent *bool, dacl **ACL, daclDefaulted *bool) (err error) {
822 var _p0 uint32
823 if *daclPresent {
824 _p0 = 1
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600825 }
826 var _p1 uint32
827 if *daclDefaulted {
828 _p1 = 1
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600829 }
830 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)
831 *daclPresent = _p0 != 0
832 *daclDefaulted = _p1 != 0
833 if r1 == 0 {
Sebastiaan van Stijndfb3f7c2020-10-09 00:24:30 +0000834 err = errnoErr(e1)
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600835 }
836 return
837}
838
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600839func getSecurityDescriptorGroup(sd *SECURITY_DESCRIPTOR, group **SID, groupDefaulted *bool) (err error) {
840 var _p0 uint32
841 if *groupDefaulted {
842 _p0 = 1
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600843 }
844 r1, _, e1 := syscall.Syscall(procGetSecurityDescriptorGroup.Addr(), 3, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(group)), uintptr(unsafe.Pointer(&_p0)))
845 *groupDefaulted = _p0 != 0
846 if r1 == 0 {
Sebastiaan van Stijndfb3f7c2020-10-09 00:24:30 +0000847 err = errnoErr(e1)
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600848 }
849 return
850}
851
852func getSecurityDescriptorLength(sd *SECURITY_DESCRIPTOR) (len uint32) {
853 r0, _, _ := syscall.Syscall(procGetSecurityDescriptorLength.Addr(), 1, uintptr(unsafe.Pointer(sd)), 0, 0)
854 len = uint32(r0)
855 return
856}
857
Alex Brainman0aaa2712020-10-11 09:49:28 +1100858func getSecurityDescriptorOwner(sd *SECURITY_DESCRIPTOR, owner **SID, ownerDefaulted *bool) (err error) {
859 var _p0 uint32
860 if *ownerDefaulted {
861 _p0 = 1
862 }
863 r1, _, e1 := syscall.Syscall(procGetSecurityDescriptorOwner.Addr(), 3, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(owner)), uintptr(unsafe.Pointer(&_p0)))
864 *ownerDefaulted = _p0 != 0
865 if r1 == 0 {
866 err = errnoErr(e1)
867 }
868 return
869}
870
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600871func getSecurityDescriptorRMControl(sd *SECURITY_DESCRIPTOR, rmControl *uint8) (ret error) {
872 r0, _, _ := syscall.Syscall(procGetSecurityDescriptorRMControl.Addr(), 2, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(rmControl)), 0)
873 if r0 != 0 {
874 ret = syscall.Errno(r0)
875 }
876 return
877}
878
Alex Brainman0aaa2712020-10-11 09:49:28 +1100879func getSecurityDescriptorSacl(sd *SECURITY_DESCRIPTOR, saclPresent *bool, sacl **ACL, saclDefaulted *bool) (err error) {
880 var _p0 uint32
881 if *saclPresent {
882 _p0 = 1
883 }
884 var _p1 uint32
885 if *saclDefaulted {
886 _p1 = 1
887 }
888 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)
889 *saclPresent = _p0 != 0
890 *saclDefaulted = _p1 != 0
891 if r1 == 0 {
892 err = errnoErr(e1)
893 }
894 return
895}
896
897func getSecurityInfo(handle Handle, objectType SE_OBJECT_TYPE, securityInformation SECURITY_INFORMATION, owner **SID, group **SID, dacl **ACL, sacl **ACL, sd **SECURITY_DESCRIPTOR) (ret error) {
898 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)
899 if r0 != 0 {
900 ret = syscall.Errno(r0)
901 }
902 return
903}
904
905func getSidIdentifierAuthority(sid *SID) (authority *SidIdentifierAuthority) {
906 r0, _, _ := syscall.Syscall(procGetSidIdentifierAuthority.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0)
907 authority = (*SidIdentifierAuthority)(unsafe.Pointer(r0))
908 return
909}
910
911func getSidSubAuthority(sid *SID, index uint32) (subAuthority *uint32) {
912 r0, _, _ := syscall.Syscall(procGetSidSubAuthority.Addr(), 2, uintptr(unsafe.Pointer(sid)), uintptr(index), 0)
913 subAuthority = (*uint32)(unsafe.Pointer(r0))
914 return
915}
916
917func getSidSubAuthorityCount(sid *SID) (count *uint8) {
918 r0, _, _ := syscall.Syscall(procGetSidSubAuthorityCount.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0)
919 count = (*uint8)(unsafe.Pointer(r0))
920 return
921}
922
923func GetTokenInformation(token Token, infoClass uint32, info *byte, infoLen uint32, returnedLen *uint32) (err error) {
924 r1, _, e1 := syscall.Syscall6(procGetTokenInformation.Addr(), 5, uintptr(token), uintptr(infoClass), uintptr(unsafe.Pointer(info)), uintptr(infoLen), uintptr(unsafe.Pointer(returnedLen)), 0)
925 if r1 == 0 {
926 err = errnoErr(e1)
927 }
928 return
929}
930
931func ImpersonateSelf(impersonationlevel uint32) (err error) {
932 r1, _, e1 := syscall.Syscall(procImpersonateSelf.Addr(), 1, uintptr(impersonationlevel), 0, 0)
933 if r1 == 0 {
934 err = errnoErr(e1)
935 }
936 return
937}
938
939func initializeSecurityDescriptor(absoluteSD *SECURITY_DESCRIPTOR, revision uint32) (err error) {
940 r1, _, e1 := syscall.Syscall(procInitializeSecurityDescriptor.Addr(), 2, uintptr(unsafe.Pointer(absoluteSD)), uintptr(revision), 0)
941 if r1 == 0 {
942 err = errnoErr(e1)
943 }
944 return
945}
946
947func InitiateSystemShutdownEx(machineName *uint16, message *uint16, timeout uint32, forceAppsClosed bool, rebootAfterShutdown bool, reason uint32) (err error) {
948 var _p0 uint32
949 if forceAppsClosed {
950 _p0 = 1
951 }
952 var _p1 uint32
953 if rebootAfterShutdown {
954 _p1 = 1
955 }
956 r1, _, e1 := syscall.Syscall6(procInitiateSystemShutdownExW.Addr(), 6, uintptr(unsafe.Pointer(machineName)), uintptr(unsafe.Pointer(message)), uintptr(timeout), uintptr(_p0), uintptr(_p1), uintptr(reason))
957 if r1 == 0 {
958 err = errnoErr(e1)
959 }
960 return
961}
962
Jason A. Donenfeldf88b8272020-11-21 10:31:08 +0100963func isTokenRestricted(tokenHandle Token) (ret bool, err error) {
964 r0, _, e1 := syscall.Syscall(procIsTokenRestricted.Addr(), 1, uintptr(tokenHandle), 0, 0)
965 ret = r0 != 0
966 if !ret {
967 err = errnoErr(e1)
968 }
969 return
970}
971
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -0600972func isValidSecurityDescriptor(sd *SECURITY_DESCRIPTOR) (isValid bool) {
973 r0, _, _ := syscall.Syscall(procIsValidSecurityDescriptor.Addr(), 1, uintptr(unsafe.Pointer(sd)), 0, 0)
974 isValid = r0 != 0
975 return
976}
977
Alex Brainman0aaa2712020-10-11 09:49:28 +1100978func isValidSid(sid *SID) (isValid bool) {
979 r0, _, _ := syscall.Syscall(procIsValidSid.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0)
980 isValid = r0 != 0
981 return
982}
983
984func isWellKnownSid(sid *SID, sidType WELL_KNOWN_SID_TYPE) (isWellKnown bool) {
985 r0, _, _ := syscall.Syscall(procIsWellKnownSid.Addr(), 2, uintptr(unsafe.Pointer(sid)), uintptr(sidType), 0)
986 isWellKnown = r0 != 0
987 return
988}
989
990func LookupAccountName(systemName *uint16, accountName *uint16, sid *SID, sidLen *uint32, refdDomainName *uint16, refdDomainNameLen *uint32, use *uint32) (err error) {
991 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)
992 if r1 == 0 {
993 err = errnoErr(e1)
994 }
995 return
996}
997
998func LookupAccountSid(systemName *uint16, sid *SID, name *uint16, nameLen *uint32, refdDomainName *uint16, refdDomainNameLen *uint32, use *uint32) (err error) {
999 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)
1000 if r1 == 0 {
1001 err = errnoErr(e1)
1002 }
1003 return
1004}
1005
1006func LookupPrivilegeValue(systemname *uint16, name *uint16, luid *LUID) (err error) {
1007 r1, _, e1 := syscall.Syscall(procLookupPrivilegeValueW.Addr(), 3, uintptr(unsafe.Pointer(systemname)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(luid)))
1008 if r1 == 0 {
1009 err = errnoErr(e1)
1010 }
1011 return
1012}
1013
1014func 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) {
1015 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)
1016 if r1 == 0 {
1017 err = errnoErr(e1)
1018 }
1019 return
1020}
1021
1022func makeSelfRelativeSD(absoluteSD *SECURITY_DESCRIPTOR, selfRelativeSD *SECURITY_DESCRIPTOR, selfRelativeSDSize *uint32) (err error) {
1023 r1, _, e1 := syscall.Syscall(procMakeSelfRelativeSD.Addr(), 3, uintptr(unsafe.Pointer(absoluteSD)), uintptr(unsafe.Pointer(selfRelativeSD)), uintptr(unsafe.Pointer(selfRelativeSDSize)))
1024 if r1 == 0 {
1025 err = errnoErr(e1)
1026 }
1027 return
1028}
1029
1030func NotifyServiceStatusChange(service Handle, notifyMask uint32, notifier *SERVICE_NOTIFY) (ret error) {
1031 r0, _, _ := syscall.Syscall(procNotifyServiceStatusChangeW.Addr(), 3, uintptr(service), uintptr(notifyMask), uintptr(unsafe.Pointer(notifier)))
1032 if r0 != 0 {
1033 ret = syscall.Errno(r0)
1034 }
1035 return
1036}
1037
1038func OpenProcessToken(process Handle, access uint32, token *Token) (err error) {
1039 r1, _, e1 := syscall.Syscall(procOpenProcessToken.Addr(), 3, uintptr(process), uintptr(access), uintptr(unsafe.Pointer(token)))
1040 if r1 == 0 {
1041 err = errnoErr(e1)
1042 }
1043 return
1044}
1045
1046func OpenSCManager(machineName *uint16, databaseName *uint16, access uint32) (handle Handle, err error) {
1047 r0, _, e1 := syscall.Syscall(procOpenSCManagerW.Addr(), 3, uintptr(unsafe.Pointer(machineName)), uintptr(unsafe.Pointer(databaseName)), uintptr(access))
1048 handle = Handle(r0)
1049 if handle == 0 {
1050 err = errnoErr(e1)
1051 }
1052 return
1053}
1054
1055func OpenService(mgr Handle, serviceName *uint16, access uint32) (handle Handle, err error) {
1056 r0, _, e1 := syscall.Syscall(procOpenServiceW.Addr(), 3, uintptr(mgr), uintptr(unsafe.Pointer(serviceName)), uintptr(access))
1057 handle = Handle(r0)
1058 if handle == 0 {
1059 err = errnoErr(e1)
1060 }
1061 return
1062}
1063
1064func OpenThreadToken(thread Handle, access uint32, openAsSelf bool, token *Token) (err error) {
1065 var _p0 uint32
1066 if openAsSelf {
1067 _p0 = 1
1068 }
1069 r1, _, e1 := syscall.Syscall6(procOpenThreadToken.Addr(), 4, uintptr(thread), uintptr(access), uintptr(_p0), uintptr(unsafe.Pointer(token)), 0, 0)
1070 if r1 == 0 {
1071 err = errnoErr(e1)
1072 }
1073 return
1074}
1075
1076func QueryServiceConfig2(service Handle, infoLevel uint32, buff *byte, buffSize uint32, bytesNeeded *uint32) (err error) {
1077 r1, _, e1 := syscall.Syscall6(procQueryServiceConfig2W.Addr(), 5, uintptr(service), uintptr(infoLevel), uintptr(unsafe.Pointer(buff)), uintptr(buffSize), uintptr(unsafe.Pointer(bytesNeeded)), 0)
1078 if r1 == 0 {
1079 err = errnoErr(e1)
1080 }
1081 return
1082}
1083
1084func QueryServiceConfig(service Handle, serviceConfig *QUERY_SERVICE_CONFIG, bufSize uint32, bytesNeeded *uint32) (err error) {
1085 r1, _, e1 := syscall.Syscall6(procQueryServiceConfigW.Addr(), 4, uintptr(service), uintptr(unsafe.Pointer(serviceConfig)), uintptr(bufSize), uintptr(unsafe.Pointer(bytesNeeded)), 0, 0)
1086 if r1 == 0 {
1087 err = errnoErr(e1)
1088 }
1089 return
1090}
1091
Jason A. Donenfeld6e787282021-10-25 14:45:05 +02001092func QueryServiceDynamicInformation(service Handle, infoLevel uint32, dynamicInfo unsafe.Pointer) (err error) {
1093 err = procQueryServiceDynamicInformation.Find()
1094 if err != nil {
1095 return
1096 }
1097 r1, _, e1 := syscall.Syscall(procQueryServiceDynamicInformation.Addr(), 3, uintptr(service), uintptr(infoLevel), uintptr(dynamicInfo))
1098 if r1 == 0 {
1099 err = errnoErr(e1)
1100 }
1101 return
1102}
1103
Alex Brainman0aaa2712020-10-11 09:49:28 +11001104func QueryServiceLockStatus(mgr Handle, lockStatus *QUERY_SERVICE_LOCK_STATUS, bufSize uint32, bytesNeeded *uint32) (err error) {
1105 r1, _, e1 := syscall.Syscall6(procQueryServiceLockStatusW.Addr(), 4, uintptr(mgr), uintptr(unsafe.Pointer(lockStatus)), uintptr(bufSize), uintptr(unsafe.Pointer(bytesNeeded)), 0, 0)
1106 if r1 == 0 {
1107 err = errnoErr(e1)
1108 }
1109 return
1110}
1111
1112func QueryServiceStatus(service Handle, status *SERVICE_STATUS) (err error) {
1113 r1, _, e1 := syscall.Syscall(procQueryServiceStatus.Addr(), 2, uintptr(service), uintptr(unsafe.Pointer(status)), 0)
1114 if r1 == 0 {
1115 err = errnoErr(e1)
1116 }
1117 return
1118}
1119
1120func QueryServiceStatusEx(service Handle, infoLevel uint32, buff *byte, buffSize uint32, bytesNeeded *uint32) (err error) {
1121 r1, _, e1 := syscall.Syscall6(procQueryServiceStatusEx.Addr(), 5, uintptr(service), uintptr(infoLevel), uintptr(unsafe.Pointer(buff)), uintptr(buffSize), uintptr(unsafe.Pointer(bytesNeeded)), 0)
1122 if r1 == 0 {
1123 err = errnoErr(e1)
1124 }
1125 return
1126}
1127
1128func RegCloseKey(key Handle) (regerrno error) {
1129 r0, _, _ := syscall.Syscall(procRegCloseKey.Addr(), 1, uintptr(key), 0, 0)
1130 if r0 != 0 {
1131 regerrno = syscall.Errno(r0)
1132 }
1133 return
1134}
1135
1136func RegEnumKeyEx(key Handle, index uint32, name *uint16, nameLen *uint32, reserved *uint32, class *uint16, classLen *uint32, lastWriteTime *Filetime) (regerrno error) {
1137 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)
1138 if r0 != 0 {
1139 regerrno = syscall.Errno(r0)
1140 }
1141 return
1142}
1143
Josh Bleecher Snyder7e3030f2020-12-10 12:50:29 -08001144func RegNotifyChangeKeyValue(key Handle, watchSubtree bool, notifyFilter uint32, event Handle, asynchronous bool) (regerrno error) {
1145 var _p0 uint32
1146 if watchSubtree {
1147 _p0 = 1
1148 }
1149 var _p1 uint32
1150 if asynchronous {
1151 _p1 = 1
1152 }
1153 r0, _, _ := syscall.Syscall6(procRegNotifyChangeKeyValue.Addr(), 5, uintptr(key), uintptr(_p0), uintptr(notifyFilter), uintptr(event), uintptr(_p1), 0)
1154 if r0 != 0 {
1155 regerrno = syscall.Errno(r0)
1156 }
1157 return
1158}
1159
Alex Brainman0aaa2712020-10-11 09:49:28 +11001160func RegOpenKeyEx(key Handle, subkey *uint16, options uint32, desiredAccess uint32, result *Handle) (regerrno error) {
1161 r0, _, _ := syscall.Syscall6(procRegOpenKeyExW.Addr(), 5, uintptr(key), uintptr(unsafe.Pointer(subkey)), uintptr(options), uintptr(desiredAccess), uintptr(unsafe.Pointer(result)), 0)
1162 if r0 != 0 {
1163 regerrno = syscall.Errno(r0)
1164 }
1165 return
1166}
1167
1168func 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) {
1169 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)))
1170 if r0 != 0 {
1171 regerrno = syscall.Errno(r0)
1172 }
1173 return
1174}
1175
1176func RegQueryValueEx(key Handle, name *uint16, reserved *uint32, valtype *uint32, buf *byte, buflen *uint32) (regerrno error) {
1177 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)))
1178 if r0 != 0 {
1179 regerrno = syscall.Errno(r0)
1180 }
1181 return
1182}
1183
1184func RegisterEventSource(uncServerName *uint16, sourceName *uint16) (handle Handle, err error) {
1185 r0, _, e1 := syscall.Syscall(procRegisterEventSourceW.Addr(), 2, uintptr(unsafe.Pointer(uncServerName)), uintptr(unsafe.Pointer(sourceName)), 0)
1186 handle = Handle(r0)
1187 if handle == 0 {
1188 err = errnoErr(e1)
1189 }
1190 return
1191}
1192
Jason A. Donenfeld0ec99a62021-06-22 16:38:31 +02001193func RegisterServiceCtrlHandlerEx(serviceName *uint16, handlerProc uintptr, context uintptr) (handle Handle, err error) {
1194 r0, _, e1 := syscall.Syscall(procRegisterServiceCtrlHandlerExW.Addr(), 3, uintptr(unsafe.Pointer(serviceName)), uintptr(handlerProc), uintptr(context))
1195 handle = Handle(r0)
1196 if handle == 0 {
1197 err = errnoErr(e1)
1198 }
1199 return
1200}
1201
Alex Brainman0aaa2712020-10-11 09:49:28 +11001202func ReportEvent(log Handle, etype uint16, category uint16, eventId uint32, usrSId uintptr, numStrings uint16, dataSize uint32, strings **uint16, rawData *byte) (err error) {
1203 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)))
1204 if r1 == 0 {
1205 err = errnoErr(e1)
1206 }
1207 return
1208}
1209
1210func RevertToSelf() (err error) {
1211 r1, _, e1 := syscall.Syscall(procRevertToSelf.Addr(), 0, 0, 0, 0)
1212 if r1 == 0 {
1213 err = errnoErr(e1)
1214 }
1215 return
1216}
1217
1218func setEntriesInAcl(countExplicitEntries uint32, explicitEntries *EXPLICIT_ACCESS, oldACL *ACL, newACL **ACL) (ret error) {
1219 r0, _, _ := syscall.Syscall6(procSetEntriesInAclW.Addr(), 4, uintptr(countExplicitEntries), uintptr(unsafe.Pointer(explicitEntries)), uintptr(unsafe.Pointer(oldACL)), uintptr(unsafe.Pointer(newACL)), 0, 0)
1220 if r0 != 0 {
1221 ret = syscall.Errno(r0)
1222 }
1223 return
1224}
1225
Jason A. Donenfeld3a5be022020-11-16 17:33:31 +01001226func SetKernelObjectSecurity(handle Handle, securityInformation SECURITY_INFORMATION, securityDescriptor *SECURITY_DESCRIPTOR) (err error) {
1227 r1, _, e1 := syscall.Syscall(procSetKernelObjectSecurity.Addr(), 3, uintptr(handle), uintptr(securityInformation), uintptr(unsafe.Pointer(securityDescriptor)))
1228 if r1 == 0 {
1229 err = errnoErr(e1)
1230 }
1231 return
1232}
1233
Alex Brainman0aaa2712020-10-11 09:49:28 +11001234func SetNamedSecurityInfo(objectName string, objectType SE_OBJECT_TYPE, securityInformation SECURITY_INFORMATION, owner *SID, group *SID, dacl *ACL, sacl *ACL) (ret error) {
1235 var _p0 *uint16
1236 _p0, ret = syscall.UTF16PtrFromString(objectName)
1237 if ret != nil {
1238 return
1239 }
1240 return _SetNamedSecurityInfo(_p0, objectType, securityInformation, owner, group, dacl, sacl)
1241}
1242
1243func _SetNamedSecurityInfo(objectName *uint16, objectType SE_OBJECT_TYPE, securityInformation SECURITY_INFORMATION, owner *SID, group *SID, dacl *ACL, sacl *ACL) (ret error) {
1244 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)
1245 if r0 != 0 {
1246 ret = syscall.Errno(r0)
1247 }
1248 return
1249}
1250
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -06001251func setSecurityDescriptorControl(sd *SECURITY_DESCRIPTOR, controlBitsOfInterest SECURITY_DESCRIPTOR_CONTROL, controlBitsToSet SECURITY_DESCRIPTOR_CONTROL) (err error) {
1252 r1, _, e1 := syscall.Syscall(procSetSecurityDescriptorControl.Addr(), 3, uintptr(unsafe.Pointer(sd)), uintptr(controlBitsOfInterest), uintptr(controlBitsToSet))
1253 if r1 == 0 {
Sebastiaan van Stijndfb3f7c2020-10-09 00:24:30 +00001254 err = errnoErr(e1)
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -06001255 }
1256 return
1257}
1258
1259func setSecurityDescriptorDacl(sd *SECURITY_DESCRIPTOR, daclPresent bool, dacl *ACL, daclDefaulted bool) (err error) {
1260 var _p0 uint32
1261 if daclPresent {
1262 _p0 = 1
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -06001263 }
1264 var _p1 uint32
1265 if daclDefaulted {
1266 _p1 = 1
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -06001267 }
1268 r1, _, e1 := syscall.Syscall6(procSetSecurityDescriptorDacl.Addr(), 4, uintptr(unsafe.Pointer(sd)), uintptr(_p0), uintptr(unsafe.Pointer(dacl)), uintptr(_p1), 0, 0)
1269 if r1 == 0 {
Sebastiaan van Stijndfb3f7c2020-10-09 00:24:30 +00001270 err = errnoErr(e1)
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -06001271 }
1272 return
1273}
1274
Alex Brainman0aaa2712020-10-11 09:49:28 +11001275func setSecurityDescriptorGroup(sd *SECURITY_DESCRIPTOR, group *SID, groupDefaulted bool) (err error) {
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -06001276 var _p0 uint32
Alex Brainman0aaa2712020-10-11 09:49:28 +11001277 if groupDefaulted {
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -06001278 _p0 = 1
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -06001279 }
Alex Brainman0aaa2712020-10-11 09:49:28 +11001280 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 -06001281 if r1 == 0 {
Sebastiaan van Stijndfb3f7c2020-10-09 00:24:30 +00001282 err = errnoErr(e1)
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -06001283 }
1284 return
1285}
1286
1287func setSecurityDescriptorOwner(sd *SECURITY_DESCRIPTOR, owner *SID, ownerDefaulted bool) (err error) {
1288 var _p0 uint32
1289 if ownerDefaulted {
1290 _p0 = 1
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -06001291 }
1292 r1, _, e1 := syscall.Syscall(procSetSecurityDescriptorOwner.Addr(), 3, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(owner)), uintptr(_p0))
1293 if r1 == 0 {
Sebastiaan van Stijndfb3f7c2020-10-09 00:24:30 +00001294 err = errnoErr(e1)
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -06001295 }
1296 return
1297}
1298
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -06001299func setSecurityDescriptorRMControl(sd *SECURITY_DESCRIPTOR, rmControl *uint8) {
1300 syscall.Syscall(procSetSecurityDescriptorRMControl.Addr(), 2, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(rmControl)), 0)
1301 return
1302}
1303
Alex Brainman0aaa2712020-10-11 09:49:28 +11001304func setSecurityDescriptorSacl(sd *SECURITY_DESCRIPTOR, saclPresent bool, sacl *ACL, saclDefaulted bool) (err error) {
1305 var _p0 uint32
1306 if saclPresent {
1307 _p0 = 1
1308 }
1309 var _p1 uint32
1310 if saclDefaulted {
1311 _p1 = 1
1312 }
1313 r1, _, e1 := syscall.Syscall6(procSetSecurityDescriptorSacl.Addr(), 4, uintptr(unsafe.Pointer(sd)), uintptr(_p0), uintptr(unsafe.Pointer(sacl)), uintptr(_p1), 0, 0)
1314 if r1 == 0 {
1315 err = errnoErr(e1)
1316 }
1317 return
1318}
1319
Jason A. Donenfelda8a4db92020-11-16 17:32:51 +01001320func SetSecurityInfo(handle Handle, objectType SE_OBJECT_TYPE, securityInformation SECURITY_INFORMATION, owner *SID, group *SID, dacl *ACL, sacl *ACL) (ret error) {
1321 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)
1322 if r0 != 0 {
1323 ret = syscall.Errno(r0)
1324 }
Alex Brainman0aaa2712020-10-11 09:49:28 +11001325 return
1326}
1327
1328func SetServiceStatus(service Handle, serviceStatus *SERVICE_STATUS) (err error) {
1329 r1, _, e1 := syscall.Syscall(procSetServiceStatus.Addr(), 2, uintptr(service), uintptr(unsafe.Pointer(serviceStatus)), 0)
1330 if r1 == 0 {
1331 err = errnoErr(e1)
1332 }
1333 return
1334}
1335
1336func SetThreadToken(thread *Handle, token Token) (err error) {
1337 r1, _, e1 := syscall.Syscall(procSetThreadToken.Addr(), 2, uintptr(unsafe.Pointer(thread)), uintptr(token), 0)
1338 if r1 == 0 {
1339 err = errnoErr(e1)
1340 }
1341 return
1342}
1343
1344func SetTokenInformation(token Token, infoClass uint32, info *byte, infoLen uint32) (err error) {
1345 r1, _, e1 := syscall.Syscall6(procSetTokenInformation.Addr(), 4, uintptr(token), uintptr(infoClass), uintptr(unsafe.Pointer(info)), uintptr(infoLen), 0, 0)
1346 if r1 == 0 {
1347 err = errnoErr(e1)
1348 }
1349 return
1350}
1351
1352func StartServiceCtrlDispatcher(serviceTable *SERVICE_TABLE_ENTRY) (err error) {
1353 r1, _, e1 := syscall.Syscall(procStartServiceCtrlDispatcherW.Addr(), 1, uintptr(unsafe.Pointer(serviceTable)), 0, 0)
1354 if r1 == 0 {
1355 err = errnoErr(e1)
1356 }
1357 return
1358}
1359
1360func StartService(service Handle, numArgs uint32, argVectors **uint16) (err error) {
1361 r1, _, e1 := syscall.Syscall(procStartServiceW.Addr(), 3, uintptr(service), uintptr(numArgs), uintptr(unsafe.Pointer(argVectors)))
1362 if r1 == 0 {
1363 err = errnoErr(e1)
1364 }
1365 return
1366}
1367
1368func CertAddCertificateContextToStore(store Handle, certContext *CertContext, addDisposition uint32, storeContext **CertContext) (err error) {
1369 r1, _, e1 := syscall.Syscall6(procCertAddCertificateContextToStore.Addr(), 4, uintptr(store), uintptr(unsafe.Pointer(certContext)), uintptr(addDisposition), uintptr(unsafe.Pointer(storeContext)), 0, 0)
1370 if r1 == 0 {
1371 err = errnoErr(e1)
1372 }
1373 return
1374}
1375
1376func CertCloseStore(store Handle, flags uint32) (err error) {
1377 r1, _, e1 := syscall.Syscall(procCertCloseStore.Addr(), 2, uintptr(store), uintptr(flags), 0)
1378 if r1 == 0 {
1379 err = errnoErr(e1)
1380 }
1381 return
1382}
1383
1384func CertCreateCertificateContext(certEncodingType uint32, certEncoded *byte, encodedLen uint32) (context *CertContext, err error) {
1385 r0, _, e1 := syscall.Syscall(procCertCreateCertificateContext.Addr(), 3, uintptr(certEncodingType), uintptr(unsafe.Pointer(certEncoded)), uintptr(encodedLen))
1386 context = (*CertContext)(unsafe.Pointer(r0))
1387 if context == nil {
1388 err = errnoErr(e1)
1389 }
1390 return
1391}
1392
Daniel Kessler80594f22020-11-04 13:11:48 -08001393func CertDeleteCertificateFromStore(certContext *CertContext) (err error) {
1394 r1, _, e1 := syscall.Syscall(procCertDeleteCertificateFromStore.Addr(), 1, uintptr(unsafe.Pointer(certContext)), 0, 0)
1395 if r1 == 0 {
1396 err = errnoErr(e1)
1397 }
1398 return
1399}
1400
Boshi LIAN2d187342020-12-31 18:09:48 +00001401func CertDuplicateCertificateContext(certContext *CertContext) (dupContext *CertContext) {
1402 r0, _, _ := syscall.Syscall(procCertDuplicateCertificateContext.Addr(), 1, uintptr(unsafe.Pointer(certContext)), 0, 0)
1403 dupContext = (*CertContext)(unsafe.Pointer(r0))
1404 return
1405}
1406
Alex Brainman0aaa2712020-10-11 09:49:28 +11001407func CertEnumCertificatesInStore(store Handle, prevContext *CertContext) (context *CertContext, err error) {
1408 r0, _, e1 := syscall.Syscall(procCertEnumCertificatesInStore.Addr(), 2, uintptr(store), uintptr(unsafe.Pointer(prevContext)), 0)
1409 context = (*CertContext)(unsafe.Pointer(r0))
1410 if context == nil {
1411 err = errnoErr(e1)
1412 }
1413 return
1414}
1415
Boshi LIAN3351caf2021-02-12 18:49:36 +00001416func CertFindCertificateInStore(store Handle, certEncodingType uint32, findFlags uint32, findType uint32, findPara unsafe.Pointer, prevCertContext *CertContext) (cert *CertContext, err error) {
1417 r0, _, e1 := syscall.Syscall6(procCertFindCertificateInStore.Addr(), 6, uintptr(store), uintptr(certEncodingType), uintptr(findFlags), uintptr(findType), uintptr(findPara), uintptr(unsafe.Pointer(prevCertContext)))
1418 cert = (*CertContext)(unsafe.Pointer(r0))
1419 if cert == nil {
1420 err = errnoErr(e1)
1421 }
1422 return
1423}
1424
1425func CertFindChainInStore(store Handle, certEncodingType uint32, findFlags uint32, findType uint32, findPara unsafe.Pointer, prevChainContext *CertChainContext) (certchain *CertChainContext, err error) {
1426 r0, _, e1 := syscall.Syscall6(procCertFindChainInStore.Addr(), 6, uintptr(store), uintptr(certEncodingType), uintptr(findFlags), uintptr(findType), uintptr(findPara), uintptr(unsafe.Pointer(prevChainContext)))
1427 certchain = (*CertChainContext)(unsafe.Pointer(r0))
1428 if certchain == nil {
1429 err = errnoErr(e1)
1430 }
1431 return
1432}
1433
Jason A. Donenfeld4df39782021-01-22 14:23:17 +01001434func CertFindExtension(objId *byte, countExtensions uint32, extensions *CertExtension) (ret *CertExtension) {
1435 r0, _, _ := syscall.Syscall(procCertFindExtension.Addr(), 3, uintptr(unsafe.Pointer(objId)), uintptr(countExtensions), uintptr(unsafe.Pointer(extensions)))
1436 ret = (*CertExtension)(unsafe.Pointer(r0))
1437 return
1438}
1439
Alex Brainman0aaa2712020-10-11 09:49:28 +11001440func CertFreeCertificateChain(ctx *CertChainContext) {
1441 syscall.Syscall(procCertFreeCertificateChain.Addr(), 1, uintptr(unsafe.Pointer(ctx)), 0, 0)
1442 return
1443}
1444
1445func CertFreeCertificateContext(ctx *CertContext) (err error) {
1446 r1, _, e1 := syscall.Syscall(procCertFreeCertificateContext.Addr(), 1, uintptr(unsafe.Pointer(ctx)), 0, 0)
1447 if r1 == 0 {
1448 err = errnoErr(e1)
1449 }
1450 return
1451}
1452
1453func CertGetCertificateChain(engine Handle, leaf *CertContext, time *Filetime, additionalStore Handle, para *CertChainPara, flags uint32, reserved uintptr, chainCtx **CertChainContext) (err error) {
1454 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)
1455 if r1 == 0 {
1456 err = errnoErr(e1)
1457 }
1458 return
1459}
1460
Jason A. Donenfeld4df39782021-01-22 14:23:17 +01001461func CertGetNameString(certContext *CertContext, nameType uint32, flags uint32, typePara unsafe.Pointer, name *uint16, size uint32) (chars uint32) {
1462 r0, _, _ := syscall.Syscall6(procCertGetNameStringW.Addr(), 6, uintptr(unsafe.Pointer(certContext)), uintptr(nameType), uintptr(flags), uintptr(typePara), uintptr(unsafe.Pointer(name)), uintptr(size))
1463 chars = uint32(r0)
1464 return
1465}
1466
Alex Brainman0aaa2712020-10-11 09:49:28 +11001467func CertOpenStore(storeProvider uintptr, msgAndCertEncodingType uint32, cryptProv uintptr, flags uint32, para uintptr) (handle Handle, err error) {
1468 r0, _, e1 := syscall.Syscall6(procCertOpenStore.Addr(), 5, uintptr(storeProvider), uintptr(msgAndCertEncodingType), uintptr(cryptProv), uintptr(flags), uintptr(para), 0)
1469 handle = Handle(r0)
Boshi Lian111129e2020-11-29 13:33:00 +00001470 if handle == 0 {
Alex Brainman0aaa2712020-10-11 09:49:28 +11001471 err = errnoErr(e1)
1472 }
1473 return
1474}
1475
1476func CertOpenSystemStore(hprov Handle, name *uint16) (store Handle, err error) {
1477 r0, _, e1 := syscall.Syscall(procCertOpenSystemStoreW.Addr(), 2, uintptr(hprov), uintptr(unsafe.Pointer(name)), 0)
1478 store = Handle(r0)
1479 if store == 0 {
1480 err = errnoErr(e1)
1481 }
1482 return
1483}
1484
1485func CertVerifyCertificateChainPolicy(policyOID uintptr, chain *CertChainContext, para *CertChainPolicyPara, status *CertChainPolicyStatus) (err error) {
1486 r1, _, e1 := syscall.Syscall6(procCertVerifyCertificateChainPolicy.Addr(), 4, uintptr(policyOID), uintptr(unsafe.Pointer(chain)), uintptr(unsafe.Pointer(para)), uintptr(unsafe.Pointer(status)), 0, 0)
1487 if r1 == 0 {
1488 err = errnoErr(e1)
1489 }
1490 return
1491}
1492
Boshi LIAN3351caf2021-02-12 18:49:36 +00001493func CryptAcquireCertificatePrivateKey(cert *CertContext, flags uint32, parameters unsafe.Pointer, cryptProvOrNCryptKey *Handle, keySpec *uint32, callerFreeProvOrNCryptKey *bool) (err error) {
1494 var _p0 uint32
1495 if *callerFreeProvOrNCryptKey {
1496 _p0 = 1
1497 }
1498 r1, _, e1 := syscall.Syscall6(procCryptAcquireCertificatePrivateKey.Addr(), 6, uintptr(unsafe.Pointer(cert)), uintptr(flags), uintptr(parameters), uintptr(unsafe.Pointer(cryptProvOrNCryptKey)), uintptr(unsafe.Pointer(keySpec)), uintptr(unsafe.Pointer(&_p0)))
1499 *callerFreeProvOrNCryptKey = _p0 != 0
1500 if r1 == 0 {
1501 err = errnoErr(e1)
1502 }
1503 return
1504}
1505
Jason A. Donenfeld4df39782021-01-22 14:23:17 +01001506func CryptDecodeObject(encodingType uint32, structType *byte, encodedBytes *byte, lenEncodedBytes uint32, flags uint32, decoded unsafe.Pointer, decodedLen *uint32) (err error) {
1507 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)
1508 if r1 == 0 {
1509 err = errnoErr(e1)
1510 }
1511 return
1512}
1513
Jason A. Donenfeld1d476972021-01-22 18:27:41 +01001514func CryptProtectData(dataIn *DataBlob, name *uint16, optionalEntropy *DataBlob, reserved uintptr, promptStruct *CryptProtectPromptStruct, flags uint32, dataOut *DataBlob) (err error) {
1515 r1, _, e1 := syscall.Syscall9(procCryptProtectData.Addr(), 7, uintptr(unsafe.Pointer(dataIn)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(optionalEntropy)), uintptr(reserved), uintptr(unsafe.Pointer(promptStruct)), uintptr(flags), uintptr(unsafe.Pointer(dataOut)), 0, 0)
1516 if r1 == 0 {
1517 err = errnoErr(e1)
1518 }
1519 return
1520}
1521
Jason A. Donenfeld4df39782021-01-22 14:23:17 +01001522func 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) {
1523 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)
1524 if r1 == 0 {
1525 err = errnoErr(e1)
1526 }
1527 return
1528}
1529
Jason A. Donenfeld1d476972021-01-22 18:27:41 +01001530func CryptUnprotectData(dataIn *DataBlob, name **uint16, optionalEntropy *DataBlob, reserved uintptr, promptStruct *CryptProtectPromptStruct, flags uint32, dataOut *DataBlob) (err error) {
1531 r1, _, e1 := syscall.Syscall9(procCryptUnprotectData.Addr(), 7, uintptr(unsafe.Pointer(dataIn)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(optionalEntropy)), uintptr(reserved), uintptr(unsafe.Pointer(promptStruct)), uintptr(flags), uintptr(unsafe.Pointer(dataOut)), 0, 0)
1532 if r1 == 0 {
1533 err = errnoErr(e1)
1534 }
1535 return
1536}
1537
Boshi LIAN2d187342020-12-31 18:09:48 +00001538func PFXImportCertStore(pfx *CryptDataBlob, password *uint16, flags uint32) (store Handle, err error) {
1539 r0, _, e1 := syscall.Syscall(procPFXImportCertStore.Addr(), 3, uintptr(unsafe.Pointer(pfx)), uintptr(unsafe.Pointer(password)), uintptr(flags))
1540 store = Handle(r0)
1541 if store == 0 {
1542 err = errnoErr(e1)
1543 }
1544 return
1545}
1546
Alex Brainman0aaa2712020-10-11 09:49:28 +11001547func DnsNameCompare(name1 *uint16, name2 *uint16) (same bool) {
1548 r0, _, _ := syscall.Syscall(procDnsNameCompare_W.Addr(), 2, uintptr(unsafe.Pointer(name1)), uintptr(unsafe.Pointer(name2)), 0)
1549 same = r0 != 0
1550 return
1551}
1552
1553func DnsQuery(name string, qtype uint16, options uint32, extra *byte, qrs **DNSRecord, pr *byte) (status error) {
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -06001554 var _p0 *uint16
Alex Brainman0aaa2712020-10-11 09:49:28 +11001555 _p0, status = syscall.UTF16PtrFromString(name)
1556 if status != nil {
1557 return
1558 }
1559 return _DnsQuery(_p0, qtype, options, extra, qrs, pr)
1560}
1561
1562func _DnsQuery(name *uint16, qtype uint16, options uint32, extra *byte, qrs **DNSRecord, pr *byte) (status error) {
1563 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)))
1564 if r0 != 0 {
1565 status = syscall.Errno(r0)
1566 }
1567 return
1568}
1569
1570func DnsRecordListFree(rl *DNSRecord, freetype uint32) {
1571 syscall.Syscall(procDnsRecordListFree.Addr(), 2, uintptr(unsafe.Pointer(rl)), uintptr(freetype), 0)
1572 return
1573}
1574
Michael Lellifb04ddd2022-09-17 22:48:29 +00001575func DwmGetWindowAttribute(hwnd HWND, attribute uint32, value unsafe.Pointer, size uint32) (ret error) {
1576 r0, _, _ := syscall.Syscall6(procDwmGetWindowAttribute.Addr(), 4, uintptr(hwnd), uintptr(attribute), uintptr(value), uintptr(size), 0, 0)
1577 if r0 != 0 {
1578 ret = syscall.Errno(r0)
1579 }
1580 return
1581}
1582
1583func DwmSetWindowAttribute(hwnd HWND, attribute uint32, value unsafe.Pointer, size uint32) (ret error) {
1584 r0, _, _ := syscall.Syscall6(procDwmSetWindowAttribute.Addr(), 4, uintptr(hwnd), uintptr(attribute), uintptr(value), uintptr(size), 0, 0)
1585 if r0 != 0 {
1586 ret = syscall.Errno(r0)
1587 }
1588 return
1589}
1590
Alex Brainman0aaa2712020-10-11 09:49:28 +11001591func GetAdaptersAddresses(family uint32, flags uint32, reserved uintptr, adapterAddresses *IpAdapterAddresses, sizePointer *uint32) (errcode error) {
1592 r0, _, _ := syscall.Syscall6(procGetAdaptersAddresses.Addr(), 5, uintptr(family), uintptr(flags), uintptr(reserved), uintptr(unsafe.Pointer(adapterAddresses)), uintptr(unsafe.Pointer(sizePointer)), 0)
1593 if r0 != 0 {
1594 errcode = syscall.Errno(r0)
1595 }
1596 return
1597}
1598
1599func GetAdaptersInfo(ai *IpAdapterInfo, ol *uint32) (errcode error) {
1600 r0, _, _ := syscall.Syscall(procGetAdaptersInfo.Addr(), 2, uintptr(unsafe.Pointer(ai)), uintptr(unsafe.Pointer(ol)), 0)
1601 if r0 != 0 {
1602 errcode = syscall.Errno(r0)
1603 }
1604 return
1605}
1606
Dan Kortschak179beb02022-06-24 17:17:25 +09301607func getBestInterfaceEx(sockaddr unsafe.Pointer, pdwBestIfIndex *uint32) (errcode error) {
1608 r0, _, _ := syscall.Syscall(procGetBestInterfaceEx.Addr(), 2, uintptr(sockaddr), uintptr(unsafe.Pointer(pdwBestIfIndex)), 0)
1609 if r0 != 0 {
1610 errcode = syscall.Errno(r0)
1611 }
1612 return
1613}
1614
Alex Brainman0aaa2712020-10-11 09:49:28 +11001615func GetIfEntry(pIfRow *MibIfRow) (errcode error) {
1616 r0, _, _ := syscall.Syscall(procGetIfEntry.Addr(), 1, uintptr(unsafe.Pointer(pIfRow)), 0, 0)
1617 if r0 != 0 {
1618 errcode = syscall.Errno(r0)
1619 }
1620 return
1621}
1622
Roland Shoemaker11eadc02023-11-08 11:08:03 -08001623func AddDllDirectory(path *uint16) (cookie uintptr, err error) {
1624 r0, _, e1 := syscall.Syscall(procAddDllDirectory.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0)
1625 cookie = uintptr(r0)
1626 if cookie == 0 {
1627 err = errnoErr(e1)
1628 }
1629 return
1630}
1631
Alex Brainman0aaa2712020-10-11 09:49:28 +11001632func AssignProcessToJobObject(job Handle, process Handle) (err error) {
1633 r1, _, e1 := syscall.Syscall(procAssignProcessToJobObject.Addr(), 2, uintptr(job), uintptr(process), 0)
1634 if r1 == 0 {
1635 err = errnoErr(e1)
1636 }
1637 return
1638}
1639
1640func CancelIo(s Handle) (err error) {
1641 r1, _, e1 := syscall.Syscall(procCancelIo.Addr(), 1, uintptr(s), 0, 0)
1642 if r1 == 0 {
1643 err = errnoErr(e1)
1644 }
1645 return
1646}
1647
1648func CancelIoEx(s Handle, o *Overlapped) (err error) {
1649 r1, _, e1 := syscall.Syscall(procCancelIoEx.Addr(), 2, uintptr(s), uintptr(unsafe.Pointer(o)), 0)
1650 if r1 == 0 {
1651 err = errnoErr(e1)
1652 }
1653 return
1654}
1655
Tom Payne1a50d972024-03-31 22:00:41 +00001656func ClearCommBreak(handle Handle) (err error) {
1657 r1, _, e1 := syscall.Syscall(procClearCommBreak.Addr(), 1, uintptr(handle), 0, 0)
1658 if r1 == 0 {
1659 err = errnoErr(e1)
1660 }
1661 return
1662}
1663
1664func ClearCommError(handle Handle, lpErrors *uint32, lpStat *ComStat) (err error) {
1665 r1, _, e1 := syscall.Syscall(procClearCommError.Addr(), 3, uintptr(handle), uintptr(unsafe.Pointer(lpErrors)), uintptr(unsafe.Pointer(lpStat)))
1666 if r1 == 0 {
1667 err = errnoErr(e1)
1668 }
1669 return
1670}
1671
Alex Brainman0aaa2712020-10-11 09:49:28 +11001672func CloseHandle(handle Handle) (err error) {
1673 r1, _, e1 := syscall.Syscall(procCloseHandle.Addr(), 1, uintptr(handle), 0, 0)
1674 if r1 == 0 {
1675 err = errnoErr(e1)
1676 }
1677 return
1678}
1679
Ayman Bagabas71c9d872023-09-26 15:53:15 +00001680func ClosePseudoConsole(console Handle) {
1681 syscall.Syscall(procClosePseudoConsole.Addr(), 1, uintptr(console), 0, 0)
1682 return
1683}
1684
Jason A. Donenfeld7b4935e2021-03-03 14:05:15 +01001685func ConnectNamedPipe(pipe Handle, overlapped *Overlapped) (err error) {
1686 r1, _, e1 := syscall.Syscall(procConnectNamedPipe.Addr(), 2, uintptr(pipe), uintptr(unsafe.Pointer(overlapped)), 0)
1687 if r1 == 0 {
1688 err = errnoErr(e1)
1689 }
1690 return
1691}
1692
Alex Brainman0aaa2712020-10-11 09:49:28 +11001693func CreateDirectory(path *uint16, sa *SecurityAttributes) (err error) {
1694 r1, _, e1 := syscall.Syscall(procCreateDirectoryW.Addr(), 2, uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(sa)), 0)
1695 if r1 == 0 {
1696 err = errnoErr(e1)
1697 }
1698 return
1699}
1700
1701func CreateEventEx(eventAttrs *SecurityAttributes, name *uint16, flags uint32, desiredAccess uint32) (handle Handle, err error) {
1702 r0, _, e1 := syscall.Syscall6(procCreateEventExW.Addr(), 4, uintptr(unsafe.Pointer(eventAttrs)), uintptr(unsafe.Pointer(name)), uintptr(flags), uintptr(desiredAccess), 0, 0)
1703 handle = Handle(r0)
Jason A. Donenfeld8fe3ee52021-02-28 20:49:10 +01001704 if handle == 0 || e1 == ERROR_ALREADY_EXISTS {
Alex Brainman0aaa2712020-10-11 09:49:28 +11001705 err = errnoErr(e1)
1706 }
1707 return
1708}
1709
1710func CreateEvent(eventAttrs *SecurityAttributes, manualReset uint32, initialState uint32, name *uint16) (handle Handle, err error) {
1711 r0, _, e1 := syscall.Syscall6(procCreateEventW.Addr(), 4, uintptr(unsafe.Pointer(eventAttrs)), uintptr(manualReset), uintptr(initialState), uintptr(unsafe.Pointer(name)), 0, 0)
1712 handle = Handle(r0)
Jason A. Donenfeld8fe3ee52021-02-28 20:49:10 +01001713 if handle == 0 || e1 == ERROR_ALREADY_EXISTS {
Alex Brainman0aaa2712020-10-11 09:49:28 +11001714 err = errnoErr(e1)
1715 }
1716 return
1717}
1718
1719func CreateFileMapping(fhandle Handle, sa *SecurityAttributes, prot uint32, maxSizeHigh uint32, maxSizeLow uint32, name *uint16) (handle Handle, err error) {
1720 r0, _, e1 := syscall.Syscall6(procCreateFileMappingW.Addr(), 6, uintptr(fhandle), uintptr(unsafe.Pointer(sa)), uintptr(prot), uintptr(maxSizeHigh), uintptr(maxSizeLow), uintptr(unsafe.Pointer(name)))
1721 handle = Handle(r0)
Jason A. Donenfeld8fe3ee52021-02-28 20:49:10 +01001722 if handle == 0 || e1 == ERROR_ALREADY_EXISTS {
Alex Brainman0aaa2712020-10-11 09:49:28 +11001723 err = errnoErr(e1)
1724 }
1725 return
1726}
1727
1728func CreateFile(name *uint16, access uint32, mode uint32, sa *SecurityAttributes, createmode uint32, attrs uint32, templatefile Handle) (handle Handle, err error) {
1729 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)
1730 handle = Handle(r0)
1731 if handle == InvalidHandle {
1732 err = errnoErr(e1)
1733 }
1734 return
1735}
1736
1737func CreateHardLink(filename *uint16, existingfilename *uint16, reserved uintptr) (err error) {
1738 r1, _, e1 := syscall.Syscall(procCreateHardLinkW.Addr(), 3, uintptr(unsafe.Pointer(filename)), uintptr(unsafe.Pointer(existingfilename)), uintptr(reserved))
1739 if r1&0xff == 0 {
1740 err = errnoErr(e1)
1741 }
1742 return
1743}
1744
Jason A. Donenfeld683adc92021-02-23 13:32:03 +01001745func CreateIoCompletionPort(filehandle Handle, cphandle Handle, key uintptr, threadcnt uint32) (handle Handle, err error) {
Alex Brainman0aaa2712020-10-11 09:49:28 +11001746 r0, _, e1 := syscall.Syscall6(procCreateIoCompletionPort.Addr(), 4, uintptr(filehandle), uintptr(cphandle), uintptr(key), uintptr(threadcnt), 0, 0)
1747 handle = Handle(r0)
1748 if handle == 0 {
1749 err = errnoErr(e1)
1750 }
1751 return
1752}
1753
1754func CreateJobObject(jobAttr *SecurityAttributes, name *uint16) (handle Handle, err error) {
1755 r0, _, e1 := syscall.Syscall(procCreateJobObjectW.Addr(), 2, uintptr(unsafe.Pointer(jobAttr)), uintptr(unsafe.Pointer(name)), 0)
1756 handle = Handle(r0)
1757 if handle == 0 {
1758 err = errnoErr(e1)
1759 }
1760 return
1761}
1762
1763func CreateMutexEx(mutexAttrs *SecurityAttributes, name *uint16, flags uint32, desiredAccess uint32) (handle Handle, err error) {
1764 r0, _, e1 := syscall.Syscall6(procCreateMutexExW.Addr(), 4, uintptr(unsafe.Pointer(mutexAttrs)), uintptr(unsafe.Pointer(name)), uintptr(flags), uintptr(desiredAccess), 0, 0)
1765 handle = Handle(r0)
Jason A. Donenfeld8fe3ee52021-02-28 20:49:10 +01001766 if handle == 0 || e1 == ERROR_ALREADY_EXISTS {
Alex Brainman0aaa2712020-10-11 09:49:28 +11001767 err = errnoErr(e1)
1768 }
1769 return
1770}
1771
1772func CreateMutex(mutexAttrs *SecurityAttributes, initialOwner bool, name *uint16) (handle Handle, err error) {
1773 var _p0 uint32
1774 if initialOwner {
1775 _p0 = 1
1776 }
1777 r0, _, e1 := syscall.Syscall(procCreateMutexW.Addr(), 3, uintptr(unsafe.Pointer(mutexAttrs)), uintptr(_p0), uintptr(unsafe.Pointer(name)))
1778 handle = Handle(r0)
Jason A. Donenfeld8fe3ee52021-02-28 20:49:10 +01001779 if handle == 0 || e1 == ERROR_ALREADY_EXISTS {
Alex Brainman0aaa2712020-10-11 09:49:28 +11001780 err = errnoErr(e1)
1781 }
1782 return
1783}
1784
Jason A. Donenfeld7b4935e2021-03-03 14:05:15 +01001785func CreateNamedPipe(name *uint16, flags uint32, pipeMode uint32, maxInstances uint32, outSize uint32, inSize uint32, defaultTimeout uint32, sa *SecurityAttributes) (handle Handle, err error) {
1786 r0, _, e1 := syscall.Syscall9(procCreateNamedPipeW.Addr(), 8, uintptr(unsafe.Pointer(name)), uintptr(flags), uintptr(pipeMode), uintptr(maxInstances), uintptr(outSize), uintptr(inSize), uintptr(defaultTimeout), uintptr(unsafe.Pointer(sa)), 0)
1787 handle = Handle(r0)
1788 if handle == InvalidHandle {
1789 err = errnoErr(e1)
1790 }
1791 return
1792}
1793
Alex Brainman0aaa2712020-10-11 09:49:28 +11001794func CreatePipe(readhandle *Handle, writehandle *Handle, sa *SecurityAttributes, size uint32) (err error) {
1795 r1, _, e1 := syscall.Syscall6(procCreatePipe.Addr(), 4, uintptr(unsafe.Pointer(readhandle)), uintptr(unsafe.Pointer(writehandle)), uintptr(unsafe.Pointer(sa)), uintptr(size), 0, 0)
1796 if r1 == 0 {
1797 err = errnoErr(e1)
1798 }
1799 return
1800}
1801
1802func CreateProcess(appName *uint16, commandLine *uint16, procSecurity *SecurityAttributes, threadSecurity *SecurityAttributes, inheritHandles bool, creationFlags uint32, env *uint16, currentDir *uint16, startupInfo *StartupInfo, outProcInfo *ProcessInformation) (err error) {
1803 var _p0 uint32
1804 if inheritHandles {
1805 _p0 = 1
1806 }
1807 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)
1808 if r1 == 0 {
1809 err = errnoErr(e1)
1810 }
1811 return
1812}
1813
Ayman Bagabas71c9d872023-09-26 15:53:15 +00001814func createPseudoConsole(size uint32, in Handle, out Handle, flags uint32, pconsole *Handle) (hr error) {
1815 r0, _, _ := syscall.Syscall6(procCreatePseudoConsole.Addr(), 5, uintptr(size), uintptr(in), uintptr(out), uintptr(flags), uintptr(unsafe.Pointer(pconsole)), 0)
1816 if r0 != 0 {
1817 hr = syscall.Errno(r0)
1818 }
1819 return
1820}
1821
Alex Brainman0aaa2712020-10-11 09:49:28 +11001822func CreateSymbolicLink(symlinkfilename *uint16, targetfilename *uint16, flags uint32) (err error) {
1823 r1, _, e1 := syscall.Syscall(procCreateSymbolicLinkW.Addr(), 3, uintptr(unsafe.Pointer(symlinkfilename)), uintptr(unsafe.Pointer(targetfilename)), uintptr(flags))
1824 if r1&0xff == 0 {
1825 err = errnoErr(e1)
1826 }
1827 return
1828}
1829
1830func CreateToolhelp32Snapshot(flags uint32, processId uint32) (handle Handle, err error) {
1831 r0, _, e1 := syscall.Syscall(procCreateToolhelp32Snapshot.Addr(), 2, uintptr(flags), uintptr(processId), 0)
1832 handle = Handle(r0)
1833 if handle == InvalidHandle {
1834 err = errnoErr(e1)
1835 }
1836 return
1837}
1838
1839func DefineDosDevice(flags uint32, deviceName *uint16, targetPath *uint16) (err error) {
1840 r1, _, e1 := syscall.Syscall(procDefineDosDeviceW.Addr(), 3, uintptr(flags), uintptr(unsafe.Pointer(deviceName)), uintptr(unsafe.Pointer(targetPath)))
1841 if r1 == 0 {
1842 err = errnoErr(e1)
1843 }
1844 return
1845}
1846
1847func DeleteFile(path *uint16) (err error) {
1848 r1, _, e1 := syscall.Syscall(procDeleteFileW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0)
1849 if r1 == 0 {
1850 err = errnoErr(e1)
1851 }
1852 return
1853}
1854
Jason A. Donenfeldf36f7822021-02-01 00:16:53 +01001855func deleteProcThreadAttributeList(attrlist *ProcThreadAttributeList) {
1856 syscall.Syscall(procDeleteProcThreadAttributeList.Addr(), 1, uintptr(unsafe.Pointer(attrlist)), 0, 0)
1857 return
1858}
1859
Alex Brainman0aaa2712020-10-11 09:49:28 +11001860func DeleteVolumeMountPoint(volumeMountPoint *uint16) (err error) {
1861 r1, _, e1 := syscall.Syscall(procDeleteVolumeMountPointW.Addr(), 1, uintptr(unsafe.Pointer(volumeMountPoint)), 0, 0)
1862 if r1 == 0 {
1863 err = errnoErr(e1)
1864 }
1865 return
1866}
1867
1868func DeviceIoControl(handle Handle, ioControlCode uint32, inBuffer *byte, inBufferSize uint32, outBuffer *byte, outBufferSize uint32, bytesReturned *uint32, overlapped *Overlapped) (err error) {
1869 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)
1870 if r1 == 0 {
1871 err = errnoErr(e1)
1872 }
1873 return
1874}
1875
Peter Hoogendijk95f07ec2024-03-10 14:49:55 +01001876func DisconnectNamedPipe(pipe Handle) (err error) {
1877 r1, _, e1 := syscall.Syscall(procDisconnectNamedPipe.Addr(), 1, uintptr(pipe), 0, 0)
1878 if r1 == 0 {
1879 err = errnoErr(e1)
1880 }
1881 return
1882}
1883
Alex Brainman0aaa2712020-10-11 09:49:28 +11001884func DuplicateHandle(hSourceProcessHandle Handle, hSourceHandle Handle, hTargetProcessHandle Handle, lpTargetHandle *Handle, dwDesiredAccess uint32, bInheritHandle bool, dwOptions uint32) (err error) {
1885 var _p0 uint32
1886 if bInheritHandle {
1887 _p0 = 1
1888 }
1889 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)
1890 if r1 == 0 {
1891 err = errnoErr(e1)
1892 }
1893 return
1894}
1895
Tom Payne1a50d972024-03-31 22:00:41 +00001896func EscapeCommFunction(handle Handle, dwFunc uint32) (err error) {
1897 r1, _, e1 := syscall.Syscall(procEscapeCommFunction.Addr(), 2, uintptr(handle), uintptr(dwFunc), 0)
1898 if r1 == 0 {
1899 err = errnoErr(e1)
1900 }
1901 return
1902}
1903
Alex Brainman0aaa2712020-10-11 09:49:28 +11001904func ExitProcess(exitcode uint32) {
1905 syscall.Syscall(procExitProcess.Addr(), 1, uintptr(exitcode), 0, 0)
1906 return
1907}
1908
Jason A. Donenfeldfe613092021-10-27 15:23:03 +02001909func ExpandEnvironmentStrings(src *uint16, dst *uint16, size uint32) (n uint32, err error) {
1910 r0, _, e1 := syscall.Syscall(procExpandEnvironmentStringsW.Addr(), 3, uintptr(unsafe.Pointer(src)), uintptr(unsafe.Pointer(dst)), uintptr(size))
1911 n = uint32(r0)
1912 if n == 0 {
1913 err = errnoErr(e1)
1914 }
1915 return
1916}
1917
Alex Brainman0aaa2712020-10-11 09:49:28 +11001918func FindClose(handle Handle) (err error) {
1919 r1, _, e1 := syscall.Syscall(procFindClose.Addr(), 1, uintptr(handle), 0, 0)
1920 if r1 == 0 {
1921 err = errnoErr(e1)
1922 }
1923 return
1924}
1925
Jason A. Donenfelda8b976e2021-01-22 14:20:47 +01001926func FindCloseChangeNotification(handle Handle) (err error) {
1927 r1, _, e1 := syscall.Syscall(procFindCloseChangeNotification.Addr(), 1, uintptr(handle), 0, 0)
1928 if r1 == 0 {
1929 err = errnoErr(e1)
1930 }
1931 return
1932}
1933
1934func FindFirstChangeNotification(path string, watchSubtree bool, notifyFilter uint32) (handle Handle, err error) {
1935 var _p0 *uint16
1936 _p0, err = syscall.UTF16PtrFromString(path)
1937 if err != nil {
1938 return
1939 }
1940 return _FindFirstChangeNotification(_p0, watchSubtree, notifyFilter)
1941}
1942
1943func _FindFirstChangeNotification(path *uint16, watchSubtree bool, notifyFilter uint32) (handle Handle, err error) {
1944 var _p1 uint32
1945 if watchSubtree {
1946 _p1 = 1
1947 }
1948 r0, _, e1 := syscall.Syscall(procFindFirstChangeNotificationW.Addr(), 3, uintptr(unsafe.Pointer(path)), uintptr(_p1), uintptr(notifyFilter))
1949 handle = Handle(r0)
1950 if handle == InvalidHandle {
1951 err = errnoErr(e1)
1952 }
1953 return
1954}
1955
Alex Brainman0aaa2712020-10-11 09:49:28 +11001956func findFirstFile1(name *uint16, data *win32finddata1) (handle Handle, err error) {
1957 r0, _, e1 := syscall.Syscall(procFindFirstFileW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(data)), 0)
1958 handle = Handle(r0)
1959 if handle == InvalidHandle {
1960 err = errnoErr(e1)
1961 }
1962 return
1963}
1964
1965func FindFirstVolumeMountPoint(rootPathName *uint16, volumeMountPoint *uint16, bufferLength uint32) (handle Handle, err error) {
1966 r0, _, e1 := syscall.Syscall(procFindFirstVolumeMountPointW.Addr(), 3, uintptr(unsafe.Pointer(rootPathName)), uintptr(unsafe.Pointer(volumeMountPoint)), uintptr(bufferLength))
1967 handle = Handle(r0)
1968 if handle == InvalidHandle {
1969 err = errnoErr(e1)
1970 }
1971 return
1972}
1973
1974func FindFirstVolume(volumeName *uint16, bufferLength uint32) (handle Handle, err error) {
1975 r0, _, e1 := syscall.Syscall(procFindFirstVolumeW.Addr(), 2, uintptr(unsafe.Pointer(volumeName)), uintptr(bufferLength), 0)
1976 handle = Handle(r0)
1977 if handle == InvalidHandle {
1978 err = errnoErr(e1)
1979 }
1980 return
1981}
1982
Jason A. Donenfelda8b976e2021-01-22 14:20:47 +01001983func FindNextChangeNotification(handle Handle) (err error) {
1984 r1, _, e1 := syscall.Syscall(procFindNextChangeNotification.Addr(), 1, uintptr(handle), 0, 0)
1985 if r1 == 0 {
1986 err = errnoErr(e1)
1987 }
1988 return
1989}
1990
Alex Brainman0aaa2712020-10-11 09:49:28 +11001991func findNextFile1(handle Handle, data *win32finddata1) (err error) {
1992 r1, _, e1 := syscall.Syscall(procFindNextFileW.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(data)), 0)
1993 if r1 == 0 {
1994 err = errnoErr(e1)
1995 }
1996 return
1997}
1998
1999func FindNextVolumeMountPoint(findVolumeMountPoint Handle, volumeMountPoint *uint16, bufferLength uint32) (err error) {
2000 r1, _, e1 := syscall.Syscall(procFindNextVolumeMountPointW.Addr(), 3, uintptr(findVolumeMountPoint), uintptr(unsafe.Pointer(volumeMountPoint)), uintptr(bufferLength))
2001 if r1 == 0 {
2002 err = errnoErr(e1)
2003 }
2004 return
2005}
2006
2007func FindNextVolume(findVolume Handle, volumeName *uint16, bufferLength uint32) (err error) {
2008 r1, _, e1 := syscall.Syscall(procFindNextVolumeW.Addr(), 3, uintptr(findVolume), uintptr(unsafe.Pointer(volumeName)), uintptr(bufferLength))
2009 if r1 == 0 {
2010 err = errnoErr(e1)
2011 }
2012 return
2013}
2014
Jason A. Donenfeldf9bc61c2021-03-03 15:00:01 +01002015func findResource(module Handle, name uintptr, resType uintptr) (resInfo Handle, err error) {
2016 r0, _, e1 := syscall.Syscall(procFindResourceW.Addr(), 3, uintptr(module), uintptr(name), uintptr(resType))
2017 resInfo = Handle(r0)
2018 if resInfo == 0 {
2019 err = errnoErr(e1)
2020 }
2021 return
2022}
2023
Alex Brainman0aaa2712020-10-11 09:49:28 +11002024func FindVolumeClose(findVolume Handle) (err error) {
2025 r1, _, e1 := syscall.Syscall(procFindVolumeClose.Addr(), 1, uintptr(findVolume), 0, 0)
2026 if r1 == 0 {
2027 err = errnoErr(e1)
2028 }
2029 return
2030}
2031
2032func FindVolumeMountPointClose(findVolumeMountPoint Handle) (err error) {
2033 r1, _, e1 := syscall.Syscall(procFindVolumeMountPointClose.Addr(), 1, uintptr(findVolumeMountPoint), 0, 0)
2034 if r1 == 0 {
2035 err = errnoErr(e1)
2036 }
2037 return
2038}
2039
2040func FlushFileBuffers(handle Handle) (err error) {
2041 r1, _, e1 := syscall.Syscall(procFlushFileBuffers.Addr(), 1, uintptr(handle), 0, 0)
2042 if r1 == 0 {
2043 err = errnoErr(e1)
2044 }
2045 return
2046}
2047
2048func FlushViewOfFile(addr uintptr, length uintptr) (err error) {
2049 r1, _, e1 := syscall.Syscall(procFlushViewOfFile.Addr(), 2, uintptr(addr), uintptr(length), 0)
2050 if r1 == 0 {
2051 err = errnoErr(e1)
2052 }
2053 return
2054}
2055
2056func FormatMessage(flags uint32, msgsrc uintptr, msgid uint32, langid uint32, buf []uint16, args *byte) (n uint32, err error) {
2057 var _p0 *uint16
2058 if len(buf) > 0 {
2059 _p0 = &buf[0]
2060 }
2061 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)
2062 n = uint32(r0)
2063 if n == 0 {
2064 err = errnoErr(e1)
2065 }
2066 return
2067}
2068
2069func FreeEnvironmentStrings(envs *uint16) (err error) {
2070 r1, _, e1 := syscall.Syscall(procFreeEnvironmentStringsW.Addr(), 1, uintptr(unsafe.Pointer(envs)), 0, 0)
2071 if r1 == 0 {
2072 err = errnoErr(e1)
2073 }
2074 return
2075}
2076
2077func FreeLibrary(handle Handle) (err error) {
2078 r1, _, e1 := syscall.Syscall(procFreeLibrary.Addr(), 1, uintptr(handle), 0, 0)
2079 if r1 == 0 {
2080 err = errnoErr(e1)
2081 }
2082 return
2083}
2084
2085func GenerateConsoleCtrlEvent(ctrlEvent uint32, processGroupID uint32) (err error) {
2086 r1, _, e1 := syscall.Syscall(procGenerateConsoleCtrlEvent.Addr(), 2, uintptr(ctrlEvent), uintptr(processGroupID), 0)
2087 if r1 == 0 {
2088 err = errnoErr(e1)
2089 }
2090 return
2091}
2092
2093func GetACP() (acp uint32) {
2094 r0, _, _ := syscall.Syscall(procGetACP.Addr(), 0, 0, 0, 0)
2095 acp = uint32(r0)
2096 return
2097}
2098
Tobias Klauser5a964db2022-01-05 12:16:54 +01002099func GetActiveProcessorCount(groupNumber uint16) (ret uint32) {
2100 r0, _, _ := syscall.Syscall(procGetActiveProcessorCount.Addr(), 1, uintptr(groupNumber), 0, 0)
2101 ret = uint32(r0)
2102 return
2103}
2104
Tom Payne1a50d972024-03-31 22:00:41 +00002105func GetCommModemStatus(handle Handle, lpModemStat *uint32) (err error) {
2106 r1, _, e1 := syscall.Syscall(procGetCommModemStatus.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(lpModemStat)), 0)
2107 if r1 == 0 {
2108 err = errnoErr(e1)
2109 }
2110 return
2111}
2112
2113func GetCommState(handle Handle, lpDCB *DCB) (err error) {
2114 r1, _, e1 := syscall.Syscall(procGetCommState.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(lpDCB)), 0)
2115 if r1 == 0 {
2116 err = errnoErr(e1)
2117 }
2118 return
2119}
2120
Tobias Kohlbau479acdf2021-02-06 08:58:28 +01002121func GetCommTimeouts(handle Handle, timeouts *CommTimeouts) (err error) {
2122 r1, _, e1 := syscall.Syscall(procGetCommTimeouts.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(timeouts)), 0)
2123 if r1 == 0 {
2124 err = errnoErr(e1)
2125 }
2126 return
2127}
2128
Alex Brainman0aaa2712020-10-11 09:49:28 +11002129func GetCommandLine() (cmd *uint16) {
2130 r0, _, _ := syscall.Syscall(procGetCommandLineW.Addr(), 0, 0, 0, 0)
2131 cmd = (*uint16)(unsafe.Pointer(r0))
2132 return
2133}
2134
2135func GetComputerNameEx(nametype uint32, buf *uint16, n *uint32) (err error) {
2136 r1, _, e1 := syscall.Syscall(procGetComputerNameExW.Addr(), 3, uintptr(nametype), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(n)))
2137 if r1 == 0 {
2138 err = errnoErr(e1)
2139 }
2140 return
2141}
2142
2143func GetComputerName(buf *uint16, n *uint32) (err error) {
2144 r1, _, e1 := syscall.Syscall(procGetComputerNameW.Addr(), 2, uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(n)), 0)
2145 if r1 == 0 {
2146 err = errnoErr(e1)
2147 }
2148 return
2149}
2150
2151func GetConsoleMode(console Handle, mode *uint32) (err error) {
2152 r1, _, e1 := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(console), uintptr(unsafe.Pointer(mode)), 0)
2153 if r1 == 0 {
2154 err = errnoErr(e1)
2155 }
2156 return
2157}
2158
2159func GetConsoleScreenBufferInfo(console Handle, info *ConsoleScreenBufferInfo) (err error) {
2160 r1, _, e1 := syscall.Syscall(procGetConsoleScreenBufferInfo.Addr(), 2, uintptr(console), uintptr(unsafe.Pointer(info)), 0)
2161 if r1 == 0 {
2162 err = errnoErr(e1)
2163 }
2164 return
2165}
2166
2167func GetCurrentDirectory(buflen uint32, buf *uint16) (n uint32, err error) {
2168 r0, _, e1 := syscall.Syscall(procGetCurrentDirectoryW.Addr(), 2, uintptr(buflen), uintptr(unsafe.Pointer(buf)), 0)
2169 n = uint32(r0)
2170 if n == 0 {
2171 err = errnoErr(e1)
2172 }
2173 return
2174}
2175
2176func GetCurrentProcessId() (pid uint32) {
2177 r0, _, _ := syscall.Syscall(procGetCurrentProcessId.Addr(), 0, 0, 0, 0)
2178 pid = uint32(r0)
2179 return
2180}
2181
2182func GetCurrentThreadId() (id uint32) {
2183 r0, _, _ := syscall.Syscall(procGetCurrentThreadId.Addr(), 0, 0, 0, 0)
2184 id = uint32(r0)
2185 return
2186}
2187
2188func GetDiskFreeSpaceEx(directoryName *uint16, freeBytesAvailableToCaller *uint64, totalNumberOfBytes *uint64, totalNumberOfFreeBytes *uint64) (err error) {
2189 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)
2190 if r1 == 0 {
2191 err = errnoErr(e1)
2192 }
2193 return
2194}
2195
2196func GetDriveType(rootPathName *uint16) (driveType uint32) {
2197 r0, _, _ := syscall.Syscall(procGetDriveTypeW.Addr(), 1, uintptr(unsafe.Pointer(rootPathName)), 0, 0)
2198 driveType = uint32(r0)
2199 return
2200}
2201
2202func GetEnvironmentStrings() (envs *uint16, err error) {
2203 r0, _, e1 := syscall.Syscall(procGetEnvironmentStringsW.Addr(), 0, 0, 0, 0)
2204 envs = (*uint16)(unsafe.Pointer(r0))
2205 if envs == nil {
2206 err = errnoErr(e1)
2207 }
2208 return
2209}
2210
2211func GetEnvironmentVariable(name *uint16, buffer *uint16, size uint32) (n uint32, err error) {
2212 r0, _, e1 := syscall.Syscall(procGetEnvironmentVariableW.Addr(), 3, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(buffer)), uintptr(size))
2213 n = uint32(r0)
2214 if n == 0 {
2215 err = errnoErr(e1)
2216 }
2217 return
2218}
2219
2220func GetExitCodeProcess(handle Handle, exitcode *uint32) (err error) {
2221 r1, _, e1 := syscall.Syscall(procGetExitCodeProcess.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(exitcode)), 0)
2222 if r1 == 0 {
2223 err = errnoErr(e1)
2224 }
2225 return
2226}
2227
2228func GetFileAttributesEx(name *uint16, level uint32, info *byte) (err error) {
2229 r1, _, e1 := syscall.Syscall(procGetFileAttributesExW.Addr(), 3, uintptr(unsafe.Pointer(name)), uintptr(level), uintptr(unsafe.Pointer(info)))
2230 if r1 == 0 {
2231 err = errnoErr(e1)
2232 }
2233 return
2234}
2235
2236func GetFileAttributes(name *uint16) (attrs uint32, err error) {
2237 r0, _, e1 := syscall.Syscall(procGetFileAttributesW.Addr(), 1, uintptr(unsafe.Pointer(name)), 0, 0)
2238 attrs = uint32(r0)
2239 if attrs == INVALID_FILE_ATTRIBUTES {
2240 err = errnoErr(e1)
2241 }
2242 return
2243}
2244
2245func GetFileInformationByHandle(handle Handle, data *ByHandleFileInformation) (err error) {
2246 r1, _, e1 := syscall.Syscall(procGetFileInformationByHandle.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(data)), 0)
2247 if r1 == 0 {
2248 err = errnoErr(e1)
2249 }
2250 return
2251}
2252
2253func GetFileInformationByHandleEx(handle Handle, class uint32, outBuffer *byte, outBufferLen uint32) (err error) {
2254 r1, _, e1 := syscall.Syscall6(procGetFileInformationByHandleEx.Addr(), 4, uintptr(handle), uintptr(class), uintptr(unsafe.Pointer(outBuffer)), uintptr(outBufferLen), 0, 0)
2255 if r1 == 0 {
2256 err = errnoErr(e1)
2257 }
2258 return
2259}
2260
AN Long8ccaaf02023-09-13 14:24:41 +00002261func GetFileTime(handle Handle, ctime *Filetime, atime *Filetime, wtime *Filetime) (err error) {
2262 r1, _, e1 := syscall.Syscall6(procGetFileTime.Addr(), 4, uintptr(handle), uintptr(unsafe.Pointer(ctime)), uintptr(unsafe.Pointer(atime)), uintptr(unsafe.Pointer(wtime)), 0, 0)
2263 if r1 == 0 {
2264 err = errnoErr(e1)
2265 }
2266 return
2267}
2268
Alex Brainman0aaa2712020-10-11 09:49:28 +11002269func GetFileType(filehandle Handle) (n uint32, err error) {
2270 r0, _, e1 := syscall.Syscall(procGetFileType.Addr(), 1, uintptr(filehandle), 0, 0)
2271 n = uint32(r0)
2272 if n == 0 {
2273 err = errnoErr(e1)
2274 }
2275 return
2276}
2277
Jason A. Donenfeldcc9327a2020-11-16 17:45:47 +01002278func GetFinalPathNameByHandle(file Handle, filePath *uint16, filePathSize uint32, flags uint32) (n uint32, err error) {
Meng Zhuo35185872020-10-28 14:35:39 +08002279 r0, _, e1 := syscall.Syscall6(procGetFinalPathNameByHandleW.Addr(), 4, uintptr(file), uintptr(unsafe.Pointer(filePath)), uintptr(filePathSize), uintptr(flags), 0, 0)
2280 n = uint32(r0)
2281 if n == 0 {
2282 err = errnoErr(e1)
2283 }
2284 return
2285}
2286
Alex Brainman0aaa2712020-10-11 09:49:28 +11002287func GetFullPathName(path *uint16, buflen uint32, buf *uint16, fname **uint16) (n uint32, err error) {
2288 r0, _, e1 := syscall.Syscall6(procGetFullPathNameW.Addr(), 4, uintptr(unsafe.Pointer(path)), uintptr(buflen), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(fname)), 0, 0)
2289 n = uint32(r0)
2290 if n == 0 {
2291 err = errnoErr(e1)
2292 }
2293 return
2294}
2295
Johan Jansson3ca3b182022-10-23 12:59:07 +03002296func GetLargePageMinimum() (size uintptr) {
2297 r0, _, _ := syscall.Syscall(procGetLargePageMinimum.Addr(), 0, 0, 0, 0)
2298 size = uintptr(r0)
2299 return
2300}
2301
Alex Brainman0aaa2712020-10-11 09:49:28 +11002302func GetLastError() (lasterr error) {
2303 r0, _, _ := syscall.Syscall(procGetLastError.Addr(), 0, 0, 0, 0)
2304 if r0 != 0 {
2305 lasterr = syscall.Errno(r0)
2306 }
2307 return
2308}
2309
2310func GetLogicalDriveStrings(bufferLength uint32, buffer *uint16) (n uint32, err error) {
2311 r0, _, e1 := syscall.Syscall(procGetLogicalDriveStringsW.Addr(), 2, uintptr(bufferLength), uintptr(unsafe.Pointer(buffer)), 0)
2312 n = uint32(r0)
2313 if n == 0 {
2314 err = errnoErr(e1)
2315 }
2316 return
2317}
2318
2319func GetLogicalDrives() (drivesBitMask uint32, err error) {
2320 r0, _, e1 := syscall.Syscall(procGetLogicalDrives.Addr(), 0, 0, 0, 0)
2321 drivesBitMask = uint32(r0)
2322 if drivesBitMask == 0 {
2323 err = errnoErr(e1)
2324 }
2325 return
2326}
2327
2328func GetLongPathName(path *uint16, buf *uint16, buflen uint32) (n uint32, err error) {
2329 r0, _, e1 := syscall.Syscall(procGetLongPathNameW.Addr(), 3, uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(buf)), uintptr(buflen))
2330 n = uint32(r0)
2331 if n == 0 {
2332 err = errnoErr(e1)
2333 }
2334 return
2335}
2336
Tobias Klauser5a964db2022-01-05 12:16:54 +01002337func GetMaximumProcessorCount(groupNumber uint16) (ret uint32) {
2338 r0, _, _ := syscall.Syscall(procGetMaximumProcessorCount.Addr(), 1, uintptr(groupNumber), 0, 0)
2339 ret = uint32(r0)
2340 return
2341}
2342
Alex Brainman0aaa2712020-10-11 09:49:28 +11002343func GetModuleFileName(module Handle, filename *uint16, size uint32) (n uint32, err error) {
2344 r0, _, e1 := syscall.Syscall(procGetModuleFileNameW.Addr(), 3, uintptr(module), uintptr(unsafe.Pointer(filename)), uintptr(size))
2345 n = uint32(r0)
2346 if n == 0 {
2347 err = errnoErr(e1)
2348 }
2349 return
2350}
2351
2352func GetModuleHandleEx(flags uint32, moduleName *uint16, module *Handle) (err error) {
2353 r1, _, e1 := syscall.Syscall(procGetModuleHandleExW.Addr(), 3, uintptr(flags), uintptr(unsafe.Pointer(moduleName)), uintptr(unsafe.Pointer(module)))
2354 if r1 == 0 {
2355 err = errnoErr(e1)
2356 }
2357 return
2358}
2359
Jason A. Donenfeld7b4935e2021-03-03 14:05:15 +01002360func GetNamedPipeHandleState(pipe Handle, state *uint32, curInstances *uint32, maxCollectionCount *uint32, collectDataTimeout *uint32, userName *uint16, maxUserNameSize uint32) (err error) {
2361 r1, _, e1 := syscall.Syscall9(procGetNamedPipeHandleStateW.Addr(), 7, uintptr(pipe), uintptr(unsafe.Pointer(state)), uintptr(unsafe.Pointer(curInstances)), uintptr(unsafe.Pointer(maxCollectionCount)), uintptr(unsafe.Pointer(collectDataTimeout)), uintptr(unsafe.Pointer(userName)), uintptr(maxUserNameSize), 0, 0)
2362 if r1 == 0 {
2363 err = errnoErr(e1)
2364 }
2365 return
2366}
2367
2368func GetNamedPipeInfo(pipe Handle, flags *uint32, outSize *uint32, inSize *uint32, maxInstances *uint32) (err error) {
2369 r1, _, e1 := syscall.Syscall6(procGetNamedPipeInfo.Addr(), 5, uintptr(pipe), uintptr(unsafe.Pointer(flags)), uintptr(unsafe.Pointer(outSize)), uintptr(unsafe.Pointer(inSize)), uintptr(unsafe.Pointer(maxInstances)), 0)
2370 if r1 == 0 {
2371 err = errnoErr(e1)
2372 }
2373 return
2374}
2375
Alex Brainman0aaa2712020-10-11 09:49:28 +11002376func GetOverlappedResult(handle Handle, overlapped *Overlapped, done *uint32, wait bool) (err error) {
2377 var _p0 uint32
2378 if wait {
2379 _p0 = 1
2380 }
2381 r1, _, e1 := syscall.Syscall6(procGetOverlappedResult.Addr(), 4, uintptr(handle), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(done)), uintptr(_p0), 0, 0)
2382 if r1 == 0 {
2383 err = errnoErr(e1)
2384 }
2385 return
2386}
2387
2388func GetPriorityClass(process Handle) (ret uint32, err error) {
2389 r0, _, e1 := syscall.Syscall(procGetPriorityClass.Addr(), 1, uintptr(process), 0, 0)
2390 ret = uint32(r0)
2391 if ret == 0 {
2392 err = errnoErr(e1)
2393 }
2394 return
2395}
2396
2397func GetProcAddress(module Handle, procname string) (proc uintptr, err error) {
2398 var _p0 *byte
2399 _p0, err = syscall.BytePtrFromString(procname)
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -06002400 if err != nil {
2401 return
2402 }
Alex Brainman0aaa2712020-10-11 09:49:28 +11002403 return _GetProcAddress(module, _p0)
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -06002404}
2405
Alex Brainman0aaa2712020-10-11 09:49:28 +11002406func _GetProcAddress(module Handle, procname *byte) (proc uintptr, err error) {
2407 r0, _, e1 := syscall.Syscall(procGetProcAddress.Addr(), 2, uintptr(module), uintptr(unsafe.Pointer(procname)), 0)
2408 proc = uintptr(r0)
2409 if proc == 0 {
2410 err = errnoErr(e1)
2411 }
2412 return
2413}
2414
2415func GetProcessId(process Handle) (id uint32, err error) {
2416 r0, _, e1 := syscall.Syscall(procGetProcessId.Addr(), 1, uintptr(process), 0, 0)
2417 id = uint32(r0)
2418 if id == 0 {
2419 err = errnoErr(e1)
2420 }
2421 return
2422}
2423
2424func getProcessPreferredUILanguages(flags uint32, numLanguages *uint32, buf *uint16, bufSize *uint32) (err error) {
2425 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 -06002426 if r1 == 0 {
Sebastiaan van Stijndfb3f7c2020-10-09 00:24:30 +00002427 err = errnoErr(e1)
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -06002428 }
2429 return
2430}
2431
Alex Brainman0aaa2712020-10-11 09:49:28 +11002432func GetProcessShutdownParameters(level *uint32, flags *uint32) (err error) {
2433 r1, _, e1 := syscall.Syscall(procGetProcessShutdownParameters.Addr(), 2, uintptr(unsafe.Pointer(level)), uintptr(unsafe.Pointer(flags)), 0)
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -06002434 if r1 == 0 {
Sebastiaan van Stijndfb3f7c2020-10-09 00:24:30 +00002435 err = errnoErr(e1)
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -06002436 }
2437 return
2438}
2439
Alex Brainman0aaa2712020-10-11 09:49:28 +11002440func GetProcessTimes(handle Handle, creationTime *Filetime, exitTime *Filetime, kernelTime *Filetime, userTime *Filetime) (err error) {
2441 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 -06002442 if r1 == 0 {
Sebastiaan van Stijndfb3f7c2020-10-09 00:24:30 +00002443 err = errnoErr(e1)
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -06002444 }
2445 return
2446}
2447
Alex Brainman0aaa2712020-10-11 09:49:28 +11002448func GetProcessWorkingSetSizeEx(hProcess Handle, lpMinimumWorkingSetSize *uintptr, lpMaximumWorkingSetSize *uintptr, flags *uint32) {
2449 syscall.Syscall6(procGetProcessWorkingSetSizeEx.Addr(), 4, uintptr(hProcess), uintptr(unsafe.Pointer(lpMinimumWorkingSetSize)), uintptr(unsafe.Pointer(lpMaximumWorkingSetSize)), uintptr(unsafe.Pointer(flags)), 0, 0)
2450 return
2451}
2452
Jason A. Donenfeld683adc92021-02-23 13:32:03 +01002453func GetQueuedCompletionStatus(cphandle Handle, qty *uint32, key *uintptr, overlapped **Overlapped, timeout uint32) (err error) {
Alex Brainman0aaa2712020-10-11 09:49:28 +11002454 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 -06002455 if r1 == 0 {
Sebastiaan van Stijndfb3f7c2020-10-09 00:24:30 +00002456 err = errnoErr(e1)
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -06002457 }
2458 return
2459}
2460
Alex Brainman0aaa2712020-10-11 09:49:28 +11002461func GetShortPathName(longpath *uint16, shortpath *uint16, buflen uint32) (n uint32, err error) {
2462 r0, _, e1 := syscall.Syscall(procGetShortPathNameW.Addr(), 3, uintptr(unsafe.Pointer(longpath)), uintptr(unsafe.Pointer(shortpath)), uintptr(buflen))
2463 n = uint32(r0)
2464 if n == 0 {
2465 err = errnoErr(e1)
2466 }
2467 return
2468}
2469
Tobias Klausere8190d92023-08-17 00:03:41 +02002470func getStartupInfo(startupInfo *StartupInfo) {
2471 syscall.Syscall(procGetStartupInfoW.Addr(), 1, uintptr(unsafe.Pointer(startupInfo)), 0, 0)
Alex Brainman0aaa2712020-10-11 09:49:28 +11002472 return
2473}
2474
2475func GetStdHandle(stdhandle uint32) (handle Handle, err error) {
2476 r0, _, e1 := syscall.Syscall(procGetStdHandle.Addr(), 1, uintptr(stdhandle), 0, 0)
2477 handle = Handle(r0)
2478 if handle == InvalidHandle {
2479 err = errnoErr(e1)
2480 }
2481 return
2482}
2483
2484func getSystemDirectory(dir *uint16, dirLen uint32) (len uint32, err error) {
2485 r0, _, e1 := syscall.Syscall(procGetSystemDirectoryW.Addr(), 2, uintptr(unsafe.Pointer(dir)), uintptr(dirLen), 0)
2486 len = uint32(r0)
2487 if len == 0 {
2488 err = errnoErr(e1)
2489 }
2490 return
2491}
2492
2493func getSystemPreferredUILanguages(flags uint32, numLanguages *uint32, buf *uint16, bufSize *uint32) (err error) {
2494 r1, _, e1 := syscall.Syscall6(procGetSystemPreferredUILanguages.Addr(), 4, uintptr(flags), uintptr(unsafe.Pointer(numLanguages)), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(bufSize)), 0, 0)
2495 if r1 == 0 {
2496 err = errnoErr(e1)
2497 }
2498 return
2499}
2500
2501func GetSystemTimeAsFileTime(time *Filetime) {
2502 syscall.Syscall(procGetSystemTimeAsFileTime.Addr(), 1, uintptr(unsafe.Pointer(time)), 0, 0)
2503 return
2504}
2505
2506func GetSystemTimePreciseAsFileTime(time *Filetime) {
2507 syscall.Syscall(procGetSystemTimePreciseAsFileTime.Addr(), 1, uintptr(unsafe.Pointer(time)), 0, 0)
2508 return
2509}
2510
2511func getSystemWindowsDirectory(dir *uint16, dirLen uint32) (len uint32, err error) {
2512 r0, _, e1 := syscall.Syscall(procGetSystemWindowsDirectoryW.Addr(), 2, uintptr(unsafe.Pointer(dir)), uintptr(dirLen), 0)
2513 len = uint32(r0)
2514 if len == 0 {
2515 err = errnoErr(e1)
2516 }
2517 return
2518}
2519
2520func GetTempPath(buflen uint32, buf *uint16) (n uint32, err error) {
2521 r0, _, e1 := syscall.Syscall(procGetTempPathW.Addr(), 2, uintptr(buflen), uintptr(unsafe.Pointer(buf)), 0)
2522 n = uint32(r0)
2523 if n == 0 {
2524 err = errnoErr(e1)
2525 }
2526 return
2527}
2528
2529func getThreadPreferredUILanguages(flags uint32, numLanguages *uint32, buf *uint16, bufSize *uint32) (err error) {
2530 r1, _, e1 := syscall.Syscall6(procGetThreadPreferredUILanguages.Addr(), 4, uintptr(flags), uintptr(unsafe.Pointer(numLanguages)), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(bufSize)), 0, 0)
2531 if r1 == 0 {
2532 err = errnoErr(e1)
2533 }
2534 return
2535}
2536
2537func getTickCount64() (ms uint64) {
2538 r0, _, _ := syscall.Syscall(procGetTickCount64.Addr(), 0, 0, 0, 0)
2539 ms = uint64(r0)
2540 return
2541}
2542
2543func GetTimeZoneInformation(tzi *Timezoneinformation) (rc uint32, err error) {
2544 r0, _, e1 := syscall.Syscall(procGetTimeZoneInformation.Addr(), 1, uintptr(unsafe.Pointer(tzi)), 0, 0)
2545 rc = uint32(r0)
2546 if rc == 0xffffffff {
2547 err = errnoErr(e1)
2548 }
2549 return
2550}
2551
2552func getUserPreferredUILanguages(flags uint32, numLanguages *uint32, buf *uint16, bufSize *uint32) (err error) {
2553 r1, _, e1 := syscall.Syscall6(procGetUserPreferredUILanguages.Addr(), 4, uintptr(flags), uintptr(unsafe.Pointer(numLanguages)), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(bufSize)), 0, 0)
2554 if r1 == 0 {
2555 err = errnoErr(e1)
2556 }
2557 return
2558}
2559
2560func GetVersion() (ver uint32, err error) {
2561 r0, _, e1 := syscall.Syscall(procGetVersion.Addr(), 0, 0, 0, 0)
2562 ver = uint32(r0)
2563 if ver == 0 {
2564 err = errnoErr(e1)
2565 }
2566 return
2567}
2568
2569func GetVolumeInformationByHandle(file Handle, volumeNameBuffer *uint16, volumeNameSize uint32, volumeNameSerialNumber *uint32, maximumComponentLength *uint32, fileSystemFlags *uint32, fileSystemNameBuffer *uint16, fileSystemNameSize uint32) (err error) {
2570 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)
2571 if r1 == 0 {
2572 err = errnoErr(e1)
2573 }
2574 return
2575}
2576
2577func GetVolumeInformation(rootPathName *uint16, volumeNameBuffer *uint16, volumeNameSize uint32, volumeNameSerialNumber *uint32, maximumComponentLength *uint32, fileSystemFlags *uint32, fileSystemNameBuffer *uint16, fileSystemNameSize uint32) (err error) {
2578 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)
2579 if r1 == 0 {
2580 err = errnoErr(e1)
2581 }
2582 return
2583}
2584
2585func GetVolumeNameForVolumeMountPoint(volumeMountPoint *uint16, volumeName *uint16, bufferlength uint32) (err error) {
2586 r1, _, e1 := syscall.Syscall(procGetVolumeNameForVolumeMountPointW.Addr(), 3, uintptr(unsafe.Pointer(volumeMountPoint)), uintptr(unsafe.Pointer(volumeName)), uintptr(bufferlength))
2587 if r1 == 0 {
2588 err = errnoErr(e1)
2589 }
2590 return
2591}
2592
2593func GetVolumePathName(fileName *uint16, volumePathName *uint16, bufferLength uint32) (err error) {
2594 r1, _, e1 := syscall.Syscall(procGetVolumePathNameW.Addr(), 3, uintptr(unsafe.Pointer(fileName)), uintptr(unsafe.Pointer(volumePathName)), uintptr(bufferLength))
2595 if r1 == 0 {
2596 err = errnoErr(e1)
2597 }
2598 return
2599}
2600
2601func GetVolumePathNamesForVolumeName(volumeName *uint16, volumePathNames *uint16, bufferLength uint32, returnLength *uint32) (err error) {
2602 r1, _, e1 := syscall.Syscall6(procGetVolumePathNamesForVolumeNameW.Addr(), 4, uintptr(unsafe.Pointer(volumeName)), uintptr(unsafe.Pointer(volumePathNames)), uintptr(bufferLength), uintptr(unsafe.Pointer(returnLength)), 0, 0)
2603 if r1 == 0 {
2604 err = errnoErr(e1)
2605 }
2606 return
2607}
2608
2609func getWindowsDirectory(dir *uint16, dirLen uint32) (len uint32, err error) {
2610 r0, _, e1 := syscall.Syscall(procGetWindowsDirectoryW.Addr(), 2, uintptr(unsafe.Pointer(dir)), uintptr(dirLen), 0)
2611 len = uint32(r0)
2612 if len == 0 {
2613 err = errnoErr(e1)
2614 }
2615 return
2616}
2617
Jason A. Donenfeldf36f7822021-02-01 00:16:53 +01002618func initializeProcThreadAttributeList(attrlist *ProcThreadAttributeList, attrcount uint32, flags uint32, size *uintptr) (err error) {
2619 r1, _, e1 := syscall.Syscall6(procInitializeProcThreadAttributeList.Addr(), 4, uintptr(unsafe.Pointer(attrlist)), uintptr(attrcount), uintptr(flags), uintptr(unsafe.Pointer(size)), 0, 0)
2620 if r1 == 0 {
2621 err = errnoErr(e1)
2622 }
2623 return
2624}
2625
Alex Brainman0aaa2712020-10-11 09:49:28 +11002626func IsWow64Process(handle Handle, isWow64 *bool) (err error) {
2627 var _p0 uint32
2628 if *isWow64 {
2629 _p0 = 1
2630 }
2631 r1, _, e1 := syscall.Syscall(procIsWow64Process.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(&_p0)), 0)
2632 *isWow64 = _p0 != 0
2633 if r1 == 0 {
2634 err = errnoErr(e1)
2635 }
2636 return
2637}
2638
Jason A. Donenfeld12cec1f2020-11-13 15:51:52 +01002639func IsWow64Process2(handle Handle, processMachine *uint16, nativeMachine *uint16) (err error) {
2640 err = procIsWow64Process2.Find()
2641 if err != nil {
2642 return
2643 }
2644 r1, _, e1 := syscall.Syscall(procIsWow64Process2.Addr(), 3, uintptr(handle), uintptr(unsafe.Pointer(processMachine)), uintptr(unsafe.Pointer(nativeMachine)))
2645 if r1 == 0 {
2646 err = errnoErr(e1)
2647 }
2648 return
2649}
2650
Alex Brainman0aaa2712020-10-11 09:49:28 +11002651func LoadLibraryEx(libname string, zero Handle, flags uintptr) (handle Handle, err error) {
2652 var _p0 *uint16
2653 _p0, err = syscall.UTF16PtrFromString(libname)
2654 if err != nil {
2655 return
2656 }
2657 return _LoadLibraryEx(_p0, zero, flags)
2658}
2659
2660func _LoadLibraryEx(libname *uint16, zero Handle, flags uintptr) (handle Handle, err error) {
2661 r0, _, e1 := syscall.Syscall(procLoadLibraryExW.Addr(), 3, uintptr(unsafe.Pointer(libname)), uintptr(zero), uintptr(flags))
2662 handle = Handle(r0)
2663 if handle == 0 {
2664 err = errnoErr(e1)
2665 }
2666 return
2667}
2668
2669func LoadLibrary(libname string) (handle Handle, err error) {
2670 var _p0 *uint16
2671 _p0, err = syscall.UTF16PtrFromString(libname)
2672 if err != nil {
2673 return
2674 }
2675 return _LoadLibrary(_p0)
2676}
2677
2678func _LoadLibrary(libname *uint16) (handle Handle, err error) {
2679 r0, _, e1 := syscall.Syscall(procLoadLibraryW.Addr(), 1, uintptr(unsafe.Pointer(libname)), 0, 0)
2680 handle = Handle(r0)
2681 if handle == 0 {
2682 err = errnoErr(e1)
2683 }
2684 return
2685}
2686
Jason A. Donenfeldf9bc61c2021-03-03 15:00:01 +01002687func LoadResource(module Handle, resInfo Handle) (resData Handle, err error) {
2688 r0, _, e1 := syscall.Syscall(procLoadResource.Addr(), 2, uintptr(module), uintptr(resInfo), 0)
2689 resData = Handle(r0)
2690 if resData == 0 {
2691 err = errnoErr(e1)
2692 }
2693 return
2694}
2695
Jason A. Donenfeld7b4935e2021-03-03 14:05:15 +01002696func LocalAlloc(flags uint32, length uint32) (ptr uintptr, err error) {
2697 r0, _, e1 := syscall.Syscall(procLocalAlloc.Addr(), 2, uintptr(flags), uintptr(length), 0)
2698 ptr = uintptr(r0)
2699 if ptr == 0 {
2700 err = errnoErr(e1)
2701 }
2702 return
2703}
2704
Alex Brainman0aaa2712020-10-11 09:49:28 +11002705func LocalFree(hmem Handle) (handle Handle, err error) {
2706 r0, _, e1 := syscall.Syscall(procLocalFree.Addr(), 1, uintptr(hmem), 0, 0)
2707 handle = Handle(r0)
2708 if handle != 0 {
2709 err = errnoErr(e1)
2710 }
2711 return
2712}
2713
2714func LockFileEx(file Handle, flags uint32, reserved uint32, bytesLow uint32, bytesHigh uint32, overlapped *Overlapped) (err error) {
2715 r1, _, e1 := syscall.Syscall6(procLockFileEx.Addr(), 6, uintptr(file), uintptr(flags), uintptr(reserved), uintptr(bytesLow), uintptr(bytesHigh), uintptr(unsafe.Pointer(overlapped)))
2716 if r1 == 0 {
2717 err = errnoErr(e1)
2718 }
2719 return
2720}
2721
Jason A. Donenfeldf9bc61c2021-03-03 15:00:01 +01002722func LockResource(resData Handle) (addr uintptr, err error) {
2723 r0, _, e1 := syscall.Syscall(procLockResource.Addr(), 1, uintptr(resData), 0, 0)
2724 addr = uintptr(r0)
2725 if addr == 0 {
2726 err = errnoErr(e1)
2727 }
2728 return
2729}
2730
Alex Brainman0aaa2712020-10-11 09:49:28 +11002731func MapViewOfFile(handle Handle, access uint32, offsetHigh uint32, offsetLow uint32, length uintptr) (addr uintptr, err error) {
2732 r0, _, e1 := syscall.Syscall6(procMapViewOfFile.Addr(), 5, uintptr(handle), uintptr(access), uintptr(offsetHigh), uintptr(offsetLow), uintptr(length), 0)
2733 addr = uintptr(r0)
2734 if addr == 0 {
2735 err = errnoErr(e1)
2736 }
2737 return
2738}
2739
Tobias Klauser94396e42021-12-03 19:58:53 +01002740func Module32First(snapshot Handle, moduleEntry *ModuleEntry32) (err error) {
2741 r1, _, e1 := syscall.Syscall(procModule32FirstW.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(moduleEntry)), 0)
2742 if r1 == 0 {
2743 err = errnoErr(e1)
2744 }
2745 return
2746}
2747
2748func Module32Next(snapshot Handle, moduleEntry *ModuleEntry32) (err error) {
2749 r1, _, e1 := syscall.Syscall(procModule32NextW.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(moduleEntry)), 0)
2750 if r1 == 0 {
2751 err = errnoErr(e1)
2752 }
2753 return
2754}
2755
Alex Brainman0aaa2712020-10-11 09:49:28 +11002756func MoveFileEx(from *uint16, to *uint16, flags uint32) (err error) {
2757 r1, _, e1 := syscall.Syscall(procMoveFileExW.Addr(), 3, uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(to)), uintptr(flags))
2758 if r1 == 0 {
2759 err = errnoErr(e1)
2760 }
2761 return
2762}
2763
2764func MoveFile(from *uint16, to *uint16) (err error) {
2765 r1, _, e1 := syscall.Syscall(procMoveFileW.Addr(), 2, uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(to)), 0)
2766 if r1 == 0 {
2767 err = errnoErr(e1)
2768 }
2769 return
2770}
2771
2772func MultiByteToWideChar(codePage uint32, dwFlags uint32, str *byte, nstr int32, wchar *uint16, nwchar int32) (nwrite int32, err error) {
2773 r0, _, e1 := syscall.Syscall6(procMultiByteToWideChar.Addr(), 6, uintptr(codePage), uintptr(dwFlags), uintptr(unsafe.Pointer(str)), uintptr(nstr), uintptr(unsafe.Pointer(wchar)), uintptr(nwchar))
2774 nwrite = int32(r0)
2775 if nwrite == 0 {
2776 err = errnoErr(e1)
2777 }
2778 return
2779}
2780
2781func OpenEvent(desiredAccess uint32, inheritHandle bool, name *uint16) (handle Handle, err error) {
2782 var _p0 uint32
2783 if inheritHandle {
2784 _p0 = 1
2785 }
2786 r0, _, e1 := syscall.Syscall(procOpenEventW.Addr(), 3, uintptr(desiredAccess), uintptr(_p0), uintptr(unsafe.Pointer(name)))
2787 handle = Handle(r0)
2788 if handle == 0 {
2789 err = errnoErr(e1)
2790 }
2791 return
2792}
2793
2794func OpenMutex(desiredAccess uint32, inheritHandle bool, name *uint16) (handle Handle, err error) {
2795 var _p0 uint32
2796 if inheritHandle {
2797 _p0 = 1
2798 }
2799 r0, _, e1 := syscall.Syscall(procOpenMutexW.Addr(), 3, uintptr(desiredAccess), uintptr(_p0), uintptr(unsafe.Pointer(name)))
2800 handle = Handle(r0)
2801 if handle == 0 {
2802 err = errnoErr(e1)
2803 }
2804 return
2805}
2806
2807func OpenProcess(desiredAccess uint32, inheritHandle bool, processId uint32) (handle Handle, err error) {
2808 var _p0 uint32
2809 if inheritHandle {
2810 _p0 = 1
2811 }
2812 r0, _, e1 := syscall.Syscall(procOpenProcess.Addr(), 3, uintptr(desiredAccess), uintptr(_p0), uintptr(processId))
2813 handle = Handle(r0)
2814 if handle == 0 {
2815 err = errnoErr(e1)
2816 }
2817 return
2818}
2819
2820func OpenThread(desiredAccess uint32, inheritHandle bool, threadId uint32) (handle Handle, err error) {
2821 var _p0 uint32
2822 if inheritHandle {
2823 _p0 = 1
2824 }
2825 r0, _, e1 := syscall.Syscall(procOpenThread.Addr(), 3, uintptr(desiredAccess), uintptr(_p0), uintptr(threadId))
2826 handle = Handle(r0)
2827 if handle == 0 {
2828 err = errnoErr(e1)
2829 }
2830 return
2831}
2832
Jason A. Donenfeld683adc92021-02-23 13:32:03 +01002833func PostQueuedCompletionStatus(cphandle Handle, qty uint32, key uintptr, overlapped *Overlapped) (err error) {
Alex Brainman0aaa2712020-10-11 09:49:28 +11002834 r1, _, e1 := syscall.Syscall6(procPostQueuedCompletionStatus.Addr(), 4, uintptr(cphandle), uintptr(qty), uintptr(key), uintptr(unsafe.Pointer(overlapped)), 0, 0)
2835 if r1 == 0 {
2836 err = errnoErr(e1)
2837 }
2838 return
2839}
2840
2841func Process32First(snapshot Handle, procEntry *ProcessEntry32) (err error) {
2842 r1, _, e1 := syscall.Syscall(procProcess32FirstW.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(procEntry)), 0)
2843 if r1 == 0 {
2844 err = errnoErr(e1)
2845 }
2846 return
2847}
2848
2849func Process32Next(snapshot Handle, procEntry *ProcessEntry32) (err error) {
2850 r1, _, e1 := syscall.Syscall(procProcess32NextW.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(procEntry)), 0)
2851 if r1 == 0 {
2852 err = errnoErr(e1)
2853 }
2854 return
2855}
2856
2857func ProcessIdToSessionId(pid uint32, sessionid *uint32) (err error) {
2858 r1, _, e1 := syscall.Syscall(procProcessIdToSessionId.Addr(), 2, uintptr(pid), uintptr(unsafe.Pointer(sessionid)), 0)
2859 if r1 == 0 {
2860 err = errnoErr(e1)
2861 }
2862 return
2863}
2864
2865func PulseEvent(event Handle) (err error) {
2866 r1, _, e1 := syscall.Syscall(procPulseEvent.Addr(), 1, uintptr(event), 0, 0)
2867 if r1 == 0 {
2868 err = errnoErr(e1)
2869 }
2870 return
2871}
2872
Tom Payne1a50d972024-03-31 22:00:41 +00002873func PurgeComm(handle Handle, dwFlags uint32) (err error) {
2874 r1, _, e1 := syscall.Syscall(procPurgeComm.Addr(), 2, uintptr(handle), uintptr(dwFlags), 0)
2875 if r1 == 0 {
2876 err = errnoErr(e1)
2877 }
2878 return
2879}
2880
Alex Brainman0aaa2712020-10-11 09:49:28 +11002881func QueryDosDevice(deviceName *uint16, targetPath *uint16, max uint32) (n uint32, err error) {
2882 r0, _, e1 := syscall.Syscall(procQueryDosDeviceW.Addr(), 3, uintptr(unsafe.Pointer(deviceName)), uintptr(unsafe.Pointer(targetPath)), uintptr(max))
2883 n = uint32(r0)
2884 if n == 0 {
2885 err = errnoErr(e1)
2886 }
2887 return
2888}
2889
Jason A. Donenfeld61f932b2021-03-04 12:14:53 -07002890func QueryFullProcessImageName(proc Handle, flags uint32, exeName *uint16, size *uint32) (err error) {
2891 r1, _, e1 := syscall.Syscall6(procQueryFullProcessImageNameW.Addr(), 4, uintptr(proc), uintptr(flags), uintptr(unsafe.Pointer(exeName)), uintptr(unsafe.Pointer(size)), 0, 0)
2892 if r1 == 0 {
2893 err = errnoErr(e1)
2894 }
2895 return
2896}
2897
Alex Brainman0aaa2712020-10-11 09:49:28 +11002898func QueryInformationJobObject(job Handle, JobObjectInformationClass int32, JobObjectInformation uintptr, JobObjectInformationLength uint32, retlen *uint32) (err error) {
2899 r1, _, e1 := syscall.Syscall6(procQueryInformationJobObject.Addr(), 5, uintptr(job), uintptr(JobObjectInformationClass), uintptr(JobObjectInformation), uintptr(JobObjectInformationLength), uintptr(unsafe.Pointer(retlen)), 0)
2900 if r1 == 0 {
2901 err = errnoErr(e1)
2902 }
2903 return
2904}
2905
2906func ReadConsole(console Handle, buf *uint16, toread uint32, read *uint32, inputControl *byte) (err error) {
2907 r1, _, e1 := syscall.Syscall6(procReadConsoleW.Addr(), 5, uintptr(console), uintptr(unsafe.Pointer(buf)), uintptr(toread), uintptr(unsafe.Pointer(read)), uintptr(unsafe.Pointer(inputControl)), 0)
2908 if r1 == 0 {
2909 err = errnoErr(e1)
2910 }
2911 return
2912}
2913
2914func ReadDirectoryChanges(handle Handle, buf *byte, buflen uint32, watchSubTree bool, mask uint32, retlen *uint32, overlapped *Overlapped, completionRoutine uintptr) (err error) {
2915 var _p0 uint32
2916 if watchSubTree {
2917 _p0 = 1
2918 }
2919 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)
2920 if r1 == 0 {
2921 err = errnoErr(e1)
2922 }
2923 return
2924}
2925
Tobias Klauser27bbf832022-03-15 10:47:22 +01002926func readFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) (err error) {
Alex Brainman0aaa2712020-10-11 09:49:28 +11002927 var _p0 *byte
2928 if len(buf) > 0 {
2929 _p0 = &buf[0]
2930 }
2931 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)
2932 if r1 == 0 {
2933 err = errnoErr(e1)
2934 }
2935 return
2936}
2937
Weilu Jiad3039522021-10-05 07:50:15 +00002938func ReadProcessMemory(process Handle, baseAddress uintptr, buffer *byte, size uintptr, numberOfBytesRead *uintptr) (err error) {
2939 r1, _, e1 := syscall.Syscall6(procReadProcessMemory.Addr(), 5, uintptr(process), uintptr(baseAddress), uintptr(unsafe.Pointer(buffer)), uintptr(size), uintptr(unsafe.Pointer(numberOfBytesRead)), 0)
2940 if r1 == 0 {
2941 err = errnoErr(e1)
2942 }
2943 return
2944}
2945
Alex Brainman0aaa2712020-10-11 09:49:28 +11002946func ReleaseMutex(mutex Handle) (err error) {
2947 r1, _, e1 := syscall.Syscall(procReleaseMutex.Addr(), 1, uintptr(mutex), 0, 0)
2948 if r1 == 0 {
2949 err = errnoErr(e1)
2950 }
2951 return
2952}
2953
2954func RemoveDirectory(path *uint16) (err error) {
2955 r1, _, e1 := syscall.Syscall(procRemoveDirectoryW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0)
2956 if r1 == 0 {
2957 err = errnoErr(e1)
2958 }
2959 return
2960}
2961
Roland Shoemaker11eadc02023-11-08 11:08:03 -08002962func RemoveDllDirectory(cookie uintptr) (err error) {
2963 r1, _, e1 := syscall.Syscall(procRemoveDllDirectory.Addr(), 1, uintptr(cookie), 0, 0)
2964 if r1 == 0 {
2965 err = errnoErr(e1)
2966 }
2967 return
2968}
2969
Alex Brainman0aaa2712020-10-11 09:49:28 +11002970func ResetEvent(event Handle) (err error) {
2971 r1, _, e1 := syscall.Syscall(procResetEvent.Addr(), 1, uintptr(event), 0, 0)
2972 if r1 == 0 {
2973 err = errnoErr(e1)
2974 }
2975 return
2976}
2977
Ayman Bagabas71c9d872023-09-26 15:53:15 +00002978func resizePseudoConsole(pconsole Handle, size uint32) (hr error) {
2979 r0, _, _ := syscall.Syscall(procResizePseudoConsole.Addr(), 2, uintptr(pconsole), uintptr(size), 0)
2980 if r0 != 0 {
2981 hr = syscall.Errno(r0)
2982 }
2983 return
2984}
2985
Alex Brainman0aaa2712020-10-11 09:49:28 +11002986func ResumeThread(thread Handle) (ret uint32, err error) {
2987 r0, _, e1 := syscall.Syscall(procResumeThread.Addr(), 1, uintptr(thread), 0, 0)
2988 ret = uint32(r0)
2989 if ret == 0xffffffff {
2990 err = errnoErr(e1)
2991 }
2992 return
2993}
2994
Tom Payne1a50d972024-03-31 22:00:41 +00002995func SetCommBreak(handle Handle) (err error) {
2996 r1, _, e1 := syscall.Syscall(procSetCommBreak.Addr(), 1, uintptr(handle), 0, 0)
2997 if r1 == 0 {
2998 err = errnoErr(e1)
2999 }
3000 return
3001}
3002
3003func SetCommMask(handle Handle, dwEvtMask uint32) (err error) {
3004 r1, _, e1 := syscall.Syscall(procSetCommMask.Addr(), 2, uintptr(handle), uintptr(dwEvtMask), 0)
3005 if r1 == 0 {
3006 err = errnoErr(e1)
3007 }
3008 return
3009}
3010
3011func SetCommState(handle Handle, lpDCB *DCB) (err error) {
3012 r1, _, e1 := syscall.Syscall(procSetCommState.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(lpDCB)), 0)
3013 if r1 == 0 {
3014 err = errnoErr(e1)
3015 }
3016 return
3017}
3018
Tobias Kohlbau479acdf2021-02-06 08:58:28 +01003019func SetCommTimeouts(handle Handle, timeouts *CommTimeouts) (err error) {
3020 r1, _, e1 := syscall.Syscall(procSetCommTimeouts.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(timeouts)), 0)
3021 if r1 == 0 {
3022 err = errnoErr(e1)
3023 }
3024 return
3025}
3026
Jason A. Donenfeld35f3e6c2020-11-10 11:04:08 +01003027func setConsoleCursorPosition(console Handle, position uint32) (err error) {
3028 r1, _, e1 := syscall.Syscall(procSetConsoleCursorPosition.Addr(), 2, uintptr(console), uintptr(position), 0)
Alex Brainman0aaa2712020-10-11 09:49:28 +11003029 if r1 == 0 {
3030 err = errnoErr(e1)
3031 }
3032 return
3033}
3034
3035func SetConsoleMode(console Handle, mode uint32) (err error) {
3036 r1, _, e1 := syscall.Syscall(procSetConsoleMode.Addr(), 2, uintptr(console), uintptr(mode), 0)
3037 if r1 == 0 {
3038 err = errnoErr(e1)
3039 }
3040 return
3041}
3042
3043func SetCurrentDirectory(path *uint16) (err error) {
3044 r1, _, e1 := syscall.Syscall(procSetCurrentDirectoryW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0)
3045 if r1 == 0 {
3046 err = errnoErr(e1)
3047 }
3048 return
3049}
3050
Jason A. Donenfeld77190672020-11-26 23:54:44 +01003051func SetDefaultDllDirectories(directoryFlags uint32) (err error) {
3052 r1, _, e1 := syscall.Syscall(procSetDefaultDllDirectories.Addr(), 1, uintptr(directoryFlags), 0, 0)
3053 if r1 == 0 {
3054 err = errnoErr(e1)
3055 }
3056 return
3057}
3058
3059func SetDllDirectory(path string) (err error) {
3060 var _p0 *uint16
3061 _p0, err = syscall.UTF16PtrFromString(path)
3062 if err != nil {
3063 return
3064 }
3065 return _SetDllDirectory(_p0)
3066}
3067
3068func _SetDllDirectory(path *uint16) (err error) {
3069 r1, _, e1 := syscall.Syscall(procSetDllDirectoryW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0)
3070 if r1 == 0 {
3071 err = errnoErr(e1)
3072 }
3073 return
3074}
3075
Alex Brainman0aaa2712020-10-11 09:49:28 +11003076func SetEndOfFile(handle Handle) (err error) {
3077 r1, _, e1 := syscall.Syscall(procSetEndOfFile.Addr(), 1, uintptr(handle), 0, 0)
3078 if r1 == 0 {
3079 err = errnoErr(e1)
3080 }
3081 return
3082}
3083
3084func SetEnvironmentVariable(name *uint16, value *uint16) (err error) {
3085 r1, _, e1 := syscall.Syscall(procSetEnvironmentVariableW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(value)), 0)
3086 if r1 == 0 {
3087 err = errnoErr(e1)
3088 }
3089 return
3090}
3091
3092func SetErrorMode(mode uint32) (ret uint32) {
3093 r0, _, _ := syscall.Syscall(procSetErrorMode.Addr(), 1, uintptr(mode), 0, 0)
3094 ret = uint32(r0)
3095 return
3096}
3097
3098func SetEvent(event Handle) (err error) {
3099 r1, _, e1 := syscall.Syscall(procSetEvent.Addr(), 1, uintptr(event), 0, 0)
3100 if r1 == 0 {
3101 err = errnoErr(e1)
3102 }
3103 return
3104}
3105
3106func SetFileAttributes(name *uint16, attrs uint32) (err error) {
3107 r1, _, e1 := syscall.Syscall(procSetFileAttributesW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(attrs), 0)
3108 if r1 == 0 {
3109 err = errnoErr(e1)
3110 }
3111 return
3112}
3113
3114func SetFileCompletionNotificationModes(handle Handle, flags uint8) (err error) {
3115 r1, _, e1 := syscall.Syscall(procSetFileCompletionNotificationModes.Addr(), 2, uintptr(handle), uintptr(flags), 0)
3116 if r1 == 0 {
3117 err = errnoErr(e1)
3118 }
3119 return
3120}
3121
Jason A. Donenfeldd9b008d2020-11-17 10:19:46 +01003122func SetFileInformationByHandle(handle Handle, class uint32, inBuffer *byte, inBufferLen uint32) (err error) {
3123 r1, _, e1 := syscall.Syscall6(procSetFileInformationByHandle.Addr(), 4, uintptr(handle), uintptr(class), uintptr(unsafe.Pointer(inBuffer)), uintptr(inBufferLen), 0, 0)
3124 if r1 == 0 {
3125 err = errnoErr(e1)
3126 }
3127 return
3128}
3129
Alex Brainman0aaa2712020-10-11 09:49:28 +11003130func SetFilePointer(handle Handle, lowoffset int32, highoffsetptr *int32, whence uint32) (newlowoffset uint32, err error) {
3131 r0, _, e1 := syscall.Syscall6(procSetFilePointer.Addr(), 4, uintptr(handle), uintptr(lowoffset), uintptr(unsafe.Pointer(highoffsetptr)), uintptr(whence), 0, 0)
3132 newlowoffset = uint32(r0)
3133 if newlowoffset == 0xffffffff {
3134 err = errnoErr(e1)
3135 }
3136 return
3137}
3138
3139func SetFileTime(handle Handle, ctime *Filetime, atime *Filetime, wtime *Filetime) (err error) {
3140 r1, _, e1 := syscall.Syscall6(procSetFileTime.Addr(), 4, uintptr(handle), uintptr(unsafe.Pointer(ctime)), uintptr(unsafe.Pointer(atime)), uintptr(unsafe.Pointer(wtime)), 0, 0)
3141 if r1 == 0 {
3142 err = errnoErr(e1)
3143 }
3144 return
3145}
3146
Peter Hoogendijk95f07ec2024-03-10 14:49:55 +01003147func SetFileValidData(handle Handle, validDataLength int64) (err error) {
3148 r1, _, e1 := syscall.Syscall(procSetFileValidData.Addr(), 2, uintptr(handle), uintptr(validDataLength), 0)
3149 if r1 == 0 {
3150 err = errnoErr(e1)
3151 }
3152 return
3153}
3154
Alex Brainman0aaa2712020-10-11 09:49:28 +11003155func SetHandleInformation(handle Handle, mask uint32, flags uint32) (err error) {
3156 r1, _, e1 := syscall.Syscall(procSetHandleInformation.Addr(), 3, uintptr(handle), uintptr(mask), uintptr(flags))
3157 if r1 == 0 {
3158 err = errnoErr(e1)
3159 }
3160 return
3161}
3162
3163func SetInformationJobObject(job Handle, JobObjectInformationClass uint32, JobObjectInformation uintptr, JobObjectInformationLength uint32) (ret int, err error) {
3164 r0, _, e1 := syscall.Syscall6(procSetInformationJobObject.Addr(), 4, uintptr(job), uintptr(JobObjectInformationClass), uintptr(JobObjectInformation), uintptr(JobObjectInformationLength), 0, 0)
3165 ret = int(r0)
3166 if ret == 0 {
3167 err = errnoErr(e1)
3168 }
3169 return
3170}
3171
Jason A. Donenfeld94ec62e2021-03-05 09:45:33 -07003172func SetNamedPipeHandleState(pipe Handle, state *uint32, maxCollectionCount *uint32, collectDataTimeout *uint32) (err error) {
3173 r1, _, e1 := syscall.Syscall6(procSetNamedPipeHandleState.Addr(), 4, uintptr(pipe), uintptr(unsafe.Pointer(state)), uintptr(unsafe.Pointer(maxCollectionCount)), uintptr(unsafe.Pointer(collectDataTimeout)), 0, 0)
3174 if r1 == 0 {
3175 err = errnoErr(e1)
3176 }
3177 return
3178}
3179
Alex Brainman0aaa2712020-10-11 09:49:28 +11003180func SetPriorityClass(process Handle, priorityClass uint32) (err error) {
3181 r1, _, e1 := syscall.Syscall(procSetPriorityClass.Addr(), 2, uintptr(process), uintptr(priorityClass), 0)
3182 if r1 == 0 {
3183 err = errnoErr(e1)
3184 }
3185 return
3186}
3187
3188func SetProcessPriorityBoost(process Handle, disable bool) (err error) {
3189 var _p0 uint32
3190 if disable {
3191 _p0 = 1
3192 }
3193 r1, _, e1 := syscall.Syscall(procSetProcessPriorityBoost.Addr(), 2, uintptr(process), uintptr(_p0), 0)
3194 if r1 == 0 {
3195 err = errnoErr(e1)
3196 }
3197 return
3198}
3199
3200func SetProcessShutdownParameters(level uint32, flags uint32) (err error) {
3201 r1, _, e1 := syscall.Syscall(procSetProcessShutdownParameters.Addr(), 2, uintptr(level), uintptr(flags), 0)
3202 if r1 == 0 {
3203 err = errnoErr(e1)
3204 }
3205 return
3206}
3207
3208func SetProcessWorkingSetSizeEx(hProcess Handle, dwMinimumWorkingSetSize uintptr, dwMaximumWorkingSetSize uintptr, flags uint32) (err error) {
3209 r1, _, e1 := syscall.Syscall6(procSetProcessWorkingSetSizeEx.Addr(), 4, uintptr(hProcess), uintptr(dwMinimumWorkingSetSize), uintptr(dwMaximumWorkingSetSize), uintptr(flags), 0, 0)
3210 if r1 == 0 {
3211 err = errnoErr(e1)
3212 }
3213 return
3214}
3215
3216func SetStdHandle(stdhandle uint32, handle Handle) (err error) {
3217 r1, _, e1 := syscall.Syscall(procSetStdHandle.Addr(), 2, uintptr(stdhandle), uintptr(handle), 0)
3218 if r1 == 0 {
3219 err = errnoErr(e1)
3220 }
3221 return
3222}
3223
3224func SetVolumeLabel(rootPathName *uint16, volumeName *uint16) (err error) {
3225 r1, _, e1 := syscall.Syscall(procSetVolumeLabelW.Addr(), 2, uintptr(unsafe.Pointer(rootPathName)), uintptr(unsafe.Pointer(volumeName)), 0)
3226 if r1 == 0 {
3227 err = errnoErr(e1)
3228 }
3229 return
3230}
3231
3232func SetVolumeMountPoint(volumeMountPoint *uint16, volumeName *uint16) (err error) {
3233 r1, _, e1 := syscall.Syscall(procSetVolumeMountPointW.Addr(), 2, uintptr(unsafe.Pointer(volumeMountPoint)), uintptr(unsafe.Pointer(volumeName)), 0)
3234 if r1 == 0 {
3235 err = errnoErr(e1)
3236 }
3237 return
3238}
3239
Tom Payne1a50d972024-03-31 22:00:41 +00003240func SetupComm(handle Handle, dwInQueue uint32, dwOutQueue uint32) (err error) {
3241 r1, _, e1 := syscall.Syscall(procSetupComm.Addr(), 3, uintptr(handle), uintptr(dwInQueue), uintptr(dwOutQueue))
3242 if r1 == 0 {
3243 err = errnoErr(e1)
3244 }
3245 return
3246}
3247
Jason A. Donenfeldf9bc61c2021-03-03 15:00:01 +01003248func SizeofResource(module Handle, resInfo Handle) (size uint32, err error) {
3249 r0, _, e1 := syscall.Syscall(procSizeofResource.Addr(), 2, uintptr(module), uintptr(resInfo), 0)
3250 size = uint32(r0)
3251 if size == 0 {
3252 err = errnoErr(e1)
3253 }
3254 return
3255}
3256
Alex Brainman0aaa2712020-10-11 09:49:28 +11003257func SleepEx(milliseconds uint32, alertable bool) (ret uint32) {
3258 var _p0 uint32
3259 if alertable {
3260 _p0 = 1
3261 }
3262 r0, _, _ := syscall.Syscall(procSleepEx.Addr(), 2, uintptr(milliseconds), uintptr(_p0), 0)
3263 ret = uint32(r0)
3264 return
3265}
3266
3267func TerminateJobObject(job Handle, exitCode uint32) (err error) {
3268 r1, _, e1 := syscall.Syscall(procTerminateJobObject.Addr(), 2, uintptr(job), uintptr(exitCode), 0)
3269 if r1 == 0 {
3270 err = errnoErr(e1)
3271 }
3272 return
3273}
3274
3275func TerminateProcess(handle Handle, exitcode uint32) (err error) {
3276 r1, _, e1 := syscall.Syscall(procTerminateProcess.Addr(), 2, uintptr(handle), uintptr(exitcode), 0)
3277 if r1 == 0 {
3278 err = errnoErr(e1)
3279 }
3280 return
3281}
3282
3283func Thread32First(snapshot Handle, threadEntry *ThreadEntry32) (err error) {
3284 r1, _, e1 := syscall.Syscall(procThread32First.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(threadEntry)), 0)
3285 if r1 == 0 {
3286 err = errnoErr(e1)
3287 }
3288 return
3289}
3290
3291func Thread32Next(snapshot Handle, threadEntry *ThreadEntry32) (err error) {
3292 r1, _, e1 := syscall.Syscall(procThread32Next.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(threadEntry)), 0)
3293 if r1 == 0 {
3294 err = errnoErr(e1)
3295 }
3296 return
3297}
3298
3299func UnlockFileEx(file Handle, reserved uint32, bytesLow uint32, bytesHigh uint32, overlapped *Overlapped) (err error) {
3300 r1, _, e1 := syscall.Syscall6(procUnlockFileEx.Addr(), 5, uintptr(file), uintptr(reserved), uintptr(bytesLow), uintptr(bytesHigh), uintptr(unsafe.Pointer(overlapped)), 0)
3301 if r1 == 0 {
3302 err = errnoErr(e1)
3303 }
3304 return
3305}
3306
3307func UnmapViewOfFile(addr uintptr) (err error) {
3308 r1, _, e1 := syscall.Syscall(procUnmapViewOfFile.Addr(), 1, uintptr(addr), 0, 0)
3309 if r1 == 0 {
3310 err = errnoErr(e1)
3311 }
3312 return
3313}
3314
Jason A. Donenfeld44425432021-02-28 12:33:30 +01003315func updateProcThreadAttribute(attrlist *ProcThreadAttributeList, flags uint32, attr uintptr, value unsafe.Pointer, size uintptr, prevvalue unsafe.Pointer, returnedsize *uintptr) (err error) {
Jason A. Donenfeldf36f7822021-02-01 00:16:53 +01003316 r1, _, e1 := syscall.Syscall9(procUpdateProcThreadAttribute.Addr(), 7, uintptr(unsafe.Pointer(attrlist)), uintptr(flags), uintptr(attr), uintptr(value), uintptr(size), uintptr(prevvalue), uintptr(unsafe.Pointer(returnedsize)), 0, 0)
3317 if r1 == 0 {
3318 err = errnoErr(e1)
3319 }
3320 return
3321}
3322
Alex Brainman0aaa2712020-10-11 09:49:28 +11003323func VirtualAlloc(address uintptr, size uintptr, alloctype uint32, protect uint32) (value uintptr, err error) {
3324 r0, _, e1 := syscall.Syscall6(procVirtualAlloc.Addr(), 4, uintptr(address), uintptr(size), uintptr(alloctype), uintptr(protect), 0, 0)
3325 value = uintptr(r0)
3326 if value == 0 {
3327 err = errnoErr(e1)
3328 }
3329 return
3330}
3331
3332func VirtualFree(address uintptr, size uintptr, freetype uint32) (err error) {
3333 r1, _, e1 := syscall.Syscall(procVirtualFree.Addr(), 3, uintptr(address), uintptr(size), uintptr(freetype))
3334 if r1 == 0 {
3335 err = errnoErr(e1)
3336 }
3337 return
3338}
3339
3340func VirtualLock(addr uintptr, length uintptr) (err error) {
3341 r1, _, e1 := syscall.Syscall(procVirtualLock.Addr(), 2, uintptr(addr), uintptr(length), 0)
3342 if r1 == 0 {
3343 err = errnoErr(e1)
3344 }
3345 return
3346}
3347
3348func VirtualProtect(address uintptr, size uintptr, newprotect uint32, oldprotect *uint32) (err error) {
3349 r1, _, e1 := syscall.Syscall6(procVirtualProtect.Addr(), 4, uintptr(address), uintptr(size), uintptr(newprotect), uintptr(unsafe.Pointer(oldprotect)), 0, 0)
3350 if r1 == 0 {
3351 err = errnoErr(e1)
3352 }
3353 return
3354}
3355
Weilu Jiad3039522021-10-05 07:50:15 +00003356func VirtualProtectEx(process Handle, address uintptr, size uintptr, newProtect uint32, oldProtect *uint32) (err error) {
3357 r1, _, e1 := syscall.Syscall6(procVirtualProtectEx.Addr(), 5, uintptr(process), uintptr(address), uintptr(size), uintptr(newProtect), uintptr(unsafe.Pointer(oldProtect)), 0)
3358 if r1 == 0 {
3359 err = errnoErr(e1)
3360 }
3361 return
3362}
3363
3364func VirtualQuery(address uintptr, buffer *MemoryBasicInformation, length uintptr) (err error) {
3365 r1, _, e1 := syscall.Syscall(procVirtualQuery.Addr(), 3, uintptr(address), uintptr(unsafe.Pointer(buffer)), uintptr(length))
3366 if r1 == 0 {
3367 err = errnoErr(e1)
3368 }
3369 return
3370}
3371
3372func VirtualQueryEx(process Handle, address uintptr, buffer *MemoryBasicInformation, length uintptr) (err error) {
3373 r1, _, e1 := syscall.Syscall6(procVirtualQueryEx.Addr(), 4, uintptr(process), uintptr(address), uintptr(unsafe.Pointer(buffer)), uintptr(length), 0, 0)
3374 if r1 == 0 {
3375 err = errnoErr(e1)
3376 }
3377 return
3378}
3379
Alex Brainman0aaa2712020-10-11 09:49:28 +11003380func VirtualUnlock(addr uintptr, length uintptr) (err error) {
3381 r1, _, e1 := syscall.Syscall(procVirtualUnlock.Addr(), 2, uintptr(addr), uintptr(length), 0)
3382 if r1 == 0 {
3383 err = errnoErr(e1)
3384 }
3385 return
3386}
3387
David Crawshaw44f02d92021-06-30 06:31:16 -07003388func WTSGetActiveConsoleSessionId() (sessionID uint32) {
3389 r0, _, _ := syscall.Syscall(procWTSGetActiveConsoleSessionId.Addr(), 0, 0, 0, 0)
3390 sessionID = uint32(r0)
3391 return
3392}
3393
Tom Payne1a50d972024-03-31 22:00:41 +00003394func WaitCommEvent(handle Handle, lpEvtMask *uint32, lpOverlapped *Overlapped) (err error) {
3395 r1, _, e1 := syscall.Syscall(procWaitCommEvent.Addr(), 3, uintptr(handle), uintptr(unsafe.Pointer(lpEvtMask)), uintptr(unsafe.Pointer(lpOverlapped)))
3396 if r1 == 0 {
3397 err = errnoErr(e1)
3398 }
3399 return
3400}
3401
Alex Brainman0aaa2712020-10-11 09:49:28 +11003402func waitForMultipleObjects(count uint32, handles uintptr, waitAll bool, waitMilliseconds uint32) (event uint32, err error) {
3403 var _p0 uint32
3404 if waitAll {
3405 _p0 = 1
3406 }
3407 r0, _, e1 := syscall.Syscall6(procWaitForMultipleObjects.Addr(), 4, uintptr(count), uintptr(handles), uintptr(_p0), uintptr(waitMilliseconds), 0, 0)
3408 event = uint32(r0)
3409 if event == 0xffffffff {
3410 err = errnoErr(e1)
3411 }
3412 return
3413}
3414
3415func WaitForSingleObject(handle Handle, waitMilliseconds uint32) (event uint32, err error) {
3416 r0, _, e1 := syscall.Syscall(procWaitForSingleObject.Addr(), 2, uintptr(handle), uintptr(waitMilliseconds), 0)
3417 event = uint32(r0)
3418 if event == 0xffffffff {
3419 err = errnoErr(e1)
3420 }
3421 return
3422}
3423
3424func WriteConsole(console Handle, buf *uint16, towrite uint32, written *uint32, reserved *byte) (err error) {
3425 r1, _, e1 := syscall.Syscall6(procWriteConsoleW.Addr(), 5, uintptr(console), uintptr(unsafe.Pointer(buf)), uintptr(towrite), uintptr(unsafe.Pointer(written)), uintptr(unsafe.Pointer(reserved)), 0)
3426 if r1 == 0 {
3427 err = errnoErr(e1)
3428 }
3429 return
3430}
3431
Tobias Klauser27bbf832022-03-15 10:47:22 +01003432func writeFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) (err error) {
Alex Brainman0aaa2712020-10-11 09:49:28 +11003433 var _p0 *byte
3434 if len(buf) > 0 {
3435 _p0 = &buf[0]
3436 }
3437 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)
3438 if r1 == 0 {
3439 err = errnoErr(e1)
3440 }
3441 return
3442}
3443
Weilu Jiad3039522021-10-05 07:50:15 +00003444func WriteProcessMemory(process Handle, baseAddress uintptr, buffer *byte, size uintptr, numberOfBytesWritten *uintptr) (err error) {
3445 r1, _, e1 := syscall.Syscall6(procWriteProcessMemory.Addr(), 5, uintptr(process), uintptr(baseAddress), uintptr(unsafe.Pointer(buffer)), uintptr(size), uintptr(unsafe.Pointer(numberOfBytesWritten)), 0)
3446 if r1 == 0 {
3447 err = errnoErr(e1)
3448 }
3449 return
3450}
3451
Alex Brainman0aaa2712020-10-11 09:49:28 +11003452func AcceptEx(ls Handle, as Handle, buf *byte, rxdatalen uint32, laddrlen uint32, raddrlen uint32, recvd *uint32, overlapped *Overlapped) (err error) {
3453 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)
3454 if r1 == 0 {
3455 err = errnoErr(e1)
3456 }
3457 return
3458}
3459
3460func GetAcceptExSockaddrs(buf *byte, rxdatalen uint32, laddrlen uint32, raddrlen uint32, lrsa **RawSockaddrAny, lrsalen *int32, rrsa **RawSockaddrAny, rrsalen *int32) {
3461 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)
3462 return
3463}
3464
3465func TransmitFile(s Handle, handle Handle, bytesToWrite uint32, bytsPerSend uint32, overlapped *Overlapped, transmitFileBuf *TransmitFileBuffers, flags uint32) (err error) {
3466 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)
3467 if r1 == 0 {
3468 err = errnoErr(e1)
3469 }
3470 return
3471}
3472
3473func NetApiBufferFree(buf *byte) (neterr error) {
3474 r0, _, _ := syscall.Syscall(procNetApiBufferFree.Addr(), 1, uintptr(unsafe.Pointer(buf)), 0, 0)
3475 if r0 != 0 {
3476 neterr = syscall.Errno(r0)
3477 }
3478 return
3479}
3480
3481func NetGetJoinInformation(server *uint16, name **uint16, bufType *uint32) (neterr error) {
3482 r0, _, _ := syscall.Syscall(procNetGetJoinInformation.Addr(), 3, uintptr(unsafe.Pointer(server)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(bufType)))
3483 if r0 != 0 {
3484 neterr = syscall.Errno(r0)
3485 }
3486 return
3487}
3488
3489func NetUserGetInfo(serverName *uint16, userName *uint16, level uint32, buf **byte) (neterr error) {
3490 r0, _, _ := syscall.Syscall6(procNetUserGetInfo.Addr(), 4, uintptr(unsafe.Pointer(serverName)), uintptr(unsafe.Pointer(userName)), uintptr(level), uintptr(unsafe.Pointer(buf)), 0, 0)
3491 if r0 != 0 {
3492 neterr = syscall.Errno(r0)
3493 }
3494 return
3495}
3496
Jason A. Donenfeld1243437a82021-03-03 13:10:42 +01003497func NtCreateFile(handle *Handle, access uint32, oa *OBJECT_ATTRIBUTES, iosb *IO_STATUS_BLOCK, allocationSize *int64, attributes uint32, share uint32, disposition uint32, options uint32, eabuffer uintptr, ealength uint32) (ntstatus error) {
3498 r0, _, _ := syscall.Syscall12(procNtCreateFile.Addr(), 11, uintptr(unsafe.Pointer(handle)), uintptr(access), uintptr(unsafe.Pointer(oa)), uintptr(unsafe.Pointer(iosb)), uintptr(unsafe.Pointer(allocationSize)), uintptr(attributes), uintptr(share), uintptr(disposition), uintptr(options), uintptr(eabuffer), uintptr(ealength), 0)
3499 if r0 != 0 {
3500 ntstatus = NTStatus(r0)
3501 }
3502 return
3503}
3504
3505func NtCreateNamedPipeFile(pipe *Handle, access uint32, oa *OBJECT_ATTRIBUTES, iosb *IO_STATUS_BLOCK, share uint32, disposition uint32, options uint32, typ uint32, readMode uint32, completionMode uint32, maxInstances uint32, inboundQuota uint32, outputQuota uint32, timeout *int64) (ntstatus error) {
3506 r0, _, _ := syscall.Syscall15(procNtCreateNamedPipeFile.Addr(), 14, uintptr(unsafe.Pointer(pipe)), uintptr(access), uintptr(unsafe.Pointer(oa)), uintptr(unsafe.Pointer(iosb)), uintptr(share), uintptr(disposition), uintptr(options), uintptr(typ), uintptr(readMode), uintptr(completionMode), uintptr(maxInstances), uintptr(inboundQuota), uintptr(outputQuota), uintptr(unsafe.Pointer(timeout)), 0)
3507 if r0 != 0 {
3508 ntstatus = NTStatus(r0)
3509 }
3510 return
3511}
3512
3513func NtQueryInformationProcess(proc Handle, procInfoClass int32, procInfo unsafe.Pointer, procInfoLen uint32, retLen *uint32) (ntstatus error) {
3514 r0, _, _ := syscall.Syscall6(procNtQueryInformationProcess.Addr(), 5, uintptr(proc), uintptr(procInfoClass), uintptr(procInfo), uintptr(procInfoLen), uintptr(unsafe.Pointer(retLen)), 0)
3515 if r0 != 0 {
3516 ntstatus = NTStatus(r0)
3517 }
3518 return
3519}
3520
Jason A. Donenfeld153b1542021-10-19 17:25:37 -06003521func NtQuerySystemInformation(sysInfoClass int32, sysInfo unsafe.Pointer, sysInfoLen uint32, retLen *uint32) (ntstatus error) {
3522 r0, _, _ := syscall.Syscall6(procNtQuerySystemInformation.Addr(), 4, uintptr(sysInfoClass), uintptr(sysInfo), uintptr(sysInfoLen), uintptr(unsafe.Pointer(retLen)), 0, 0)
3523 if r0 != 0 {
3524 ntstatus = NTStatus(r0)
3525 }
3526 return
3527}
3528
Takuto Ikutac1bf0bb2021-10-29 17:43:04 +09003529func NtSetInformationFile(handle Handle, iosb *IO_STATUS_BLOCK, inBuffer *byte, inBufferLen uint32, class uint32) (ntstatus error) {
3530 r0, _, _ := syscall.Syscall6(procNtSetInformationFile.Addr(), 5, uintptr(handle), uintptr(unsafe.Pointer(iosb)), uintptr(unsafe.Pointer(inBuffer)), uintptr(inBufferLen), uintptr(class), 0)
3531 if r0 != 0 {
3532 ntstatus = NTStatus(r0)
3533 }
3534 return
3535}
3536
Jason A. Donenfeld1243437a82021-03-03 13:10:42 +01003537func NtSetInformationProcess(proc Handle, procInfoClass int32, procInfo unsafe.Pointer, procInfoLen uint32) (ntstatus error) {
3538 r0, _, _ := syscall.Syscall6(procNtSetInformationProcess.Addr(), 4, uintptr(proc), uintptr(procInfoClass), uintptr(procInfo), uintptr(procInfoLen), 0, 0)
3539 if r0 != 0 {
3540 ntstatus = NTStatus(r0)
3541 }
3542 return
3543}
3544
Jason A. Donenfeld153b1542021-10-19 17:25:37 -06003545func NtSetSystemInformation(sysInfoClass int32, sysInfo unsafe.Pointer, sysInfoLen uint32) (ntstatus error) {
3546 r0, _, _ := syscall.Syscall(procNtSetSystemInformation.Addr(), 3, uintptr(sysInfoClass), uintptr(sysInfo), uintptr(sysInfoLen))
3547 if r0 != 0 {
3548 ntstatus = NTStatus(r0)
3549 }
3550 return
3551}
3552
Jason A. Donenfeld9d617382021-10-20 11:31:38 -06003553func RtlAddFunctionTable(functionTable *RUNTIME_FUNCTION, entryCount uint32, baseAddress uintptr) (ret bool) {
3554 r0, _, _ := syscall.Syscall(procRtlAddFunctionTable.Addr(), 3, uintptr(unsafe.Pointer(functionTable)), uintptr(entryCount), uintptr(baseAddress))
3555 ret = r0 != 0
3556 return
3557}
3558
Jason A. Donenfeld1243437a82021-03-03 13:10:42 +01003559func RtlDefaultNpAcl(acl **ACL) (ntstatus error) {
3560 r0, _, _ := syscall.Syscall(procRtlDefaultNpAcl.Addr(), 1, uintptr(unsafe.Pointer(acl)), 0, 0)
3561 if r0 != 0 {
3562 ntstatus = NTStatus(r0)
3563 }
3564 return
3565}
3566
Jason A. Donenfeld9d617382021-10-20 11:31:38 -06003567func RtlDeleteFunctionTable(functionTable *RUNTIME_FUNCTION) (ret bool) {
3568 r0, _, _ := syscall.Syscall(procRtlDeleteFunctionTable.Addr(), 1, uintptr(unsafe.Pointer(functionTable)), 0, 0)
3569 ret = r0 != 0
3570 return
3571}
3572
Jason A. Donenfeld5cdee2b2021-03-05 08:28:14 -07003573func RtlDosPathNameToNtPathName(dosName *uint16, ntName *NTUnicodeString, ntFileNamePart *uint16, relativeName *RTL_RELATIVE_NAME) (ntstatus error) {
Jason A. Donenfeld1243437a82021-03-03 13:10:42 +01003574 r0, _, _ := syscall.Syscall6(procRtlDosPathNameToNtPathName_U_WithStatus.Addr(), 4, uintptr(unsafe.Pointer(dosName)), uintptr(unsafe.Pointer(ntName)), uintptr(unsafe.Pointer(ntFileNamePart)), uintptr(unsafe.Pointer(relativeName)), 0, 0)
3575 if r0 != 0 {
3576 ntstatus = NTStatus(r0)
3577 }
3578 return
3579}
3580
Jason A. Donenfeld5cdee2b2021-03-05 08:28:14 -07003581func RtlDosPathNameToRelativeNtPathName(dosName *uint16, ntName *NTUnicodeString, ntFileNamePart *uint16, relativeName *RTL_RELATIVE_NAME) (ntstatus error) {
Jason A. Donenfeld1243437a82021-03-03 13:10:42 +01003582 r0, _, _ := syscall.Syscall6(procRtlDosPathNameToRelativeNtPathName_U_WithStatus.Addr(), 4, uintptr(unsafe.Pointer(dosName)), uintptr(unsafe.Pointer(ntName)), uintptr(unsafe.Pointer(ntFileNamePart)), uintptr(unsafe.Pointer(relativeName)), 0, 0)
3583 if r0 != 0 {
3584 ntstatus = NTStatus(r0)
3585 }
3586 return
3587}
3588
3589func RtlGetCurrentPeb() (peb *PEB) {
3590 r0, _, _ := syscall.Syscall(procRtlGetCurrentPeb.Addr(), 0, 0, 0, 0)
3591 peb = (*PEB)(unsafe.Pointer(r0))
3592 return
3593}
3594
Alex Brainman0aaa2712020-10-11 09:49:28 +11003595func rtlGetNtVersionNumbers(majorVersion *uint32, minorVersion *uint32, buildNumber *uint32) {
3596 syscall.Syscall(procRtlGetNtVersionNumbers.Addr(), 3, uintptr(unsafe.Pointer(majorVersion)), uintptr(unsafe.Pointer(minorVersion)), uintptr(unsafe.Pointer(buildNumber)))
3597 return
3598}
3599
Jason A. Donenfeld134d1302021-02-28 01:06:24 +01003600func rtlGetVersion(info *OsVersionInfoEx) (ntstatus error) {
Alex Brainman0aaa2712020-10-11 09:49:28 +11003601 r0, _, _ := syscall.Syscall(procRtlGetVersion.Addr(), 1, uintptr(unsafe.Pointer(info)), 0, 0)
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -06003602 if r0 != 0 {
Jason A. Donenfeld134d1302021-02-28 01:06:24 +01003603 ntstatus = NTStatus(r0)
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -06003604 }
3605 return
3606}
Alex Brainman0aaa2712020-10-11 09:49:28 +11003607
Jason A. Donenfeld5cdee2b2021-03-05 08:28:14 -07003608func RtlInitString(destinationString *NTString, sourceString *byte) {
3609 syscall.Syscall(procRtlInitString.Addr(), 2, uintptr(unsafe.Pointer(destinationString)), uintptr(unsafe.Pointer(sourceString)), 0)
3610 return
3611}
3612
3613func RtlInitUnicodeString(destinationString *NTUnicodeString, sourceString *uint16) {
Jason A. Donenfeld1243437a82021-03-03 13:10:42 +01003614 syscall.Syscall(procRtlInitUnicodeString.Addr(), 2, uintptr(unsafe.Pointer(destinationString)), uintptr(unsafe.Pointer(sourceString)), 0)
3615 return
3616}
3617
Jason A. Donenfeldafaa3652021-03-03 12:07:20 +01003618func rtlNtStatusToDosErrorNoTeb(ntstatus NTStatus) (ret syscall.Errno) {
3619 r0, _, _ := syscall.Syscall(procRtlNtStatusToDosErrorNoTeb.Addr(), 1, uintptr(ntstatus), 0, 0)
Jason A. Donenfeld134d1302021-02-28 01:06:24 +01003620 ret = syscall.Errno(r0)
3621 return
3622}
3623
Alex Brainman0aaa2712020-10-11 09:49:28 +11003624func clsidFromString(lpsz *uint16, pclsid *GUID) (ret error) {
3625 r0, _, _ := syscall.Syscall(procCLSIDFromString.Addr(), 2, uintptr(unsafe.Pointer(lpsz)), uintptr(unsafe.Pointer(pclsid)), 0)
3626 if r0 != 0 {
3627 ret = syscall.Errno(r0)
3628 }
3629 return
3630}
3631
3632func coCreateGuid(pguid *GUID) (ret error) {
3633 r0, _, _ := syscall.Syscall(procCoCreateGuid.Addr(), 1, uintptr(unsafe.Pointer(pguid)), 0, 0)
3634 if r0 != 0 {
3635 ret = syscall.Errno(r0)
3636 }
3637 return
3638}
3639
Jason A. Donenfeld0d6cb8b2021-03-03 23:50:28 +01003640func CoGetObject(name *uint16, bindOpts *BIND_OPTS3, guid *GUID, functionTable **uintptr) (ret error) {
3641 r0, _, _ := syscall.Syscall6(procCoGetObject.Addr(), 4, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(bindOpts)), uintptr(unsafe.Pointer(guid)), uintptr(unsafe.Pointer(functionTable)), 0, 0)
3642 if r0 != 0 {
3643 ret = syscall.Errno(r0)
3644 }
3645 return
3646}
3647
3648func CoInitializeEx(reserved uintptr, coInit uint32) (ret error) {
3649 r0, _, _ := syscall.Syscall(procCoInitializeEx.Addr(), 2, uintptr(reserved), uintptr(coInit), 0)
3650 if r0 != 0 {
3651 ret = syscall.Errno(r0)
3652 }
3653 return
3654}
3655
Alex Brainman0aaa2712020-10-11 09:49:28 +11003656func CoTaskMemFree(address unsafe.Pointer) {
3657 syscall.Syscall(procCoTaskMemFree.Addr(), 1, uintptr(address), 0, 0)
3658 return
3659}
3660
Jason A. Donenfeld0d6cb8b2021-03-03 23:50:28 +01003661func CoUninitialize() {
3662 syscall.Syscall(procCoUninitialize.Addr(), 0, 0, 0, 0)
3663 return
3664}
3665
Alex Brainman0aaa2712020-10-11 09:49:28 +11003666func stringFromGUID2(rguid *GUID, lpsz *uint16, cchMax int32) (chars int32) {
3667 r0, _, _ := syscall.Syscall(procStringFromGUID2.Addr(), 3, uintptr(unsafe.Pointer(rguid)), uintptr(unsafe.Pointer(lpsz)), uintptr(cchMax))
3668 chars = int32(r0)
3669 return
3670}
3671
Weilu Jia92d5a992021-09-20 22:56:04 +00003672func EnumProcessModules(process Handle, module *Handle, cb uint32, cbNeeded *uint32) (err error) {
3673 r1, _, e1 := syscall.Syscall6(procEnumProcessModules.Addr(), 4, uintptr(process), uintptr(unsafe.Pointer(module)), uintptr(cb), uintptr(unsafe.Pointer(cbNeeded)), 0, 0)
3674 if r1 == 0 {
3675 err = errnoErr(e1)
3676 }
3677 return
3678}
3679
3680func EnumProcessModulesEx(process Handle, module *Handle, cb uint32, cbNeeded *uint32, filterFlag uint32) (err error) {
3681 r1, _, e1 := syscall.Syscall6(procEnumProcessModulesEx.Addr(), 5, uintptr(process), uintptr(unsafe.Pointer(module)), uintptr(cb), uintptr(unsafe.Pointer(cbNeeded)), uintptr(filterFlag), 0)
3682 if r1 == 0 {
3683 err = errnoErr(e1)
3684 }
3685 return
3686}
3687
Roman Mazurc8ea6b02023-05-17 22:45:36 +02003688func enumProcesses(processIds *uint32, nSize uint32, bytesReturned *uint32) (err error) {
3689 r1, _, e1 := syscall.Syscall(procEnumProcesses.Addr(), 3, uintptr(unsafe.Pointer(processIds)), uintptr(nSize), uintptr(unsafe.Pointer(bytesReturned)))
Alex Brainman0aaa2712020-10-11 09:49:28 +11003690 if r1 == 0 {
3691 err = errnoErr(e1)
3692 }
3693 return
3694}
3695
Weilu Jia92d5a992021-09-20 22:56:04 +00003696func GetModuleBaseName(process Handle, module Handle, baseName *uint16, size uint32) (err error) {
3697 r1, _, e1 := syscall.Syscall6(procGetModuleBaseNameW.Addr(), 4, uintptr(process), uintptr(module), uintptr(unsafe.Pointer(baseName)), uintptr(size), 0, 0)
3698 if r1 == 0 {
3699 err = errnoErr(e1)
3700 }
3701 return
3702}
3703
3704func GetModuleFileNameEx(process Handle, module Handle, filename *uint16, size uint32) (err error) {
3705 r1, _, e1 := syscall.Syscall6(procGetModuleFileNameExW.Addr(), 4, uintptr(process), uintptr(module), uintptr(unsafe.Pointer(filename)), uintptr(size), 0, 0)
3706 if r1 == 0 {
3707 err = errnoErr(e1)
3708 }
3709 return
3710}
3711
3712func GetModuleInformation(process Handle, module Handle, modinfo *ModuleInfo, cb uint32) (err error) {
3713 r1, _, e1 := syscall.Syscall6(procGetModuleInformation.Addr(), 4, uintptr(process), uintptr(module), uintptr(unsafe.Pointer(modinfo)), uintptr(cb), 0, 0)
3714 if r1 == 0 {
3715 err = errnoErr(e1)
3716 }
3717 return
3718}
3719
awaw fumin1609e552022-07-29 01:46:33 +00003720func QueryWorkingSetEx(process Handle, pv uintptr, cb uint32) (err error) {
3721 r1, _, e1 := syscall.Syscall(procQueryWorkingSetEx.Addr(), 3, uintptr(process), uintptr(pv), uintptr(cb))
3722 if r1 == 0 {
3723 err = errnoErr(e1)
3724 }
3725 return
3726}
3727
Jason A. Donenfeldc9906e32020-12-02 23:27:29 +01003728func SubscribeServiceChangeNotifications(service Handle, eventType uint32, callback uintptr, callbackCtx uintptr, subscription *uintptr) (ret error) {
3729 ret = procSubscribeServiceChangeNotifications.Find()
3730 if ret != nil {
3731 return
3732 }
3733 r0, _, _ := syscall.Syscall6(procSubscribeServiceChangeNotifications.Addr(), 5, uintptr(service), uintptr(eventType), uintptr(callback), uintptr(callbackCtx), uintptr(unsafe.Pointer(subscription)), 0)
3734 if r0 != 0 {
3735 ret = syscall.Errno(r0)
3736 }
3737 return
3738}
3739
3740func UnsubscribeServiceChangeNotifications(subscription uintptr) (err error) {
3741 err = procUnsubscribeServiceChangeNotifications.Find()
3742 if err != nil {
3743 return
3744 }
3745 syscall.Syscall(procUnsubscribeServiceChangeNotifications.Addr(), 1, uintptr(subscription), 0, 0)
3746 return
3747}
3748
Alex Brainman0aaa2712020-10-11 09:49:28 +11003749func GetUserNameEx(nameFormat uint32, nameBuffre *uint16, nSize *uint32) (err error) {
3750 r1, _, e1 := syscall.Syscall(procGetUserNameExW.Addr(), 3, uintptr(nameFormat), uintptr(unsafe.Pointer(nameBuffre)), uintptr(unsafe.Pointer(nSize)))
3751 if r1&0xff == 0 {
3752 err = errnoErr(e1)
3753 }
3754 return
3755}
3756
3757func TranslateName(accName *uint16, accNameFormat uint32, desiredNameFormat uint32, translatedName *uint16, nSize *uint32) (err error) {
3758 r1, _, e1 := syscall.Syscall6(procTranslateNameW.Addr(), 5, uintptr(unsafe.Pointer(accName)), uintptr(accNameFormat), uintptr(desiredNameFormat), uintptr(unsafe.Pointer(translatedName)), uintptr(unsafe.Pointer(nSize)), 0)
3759 if r1&0xff == 0 {
3760 err = errnoErr(e1)
3761 }
3762 return
3763}
3764
Jason A. Donenfeldfe613092021-10-27 15:23:03 +02003765func SetupDiBuildDriverInfoList(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, driverType SPDIT) (err error) {
3766 r1, _, e1 := syscall.Syscall(procSetupDiBuildDriverInfoList.Addr(), 3, uintptr(deviceInfoSet), uintptr(unsafe.Pointer(deviceInfoData)), uintptr(driverType))
3767 if r1 == 0 {
3768 err = errnoErr(e1)
3769 }
3770 return
3771}
3772
3773func SetupDiCallClassInstaller(installFunction DI_FUNCTION, deviceInfoSet DevInfo, deviceInfoData *DevInfoData) (err error) {
3774 r1, _, e1 := syscall.Syscall(procSetupDiCallClassInstaller.Addr(), 3, uintptr(installFunction), uintptr(deviceInfoSet), uintptr(unsafe.Pointer(deviceInfoData)))
3775 if r1 == 0 {
3776 err = errnoErr(e1)
3777 }
3778 return
3779}
3780
3781func SetupDiCancelDriverInfoSearch(deviceInfoSet DevInfo) (err error) {
3782 r1, _, e1 := syscall.Syscall(procSetupDiCancelDriverInfoSearch.Addr(), 1, uintptr(deviceInfoSet), 0, 0)
3783 if r1 == 0 {
3784 err = errnoErr(e1)
3785 }
3786 return
3787}
3788
3789func setupDiClassGuidsFromNameEx(className *uint16, classGuidList *GUID, classGuidListSize uint32, requiredSize *uint32, machineName *uint16, reserved uintptr) (err error) {
3790 r1, _, e1 := syscall.Syscall6(procSetupDiClassGuidsFromNameExW.Addr(), 6, uintptr(unsafe.Pointer(className)), uintptr(unsafe.Pointer(classGuidList)), uintptr(classGuidListSize), uintptr(unsafe.Pointer(requiredSize)), uintptr(unsafe.Pointer(machineName)), uintptr(reserved))
3791 if r1 == 0 {
3792 err = errnoErr(e1)
3793 }
3794 return
3795}
3796
3797func setupDiClassNameFromGuidEx(classGUID *GUID, className *uint16, classNameSize uint32, requiredSize *uint32, machineName *uint16, reserved uintptr) (err error) {
3798 r1, _, e1 := syscall.Syscall6(procSetupDiClassNameFromGuidExW.Addr(), 6, uintptr(unsafe.Pointer(classGUID)), uintptr(unsafe.Pointer(className)), uintptr(classNameSize), uintptr(unsafe.Pointer(requiredSize)), uintptr(unsafe.Pointer(machineName)), uintptr(reserved))
3799 if r1 == 0 {
3800 err = errnoErr(e1)
3801 }
3802 return
3803}
3804
3805func setupDiCreateDeviceInfoListEx(classGUID *GUID, hwndParent uintptr, machineName *uint16, reserved uintptr) (handle DevInfo, err error) {
3806 r0, _, e1 := syscall.Syscall6(procSetupDiCreateDeviceInfoListExW.Addr(), 4, uintptr(unsafe.Pointer(classGUID)), uintptr(hwndParent), uintptr(unsafe.Pointer(machineName)), uintptr(reserved), 0, 0)
3807 handle = DevInfo(r0)
3808 if handle == DevInfo(InvalidHandle) {
3809 err = errnoErr(e1)
3810 }
3811 return
3812}
3813
3814func setupDiCreateDeviceInfo(deviceInfoSet DevInfo, DeviceName *uint16, classGUID *GUID, DeviceDescription *uint16, hwndParent uintptr, CreationFlags DICD, deviceInfoData *DevInfoData) (err error) {
3815 r1, _, e1 := syscall.Syscall9(procSetupDiCreateDeviceInfoW.Addr(), 7, uintptr(deviceInfoSet), uintptr(unsafe.Pointer(DeviceName)), uintptr(unsafe.Pointer(classGUID)), uintptr(unsafe.Pointer(DeviceDescription)), uintptr(hwndParent), uintptr(CreationFlags), uintptr(unsafe.Pointer(deviceInfoData)), 0, 0)
3816 if r1 == 0 {
3817 err = errnoErr(e1)
3818 }
3819 return
3820}
3821
3822func SetupDiDestroyDeviceInfoList(deviceInfoSet DevInfo) (err error) {
3823 r1, _, e1 := syscall.Syscall(procSetupDiDestroyDeviceInfoList.Addr(), 1, uintptr(deviceInfoSet), 0, 0)
3824 if r1 == 0 {
3825 err = errnoErr(e1)
3826 }
3827 return
3828}
3829
3830func SetupDiDestroyDriverInfoList(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, driverType SPDIT) (err error) {
3831 r1, _, e1 := syscall.Syscall(procSetupDiDestroyDriverInfoList.Addr(), 3, uintptr(deviceInfoSet), uintptr(unsafe.Pointer(deviceInfoData)), uintptr(driverType))
3832 if r1 == 0 {
3833 err = errnoErr(e1)
3834 }
3835 return
3836}
3837
3838func setupDiEnumDeviceInfo(deviceInfoSet DevInfo, memberIndex uint32, deviceInfoData *DevInfoData) (err error) {
3839 r1, _, e1 := syscall.Syscall(procSetupDiEnumDeviceInfo.Addr(), 3, uintptr(deviceInfoSet), uintptr(memberIndex), uintptr(unsafe.Pointer(deviceInfoData)))
3840 if r1 == 0 {
3841 err = errnoErr(e1)
3842 }
3843 return
3844}
3845
3846func setupDiEnumDriverInfo(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, driverType SPDIT, memberIndex uint32, driverInfoData *DrvInfoData) (err error) {
3847 r1, _, e1 := syscall.Syscall6(procSetupDiEnumDriverInfoW.Addr(), 5, uintptr(deviceInfoSet), uintptr(unsafe.Pointer(deviceInfoData)), uintptr(driverType), uintptr(memberIndex), uintptr(unsafe.Pointer(driverInfoData)), 0)
3848 if r1 == 0 {
3849 err = errnoErr(e1)
3850 }
3851 return
3852}
3853
3854func setupDiGetClassDevsEx(classGUID *GUID, Enumerator *uint16, hwndParent uintptr, Flags DIGCF, deviceInfoSet DevInfo, machineName *uint16, reserved uintptr) (handle DevInfo, err error) {
3855 r0, _, e1 := syscall.Syscall9(procSetupDiGetClassDevsExW.Addr(), 7, uintptr(unsafe.Pointer(classGUID)), uintptr(unsafe.Pointer(Enumerator)), uintptr(hwndParent), uintptr(Flags), uintptr(deviceInfoSet), uintptr(unsafe.Pointer(machineName)), uintptr(reserved), 0, 0)
3856 handle = DevInfo(r0)
3857 if handle == DevInfo(InvalidHandle) {
3858 err = errnoErr(e1)
3859 }
3860 return
3861}
3862
3863func SetupDiGetClassInstallParams(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, classInstallParams *ClassInstallHeader, classInstallParamsSize uint32, requiredSize *uint32) (err error) {
3864 r1, _, e1 := syscall.Syscall6(procSetupDiGetClassInstallParamsW.Addr(), 5, uintptr(deviceInfoSet), uintptr(unsafe.Pointer(deviceInfoData)), uintptr(unsafe.Pointer(classInstallParams)), uintptr(classInstallParamsSize), uintptr(unsafe.Pointer(requiredSize)), 0)
3865 if r1 == 0 {
3866 err = errnoErr(e1)
3867 }
3868 return
3869}
3870
3871func setupDiGetDeviceInfoListDetail(deviceInfoSet DevInfo, deviceInfoSetDetailData *DevInfoListDetailData) (err error) {
3872 r1, _, e1 := syscall.Syscall(procSetupDiGetDeviceInfoListDetailW.Addr(), 2, uintptr(deviceInfoSet), uintptr(unsafe.Pointer(deviceInfoSetDetailData)), 0)
3873 if r1 == 0 {
3874 err = errnoErr(e1)
3875 }
3876 return
3877}
3878
3879func setupDiGetDeviceInstallParams(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, deviceInstallParams *DevInstallParams) (err error) {
3880 r1, _, e1 := syscall.Syscall(procSetupDiGetDeviceInstallParamsW.Addr(), 3, uintptr(deviceInfoSet), uintptr(unsafe.Pointer(deviceInfoData)), uintptr(unsafe.Pointer(deviceInstallParams)))
3881 if r1 == 0 {
3882 err = errnoErr(e1)
3883 }
3884 return
3885}
3886
3887func setupDiGetDeviceInstanceId(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, instanceId *uint16, instanceIdSize uint32, instanceIdRequiredSize *uint32) (err error) {
3888 r1, _, e1 := syscall.Syscall6(procSetupDiGetDeviceInstanceIdW.Addr(), 5, uintptr(deviceInfoSet), uintptr(unsafe.Pointer(deviceInfoData)), uintptr(unsafe.Pointer(instanceId)), uintptr(instanceIdSize), uintptr(unsafe.Pointer(instanceIdRequiredSize)), 0)
3889 if r1 == 0 {
3890 err = errnoErr(e1)
3891 }
3892 return
3893}
3894
3895func setupDiGetDeviceProperty(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, propertyKey *DEVPROPKEY, propertyType *DEVPROPTYPE, propertyBuffer *byte, propertyBufferSize uint32, requiredSize *uint32, flags uint32) (err error) {
3896 r1, _, e1 := syscall.Syscall9(procSetupDiGetDevicePropertyW.Addr(), 8, uintptr(deviceInfoSet), uintptr(unsafe.Pointer(deviceInfoData)), uintptr(unsafe.Pointer(propertyKey)), uintptr(unsafe.Pointer(propertyType)), uintptr(unsafe.Pointer(propertyBuffer)), uintptr(propertyBufferSize), uintptr(unsafe.Pointer(requiredSize)), uintptr(flags), 0)
3897 if r1 == 0 {
3898 err = errnoErr(e1)
3899 }
3900 return
3901}
3902
3903func setupDiGetDeviceRegistryProperty(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, property SPDRP, propertyRegDataType *uint32, propertyBuffer *byte, propertyBufferSize uint32, requiredSize *uint32) (err error) {
3904 r1, _, e1 := syscall.Syscall9(procSetupDiGetDeviceRegistryPropertyW.Addr(), 7, uintptr(deviceInfoSet), uintptr(unsafe.Pointer(deviceInfoData)), uintptr(property), uintptr(unsafe.Pointer(propertyRegDataType)), uintptr(unsafe.Pointer(propertyBuffer)), uintptr(propertyBufferSize), uintptr(unsafe.Pointer(requiredSize)), 0, 0)
3905 if r1 == 0 {
3906 err = errnoErr(e1)
3907 }
3908 return
3909}
3910
3911func setupDiGetDriverInfoDetail(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, driverInfoData *DrvInfoData, driverInfoDetailData *DrvInfoDetailData, driverInfoDetailDataSize uint32, requiredSize *uint32) (err error) {
3912 r1, _, e1 := syscall.Syscall6(procSetupDiGetDriverInfoDetailW.Addr(), 6, uintptr(deviceInfoSet), uintptr(unsafe.Pointer(deviceInfoData)), uintptr(unsafe.Pointer(driverInfoData)), uintptr(unsafe.Pointer(driverInfoDetailData)), uintptr(driverInfoDetailDataSize), uintptr(unsafe.Pointer(requiredSize)))
3913 if r1 == 0 {
3914 err = errnoErr(e1)
3915 }
3916 return
3917}
3918
3919func setupDiGetSelectedDevice(deviceInfoSet DevInfo, deviceInfoData *DevInfoData) (err error) {
3920 r1, _, e1 := syscall.Syscall(procSetupDiGetSelectedDevice.Addr(), 2, uintptr(deviceInfoSet), uintptr(unsafe.Pointer(deviceInfoData)), 0)
3921 if r1 == 0 {
3922 err = errnoErr(e1)
3923 }
3924 return
3925}
3926
3927func setupDiGetSelectedDriver(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, driverInfoData *DrvInfoData) (err error) {
3928 r1, _, e1 := syscall.Syscall(procSetupDiGetSelectedDriverW.Addr(), 3, uintptr(deviceInfoSet), uintptr(unsafe.Pointer(deviceInfoData)), uintptr(unsafe.Pointer(driverInfoData)))
3929 if r1 == 0 {
3930 err = errnoErr(e1)
3931 }
3932 return
3933}
3934
3935func SetupDiOpenDevRegKey(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, Scope DICS_FLAG, HwProfile uint32, KeyType DIREG, samDesired uint32) (key Handle, err error) {
3936 r0, _, e1 := syscall.Syscall6(procSetupDiOpenDevRegKey.Addr(), 6, uintptr(deviceInfoSet), uintptr(unsafe.Pointer(deviceInfoData)), uintptr(Scope), uintptr(HwProfile), uintptr(KeyType), uintptr(samDesired))
3937 key = Handle(r0)
3938 if key == InvalidHandle {
3939 err = errnoErr(e1)
3940 }
3941 return
3942}
3943
3944func SetupDiSetClassInstallParams(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, classInstallParams *ClassInstallHeader, classInstallParamsSize uint32) (err error) {
3945 r1, _, e1 := syscall.Syscall6(procSetupDiSetClassInstallParamsW.Addr(), 4, uintptr(deviceInfoSet), uintptr(unsafe.Pointer(deviceInfoData)), uintptr(unsafe.Pointer(classInstallParams)), uintptr(classInstallParamsSize), 0, 0)
3946 if r1 == 0 {
3947 err = errnoErr(e1)
3948 }
3949 return
3950}
3951
3952func SetupDiSetDeviceInstallParams(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, deviceInstallParams *DevInstallParams) (err error) {
3953 r1, _, e1 := syscall.Syscall(procSetupDiSetDeviceInstallParamsW.Addr(), 3, uintptr(deviceInfoSet), uintptr(unsafe.Pointer(deviceInfoData)), uintptr(unsafe.Pointer(deviceInstallParams)))
3954 if r1 == 0 {
3955 err = errnoErr(e1)
3956 }
3957 return
3958}
3959
3960func setupDiSetDeviceRegistryProperty(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, property SPDRP, propertyBuffer *byte, propertyBufferSize uint32) (err error) {
3961 r1, _, e1 := syscall.Syscall6(procSetupDiSetDeviceRegistryPropertyW.Addr(), 5, uintptr(deviceInfoSet), uintptr(unsafe.Pointer(deviceInfoData)), uintptr(property), uintptr(unsafe.Pointer(propertyBuffer)), uintptr(propertyBufferSize), 0)
3962 if r1 == 0 {
3963 err = errnoErr(e1)
3964 }
3965 return
3966}
3967
3968func SetupDiSetSelectedDevice(deviceInfoSet DevInfo, deviceInfoData *DevInfoData) (err error) {
3969 r1, _, e1 := syscall.Syscall(procSetupDiSetSelectedDevice.Addr(), 2, uintptr(deviceInfoSet), uintptr(unsafe.Pointer(deviceInfoData)), 0)
3970 if r1 == 0 {
3971 err = errnoErr(e1)
3972 }
3973 return
3974}
3975
3976func SetupDiSetSelectedDriver(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, driverInfoData *DrvInfoData) (err error) {
3977 r1, _, e1 := syscall.Syscall(procSetupDiSetSelectedDriverW.Addr(), 3, uintptr(deviceInfoSet), uintptr(unsafe.Pointer(deviceInfoData)), uintptr(unsafe.Pointer(driverInfoData)))
3978 if r1 == 0 {
3979 err = errnoErr(e1)
3980 }
3981 return
3982}
3983
3984func setupUninstallOEMInf(infFileName *uint16, flags SUOI, reserved uintptr) (err error) {
3985 r1, _, e1 := syscall.Syscall(procSetupUninstallOEMInfW.Addr(), 3, uintptr(unsafe.Pointer(infFileName)), uintptr(flags), uintptr(reserved))
3986 if r1 == 0 {
3987 err = errnoErr(e1)
3988 }
3989 return
3990}
3991
Bryan C. Mills01c413d2023-09-26 10:32:10 -04003992func commandLineToArgv(cmd *uint16, argc *int32) (argv **uint16, err error) {
Alex Brainman0aaa2712020-10-11 09:49:28 +11003993 r0, _, e1 := syscall.Syscall(procCommandLineToArgvW.Addr(), 2, uintptr(unsafe.Pointer(cmd)), uintptr(unsafe.Pointer(argc)), 0)
Bryan C. Mills01c413d2023-09-26 10:32:10 -04003994 argv = (**uint16)(unsafe.Pointer(r0))
Alex Brainman0aaa2712020-10-11 09:49:28 +11003995 if argv == nil {
3996 err = errnoErr(e1)
3997 }
3998 return
3999}
4000
4001func shGetKnownFolderPath(id *KNOWNFOLDERID, flags uint32, token Token, path **uint16) (ret error) {
4002 r0, _, _ := syscall.Syscall6(procSHGetKnownFolderPath.Addr(), 4, uintptr(unsafe.Pointer(id)), uintptr(flags), uintptr(token), uintptr(unsafe.Pointer(path)), 0, 0)
4003 if r0 != 0 {
4004 ret = syscall.Errno(r0)
4005 }
4006 return
4007}
4008
4009func ShellExecute(hwnd Handle, verb *uint16, file *uint16, args *uint16, cwd *uint16, showCmd int32) (err error) {
4010 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))
4011 if r1 <= 32 {
4012 err = errnoErr(e1)
4013 }
4014 return
4015}
4016
Michael Lelli3275c402022-09-12 22:13:50 +00004017func EnumChildWindows(hwnd HWND, enumFunc uintptr, param unsafe.Pointer) {
4018 syscall.Syscall(procEnumChildWindows.Addr(), 3, uintptr(hwnd), uintptr(enumFunc), uintptr(param))
4019 return
4020}
4021
4022func EnumWindows(enumFunc uintptr, param unsafe.Pointer) (err error) {
4023 r1, _, e1 := syscall.Syscall(procEnumWindows.Addr(), 2, uintptr(enumFunc), uintptr(param), 0)
4024 if r1 == 0 {
4025 err = errnoErr(e1)
4026 }
4027 return
4028}
4029
Alex Brainman0aaa2712020-10-11 09:49:28 +11004030func ExitWindowsEx(flags uint32, reason uint32) (err error) {
4031 r1, _, e1 := syscall.Syscall(procExitWindowsEx.Addr(), 2, uintptr(flags), uintptr(reason), 0)
4032 if r1 == 0 {
4033 err = errnoErr(e1)
4034 }
4035 return
4036}
4037
Michael Lelli3275c402022-09-12 22:13:50 +00004038func GetClassName(hwnd HWND, className *uint16, maxCount int32) (copied int32, err error) {
4039 r0, _, e1 := syscall.Syscall(procGetClassNameW.Addr(), 3, uintptr(hwnd), uintptr(unsafe.Pointer(className)), uintptr(maxCount))
4040 copied = int32(r0)
4041 if copied == 0 {
4042 err = errnoErr(e1)
4043 }
4044 return
4045}
4046
4047func GetDesktopWindow() (hwnd HWND) {
4048 r0, _, _ := syscall.Syscall(procGetDesktopWindow.Addr(), 0, 0, 0, 0)
4049 hwnd = HWND(r0)
4050 return
4051}
4052
4053func GetForegroundWindow() (hwnd HWND) {
4054 r0, _, _ := syscall.Syscall(procGetForegroundWindow.Addr(), 0, 0, 0, 0)
4055 hwnd = HWND(r0)
4056 return
4057}
4058
4059func GetGUIThreadInfo(thread uint32, info *GUIThreadInfo) (err error) {
4060 r1, _, e1 := syscall.Syscall(procGetGUIThreadInfo.Addr(), 2, uintptr(thread), uintptr(unsafe.Pointer(info)), 0)
4061 if r1 == 0 {
4062 err = errnoErr(e1)
4063 }
4064 return
4065}
4066
Alex Brainman59c308d2021-01-11 16:46:25 +11004067func GetShellWindow() (shellWindow HWND) {
Alex Brainman0df21312021-01-06 18:08:16 +11004068 r0, _, _ := syscall.Syscall(procGetShellWindow.Addr(), 0, 0, 0, 0)
Alex Brainman59c308d2021-01-11 16:46:25 +11004069 shellWindow = HWND(r0)
Alex Brainman0df21312021-01-06 18:08:16 +11004070 return
4071}
4072
Jason A. Donenfeld04d74652021-01-21 15:17:19 +01004073func GetWindowThreadProcessId(hwnd HWND, pid *uint32) (tid uint32, err error) {
4074 r0, _, e1 := syscall.Syscall(procGetWindowThreadProcessId.Addr(), 2, uintptr(hwnd), uintptr(unsafe.Pointer(pid)), 0)
Alex Brainman0df21312021-01-06 18:08:16 +11004075 tid = uint32(r0)
Jason A. Donenfeld04d74652021-01-21 15:17:19 +01004076 if tid == 0 {
4077 err = errnoErr(e1)
4078 }
Alex Brainman0df21312021-01-06 18:08:16 +11004079 return
4080}
4081
Michael Lelli3275c402022-09-12 22:13:50 +00004082func IsWindow(hwnd HWND) (isWindow bool) {
4083 r0, _, _ := syscall.Syscall(procIsWindow.Addr(), 1, uintptr(hwnd), 0, 0)
4084 isWindow = r0 != 0
4085 return
4086}
4087
4088func IsWindowUnicode(hwnd HWND) (isUnicode bool) {
4089 r0, _, _ := syscall.Syscall(procIsWindowUnicode.Addr(), 1, uintptr(hwnd), 0, 0)
4090 isUnicode = r0 != 0
4091 return
4092}
4093
4094func IsWindowVisible(hwnd HWND) (isVisible bool) {
4095 r0, _, _ := syscall.Syscall(procIsWindowVisible.Addr(), 1, uintptr(hwnd), 0, 0)
4096 isVisible = r0 != 0
4097 return
4098}
4099
Alex Brainman59c308d2021-01-11 16:46:25 +11004100func MessageBox(hwnd HWND, text *uint16, caption *uint16, boxtype uint32) (ret int32, err error) {
Alex Brainman0aaa2712020-10-11 09:49:28 +11004101 r0, _, e1 := syscall.Syscall6(procMessageBoxW.Addr(), 4, uintptr(hwnd), uintptr(unsafe.Pointer(text)), uintptr(unsafe.Pointer(caption)), uintptr(boxtype), 0, 0)
4102 ret = int32(r0)
4103 if ret == 0 {
4104 err = errnoErr(e1)
4105 }
4106 return
4107}
4108
4109func CreateEnvironmentBlock(block **uint16, token Token, inheritExisting bool) (err error) {
4110 var _p0 uint32
4111 if inheritExisting {
4112 _p0 = 1
4113 }
4114 r1, _, e1 := syscall.Syscall(procCreateEnvironmentBlock.Addr(), 3, uintptr(unsafe.Pointer(block)), uintptr(token), uintptr(_p0))
4115 if r1 == 0 {
4116 err = errnoErr(e1)
4117 }
4118 return
4119}
4120
4121func DestroyEnvironmentBlock(block *uint16) (err error) {
4122 r1, _, e1 := syscall.Syscall(procDestroyEnvironmentBlock.Addr(), 1, uintptr(unsafe.Pointer(block)), 0, 0)
4123 if r1 == 0 {
4124 err = errnoErr(e1)
4125 }
4126 return
4127}
4128
4129func GetUserProfileDirectory(t Token, dir *uint16, dirLen *uint32) (err error) {
4130 r1, _, e1 := syscall.Syscall(procGetUserProfileDirectoryW.Addr(), 3, uintptr(t), uintptr(unsafe.Pointer(dir)), uintptr(unsafe.Pointer(dirLen)))
4131 if r1 == 0 {
4132 err = errnoErr(e1)
4133 }
4134 return
4135}
4136
Jason A. Donenfeld153b1542021-10-19 17:25:37 -06004137func GetFileVersionInfoSize(filename string, zeroHandle *Handle) (bufSize uint32, err error) {
4138 var _p0 *uint16
4139 _p0, err = syscall.UTF16PtrFromString(filename)
4140 if err != nil {
4141 return
4142 }
4143 return _GetFileVersionInfoSize(_p0, zeroHandle)
4144}
4145
4146func _GetFileVersionInfoSize(filename *uint16, zeroHandle *Handle) (bufSize uint32, err error) {
4147 r0, _, e1 := syscall.Syscall(procGetFileVersionInfoSizeW.Addr(), 2, uintptr(unsafe.Pointer(filename)), uintptr(unsafe.Pointer(zeroHandle)), 0)
4148 bufSize = uint32(r0)
4149 if bufSize == 0 {
4150 err = errnoErr(e1)
4151 }
4152 return
4153}
4154
4155func GetFileVersionInfo(filename string, handle uint32, bufSize uint32, buffer unsafe.Pointer) (err error) {
4156 var _p0 *uint16
4157 _p0, err = syscall.UTF16PtrFromString(filename)
4158 if err != nil {
4159 return
4160 }
4161 return _GetFileVersionInfo(_p0, handle, bufSize, buffer)
4162}
4163
4164func _GetFileVersionInfo(filename *uint16, handle uint32, bufSize uint32, buffer unsafe.Pointer) (err error) {
4165 r1, _, e1 := syscall.Syscall6(procGetFileVersionInfoW.Addr(), 4, uintptr(unsafe.Pointer(filename)), uintptr(handle), uintptr(bufSize), uintptr(buffer), 0, 0)
4166 if r1 == 0 {
4167 err = errnoErr(e1)
4168 }
4169 return
4170}
4171
4172func VerQueryValue(block unsafe.Pointer, subBlock string, pointerToBufferPointer unsafe.Pointer, bufSize *uint32) (err error) {
4173 var _p0 *uint16
4174 _p0, err = syscall.UTF16PtrFromString(subBlock)
4175 if err != nil {
4176 return
4177 }
4178 return _VerQueryValue(block, _p0, pointerToBufferPointer, bufSize)
4179}
4180
4181func _VerQueryValue(block unsafe.Pointer, subBlock *uint16, pointerToBufferPointer unsafe.Pointer, bufSize *uint32) (err error) {
4182 r1, _, e1 := syscall.Syscall6(procVerQueryValueW.Addr(), 4, uintptr(block), uintptr(unsafe.Pointer(subBlock)), uintptr(pointerToBufferPointer), uintptr(unsafe.Pointer(bufSize)), 0, 0)
4183 if r1 == 0 {
4184 err = errnoErr(e1)
4185 }
4186 return
4187}
4188
qmuntal60ecf132023-08-04 11:50:46 +02004189func TimeBeginPeriod(period uint32) (err error) {
4190 r1, _, e1 := syscall.Syscall(proctimeBeginPeriod.Addr(), 1, uintptr(period), 0, 0)
4191 if r1 != 0 {
4192 err = errnoErr(e1)
4193 }
4194 return
4195}
4196
4197func TimeEndPeriod(period uint32) (err error) {
4198 r1, _, e1 := syscall.Syscall(proctimeEndPeriod.Addr(), 1, uintptr(period), 0, 0)
4199 if r1 != 0 {
4200 err = errnoErr(e1)
4201 }
4202 return
4203}
4204
Jason A. Donenfeld07034702021-01-22 17:59:47 +01004205func WinVerifyTrustEx(hwnd HWND, actionId *GUID, data *WinTrustData) (ret error) {
4206 r0, _, _ := syscall.Syscall(procWinVerifyTrustEx.Addr(), 3, uintptr(hwnd), uintptr(unsafe.Pointer(actionId)), uintptr(unsafe.Pointer(data)))
4207 if r0 != 0 {
4208 ret = syscall.Errno(r0)
4209 }
4210 return
4211}
4212
Alex Brainman0aaa2712020-10-11 09:49:28 +11004213func FreeAddrInfoW(addrinfo *AddrinfoW) {
4214 syscall.Syscall(procFreeAddrInfoW.Addr(), 1, uintptr(unsafe.Pointer(addrinfo)), 0, 0)
4215 return
4216}
4217
4218func GetAddrInfoW(nodename *uint16, servicename *uint16, hints *AddrinfoW, result **AddrinfoW) (sockerr error) {
4219 r0, _, _ := syscall.Syscall6(procGetAddrInfoW.Addr(), 4, uintptr(unsafe.Pointer(nodename)), uintptr(unsafe.Pointer(servicename)), uintptr(unsafe.Pointer(hints)), uintptr(unsafe.Pointer(result)), 0, 0)
4220 if r0 != 0 {
4221 sockerr = syscall.Errno(r0)
4222 }
4223 return
4224}
4225
4226func WSACleanup() (err error) {
4227 r1, _, e1 := syscall.Syscall(procWSACleanup.Addr(), 0, 0, 0, 0)
4228 if r1 == socket_error {
4229 err = errnoErr(e1)
4230 }
4231 return
4232}
4233
4234func WSAEnumProtocols(protocols *int32, protocolBuffer *WSAProtocolInfo, bufferLength *uint32) (n int32, err error) {
4235 r0, _, e1 := syscall.Syscall(procWSAEnumProtocolsW.Addr(), 3, uintptr(unsafe.Pointer(protocols)), uintptr(unsafe.Pointer(protocolBuffer)), uintptr(unsafe.Pointer(bufferLength)))
4236 n = int32(r0)
4237 if n == -1 {
4238 err = errnoErr(e1)
4239 }
4240 return
4241}
4242
Jason A. Donenfeld7b4935e2021-03-03 14:05:15 +01004243func WSAGetOverlappedResult(h Handle, o *Overlapped, bytes *uint32, wait bool, flags *uint32) (err error) {
4244 var _p0 uint32
4245 if wait {
4246 _p0 = 1
4247 }
4248 r1, _, e1 := syscall.Syscall6(procWSAGetOverlappedResult.Addr(), 5, uintptr(h), uintptr(unsafe.Pointer(o)), uintptr(unsafe.Pointer(bytes)), uintptr(_p0), uintptr(unsafe.Pointer(flags)), 0)
4249 if r1 == 0 {
4250 err = errnoErr(e1)
4251 }
4252 return
4253}
4254
Alex Brainman0aaa2712020-10-11 09:49:28 +11004255func WSAIoctl(s Handle, iocc uint32, inbuf *byte, cbif uint32, outbuf *byte, cbob uint32, cbbr *uint32, overlapped *Overlapped, completionRoutine uintptr) (err error) {
4256 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))
4257 if r1 == socket_error {
4258 err = errnoErr(e1)
4259 }
4260 return
4261}
4262
PumpkinSeed4fee21c2022-08-15 10:39:57 +02004263func WSALookupServiceBegin(querySet *WSAQUERYSET, flags uint32, handle *Handle) (err error) {
4264 r1, _, e1 := syscall.Syscall(procWSALookupServiceBeginW.Addr(), 3, uintptr(unsafe.Pointer(querySet)), uintptr(flags), uintptr(unsafe.Pointer(handle)))
4265 if r1 == socket_error {
4266 err = errnoErr(e1)
4267 }
4268 return
4269}
4270
4271func WSALookupServiceEnd(handle Handle) (err error) {
4272 r1, _, e1 := syscall.Syscall(procWSALookupServiceEnd.Addr(), 1, uintptr(handle), 0, 0)
4273 if r1 == socket_error {
4274 err = errnoErr(e1)
4275 }
4276 return
4277}
4278
4279func WSALookupServiceNext(handle Handle, flags uint32, size *int32, querySet *WSAQUERYSET) (err error) {
4280 r1, _, e1 := syscall.Syscall6(procWSALookupServiceNextW.Addr(), 4, uintptr(handle), uintptr(flags), uintptr(unsafe.Pointer(size)), uintptr(unsafe.Pointer(querySet)), 0, 0)
4281 if r1 == socket_error {
4282 err = errnoErr(e1)
4283 }
4284 return
4285}
4286
Alex Brainman0aaa2712020-10-11 09:49:28 +11004287func WSARecv(s Handle, bufs *WSABuf, bufcnt uint32, recvd *uint32, flags *uint32, overlapped *Overlapped, croutine *byte) (err error) {
4288 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)
4289 if r1 == socket_error {
4290 err = errnoErr(e1)
4291 }
4292 return
4293}
4294
4295func WSARecvFrom(s Handle, bufs *WSABuf, bufcnt uint32, recvd *uint32, flags *uint32, from *RawSockaddrAny, fromlen *int32, overlapped *Overlapped, croutine *byte) (err error) {
4296 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)))
4297 if r1 == socket_error {
4298 err = errnoErr(e1)
4299 }
4300 return
4301}
4302
4303func WSASend(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, overlapped *Overlapped, croutine *byte) (err error) {
4304 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)
4305 if r1 == socket_error {
4306 err = errnoErr(e1)
4307 }
4308 return
4309}
4310
4311func WSASendTo(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, to *RawSockaddrAny, tolen int32, overlapped *Overlapped, croutine *byte) (err error) {
4312 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)))
4313 if r1 == socket_error {
4314 err = errnoErr(e1)
4315 }
4316 return
4317}
4318
Jason A. Donenfeldeede4232021-02-23 13:44:32 +01004319func WSASocket(af int32, typ int32, protocol int32, protoInfo *WSAProtocolInfo, group uint32, flags uint32) (handle Handle, err error) {
4320 r0, _, e1 := syscall.Syscall6(procWSASocketW.Addr(), 6, uintptr(af), uintptr(typ), uintptr(protocol), uintptr(unsafe.Pointer(protoInfo)), uintptr(group), uintptr(flags))
4321 handle = Handle(r0)
4322 if handle == InvalidHandle {
4323 err = errnoErr(e1)
4324 }
4325 return
4326}
4327
Alex Brainman0aaa2712020-10-11 09:49:28 +11004328func WSAStartup(verreq uint32, data *WSAData) (sockerr error) {
4329 r0, _, _ := syscall.Syscall(procWSAStartup.Addr(), 2, uintptr(verreq), uintptr(unsafe.Pointer(data)), 0)
4330 if r0 != 0 {
4331 sockerr = syscall.Errno(r0)
4332 }
4333 return
4334}
4335
4336func bind(s Handle, name unsafe.Pointer, namelen int32) (err error) {
4337 r1, _, e1 := syscall.Syscall(procbind.Addr(), 3, uintptr(s), uintptr(name), uintptr(namelen))
4338 if r1 == socket_error {
4339 err = errnoErr(e1)
4340 }
4341 return
4342}
4343
4344func Closesocket(s Handle) (err error) {
4345 r1, _, e1 := syscall.Syscall(procclosesocket.Addr(), 1, uintptr(s), 0, 0)
4346 if r1 == socket_error {
4347 err = errnoErr(e1)
4348 }
4349 return
4350}
4351
4352func connect(s Handle, name unsafe.Pointer, namelen int32) (err error) {
4353 r1, _, e1 := syscall.Syscall(procconnect.Addr(), 3, uintptr(s), uintptr(name), uintptr(namelen))
4354 if r1 == socket_error {
4355 err = errnoErr(e1)
4356 }
4357 return
4358}
4359
4360func GetHostByName(name string) (h *Hostent, err error) {
4361 var _p0 *byte
4362 _p0, err = syscall.BytePtrFromString(name)
4363 if err != nil {
4364 return
4365 }
4366 return _GetHostByName(_p0)
4367}
4368
4369func _GetHostByName(name *byte) (h *Hostent, err error) {
4370 r0, _, e1 := syscall.Syscall(procgethostbyname.Addr(), 1, uintptr(unsafe.Pointer(name)), 0, 0)
4371 h = (*Hostent)(unsafe.Pointer(r0))
4372 if h == nil {
4373 err = errnoErr(e1)
4374 }
4375 return
4376}
4377
4378func getpeername(s Handle, rsa *RawSockaddrAny, addrlen *int32) (err error) {
4379 r1, _, e1 := syscall.Syscall(procgetpeername.Addr(), 3, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
4380 if r1 == socket_error {
4381 err = errnoErr(e1)
4382 }
4383 return
4384}
4385
4386func GetProtoByName(name string) (p *Protoent, err error) {
4387 var _p0 *byte
4388 _p0, err = syscall.BytePtrFromString(name)
4389 if err != nil {
4390 return
4391 }
4392 return _GetProtoByName(_p0)
4393}
4394
4395func _GetProtoByName(name *byte) (p *Protoent, err error) {
4396 r0, _, e1 := syscall.Syscall(procgetprotobyname.Addr(), 1, uintptr(unsafe.Pointer(name)), 0, 0)
4397 p = (*Protoent)(unsafe.Pointer(r0))
4398 if p == nil {
4399 err = errnoErr(e1)
4400 }
4401 return
4402}
4403
4404func GetServByName(name string, proto string) (s *Servent, err error) {
4405 var _p0 *byte
4406 _p0, err = syscall.BytePtrFromString(name)
4407 if err != nil {
4408 return
4409 }
4410 var _p1 *byte
4411 _p1, err = syscall.BytePtrFromString(proto)
4412 if err != nil {
4413 return
4414 }
4415 return _GetServByName(_p0, _p1)
4416}
4417
4418func _GetServByName(name *byte, proto *byte) (s *Servent, err error) {
4419 r0, _, e1 := syscall.Syscall(procgetservbyname.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(proto)), 0)
4420 s = (*Servent)(unsafe.Pointer(r0))
4421 if s == nil {
4422 err = errnoErr(e1)
4423 }
4424 return
4425}
4426
4427func getsockname(s Handle, rsa *RawSockaddrAny, addrlen *int32) (err error) {
4428 r1, _, e1 := syscall.Syscall(procgetsockname.Addr(), 3, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
4429 if r1 == socket_error {
4430 err = errnoErr(e1)
4431 }
4432 return
4433}
4434
4435func Getsockopt(s Handle, level int32, optname int32, optval *byte, optlen *int32) (err error) {
4436 r1, _, e1 := syscall.Syscall6(procgetsockopt.Addr(), 5, uintptr(s), uintptr(level), uintptr(optname), uintptr(unsafe.Pointer(optval)), uintptr(unsafe.Pointer(optlen)), 0)
4437 if r1 == socket_error {
4438 err = errnoErr(e1)
4439 }
4440 return
4441}
4442
4443func listen(s Handle, backlog int32) (err error) {
4444 r1, _, e1 := syscall.Syscall(proclisten.Addr(), 2, uintptr(s), uintptr(backlog), 0)
4445 if r1 == socket_error {
4446 err = errnoErr(e1)
4447 }
4448 return
4449}
4450
4451func Ntohs(netshort uint16) (u uint16) {
4452 r0, _, _ := syscall.Syscall(procntohs.Addr(), 1, uintptr(netshort), 0, 0)
4453 u = uint16(r0)
4454 return
4455}
4456
4457func recvfrom(s Handle, buf []byte, flags int32, from *RawSockaddrAny, fromlen *int32) (n int32, err error) {
4458 var _p0 *byte
4459 if len(buf) > 0 {
4460 _p0 = &buf[0]
4461 }
4462 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)))
4463 n = int32(r0)
4464 if n == -1 {
4465 err = errnoErr(e1)
4466 }
4467 return
4468}
4469
4470func sendto(s Handle, buf []byte, flags int32, to unsafe.Pointer, tolen int32) (err error) {
4471 var _p0 *byte
4472 if len(buf) > 0 {
4473 _p0 = &buf[0]
4474 }
4475 r1, _, e1 := syscall.Syscall6(procsendto.Addr(), 6, uintptr(s), uintptr(unsafe.Pointer(_p0)), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(tolen))
4476 if r1 == socket_error {
4477 err = errnoErr(e1)
4478 }
4479 return
4480}
4481
4482func Setsockopt(s Handle, level int32, optname int32, optval *byte, optlen int32) (err error) {
4483 r1, _, e1 := syscall.Syscall6(procsetsockopt.Addr(), 5, uintptr(s), uintptr(level), uintptr(optname), uintptr(unsafe.Pointer(optval)), uintptr(optlen), 0)
4484 if r1 == socket_error {
4485 err = errnoErr(e1)
4486 }
4487 return
4488}
4489
4490func shutdown(s Handle, how int32) (err error) {
4491 r1, _, e1 := syscall.Syscall(procshutdown.Addr(), 2, uintptr(s), uintptr(how), 0)
4492 if r1 == socket_error {
4493 err = errnoErr(e1)
4494 }
4495 return
4496}
4497
4498func socket(af int32, typ int32, protocol int32) (handle Handle, err error) {
4499 r0, _, e1 := syscall.Syscall(procsocket.Addr(), 3, uintptr(af), uintptr(typ), uintptr(protocol))
4500 handle = Handle(r0)
4501 if handle == InvalidHandle {
4502 err = errnoErr(e1)
4503 }
4504 return
4505}
4506
4507func WTSEnumerateSessions(handle Handle, reserved uint32, version uint32, sessions **WTS_SESSION_INFO, count *uint32) (err error) {
4508 r1, _, e1 := syscall.Syscall6(procWTSEnumerateSessionsW.Addr(), 5, uintptr(handle), uintptr(reserved), uintptr(version), uintptr(unsafe.Pointer(sessions)), uintptr(unsafe.Pointer(count)), 0)
4509 if r1 == 0 {
4510 err = errnoErr(e1)
4511 }
4512 return
4513}
4514
4515func WTSFreeMemory(ptr uintptr) {
4516 syscall.Syscall(procWTSFreeMemory.Addr(), 1, uintptr(ptr), 0, 0)
4517 return
4518}
4519
4520func WTSQueryUserToken(session uint32, token *Token) (err error) {
4521 r1, _, e1 := syscall.Syscall(procWTSQueryUserToken.Addr(), 2, uintptr(session), uintptr(unsafe.Pointer(token)), 0)
4522 if r1 == 0 {
4523 err = errnoErr(e1)
4524 }
4525 return
4526}