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