You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

2271 lines
74 KiB

  1. // MACHINE GENERATED BY 'go generate' COMMAND; DO NOT EDIT
  2. package windows
  3. import (
  4. "syscall"
  5. "unsafe"
  6. )
  7. var _ unsafe.Pointer
  8. // Do the interface allocations only once for common
  9. // Errno values.
  10. const (
  11. errnoERROR_IO_PENDING = 997
  12. )
  13. var (
  14. errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING)
  15. )
  16. // errnoErr returns common boxed Errno values, to prevent
  17. // allocations at runtime.
  18. func errnoErr(e syscall.Errno) error {
  19. switch e {
  20. case 0:
  21. return nil
  22. case errnoERROR_IO_PENDING:
  23. return errERROR_IO_PENDING
  24. }
  25. // TODO: add more here, after collecting data on the common
  26. // error values see on Windows. (perhaps when running
  27. // all.bat?)
  28. return e
  29. }
  30. var (
  31. modadvapi32 = NewLazySystemDLL("advapi32.dll")
  32. modkernel32 = NewLazySystemDLL("kernel32.dll")
  33. modshell32 = NewLazySystemDLL("shell32.dll")
  34. modmswsock = NewLazySystemDLL("mswsock.dll")
  35. modcrypt32 = NewLazySystemDLL("crypt32.dll")
  36. modws2_32 = NewLazySystemDLL("ws2_32.dll")
  37. moddnsapi = NewLazySystemDLL("dnsapi.dll")
  38. modiphlpapi = NewLazySystemDLL("iphlpapi.dll")
  39. modsecur32 = NewLazySystemDLL("secur32.dll")
  40. modnetapi32 = NewLazySystemDLL("netapi32.dll")
  41. moduserenv = NewLazySystemDLL("userenv.dll")
  42. procRegisterEventSourceW = modadvapi32.NewProc("RegisterEventSourceW")
  43. procDeregisterEventSource = modadvapi32.NewProc("DeregisterEventSource")
  44. procReportEventW = modadvapi32.NewProc("ReportEventW")
  45. procOpenSCManagerW = modadvapi32.NewProc("OpenSCManagerW")
  46. procCloseServiceHandle = modadvapi32.NewProc("CloseServiceHandle")
  47. procCreateServiceW = modadvapi32.NewProc("CreateServiceW")
  48. procOpenServiceW = modadvapi32.NewProc("OpenServiceW")
  49. procDeleteService = modadvapi32.NewProc("DeleteService")
  50. procStartServiceW = modadvapi32.NewProc("StartServiceW")
  51. procQueryServiceStatus = modadvapi32.NewProc("QueryServiceStatus")
  52. procControlService = modadvapi32.NewProc("ControlService")
  53. procStartServiceCtrlDispatcherW = modadvapi32.NewProc("StartServiceCtrlDispatcherW")
  54. procSetServiceStatus = modadvapi32.NewProc("SetServiceStatus")
  55. procChangeServiceConfigW = modadvapi32.NewProc("ChangeServiceConfigW")
  56. procQueryServiceConfigW = modadvapi32.NewProc("QueryServiceConfigW")
  57. procChangeServiceConfig2W = modadvapi32.NewProc("ChangeServiceConfig2W")
  58. procQueryServiceConfig2W = modadvapi32.NewProc("QueryServiceConfig2W")
  59. procGetLastError = modkernel32.NewProc("GetLastError")
  60. procLoadLibraryW = modkernel32.NewProc("LoadLibraryW")
  61. procLoadLibraryExW = modkernel32.NewProc("LoadLibraryExW")
  62. procFreeLibrary = modkernel32.NewProc("FreeLibrary")
  63. procGetProcAddress = modkernel32.NewProc("GetProcAddress")
  64. procGetVersion = modkernel32.NewProc("GetVersion")
  65. procFormatMessageW = modkernel32.NewProc("FormatMessageW")
  66. procExitProcess = modkernel32.NewProc("ExitProcess")
  67. procCreateFileW = modkernel32.NewProc("CreateFileW")
  68. procReadFile = modkernel32.NewProc("ReadFile")
  69. procWriteFile = modkernel32.NewProc("WriteFile")
  70. procSetFilePointer = modkernel32.NewProc("SetFilePointer")
  71. procCloseHandle = modkernel32.NewProc("CloseHandle")
  72. procGetStdHandle = modkernel32.NewProc("GetStdHandle")
  73. procFindFirstFileW = modkernel32.NewProc("FindFirstFileW")
  74. procFindNextFileW = modkernel32.NewProc("FindNextFileW")
  75. procFindClose = modkernel32.NewProc("FindClose")
  76. procGetFileInformationByHandle = modkernel32.NewProc("GetFileInformationByHandle")
  77. procGetCurrentDirectoryW = modkernel32.NewProc("GetCurrentDirectoryW")
  78. procSetCurrentDirectoryW = modkernel32.NewProc("SetCurrentDirectoryW")
  79. procCreateDirectoryW = modkernel32.NewProc("CreateDirectoryW")
  80. procRemoveDirectoryW = modkernel32.NewProc("RemoveDirectoryW")
  81. procDeleteFileW = modkernel32.NewProc("DeleteFileW")
  82. procMoveFileW = modkernel32.NewProc("MoveFileW")
  83. procMoveFileExW = modkernel32.NewProc("MoveFileExW")
  84. procGetComputerNameW = modkernel32.NewProc("GetComputerNameW")
  85. procGetComputerNameExW = modkernel32.NewProc("GetComputerNameExW")
  86. procSetEndOfFile = modkernel32.NewProc("SetEndOfFile")
  87. procGetSystemTimeAsFileTime = modkernel32.NewProc("GetSystemTimeAsFileTime")
  88. procGetTimeZoneInformation = modkernel32.NewProc("GetTimeZoneInformation")
  89. procCreateIoCompletionPort = modkernel32.NewProc("CreateIoCompletionPort")
  90. procGetQueuedCompletionStatus = modkernel32.NewProc("GetQueuedCompletionStatus")
  91. procPostQueuedCompletionStatus = modkernel32.NewProc("PostQueuedCompletionStatus")
  92. procCancelIo = modkernel32.NewProc("CancelIo")
  93. procCancelIoEx = modkernel32.NewProc("CancelIoEx")
  94. procCreateProcessW = modkernel32.NewProc("CreateProcessW")
  95. procOpenProcess = modkernel32.NewProc("OpenProcess")
  96. procTerminateProcess = modkernel32.NewProc("TerminateProcess")
  97. procGetExitCodeProcess = modkernel32.NewProc("GetExitCodeProcess")
  98. procGetStartupInfoW = modkernel32.NewProc("GetStartupInfoW")
  99. procGetCurrentProcess = modkernel32.NewProc("GetCurrentProcess")
  100. procGetProcessTimes = modkernel32.NewProc("GetProcessTimes")
  101. procDuplicateHandle = modkernel32.NewProc("DuplicateHandle")
  102. procWaitForSingleObject = modkernel32.NewProc("WaitForSingleObject")
  103. procGetTempPathW = modkernel32.NewProc("GetTempPathW")
  104. procCreatePipe = modkernel32.NewProc("CreatePipe")
  105. procGetFileType = modkernel32.NewProc("GetFileType")
  106. procCryptAcquireContextW = modadvapi32.NewProc("CryptAcquireContextW")
  107. procCryptReleaseContext = modadvapi32.NewProc("CryptReleaseContext")
  108. procCryptGenRandom = modadvapi32.NewProc("CryptGenRandom")
  109. procGetEnvironmentStringsW = modkernel32.NewProc("GetEnvironmentStringsW")
  110. procFreeEnvironmentStringsW = modkernel32.NewProc("FreeEnvironmentStringsW")
  111. procGetEnvironmentVariableW = modkernel32.NewProc("GetEnvironmentVariableW")
  112. procSetEnvironmentVariableW = modkernel32.NewProc("SetEnvironmentVariableW")
  113. procSetFileTime = modkernel32.NewProc("SetFileTime")
  114. procGetFileAttributesW = modkernel32.NewProc("GetFileAttributesW")
  115. procSetFileAttributesW = modkernel32.NewProc("SetFileAttributesW")
  116. procGetFileAttributesExW = modkernel32.NewProc("GetFileAttributesExW")
  117. procGetCommandLineW = modkernel32.NewProc("GetCommandLineW")
  118. procCommandLineToArgvW = modshell32.NewProc("CommandLineToArgvW")
  119. procLocalFree = modkernel32.NewProc("LocalFree")
  120. procSetHandleInformation = modkernel32.NewProc("SetHandleInformation")
  121. procFlushFileBuffers = modkernel32.NewProc("FlushFileBuffers")
  122. procGetFullPathNameW = modkernel32.NewProc("GetFullPathNameW")
  123. procGetLongPathNameW = modkernel32.NewProc("GetLongPathNameW")
  124. procGetShortPathNameW = modkernel32.NewProc("GetShortPathNameW")
  125. procCreateFileMappingW = modkernel32.NewProc("CreateFileMappingW")
  126. procMapViewOfFile = modkernel32.NewProc("MapViewOfFile")
  127. procUnmapViewOfFile = modkernel32.NewProc("UnmapViewOfFile")
  128. procFlushViewOfFile = modkernel32.NewProc("FlushViewOfFile")
  129. procVirtualLock = modkernel32.NewProc("VirtualLock")
  130. procVirtualUnlock = modkernel32.NewProc("VirtualUnlock")
  131. procTransmitFile = modmswsock.NewProc("TransmitFile")
  132. procReadDirectoryChangesW = modkernel32.NewProc("ReadDirectoryChangesW")
  133. procCertOpenSystemStoreW = modcrypt32.NewProc("CertOpenSystemStoreW")
  134. procCertOpenStore = modcrypt32.NewProc("CertOpenStore")
  135. procCertEnumCertificatesInStore = modcrypt32.NewProc("CertEnumCertificatesInStore")
  136. procCertAddCertificateContextToStore = modcrypt32.NewProc("CertAddCertificateContextToStore")
  137. procCertCloseStore = modcrypt32.NewProc("CertCloseStore")
  138. procCertGetCertificateChain = modcrypt32.NewProc("CertGetCertificateChain")
  139. procCertFreeCertificateChain = modcrypt32.NewProc("CertFreeCertificateChain")
  140. procCertCreateCertificateContext = modcrypt32.NewProc("CertCreateCertificateContext")
  141. procCertFreeCertificateContext = modcrypt32.NewProc("CertFreeCertificateContext")
  142. procCertVerifyCertificateChainPolicy = modcrypt32.NewProc("CertVerifyCertificateChainPolicy")
  143. procRegOpenKeyExW = modadvapi32.NewProc("RegOpenKeyExW")
  144. procRegCloseKey = modadvapi32.NewProc("RegCloseKey")
  145. procRegQueryInfoKeyW = modadvapi32.NewProc("RegQueryInfoKeyW")
  146. procRegEnumKeyExW = modadvapi32.NewProc("RegEnumKeyExW")
  147. procRegQueryValueExW = modadvapi32.NewProc("RegQueryValueExW")
  148. procGetCurrentProcessId = modkernel32.NewProc("GetCurrentProcessId")
  149. procGetConsoleMode = modkernel32.NewProc("GetConsoleMode")
  150. procWriteConsoleW = modkernel32.NewProc("WriteConsoleW")
  151. procReadConsoleW = modkernel32.NewProc("ReadConsoleW")
  152. procCreateToolhelp32Snapshot = modkernel32.NewProc("CreateToolhelp32Snapshot")
  153. procProcess32FirstW = modkernel32.NewProc("Process32FirstW")
  154. procProcess32NextW = modkernel32.NewProc("Process32NextW")
  155. procDeviceIoControl = modkernel32.NewProc("DeviceIoControl")
  156. procCreateSymbolicLinkW = modkernel32.NewProc("CreateSymbolicLinkW")
  157. procCreateHardLinkW = modkernel32.NewProc("CreateHardLinkW")
  158. procGetCurrentThreadId = modkernel32.NewProc("GetCurrentThreadId")
  159. procCreateEventW = modkernel32.NewProc("CreateEventW")
  160. procSetEvent = modkernel32.NewProc("SetEvent")
  161. procWSAStartup = modws2_32.NewProc("WSAStartup")
  162. procWSACleanup = modws2_32.NewProc("WSACleanup")
  163. procWSAIoctl = modws2_32.NewProc("WSAIoctl")
  164. procsocket = modws2_32.NewProc("socket")
  165. procsetsockopt = modws2_32.NewProc("setsockopt")
  166. procgetsockopt = modws2_32.NewProc("getsockopt")
  167. procbind = modws2_32.NewProc("bind")
  168. procconnect = modws2_32.NewProc("connect")
  169. procgetsockname = modws2_32.NewProc("getsockname")
  170. procgetpeername = modws2_32.NewProc("getpeername")
  171. proclisten = modws2_32.NewProc("listen")
  172. procshutdown = modws2_32.NewProc("shutdown")
  173. procclosesocket = modws2_32.NewProc("closesocket")
  174. procAcceptEx = modmswsock.NewProc("AcceptEx")
  175. procGetAcceptExSockaddrs = modmswsock.NewProc("GetAcceptExSockaddrs")
  176. procWSARecv = modws2_32.NewProc("WSARecv")
  177. procWSASend = modws2_32.NewProc("WSASend")
  178. procWSARecvFrom = modws2_32.NewProc("WSARecvFrom")
  179. procWSASendTo = modws2_32.NewProc("WSASendTo")
  180. procgethostbyname = modws2_32.NewProc("gethostbyname")
  181. procgetservbyname = modws2_32.NewProc("getservbyname")
  182. procntohs = modws2_32.NewProc("ntohs")
  183. procgetprotobyname = modws2_32.NewProc("getprotobyname")
  184. procDnsQuery_W = moddnsapi.NewProc("DnsQuery_W")
  185. procDnsRecordListFree = moddnsapi.NewProc("DnsRecordListFree")
  186. procDnsNameCompare_W = moddnsapi.NewProc("DnsNameCompare_W")
  187. procGetAddrInfoW = modws2_32.NewProc("GetAddrInfoW")
  188. procFreeAddrInfoW = modws2_32.NewProc("FreeAddrInfoW")
  189. procGetIfEntry = modiphlpapi.NewProc("GetIfEntry")
  190. procGetAdaptersInfo = modiphlpapi.NewProc("GetAdaptersInfo")
  191. procSetFileCompletionNotificationModes = modkernel32.NewProc("SetFileCompletionNotificationModes")
  192. procWSAEnumProtocolsW = modws2_32.NewProc("WSAEnumProtocolsW")
  193. procGetAdaptersAddresses = modiphlpapi.NewProc("GetAdaptersAddresses")
  194. procGetACP = modkernel32.NewProc("GetACP")
  195. procMultiByteToWideChar = modkernel32.NewProc("MultiByteToWideChar")
  196. procTranslateNameW = modsecur32.NewProc("TranslateNameW")
  197. procGetUserNameExW = modsecur32.NewProc("GetUserNameExW")
  198. procNetUserGetInfo = modnetapi32.NewProc("NetUserGetInfo")
  199. procNetGetJoinInformation = modnetapi32.NewProc("NetGetJoinInformation")
  200. procNetApiBufferFree = modnetapi32.NewProc("NetApiBufferFree")
  201. procLookupAccountSidW = modadvapi32.NewProc("LookupAccountSidW")
  202. procLookupAccountNameW = modadvapi32.NewProc("LookupAccountNameW")
  203. procConvertSidToStringSidW = modadvapi32.NewProc("ConvertSidToStringSidW")
  204. procConvertStringSidToSidW = modadvapi32.NewProc("ConvertStringSidToSidW")
  205. procGetLengthSid = modadvapi32.NewProc("GetLengthSid")
  206. procCopySid = modadvapi32.NewProc("CopySid")
  207. procAllocateAndInitializeSid = modadvapi32.NewProc("AllocateAndInitializeSid")
  208. procFreeSid = modadvapi32.NewProc("FreeSid")
  209. procEqualSid = modadvapi32.NewProc("EqualSid")
  210. procOpenProcessToken = modadvapi32.NewProc("OpenProcessToken")
  211. procGetTokenInformation = modadvapi32.NewProc("GetTokenInformation")
  212. procGetUserProfileDirectoryW = moduserenv.NewProc("GetUserProfileDirectoryW")
  213. )
  214. func RegisterEventSource(uncServerName *uint16, sourceName *uint16) (handle Handle, err error) {
  215. r0, _, e1 := syscall.Syscall(procRegisterEventSourceW.Addr(), 2, uintptr(unsafe.Pointer(uncServerName)), uintptr(unsafe.Pointer(sourceName)), 0)
  216. handle = Handle(r0)
  217. if handle == 0 {
  218. if e1 != 0 {
  219. err = errnoErr(e1)
  220. } else {
  221. err = syscall.EINVAL
  222. }
  223. }
  224. return
  225. }
  226. func DeregisterEventSource(handle Handle) (err error) {
  227. r1, _, e1 := syscall.Syscall(procDeregisterEventSource.Addr(), 1, uintptr(handle), 0, 0)
  228. if r1 == 0 {
  229. if e1 != 0 {
  230. err = errnoErr(e1)
  231. } else {
  232. err = syscall.EINVAL
  233. }
  234. }
  235. return
  236. }
  237. func ReportEvent(log Handle, etype uint16, category uint16, eventId uint32, usrSId uintptr, numStrings uint16, dataSize uint32, strings **uint16, rawData *byte) (err error) {
  238. 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)))
  239. if r1 == 0 {
  240. if e1 != 0 {
  241. err = errnoErr(e1)
  242. } else {
  243. err = syscall.EINVAL
  244. }
  245. }
  246. return
  247. }
  248. func OpenSCManager(machineName *uint16, databaseName *uint16, access uint32) (handle Handle, err error) {
  249. r0, _, e1 := syscall.Syscall(procOpenSCManagerW.Addr(), 3, uintptr(unsafe.Pointer(machineName)), uintptr(unsafe.Pointer(databaseName)), uintptr(access))
  250. handle = Handle(r0)
  251. if handle == 0 {
  252. if e1 != 0 {
  253. err = errnoErr(e1)
  254. } else {
  255. err = syscall.EINVAL
  256. }
  257. }
  258. return
  259. }
  260. func CloseServiceHandle(handle Handle) (err error) {
  261. r1, _, e1 := syscall.Syscall(procCloseServiceHandle.Addr(), 1, uintptr(handle), 0, 0)
  262. if r1 == 0 {
  263. if e1 != 0 {
  264. err = errnoErr(e1)
  265. } else {
  266. err = syscall.EINVAL
  267. }
  268. }
  269. return
  270. }
  271. 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) {
  272. 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)
  273. handle = Handle(r0)
  274. if handle == 0 {
  275. if e1 != 0 {
  276. err = errnoErr(e1)
  277. } else {
  278. err = syscall.EINVAL
  279. }
  280. }
  281. return
  282. }
  283. func OpenService(mgr Handle, serviceName *uint16, access uint32) (handle Handle, err error) {
  284. r0, _, e1 := syscall.Syscall(procOpenServiceW.Addr(), 3, uintptr(mgr), uintptr(unsafe.Pointer(serviceName)), uintptr(access))
  285. handle = Handle(r0)
  286. if handle == 0 {
  287. if e1 != 0 {
  288. err = errnoErr(e1)
  289. } else {
  290. err = syscall.EINVAL
  291. }
  292. }
  293. return
  294. }
  295. func DeleteService(service Handle) (err error) {
  296. r1, _, e1 := syscall.Syscall(procDeleteService.Addr(), 1, uintptr(service), 0, 0)
  297. if r1 == 0 {
  298. if e1 != 0 {
  299. err = errnoErr(e1)
  300. } else {
  301. err = syscall.EINVAL
  302. }
  303. }
  304. return
  305. }
  306. func StartService(service Handle, numArgs uint32, argVectors **uint16) (err error) {
  307. r1, _, e1 := syscall.Syscall(procStartServiceW.Addr(), 3, uintptr(service), uintptr(numArgs), uintptr(unsafe.Pointer(argVectors)))
  308. if r1 == 0 {
  309. if e1 != 0 {
  310. err = errnoErr(e1)
  311. } else {
  312. err = syscall.EINVAL
  313. }
  314. }
  315. return
  316. }
  317. func QueryServiceStatus(service Handle, status *SERVICE_STATUS) (err error) {
  318. r1, _, e1 := syscall.Syscall(procQueryServiceStatus.Addr(), 2, uintptr(service), uintptr(unsafe.Pointer(status)), 0)
  319. if r1 == 0 {
  320. if e1 != 0 {
  321. err = errnoErr(e1)
  322. } else {
  323. err = syscall.EINVAL
  324. }
  325. }
  326. return
  327. }
  328. func ControlService(service Handle, control uint32, status *SERVICE_STATUS) (err error) {
  329. r1, _, e1 := syscall.Syscall(procControlService.Addr(), 3, uintptr(service), uintptr(control), uintptr(unsafe.Pointer(status)))
  330. if r1 == 0 {
  331. if e1 != 0 {
  332. err = errnoErr(e1)
  333. } else {
  334. err = syscall.EINVAL
  335. }
  336. }
  337. return
  338. }
  339. func StartServiceCtrlDispatcher(serviceTable *SERVICE_TABLE_ENTRY) (err error) {
  340. r1, _, e1 := syscall.Syscall(procStartServiceCtrlDispatcherW.Addr(), 1, uintptr(unsafe.Pointer(serviceTable)), 0, 0)
  341. if r1 == 0 {
  342. if e1 != 0 {
  343. err = errnoErr(e1)
  344. } else {
  345. err = syscall.EINVAL
  346. }
  347. }
  348. return
  349. }
  350. func SetServiceStatus(service Handle, serviceStatus *SERVICE_STATUS) (err error) {
  351. r1, _, e1 := syscall.Syscall(procSetServiceStatus.Addr(), 2, uintptr(service), uintptr(unsafe.Pointer(serviceStatus)), 0)
  352. if r1 == 0 {
  353. if e1 != 0 {
  354. err = errnoErr(e1)
  355. } else {
  356. err = syscall.EINVAL
  357. }
  358. }
  359. return
  360. }
  361. 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) {
  362. 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)
  363. if r1 == 0 {
  364. if e1 != 0 {
  365. err = errnoErr(e1)
  366. } else {
  367. err = syscall.EINVAL
  368. }
  369. }
  370. return
  371. }
  372. func QueryServiceConfig(service Handle, serviceConfig *QUERY_SERVICE_CONFIG, bufSize uint32, bytesNeeded *uint32) (err error) {
  373. r1, _, e1 := syscall.Syscall6(procQueryServiceConfigW.Addr(), 4, uintptr(service), uintptr(unsafe.Pointer(serviceConfig)), uintptr(bufSize), uintptr(unsafe.Pointer(bytesNeeded)), 0, 0)
  374. if r1 == 0 {
  375. if e1 != 0 {
  376. err = errnoErr(e1)
  377. } else {
  378. err = syscall.EINVAL
  379. }
  380. }
  381. return
  382. }
  383. func ChangeServiceConfig2(service Handle, infoLevel uint32, info *byte) (err error) {
  384. r1, _, e1 := syscall.Syscall(procChangeServiceConfig2W.Addr(), 3, uintptr(service), uintptr(infoLevel), uintptr(unsafe.Pointer(info)))
  385. if r1 == 0 {
  386. if e1 != 0 {
  387. err = errnoErr(e1)
  388. } else {
  389. err = syscall.EINVAL
  390. }
  391. }
  392. return
  393. }
  394. func QueryServiceConfig2(service Handle, infoLevel uint32, buff *byte, buffSize uint32, bytesNeeded *uint32) (err error) {
  395. r1, _, e1 := syscall.Syscall6(procQueryServiceConfig2W.Addr(), 5, uintptr(service), uintptr(infoLevel), uintptr(unsafe.Pointer(buff)), uintptr(buffSize), uintptr(unsafe.Pointer(bytesNeeded)), 0)
  396. if r1 == 0 {
  397. if e1 != 0 {
  398. err = errnoErr(e1)
  399. } else {
  400. err = syscall.EINVAL
  401. }
  402. }
  403. return
  404. }
  405. func GetLastError() (lasterr error) {
  406. r0, _, _ := syscall.Syscall(procGetLastError.Addr(), 0, 0, 0, 0)
  407. if r0 != 0 {
  408. lasterr = syscall.Errno(r0)
  409. }
  410. return
  411. }
  412. func LoadLibrary(libname string) (handle Handle, err error) {
  413. var _p0 *uint16
  414. _p0, err = syscall.UTF16PtrFromString(libname)
  415. if err != nil {
  416. return
  417. }
  418. return _LoadLibrary(_p0)
  419. }
  420. func _LoadLibrary(libname *uint16) (handle Handle, err error) {
  421. r0, _, e1 := syscall.Syscall(procLoadLibraryW.Addr(), 1, uintptr(unsafe.Pointer(libname)), 0, 0)
  422. handle = Handle(r0)
  423. if handle == 0 {
  424. if e1 != 0 {
  425. err = errnoErr(e1)
  426. } else {
  427. err = syscall.EINVAL
  428. }
  429. }
  430. return
  431. }
  432. func LoadLibraryEx(libname string, zero Handle, flags uintptr) (handle Handle, err error) {
  433. var _p0 *uint16
  434. _p0, err = syscall.UTF16PtrFromString(libname)
  435. if err != nil {
  436. return
  437. }
  438. return _LoadLibraryEx(_p0, zero, flags)
  439. }
  440. func _LoadLibraryEx(libname *uint16, zero Handle, flags uintptr) (handle Handle, err error) {
  441. r0, _, e1 := syscall.Syscall(procLoadLibraryExW.Addr(), 3, uintptr(unsafe.Pointer(libname)), uintptr(zero), uintptr(flags))
  442. handle = Handle(r0)
  443. if handle == 0 {
  444. if e1 != 0 {
  445. err = errnoErr(e1)
  446. } else {
  447. err = syscall.EINVAL
  448. }
  449. }
  450. return
  451. }
  452. func FreeLibrary(handle Handle) (err error) {
  453. r1, _, e1 := syscall.Syscall(procFreeLibrary.Addr(), 1, uintptr(handle), 0, 0)
  454. if r1 == 0 {
  455. if e1 != 0 {
  456. err = errnoErr(e1)
  457. } else {
  458. err = syscall.EINVAL
  459. }
  460. }
  461. return
  462. }
  463. func GetProcAddress(module Handle, procname string) (proc uintptr, err error) {
  464. var _p0 *byte
  465. _p0, err = syscall.BytePtrFromString(procname)
  466. if err != nil {
  467. return
  468. }
  469. return _GetProcAddress(module, _p0)
  470. }
  471. func _GetProcAddress(module Handle, procname *byte) (proc uintptr, err error) {
  472. r0, _, e1 := syscall.Syscall(procGetProcAddress.Addr(), 2, uintptr(module), uintptr(unsafe.Pointer(procname)), 0)
  473. proc = uintptr(r0)
  474. if proc == 0 {
  475. if e1 != 0 {
  476. err = errnoErr(e1)
  477. } else {
  478. err = syscall.EINVAL
  479. }
  480. }
  481. return
  482. }
  483. func GetVersion() (ver uint32, err error) {
  484. r0, _, e1 := syscall.Syscall(procGetVersion.Addr(), 0, 0, 0, 0)
  485. ver = uint32(r0)
  486. if ver == 0 {
  487. if e1 != 0 {
  488. err = errnoErr(e1)
  489. } else {
  490. err = syscall.EINVAL
  491. }
  492. }
  493. return
  494. }
  495. func FormatMessage(flags uint32, msgsrc uintptr, msgid uint32, langid uint32, buf []uint16, args *byte) (n uint32, err error) {
  496. var _p0 *uint16
  497. if len(buf) > 0 {
  498. _p0 = &buf[0]
  499. }
  500. 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)
  501. n = uint32(r0)
  502. if n == 0 {
  503. if e1 != 0 {
  504. err = errnoErr(e1)
  505. } else {
  506. err = syscall.EINVAL
  507. }
  508. }
  509. return
  510. }
  511. func ExitProcess(exitcode uint32) {
  512. syscall.Syscall(procExitProcess.Addr(), 1, uintptr(exitcode), 0, 0)
  513. return
  514. }
  515. func CreateFile(name *uint16, access uint32, mode uint32, sa *SecurityAttributes, createmode uint32, attrs uint32, templatefile int32) (handle Handle, err error) {
  516. 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)
  517. handle = Handle(r0)
  518. if handle == InvalidHandle {
  519. if e1 != 0 {
  520. err = errnoErr(e1)
  521. } else {
  522. err = syscall.EINVAL
  523. }
  524. }
  525. return
  526. }
  527. func ReadFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) (err error) {
  528. var _p0 *byte
  529. if len(buf) > 0 {
  530. _p0 = &buf[0]
  531. }
  532. 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)
  533. if r1 == 0 {
  534. if e1 != 0 {
  535. err = errnoErr(e1)
  536. } else {
  537. err = syscall.EINVAL
  538. }
  539. }
  540. return
  541. }
  542. func WriteFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) (err error) {
  543. var _p0 *byte
  544. if len(buf) > 0 {
  545. _p0 = &buf[0]
  546. }
  547. 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)
  548. if r1 == 0 {
  549. if e1 != 0 {
  550. err = errnoErr(e1)
  551. } else {
  552. err = syscall.EINVAL
  553. }
  554. }
  555. return
  556. }
  557. func SetFilePointer(handle Handle, lowoffset int32, highoffsetptr *int32, whence uint32) (newlowoffset uint32, err error) {
  558. r0, _, e1 := syscall.Syscall6(procSetFilePointer.Addr(), 4, uintptr(handle), uintptr(lowoffset), uintptr(unsafe.Pointer(highoffsetptr)), uintptr(whence), 0, 0)
  559. newlowoffset = uint32(r0)
  560. if newlowoffset == 0xffffffff {
  561. if e1 != 0 {
  562. err = errnoErr(e1)
  563. } else {
  564. err = syscall.EINVAL
  565. }
  566. }
  567. return
  568. }
  569. func CloseHandle(handle Handle) (err error) {
  570. r1, _, e1 := syscall.Syscall(procCloseHandle.Addr(), 1, uintptr(handle), 0, 0)
  571. if r1 == 0 {
  572. if e1 != 0 {
  573. err = errnoErr(e1)
  574. } else {
  575. err = syscall.EINVAL
  576. }
  577. }
  578. return
  579. }
  580. func GetStdHandle(stdhandle int) (handle Handle, err error) {
  581. r0, _, e1 := syscall.Syscall(procGetStdHandle.Addr(), 1, uintptr(stdhandle), 0, 0)
  582. handle = Handle(r0)
  583. if handle == InvalidHandle {
  584. if e1 != 0 {
  585. err = errnoErr(e1)
  586. } else {
  587. err = syscall.EINVAL
  588. }
  589. }
  590. return
  591. }
  592. func findFirstFile1(name *uint16, data *win32finddata1) (handle Handle, err error) {
  593. r0, _, e1 := syscall.Syscall(procFindFirstFileW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(data)), 0)
  594. handle = Handle(r0)
  595. if handle == InvalidHandle {
  596. if e1 != 0 {
  597. err = errnoErr(e1)
  598. } else {
  599. err = syscall.EINVAL
  600. }
  601. }
  602. return
  603. }
  604. func findNextFile1(handle Handle, data *win32finddata1) (err error) {
  605. r1, _, e1 := syscall.Syscall(procFindNextFileW.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(data)), 0)
  606. if r1 == 0 {
  607. if e1 != 0 {
  608. err = errnoErr(e1)
  609. } else {
  610. err = syscall.EINVAL
  611. }
  612. }
  613. return
  614. }
  615. func FindClose(handle Handle) (err error) {
  616. r1, _, e1 := syscall.Syscall(procFindClose.Addr(), 1, uintptr(handle), 0, 0)
  617. if r1 == 0 {
  618. if e1 != 0 {
  619. err = errnoErr(e1)
  620. } else {
  621. err = syscall.EINVAL
  622. }
  623. }
  624. return
  625. }
  626. func GetFileInformationByHandle(handle Handle, data *ByHandleFileInformation) (err error) {
  627. r1, _, e1 := syscall.Syscall(procGetFileInformationByHandle.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(data)), 0)
  628. if r1 == 0 {
  629. if e1 != 0 {
  630. err = errnoErr(e1)
  631. } else {
  632. err = syscall.EINVAL
  633. }
  634. }
  635. return
  636. }
  637. func GetCurrentDirectory(buflen uint32, buf *uint16) (n uint32, err error) {
  638. r0, _, e1 := syscall.Syscall(procGetCurrentDirectoryW.Addr(), 2, uintptr(buflen), uintptr(unsafe.Pointer(buf)), 0)
  639. n = uint32(r0)
  640. if n == 0 {
  641. if e1 != 0 {
  642. err = errnoErr(e1)
  643. } else {
  644. err = syscall.EINVAL
  645. }
  646. }
  647. return
  648. }
  649. func SetCurrentDirectory(path *uint16) (err error) {
  650. r1, _, e1 := syscall.Syscall(procSetCurrentDirectoryW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0)
  651. if r1 == 0 {
  652. if e1 != 0 {
  653. err = errnoErr(e1)
  654. } else {
  655. err = syscall.EINVAL
  656. }
  657. }
  658. return
  659. }
  660. func CreateDirectory(path *uint16, sa *SecurityAttributes) (err error) {
  661. r1, _, e1 := syscall.Syscall(procCreateDirectoryW.Addr(), 2, uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(sa)), 0)
  662. if r1 == 0 {
  663. if e1 != 0 {
  664. err = errnoErr(e1)
  665. } else {
  666. err = syscall.EINVAL
  667. }
  668. }
  669. return
  670. }
  671. func RemoveDirectory(path *uint16) (err error) {
  672. r1, _, e1 := syscall.Syscall(procRemoveDirectoryW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0)
  673. if r1 == 0 {
  674. if e1 != 0 {
  675. err = errnoErr(e1)
  676. } else {
  677. err = syscall.EINVAL
  678. }
  679. }
  680. return
  681. }
  682. func DeleteFile(path *uint16) (err error) {
  683. r1, _, e1 := syscall.Syscall(procDeleteFileW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0)
  684. if r1 == 0 {
  685. if e1 != 0 {
  686. err = errnoErr(e1)
  687. } else {
  688. err = syscall.EINVAL
  689. }
  690. }
  691. return
  692. }
  693. func MoveFile(from *uint16, to *uint16) (err error) {
  694. r1, _, e1 := syscall.Syscall(procMoveFileW.Addr(), 2, uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(to)), 0)
  695. if r1 == 0 {
  696. if e1 != 0 {
  697. err = errnoErr(e1)
  698. } else {
  699. err = syscall.EINVAL
  700. }
  701. }
  702. return
  703. }
  704. func MoveFileEx(from *uint16, to *uint16, flags uint32) (err error) {
  705. r1, _, e1 := syscall.Syscall(procMoveFileExW.Addr(), 3, uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(to)), uintptr(flags))
  706. if r1 == 0 {
  707. if e1 != 0 {
  708. err = errnoErr(e1)
  709. } else {
  710. err = syscall.EINVAL
  711. }
  712. }
  713. return
  714. }
  715. func GetComputerName(buf *uint16, n *uint32) (err error) {
  716. r1, _, e1 := syscall.Syscall(procGetComputerNameW.Addr(), 2, uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(n)), 0)
  717. if r1 == 0 {
  718. if e1 != 0 {
  719. err = errnoErr(e1)
  720. } else {
  721. err = syscall.EINVAL
  722. }
  723. }
  724. return
  725. }
  726. func GetComputerNameEx(nametype uint32, buf *uint16, n *uint32) (err error) {
  727. r1, _, e1 := syscall.Syscall(procGetComputerNameExW.Addr(), 3, uintptr(nametype), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(n)))
  728. if r1 == 0 {
  729. if e1 != 0 {
  730. err = errnoErr(e1)
  731. } else {
  732. err = syscall.EINVAL
  733. }
  734. }
  735. return
  736. }
  737. func SetEndOfFile(handle Handle) (err error) {
  738. r1, _, e1 := syscall.Syscall(procSetEndOfFile.Addr(), 1, uintptr(handle), 0, 0)
  739. if r1 == 0 {
  740. if e1 != 0 {
  741. err = errnoErr(e1)
  742. } else {
  743. err = syscall.EINVAL
  744. }
  745. }
  746. return
  747. }
  748. func GetSystemTimeAsFileTime(time *Filetime) {
  749. syscall.Syscall(procGetSystemTimeAsFileTime.Addr(), 1, uintptr(unsafe.Pointer(time)), 0, 0)
  750. return
  751. }
  752. func GetTimeZoneInformation(tzi *Timezoneinformation) (rc uint32, err error) {
  753. r0, _, e1 := syscall.Syscall(procGetTimeZoneInformation.Addr(), 1, uintptr(unsafe.Pointer(tzi)), 0, 0)
  754. rc = uint32(r0)
  755. if rc == 0xffffffff {
  756. if e1 != 0 {
  757. err = errnoErr(e1)
  758. } else {
  759. err = syscall.EINVAL
  760. }
  761. }
  762. return
  763. }
  764. func CreateIoCompletionPort(filehandle Handle, cphandle Handle, key uint32, threadcnt uint32) (handle Handle, err error) {
  765. r0, _, e1 := syscall.Syscall6(procCreateIoCompletionPort.Addr(), 4, uintptr(filehandle), uintptr(cphandle), uintptr(key), uintptr(threadcnt), 0, 0)
  766. handle = Handle(r0)
  767. if handle == 0 {
  768. if e1 != 0 {
  769. err = errnoErr(e1)
  770. } else {
  771. err = syscall.EINVAL
  772. }
  773. }
  774. return
  775. }
  776. func GetQueuedCompletionStatus(cphandle Handle, qty *uint32, key *uint32, overlapped **Overlapped, timeout uint32) (err error) {
  777. r1, _, e1 := syscall.Syscall6(procGetQueuedCompletionStatus.Addr(), 5, uintptr(cphandle), uintptr(unsafe.Pointer(qty)), uintptr(unsafe.Pointer(key)), uintptr(unsafe.Pointer(overlapped)), uintptr(timeout), 0)
  778. if r1 == 0 {
  779. if e1 != 0 {
  780. err = errnoErr(e1)
  781. } else {
  782. err = syscall.EINVAL
  783. }
  784. }
  785. return
  786. }
  787. func PostQueuedCompletionStatus(cphandle Handle, qty uint32, key uint32, overlapped *Overlapped) (err error) {
  788. r1, _, e1 := syscall.Syscall6(procPostQueuedCompletionStatus.Addr(), 4, uintptr(cphandle), uintptr(qty), uintptr(key), uintptr(unsafe.Pointer(overlapped)), 0, 0)
  789. if r1 == 0 {
  790. if e1 != 0 {
  791. err = errnoErr(e1)
  792. } else {
  793. err = syscall.EINVAL
  794. }
  795. }
  796. return
  797. }
  798. func CancelIo(s Handle) (err error) {
  799. r1, _, e1 := syscall.Syscall(procCancelIo.Addr(), 1, uintptr(s), 0, 0)
  800. if r1 == 0 {
  801. if e1 != 0 {
  802. err = errnoErr(e1)
  803. } else {
  804. err = syscall.EINVAL
  805. }
  806. }
  807. return
  808. }
  809. func CancelIoEx(s Handle, o *Overlapped) (err error) {
  810. r1, _, e1 := syscall.Syscall(procCancelIoEx.Addr(), 2, uintptr(s), uintptr(unsafe.Pointer(o)), 0)
  811. if r1 == 0 {
  812. if e1 != 0 {
  813. err = errnoErr(e1)
  814. } else {
  815. err = syscall.EINVAL
  816. }
  817. }
  818. return
  819. }
  820. func CreateProcess(appName *uint16, commandLine *uint16, procSecurity *SecurityAttributes, threadSecurity *SecurityAttributes, inheritHandles bool, creationFlags uint32, env *uint16, currentDir *uint16, startupInfo *StartupInfo, outProcInfo *ProcessInformation) (err error) {
  821. var _p0 uint32
  822. if inheritHandles {
  823. _p0 = 1
  824. } else {
  825. _p0 = 0
  826. }
  827. 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)
  828. if r1 == 0 {
  829. if e1 != 0 {
  830. err = errnoErr(e1)
  831. } else {
  832. err = syscall.EINVAL
  833. }
  834. }
  835. return
  836. }
  837. func OpenProcess(da uint32, inheritHandle bool, pid uint32) (handle Handle, err error) {
  838. var _p0 uint32
  839. if inheritHandle {
  840. _p0 = 1
  841. } else {
  842. _p0 = 0
  843. }
  844. r0, _, e1 := syscall.Syscall(procOpenProcess.Addr(), 3, uintptr(da), uintptr(_p0), uintptr(pid))
  845. handle = Handle(r0)
  846. if handle == 0 {
  847. if e1 != 0 {
  848. err = errnoErr(e1)
  849. } else {
  850. err = syscall.EINVAL
  851. }
  852. }
  853. return
  854. }
  855. func TerminateProcess(handle Handle, exitcode uint32) (err error) {
  856. r1, _, e1 := syscall.Syscall(procTerminateProcess.Addr(), 2, uintptr(handle), uintptr(exitcode), 0)
  857. if r1 == 0 {
  858. if e1 != 0 {
  859. err = errnoErr(e1)
  860. } else {
  861. err = syscall.EINVAL
  862. }
  863. }
  864. return
  865. }
  866. func GetExitCodeProcess(handle Handle, exitcode *uint32) (err error) {
  867. r1, _, e1 := syscall.Syscall(procGetExitCodeProcess.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(exitcode)), 0)
  868. if r1 == 0 {
  869. if e1 != 0 {
  870. err = errnoErr(e1)
  871. } else {
  872. err = syscall.EINVAL
  873. }
  874. }
  875. return
  876. }
  877. func GetStartupInfo(startupInfo *StartupInfo) (err error) {
  878. r1, _, e1 := syscall.Syscall(procGetStartupInfoW.Addr(), 1, uintptr(unsafe.Pointer(startupInfo)), 0, 0)
  879. if r1 == 0 {
  880. if e1 != 0 {
  881. err = errnoErr(e1)
  882. } else {
  883. err = syscall.EINVAL
  884. }
  885. }
  886. return
  887. }
  888. func GetCurrentProcess() (pseudoHandle Handle, err error) {
  889. r0, _, e1 := syscall.Syscall(procGetCurrentProcess.Addr(), 0, 0, 0, 0)
  890. pseudoHandle = Handle(r0)
  891. if pseudoHandle == 0 {
  892. if e1 != 0 {
  893. err = errnoErr(e1)
  894. } else {
  895. err = syscall.EINVAL
  896. }
  897. }
  898. return
  899. }
  900. func GetProcessTimes(handle Handle, creationTime *Filetime, exitTime *Filetime, kernelTime *Filetime, userTime *Filetime) (err error) {
  901. 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)
  902. if r1 == 0 {
  903. if e1 != 0 {
  904. err = errnoErr(e1)
  905. } else {
  906. err = syscall.EINVAL
  907. }
  908. }
  909. return
  910. }
  911. func DuplicateHandle(hSourceProcessHandle Handle, hSourceHandle Handle, hTargetProcessHandle Handle, lpTargetHandle *Handle, dwDesiredAccess uint32, bInheritHandle bool, dwOptions uint32) (err error) {
  912. var _p0 uint32
  913. if bInheritHandle {
  914. _p0 = 1
  915. } else {
  916. _p0 = 0
  917. }
  918. 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)
  919. if r1 == 0 {
  920. if e1 != 0 {
  921. err = errnoErr(e1)
  922. } else {
  923. err = syscall.EINVAL
  924. }
  925. }
  926. return
  927. }
  928. func WaitForSingleObject(handle Handle, waitMilliseconds uint32) (event uint32, err error) {
  929. r0, _, e1 := syscall.Syscall(procWaitForSingleObject.Addr(), 2, uintptr(handle), uintptr(waitMilliseconds), 0)
  930. event = uint32(r0)
  931. if event == 0xffffffff {
  932. if e1 != 0 {
  933. err = errnoErr(e1)
  934. } else {
  935. err = syscall.EINVAL
  936. }
  937. }
  938. return
  939. }
  940. func GetTempPath(buflen uint32, buf *uint16) (n uint32, err error) {
  941. r0, _, e1 := syscall.Syscall(procGetTempPathW.Addr(), 2, uintptr(buflen), uintptr(unsafe.Pointer(buf)), 0)
  942. n = uint32(r0)
  943. if n == 0 {
  944. if e1 != 0 {
  945. err = errnoErr(e1)
  946. } else {
  947. err = syscall.EINVAL
  948. }
  949. }
  950. return
  951. }
  952. func CreatePipe(readhandle *Handle, writehandle *Handle, sa *SecurityAttributes, size uint32) (err error) {
  953. r1, _, e1 := syscall.Syscall6(procCreatePipe.Addr(), 4, uintptr(unsafe.Pointer(readhandle)), uintptr(unsafe.Pointer(writehandle)), uintptr(unsafe.Pointer(sa)), uintptr(size), 0, 0)
  954. if r1 == 0 {
  955. if e1 != 0 {
  956. err = errnoErr(e1)
  957. } else {
  958. err = syscall.EINVAL
  959. }
  960. }
  961. return
  962. }
  963. func GetFileType(filehandle Handle) (n uint32, err error) {
  964. r0, _, e1 := syscall.Syscall(procGetFileType.Addr(), 1, uintptr(filehandle), 0, 0)
  965. n = uint32(r0)
  966. if n == 0 {
  967. if e1 != 0 {
  968. err = errnoErr(e1)
  969. } else {
  970. err = syscall.EINVAL
  971. }
  972. }
  973. return
  974. }
  975. func CryptAcquireContext(provhandle *Handle, container *uint16, provider *uint16, provtype uint32, flags uint32) (err error) {
  976. r1, _, e1 := syscall.Syscall6(procCryptAcquireContextW.Addr(), 5, uintptr(unsafe.Pointer(provhandle)), uintptr(unsafe.Pointer(container)), uintptr(unsafe.Pointer(provider)), uintptr(provtype), uintptr(flags), 0)
  977. if r1 == 0 {
  978. if e1 != 0 {
  979. err = errnoErr(e1)
  980. } else {
  981. err = syscall.EINVAL
  982. }
  983. }
  984. return
  985. }
  986. func CryptReleaseContext(provhandle Handle, flags uint32) (err error) {
  987. r1, _, e1 := syscall.Syscall(procCryptReleaseContext.Addr(), 2, uintptr(provhandle), uintptr(flags), 0)
  988. if r1 == 0 {
  989. if e1 != 0 {
  990. err = errnoErr(e1)
  991. } else {
  992. err = syscall.EINVAL
  993. }
  994. }
  995. return
  996. }
  997. func CryptGenRandom(provhandle Handle, buflen uint32, buf *byte) (err error) {
  998. r1, _, e1 := syscall.Syscall(procCryptGenRandom.Addr(), 3, uintptr(provhandle), uintptr(buflen), uintptr(unsafe.Pointer(buf)))
  999. if r1 == 0 {
  1000. if e1 != 0 {
  1001. err = errnoErr(e1)
  1002. } else {
  1003. err = syscall.EINVAL
  1004. }
  1005. }
  1006. return
  1007. }
  1008. func GetEnvironmentStrings() (envs *uint16, err error) {
  1009. r0, _, e1 := syscall.Syscall(procGetEnvironmentStringsW.Addr(), 0, 0, 0, 0)
  1010. envs = (*uint16)(unsafe.Pointer(r0))
  1011. if envs == nil {
  1012. if e1 != 0 {
  1013. err = errnoErr(e1)
  1014. } else {
  1015. err = syscall.EINVAL
  1016. }
  1017. }
  1018. return
  1019. }
  1020. func FreeEnvironmentStrings(envs *uint16) (err error) {
  1021. r1, _, e1 := syscall.Syscall(procFreeEnvironmentStringsW.Addr(), 1, uintptr(unsafe.Pointer(envs)), 0, 0)
  1022. if r1 == 0 {
  1023. if e1 != 0 {
  1024. err = errnoErr(e1)
  1025. } else {
  1026. err = syscall.EINVAL
  1027. }
  1028. }
  1029. return
  1030. }
  1031. func GetEnvironmentVariable(name *uint16, buffer *uint16, size uint32) (n uint32, err error) {
  1032. r0, _, e1 := syscall.Syscall(procGetEnvironmentVariableW.Addr(), 3, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(buffer)), uintptr(size))
  1033. n = uint32(r0)
  1034. if n == 0 {
  1035. if e1 != 0 {
  1036. err = errnoErr(e1)
  1037. } else {
  1038. err = syscall.EINVAL
  1039. }
  1040. }
  1041. return
  1042. }
  1043. func SetEnvironmentVariable(name *uint16, value *uint16) (err error) {
  1044. r1, _, e1 := syscall.Syscall(procSetEnvironmentVariableW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(value)), 0)
  1045. if r1 == 0 {
  1046. if e1 != 0 {
  1047. err = errnoErr(e1)
  1048. } else {
  1049. err = syscall.EINVAL
  1050. }
  1051. }
  1052. return
  1053. }
  1054. func SetFileTime(handle Handle, ctime *Filetime, atime *Filetime, wtime *Filetime) (err error) {
  1055. r1, _, e1 := syscall.Syscall6(procSetFileTime.Addr(), 4, uintptr(handle), uintptr(unsafe.Pointer(ctime)), uintptr(unsafe.Pointer(atime)), uintptr(unsafe.Pointer(wtime)), 0, 0)
  1056. if r1 == 0 {
  1057. if e1 != 0 {
  1058. err = errnoErr(e1)
  1059. } else {
  1060. err = syscall.EINVAL
  1061. }
  1062. }
  1063. return
  1064. }
  1065. func GetFileAttributes(name *uint16) (attrs uint32, err error) {
  1066. r0, _, e1 := syscall.Syscall(procGetFileAttributesW.Addr(), 1, uintptr(unsafe.Pointer(name)), 0, 0)
  1067. attrs = uint32(r0)
  1068. if attrs == INVALID_FILE_ATTRIBUTES {
  1069. if e1 != 0 {
  1070. err = errnoErr(e1)
  1071. } else {
  1072. err = syscall.EINVAL
  1073. }
  1074. }
  1075. return
  1076. }
  1077. func SetFileAttributes(name *uint16, attrs uint32) (err error) {
  1078. r1, _, e1 := syscall.Syscall(procSetFileAttributesW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(attrs), 0)
  1079. if r1 == 0 {
  1080. if e1 != 0 {
  1081. err = errnoErr(e1)
  1082. } else {
  1083. err = syscall.EINVAL
  1084. }
  1085. }
  1086. return
  1087. }
  1088. func GetFileAttributesEx(name *uint16, level uint32, info *byte) (err error) {
  1089. r1, _, e1 := syscall.Syscall(procGetFileAttributesExW.Addr(), 3, uintptr(unsafe.Pointer(name)), uintptr(level), uintptr(unsafe.Pointer(info)))
  1090. if r1 == 0 {
  1091. if e1 != 0 {
  1092. err = errnoErr(e1)
  1093. } else {
  1094. err = syscall.EINVAL
  1095. }
  1096. }
  1097. return
  1098. }
  1099. func GetCommandLine() (cmd *uint16) {
  1100. r0, _, _ := syscall.Syscall(procGetCommandLineW.Addr(), 0, 0, 0, 0)
  1101. cmd = (*uint16)(unsafe.Pointer(r0))
  1102. return
  1103. }
  1104. func CommandLineToArgv(cmd *uint16, argc *int32) (argv *[8192]*[8192]uint16, err error) {
  1105. r0, _, e1 := syscall.Syscall(procCommandLineToArgvW.Addr(), 2, uintptr(unsafe.Pointer(cmd)), uintptr(unsafe.Pointer(argc)), 0)
  1106. argv = (*[8192]*[8192]uint16)(unsafe.Pointer(r0))
  1107. if argv == nil {
  1108. if e1 != 0 {
  1109. err = errnoErr(e1)
  1110. } else {
  1111. err = syscall.EINVAL
  1112. }
  1113. }
  1114. return
  1115. }
  1116. func LocalFree(hmem Handle) (handle Handle, err error) {
  1117. r0, _, e1 := syscall.Syscall(procLocalFree.Addr(), 1, uintptr(hmem), 0, 0)
  1118. handle = Handle(r0)
  1119. if handle != 0 {
  1120. if e1 != 0 {
  1121. err = errnoErr(e1)
  1122. } else {
  1123. err = syscall.EINVAL
  1124. }
  1125. }
  1126. return
  1127. }
  1128. func SetHandleInformation(handle Handle, mask uint32, flags uint32) (err error) {
  1129. r1, _, e1 := syscall.Syscall(procSetHandleInformation.Addr(), 3, uintptr(handle), uintptr(mask), uintptr(flags))
  1130. if r1 == 0 {
  1131. if e1 != 0 {
  1132. err = errnoErr(e1)
  1133. } else {
  1134. err = syscall.EINVAL
  1135. }
  1136. }
  1137. return
  1138. }
  1139. func FlushFileBuffers(handle Handle) (err error) {
  1140. r1, _, e1 := syscall.Syscall(procFlushFileBuffers.Addr(), 1, uintptr(handle), 0, 0)
  1141. if r1 == 0 {
  1142. if e1 != 0 {
  1143. err = errnoErr(e1)
  1144. } else {
  1145. err = syscall.EINVAL
  1146. }
  1147. }
  1148. return
  1149. }
  1150. func GetFullPathName(path *uint16, buflen uint32, buf *uint16, fname **uint16) (n uint32, err error) {
  1151. r0, _, e1 := syscall.Syscall6(procGetFullPathNameW.Addr(), 4, uintptr(unsafe.Pointer(path)), uintptr(buflen), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(fname)), 0, 0)
  1152. n = uint32(r0)
  1153. if n == 0 {
  1154. if e1 != 0 {
  1155. err = errnoErr(e1)
  1156. } else {
  1157. err = syscall.EINVAL
  1158. }
  1159. }
  1160. return
  1161. }
  1162. func GetLongPathName(path *uint16, buf *uint16, buflen uint32) (n uint32, err error) {
  1163. r0, _, e1 := syscall.Syscall(procGetLongPathNameW.Addr(), 3, uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(buf)), uintptr(buflen))
  1164. n = uint32(r0)
  1165. if n == 0 {
  1166. if e1 != 0 {
  1167. err = errnoErr(e1)
  1168. } else {
  1169. err = syscall.EINVAL
  1170. }
  1171. }
  1172. return
  1173. }
  1174. func GetShortPathName(longpath *uint16, shortpath *uint16, buflen uint32) (n uint32, err error) {
  1175. r0, _, e1 := syscall.Syscall(procGetShortPathNameW.Addr(), 3, uintptr(unsafe.Pointer(longpath)), uintptr(unsafe.Pointer(shortpath)), uintptr(buflen))
  1176. n = uint32(r0)
  1177. if n == 0 {
  1178. if e1 != 0 {
  1179. err = errnoErr(e1)
  1180. } else {
  1181. err = syscall.EINVAL
  1182. }
  1183. }
  1184. return
  1185. }
  1186. func CreateFileMapping(fhandle Handle, sa *SecurityAttributes, prot uint32, maxSizeHigh uint32, maxSizeLow uint32, name *uint16) (handle Handle, err error) {
  1187. r0, _, e1 := syscall.Syscall6(procCreateFileMappingW.Addr(), 6, uintptr(fhandle), uintptr(unsafe.Pointer(sa)), uintptr(prot), uintptr(maxSizeHigh), uintptr(maxSizeLow), uintptr(unsafe.Pointer(name)))
  1188. handle = Handle(r0)
  1189. if handle == 0 {
  1190. if e1 != 0 {
  1191. err = errnoErr(e1)
  1192. } else {
  1193. err = syscall.EINVAL
  1194. }
  1195. }
  1196. return
  1197. }
  1198. func MapViewOfFile(handle Handle, access uint32, offsetHigh uint32, offsetLow uint32, length uintptr) (addr uintptr, err error) {
  1199. r0, _, e1 := syscall.Syscall6(procMapViewOfFile.Addr(), 5, uintptr(handle), uintptr(access), uintptr(offsetHigh), uintptr(offsetLow), uintptr(length), 0)
  1200. addr = uintptr(r0)
  1201. if addr == 0 {
  1202. if e1 != 0 {
  1203. err = errnoErr(e1)
  1204. } else {
  1205. err = syscall.EINVAL
  1206. }
  1207. }
  1208. return
  1209. }
  1210. func UnmapViewOfFile(addr uintptr) (err error) {
  1211. r1, _, e1 := syscall.Syscall(procUnmapViewOfFile.Addr(), 1, uintptr(addr), 0, 0)
  1212. if r1 == 0 {
  1213. if e1 != 0 {
  1214. err = errnoErr(e1)
  1215. } else {
  1216. err = syscall.EINVAL
  1217. }
  1218. }
  1219. return
  1220. }
  1221. func FlushViewOfFile(addr uintptr, length uintptr) (err error) {
  1222. r1, _, e1 := syscall.Syscall(procFlushViewOfFile.Addr(), 2, uintptr(addr), uintptr(length), 0)
  1223. if r1 == 0 {
  1224. if e1 != 0 {
  1225. err = errnoErr(e1)
  1226. } else {
  1227. err = syscall.EINVAL
  1228. }
  1229. }
  1230. return
  1231. }
  1232. func VirtualLock(addr uintptr, length uintptr) (err error) {
  1233. r1, _, e1 := syscall.Syscall(procVirtualLock.Addr(), 2, uintptr(addr), uintptr(length), 0)
  1234. if r1 == 0 {
  1235. if e1 != 0 {
  1236. err = errnoErr(e1)
  1237. } else {
  1238. err = syscall.EINVAL
  1239. }
  1240. }
  1241. return
  1242. }
  1243. func VirtualUnlock(addr uintptr, length uintptr) (err error) {
  1244. r1, _, e1 := syscall.Syscall(procVirtualUnlock.Addr(), 2, uintptr(addr), uintptr(length), 0)
  1245. if r1 == 0 {
  1246. if e1 != 0 {
  1247. err = errnoErr(e1)
  1248. } else {
  1249. err = syscall.EINVAL
  1250. }
  1251. }
  1252. return
  1253. }
  1254. func TransmitFile(s Handle, handle Handle, bytesToWrite uint32, bytsPerSend uint32, overlapped *Overlapped, transmitFileBuf *TransmitFileBuffers, flags uint32) (err error) {
  1255. 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)
  1256. if r1 == 0 {
  1257. if e1 != 0 {
  1258. err = errnoErr(e1)
  1259. } else {
  1260. err = syscall.EINVAL
  1261. }
  1262. }
  1263. return
  1264. }
  1265. func ReadDirectoryChanges(handle Handle, buf *byte, buflen uint32, watchSubTree bool, mask uint32, retlen *uint32, overlapped *Overlapped, completionRoutine uintptr) (err error) {
  1266. var _p0 uint32
  1267. if watchSubTree {
  1268. _p0 = 1
  1269. } else {
  1270. _p0 = 0
  1271. }
  1272. 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)
  1273. if r1 == 0 {
  1274. if e1 != 0 {
  1275. err = errnoErr(e1)
  1276. } else {
  1277. err = syscall.EINVAL
  1278. }
  1279. }
  1280. return
  1281. }
  1282. func CertOpenSystemStore(hprov Handle, name *uint16) (store Handle, err error) {
  1283. r0, _, e1 := syscall.Syscall(procCertOpenSystemStoreW.Addr(), 2, uintptr(hprov), uintptr(unsafe.Pointer(name)), 0)
  1284. store = Handle(r0)
  1285. if store == 0 {
  1286. if e1 != 0 {
  1287. err = errnoErr(e1)
  1288. } else {
  1289. err = syscall.EINVAL
  1290. }
  1291. }
  1292. return
  1293. }
  1294. func CertOpenStore(storeProvider uintptr, msgAndCertEncodingType uint32, cryptProv uintptr, flags uint32, para uintptr) (handle Handle, err error) {
  1295. r0, _, e1 := syscall.Syscall6(procCertOpenStore.Addr(), 5, uintptr(storeProvider), uintptr(msgAndCertEncodingType), uintptr(cryptProv), uintptr(flags), uintptr(para), 0)
  1296. handle = Handle(r0)
  1297. if handle == InvalidHandle {
  1298. if e1 != 0 {
  1299. err = errnoErr(e1)
  1300. } else {
  1301. err = syscall.EINVAL
  1302. }
  1303. }
  1304. return
  1305. }
  1306. func CertEnumCertificatesInStore(store Handle, prevContext *CertContext) (context *CertContext, err error) {
  1307. r0, _, e1 := syscall.Syscall(procCertEnumCertificatesInStore.Addr(), 2, uintptr(store), uintptr(unsafe.Pointer(prevContext)), 0)
  1308. context = (*CertContext)(unsafe.Pointer(r0))
  1309. if context == nil {
  1310. if e1 != 0 {
  1311. err = errnoErr(e1)
  1312. } else {
  1313. err = syscall.EINVAL
  1314. }
  1315. }
  1316. return
  1317. }
  1318. func CertAddCertificateContextToStore(store Handle, certContext *CertContext, addDisposition uint32, storeContext **CertContext) (err error) {
  1319. r1, _, e1 := syscall.Syscall6(procCertAddCertificateContextToStore.Addr(), 4, uintptr(store), uintptr(unsafe.Pointer(certContext)), uintptr(addDisposition), uintptr(unsafe.Pointer(storeContext)), 0, 0)
  1320. if r1 == 0 {
  1321. if e1 != 0 {
  1322. err = errnoErr(e1)
  1323. } else {
  1324. err = syscall.EINVAL
  1325. }
  1326. }
  1327. return
  1328. }
  1329. func CertCloseStore(store Handle, flags uint32) (err error) {
  1330. r1, _, e1 := syscall.Syscall(procCertCloseStore.Addr(), 2, uintptr(store), uintptr(flags), 0)
  1331. if r1 == 0 {
  1332. if e1 != 0 {
  1333. err = errnoErr(e1)
  1334. } else {
  1335. err = syscall.EINVAL
  1336. }
  1337. }
  1338. return
  1339. }
  1340. func CertGetCertificateChain(engine Handle, leaf *CertContext, time *Filetime, additionalStore Handle, para *CertChainPara, flags uint32, reserved uintptr, chainCtx **CertChainContext) (err error) {
  1341. 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)
  1342. if r1 == 0 {
  1343. if e1 != 0 {
  1344. err = errnoErr(e1)
  1345. } else {
  1346. err = syscall.EINVAL
  1347. }
  1348. }
  1349. return
  1350. }
  1351. func CertFreeCertificateChain(ctx *CertChainContext) {
  1352. syscall.Syscall(procCertFreeCertificateChain.Addr(), 1, uintptr(unsafe.Pointer(ctx)), 0, 0)
  1353. return
  1354. }
  1355. func CertCreateCertificateContext(certEncodingType uint32, certEncoded *byte, encodedLen uint32) (context *CertContext, err error) {
  1356. r0, _, e1 := syscall.Syscall(procCertCreateCertificateContext.Addr(), 3, uintptr(certEncodingType), uintptr(unsafe.Pointer(certEncoded)), uintptr(encodedLen))
  1357. context = (*CertContext)(unsafe.Pointer(r0))
  1358. if context == nil {
  1359. if e1 != 0 {
  1360. err = errnoErr(e1)
  1361. } else {
  1362. err = syscall.EINVAL
  1363. }
  1364. }
  1365. return
  1366. }
  1367. func CertFreeCertificateContext(ctx *CertContext) (err error) {
  1368. r1, _, e1 := syscall.Syscall(procCertFreeCertificateContext.Addr(), 1, uintptr(unsafe.Pointer(ctx)), 0, 0)
  1369. if r1 == 0 {
  1370. if e1 != 0 {
  1371. err = errnoErr(e1)
  1372. } else {
  1373. err = syscall.EINVAL
  1374. }
  1375. }
  1376. return
  1377. }
  1378. func CertVerifyCertificateChainPolicy(policyOID uintptr, chain *CertChainContext, para *CertChainPolicyPara, status *CertChainPolicyStatus) (err error) {
  1379. r1, _, e1 := syscall.Syscall6(procCertVerifyCertificateChainPolicy.Addr(), 4, uintptr(policyOID), uintptr(unsafe.Pointer(chain)), uintptr(unsafe.Pointer(para)), uintptr(unsafe.Pointer(status)), 0, 0)
  1380. if r1 == 0 {
  1381. if e1 != 0 {
  1382. err = errnoErr(e1)
  1383. } else {
  1384. err = syscall.EINVAL
  1385. }
  1386. }
  1387. return
  1388. }
  1389. func RegOpenKeyEx(key Handle, subkey *uint16, options uint32, desiredAccess uint32, result *Handle) (regerrno error) {
  1390. r0, _, _ := syscall.Syscall6(procRegOpenKeyExW.Addr(), 5, uintptr(key), uintptr(unsafe.Pointer(subkey)), uintptr(options), uintptr(desiredAccess), uintptr(unsafe.Pointer(result)), 0)
  1391. if r0 != 0 {
  1392. regerrno = syscall.Errno(r0)
  1393. }
  1394. return
  1395. }
  1396. func RegCloseKey(key Handle) (regerrno error) {
  1397. r0, _, _ := syscall.Syscall(procRegCloseKey.Addr(), 1, uintptr(key), 0, 0)
  1398. if r0 != 0 {
  1399. regerrno = syscall.Errno(r0)
  1400. }
  1401. return
  1402. }
  1403. 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) {
  1404. 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)))
  1405. if r0 != 0 {
  1406. regerrno = syscall.Errno(r0)
  1407. }
  1408. return
  1409. }
  1410. func RegEnumKeyEx(key Handle, index uint32, name *uint16, nameLen *uint32, reserved *uint32, class *uint16, classLen *uint32, lastWriteTime *Filetime) (regerrno error) {
  1411. 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)
  1412. if r0 != 0 {
  1413. regerrno = syscall.Errno(r0)
  1414. }
  1415. return
  1416. }
  1417. func RegQueryValueEx(key Handle, name *uint16, reserved *uint32, valtype *uint32, buf *byte, buflen *uint32) (regerrno error) {
  1418. 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)))
  1419. if r0 != 0 {
  1420. regerrno = syscall.Errno(r0)
  1421. }
  1422. return
  1423. }
  1424. func getCurrentProcessId() (pid uint32) {
  1425. r0, _, _ := syscall.Syscall(procGetCurrentProcessId.Addr(), 0, 0, 0, 0)
  1426. pid = uint32(r0)
  1427. return
  1428. }
  1429. func GetConsoleMode(console Handle, mode *uint32) (err error) {
  1430. r1, _, e1 := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(console), uintptr(unsafe.Pointer(mode)), 0)
  1431. if r1 == 0 {
  1432. if e1 != 0 {
  1433. err = errnoErr(e1)
  1434. } else {
  1435. err = syscall.EINVAL
  1436. }
  1437. }
  1438. return
  1439. }
  1440. func WriteConsole(console Handle, buf *uint16, towrite uint32, written *uint32, reserved *byte) (err error) {
  1441. r1, _, e1 := syscall.Syscall6(procWriteConsoleW.Addr(), 5, uintptr(console), uintptr(unsafe.Pointer(buf)), uintptr(towrite), uintptr(unsafe.Pointer(written)), uintptr(unsafe.Pointer(reserved)), 0)
  1442. if r1 == 0 {
  1443. if e1 != 0 {
  1444. err = errnoErr(e1)
  1445. } else {
  1446. err = syscall.EINVAL
  1447. }
  1448. }
  1449. return
  1450. }
  1451. func ReadConsole(console Handle, buf *uint16, toread uint32, read *uint32, inputControl *byte) (err error) {
  1452. r1, _, e1 := syscall.Syscall6(procReadConsoleW.Addr(), 5, uintptr(console), uintptr(unsafe.Pointer(buf)), uintptr(toread), uintptr(unsafe.Pointer(read)), uintptr(unsafe.Pointer(inputControl)), 0)
  1453. if r1 == 0 {
  1454. if e1 != 0 {
  1455. err = errnoErr(e1)
  1456. } else {
  1457. err = syscall.EINVAL
  1458. }
  1459. }
  1460. return
  1461. }
  1462. func CreateToolhelp32Snapshot(flags uint32, processId uint32) (handle Handle, err error) {
  1463. r0, _, e1 := syscall.Syscall(procCreateToolhelp32Snapshot.Addr(), 2, uintptr(flags), uintptr(processId), 0)
  1464. handle = Handle(r0)
  1465. if handle == InvalidHandle {
  1466. if e1 != 0 {
  1467. err = errnoErr(e1)
  1468. } else {
  1469. err = syscall.EINVAL
  1470. }
  1471. }
  1472. return
  1473. }
  1474. func Process32First(snapshot Handle, procEntry *ProcessEntry32) (err error) {
  1475. r1, _, e1 := syscall.Syscall(procProcess32FirstW.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(procEntry)), 0)
  1476. if r1 == 0 {
  1477. if e1 != 0 {
  1478. err = errnoErr(e1)
  1479. } else {
  1480. err = syscall.EINVAL
  1481. }
  1482. }
  1483. return
  1484. }
  1485. func Process32Next(snapshot Handle, procEntry *ProcessEntry32) (err error) {
  1486. r1, _, e1 := syscall.Syscall(procProcess32NextW.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(procEntry)), 0)
  1487. if r1 == 0 {
  1488. if e1 != 0 {
  1489. err = errnoErr(e1)
  1490. } else {
  1491. err = syscall.EINVAL
  1492. }
  1493. }
  1494. return
  1495. }
  1496. func DeviceIoControl(handle Handle, ioControlCode uint32, inBuffer *byte, inBufferSize uint32, outBuffer *byte, outBufferSize uint32, bytesReturned *uint32, overlapped *Overlapped) (err error) {
  1497. 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)
  1498. if r1 == 0 {
  1499. if e1 != 0 {
  1500. err = errnoErr(e1)
  1501. } else {
  1502. err = syscall.EINVAL
  1503. }
  1504. }
  1505. return
  1506. }
  1507. func CreateSymbolicLink(symlinkfilename *uint16, targetfilename *uint16, flags uint32) (err error) {
  1508. r1, _, e1 := syscall.Syscall(procCreateSymbolicLinkW.Addr(), 3, uintptr(unsafe.Pointer(symlinkfilename)), uintptr(unsafe.Pointer(targetfilename)), uintptr(flags))
  1509. if r1&0xff == 0 {
  1510. if e1 != 0 {
  1511. err = errnoErr(e1)
  1512. } else {
  1513. err = syscall.EINVAL
  1514. }
  1515. }
  1516. return
  1517. }
  1518. func CreateHardLink(filename *uint16, existingfilename *uint16, reserved uintptr) (err error) {
  1519. r1, _, e1 := syscall.Syscall(procCreateHardLinkW.Addr(), 3, uintptr(unsafe.Pointer(filename)), uintptr(unsafe.Pointer(existingfilename)), uintptr(reserved))
  1520. if r1&0xff == 0 {
  1521. if e1 != 0 {
  1522. err = errnoErr(e1)
  1523. } else {
  1524. err = syscall.EINVAL
  1525. }
  1526. }
  1527. return
  1528. }
  1529. func GetCurrentThreadId() (id uint32) {
  1530. r0, _, _ := syscall.Syscall(procGetCurrentThreadId.Addr(), 0, 0, 0, 0)
  1531. id = uint32(r0)
  1532. return
  1533. }
  1534. func CreateEvent(eventAttrs *syscall.SecurityAttributes, manualReset uint32, initialState uint32, name *uint16) (handle Handle, err error) {
  1535. r0, _, e1 := syscall.Syscall6(procCreateEventW.Addr(), 4, uintptr(unsafe.Pointer(eventAttrs)), uintptr(manualReset), uintptr(initialState), uintptr(unsafe.Pointer(name)), 0, 0)
  1536. handle = Handle(r0)
  1537. if handle == 0 {
  1538. if e1 != 0 {
  1539. err = errnoErr(e1)
  1540. } else {
  1541. err = syscall.EINVAL
  1542. }
  1543. }
  1544. return
  1545. }
  1546. func SetEvent(event Handle) (err error) {
  1547. r1, _, e1 := syscall.Syscall(procSetEvent.Addr(), 1, uintptr(event), 0, 0)
  1548. if r1 == 0 {
  1549. if e1 != 0 {
  1550. err = errnoErr(e1)
  1551. } else {
  1552. err = syscall.EINVAL
  1553. }
  1554. }
  1555. return
  1556. }
  1557. func WSAStartup(verreq uint32, data *WSAData) (sockerr error) {
  1558. r0, _, _ := syscall.Syscall(procWSAStartup.Addr(), 2, uintptr(verreq), uintptr(unsafe.Pointer(data)), 0)
  1559. if r0 != 0 {
  1560. sockerr = syscall.Errno(r0)
  1561. }
  1562. return
  1563. }
  1564. func WSACleanup() (err error) {
  1565. r1, _, e1 := syscall.Syscall(procWSACleanup.Addr(), 0, 0, 0, 0)
  1566. if r1 == socket_error {
  1567. if e1 != 0 {
  1568. err = errnoErr(e1)
  1569. } else {
  1570. err = syscall.EINVAL
  1571. }
  1572. }
  1573. return
  1574. }
  1575. func WSAIoctl(s Handle, iocc uint32, inbuf *byte, cbif uint32, outbuf *byte, cbob uint32, cbbr *uint32, overlapped *Overlapped, completionRoutine uintptr) (err error) {
  1576. 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))
  1577. if r1 == socket_error {
  1578. if e1 != 0 {
  1579. err = errnoErr(e1)
  1580. } else {
  1581. err = syscall.EINVAL
  1582. }
  1583. }
  1584. return
  1585. }
  1586. func socket(af int32, typ int32, protocol int32) (handle Handle, err error) {
  1587. r0, _, e1 := syscall.Syscall(procsocket.Addr(), 3, uintptr(af), uintptr(typ), uintptr(protocol))
  1588. handle = Handle(r0)
  1589. if handle == InvalidHandle {
  1590. if e1 != 0 {
  1591. err = errnoErr(e1)
  1592. } else {
  1593. err = syscall.EINVAL
  1594. }
  1595. }
  1596. return
  1597. }
  1598. func Setsockopt(s Handle, level int32, optname int32, optval *byte, optlen int32) (err error) {
  1599. r1, _, e1 := syscall.Syscall6(procsetsockopt.Addr(), 5, uintptr(s), uintptr(level), uintptr(optname), uintptr(unsafe.Pointer(optval)), uintptr(optlen), 0)
  1600. if r1 == socket_error {
  1601. if e1 != 0 {
  1602. err = errnoErr(e1)
  1603. } else {
  1604. err = syscall.EINVAL
  1605. }
  1606. }
  1607. return
  1608. }
  1609. func Getsockopt(s Handle, level int32, optname int32, optval *byte, optlen *int32) (err error) {
  1610. r1, _, e1 := syscall.Syscall6(procgetsockopt.Addr(), 5, uintptr(s), uintptr(level), uintptr(optname), uintptr(unsafe.Pointer(optval)), uintptr(unsafe.Pointer(optlen)), 0)
  1611. if r1 == socket_error {
  1612. if e1 != 0 {
  1613. err = errnoErr(e1)
  1614. } else {
  1615. err = syscall.EINVAL
  1616. }
  1617. }
  1618. return
  1619. }
  1620. func bind(s Handle, name unsafe.Pointer, namelen int32) (err error) {
  1621. r1, _, e1 := syscall.Syscall(procbind.Addr(), 3, uintptr(s), uintptr(name), uintptr(namelen))
  1622. if r1 == socket_error {
  1623. if e1 != 0 {
  1624. err = errnoErr(e1)
  1625. } else {
  1626. err = syscall.EINVAL
  1627. }
  1628. }
  1629. return
  1630. }
  1631. func connect(s Handle, name unsafe.Pointer, namelen int32) (err error) {
  1632. r1, _, e1 := syscall.Syscall(procconnect.Addr(), 3, uintptr(s), uintptr(name), uintptr(namelen))
  1633. if r1 == socket_error {
  1634. if e1 != 0 {
  1635. err = errnoErr(e1)
  1636. } else {
  1637. err = syscall.EINVAL
  1638. }
  1639. }
  1640. return
  1641. }
  1642. func getsockname(s Handle, rsa *RawSockaddrAny, addrlen *int32) (err error) {
  1643. r1, _, e1 := syscall.Syscall(procgetsockname.Addr(), 3, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
  1644. if r1 == socket_error {
  1645. if e1 != 0 {
  1646. err = errnoErr(e1)
  1647. } else {
  1648. err = syscall.EINVAL
  1649. }
  1650. }
  1651. return
  1652. }
  1653. func getpeername(s Handle, rsa *RawSockaddrAny, addrlen *int32) (err error) {
  1654. r1, _, e1 := syscall.Syscall(procgetpeername.Addr(), 3, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
  1655. if r1 == socket_error {
  1656. if e1 != 0 {
  1657. err = errnoErr(e1)
  1658. } else {
  1659. err = syscall.EINVAL
  1660. }
  1661. }
  1662. return
  1663. }
  1664. func listen(s Handle, backlog int32) (err error) {
  1665. r1, _, e1 := syscall.Syscall(proclisten.Addr(), 2, uintptr(s), uintptr(backlog), 0)
  1666. if r1 == socket_error {
  1667. if e1 != 0 {
  1668. err = errnoErr(e1)
  1669. } else {
  1670. err = syscall.EINVAL
  1671. }
  1672. }
  1673. return
  1674. }
  1675. func shutdown(s Handle, how int32) (err error) {
  1676. r1, _, e1 := syscall.Syscall(procshutdown.Addr(), 2, uintptr(s), uintptr(how), 0)
  1677. if r1 == socket_error {
  1678. if e1 != 0 {
  1679. err = errnoErr(e1)
  1680. } else {
  1681. err = syscall.EINVAL
  1682. }
  1683. }
  1684. return
  1685. }
  1686. func Closesocket(s Handle) (err error) {
  1687. r1, _, e1 := syscall.Syscall(procclosesocket.Addr(), 1, uintptr(s), 0, 0)
  1688. if r1 == socket_error {
  1689. if e1 != 0 {
  1690. err = errnoErr(e1)
  1691. } else {
  1692. err = syscall.EINVAL
  1693. }
  1694. }
  1695. return
  1696. }
  1697. func AcceptEx(ls Handle, as Handle, buf *byte, rxdatalen uint32, laddrlen uint32, raddrlen uint32, recvd *uint32, overlapped *Overlapped) (err error) {
  1698. 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)
  1699. if r1 == 0 {
  1700. if e1 != 0 {
  1701. err = errnoErr(e1)
  1702. } else {
  1703. err = syscall.EINVAL
  1704. }
  1705. }
  1706. return
  1707. }
  1708. func GetAcceptExSockaddrs(buf *byte, rxdatalen uint32, laddrlen uint32, raddrlen uint32, lrsa **RawSockaddrAny, lrsalen *int32, rrsa **RawSockaddrAny, rrsalen *int32) {
  1709. 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)
  1710. return
  1711. }
  1712. func WSARecv(s Handle, bufs *WSABuf, bufcnt uint32, recvd *uint32, flags *uint32, overlapped *Overlapped, croutine *byte) (err error) {
  1713. 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)
  1714. if r1 == socket_error {
  1715. if e1 != 0 {
  1716. err = errnoErr(e1)
  1717. } else {
  1718. err = syscall.EINVAL
  1719. }
  1720. }
  1721. return
  1722. }
  1723. func WSASend(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, overlapped *Overlapped, croutine *byte) (err error) {
  1724. 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)
  1725. if r1 == socket_error {
  1726. if e1 != 0 {
  1727. err = errnoErr(e1)
  1728. } else {
  1729. err = syscall.EINVAL
  1730. }
  1731. }
  1732. return
  1733. }
  1734. func WSARecvFrom(s Handle, bufs *WSABuf, bufcnt uint32, recvd *uint32, flags *uint32, from *RawSockaddrAny, fromlen *int32, overlapped *Overlapped, croutine *byte) (err error) {
  1735. 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)))
  1736. if r1 == socket_error {
  1737. if e1 != 0 {
  1738. err = errnoErr(e1)
  1739. } else {
  1740. err = syscall.EINVAL
  1741. }
  1742. }
  1743. return
  1744. }
  1745. func WSASendTo(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, to *RawSockaddrAny, tolen int32, overlapped *Overlapped, croutine *byte) (err error) {
  1746. 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)))
  1747. if r1 == socket_error {
  1748. if e1 != 0 {
  1749. err = errnoErr(e1)
  1750. } else {
  1751. err = syscall.EINVAL
  1752. }
  1753. }
  1754. return
  1755. }
  1756. func GetHostByName(name string) (h *Hostent, err error) {
  1757. var _p0 *byte
  1758. _p0, err = syscall.BytePtrFromString(name)
  1759. if err != nil {
  1760. return
  1761. }
  1762. return _GetHostByName(_p0)
  1763. }
  1764. func _GetHostByName(name *byte) (h *Hostent, err error) {
  1765. r0, _, e1 := syscall.Syscall(procgethostbyname.Addr(), 1, uintptr(unsafe.Pointer(name)), 0, 0)
  1766. h = (*Hostent)(unsafe.Pointer(r0))
  1767. if h == nil {
  1768. if e1 != 0 {
  1769. err = errnoErr(e1)
  1770. } else {
  1771. err = syscall.EINVAL
  1772. }
  1773. }
  1774. return
  1775. }
  1776. func GetServByName(name string, proto string) (s *Servent, err error) {
  1777. var _p0 *byte
  1778. _p0, err = syscall.BytePtrFromString(name)
  1779. if err != nil {
  1780. return
  1781. }
  1782. var _p1 *byte
  1783. _p1, err = syscall.BytePtrFromString(proto)
  1784. if err != nil {
  1785. return
  1786. }
  1787. return _GetServByName(_p0, _p1)
  1788. }
  1789. func _GetServByName(name *byte, proto *byte) (s *Servent, err error) {
  1790. r0, _, e1 := syscall.Syscall(procgetservbyname.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(proto)), 0)
  1791. s = (*Servent)(unsafe.Pointer(r0))
  1792. if s == nil {
  1793. if e1 != 0 {
  1794. err = errnoErr(e1)
  1795. } else {
  1796. err = syscall.EINVAL
  1797. }
  1798. }
  1799. return
  1800. }
  1801. func Ntohs(netshort uint16) (u uint16) {
  1802. r0, _, _ := syscall.Syscall(procntohs.Addr(), 1, uintptr(netshort), 0, 0)
  1803. u = uint16(r0)
  1804. return
  1805. }
  1806. func GetProtoByName(name string) (p *Protoent, err error) {
  1807. var _p0 *byte
  1808. _p0, err = syscall.BytePtrFromString(name)
  1809. if err != nil {
  1810. return
  1811. }
  1812. return _GetProtoByName(_p0)
  1813. }
  1814. func _GetProtoByName(name *byte) (p *Protoent, err error) {
  1815. r0, _, e1 := syscall.Syscall(procgetprotobyname.Addr(), 1, uintptr(unsafe.Pointer(name)), 0, 0)
  1816. p = (*Protoent)(unsafe.Pointer(r0))
  1817. if p == nil {
  1818. if e1 != 0 {
  1819. err = errnoErr(e1)
  1820. } else {
  1821. err = syscall.EINVAL
  1822. }
  1823. }
  1824. return
  1825. }
  1826. func DnsQuery(name string, qtype uint16, options uint32, extra *byte, qrs **DNSRecord, pr *byte) (status error) {
  1827. var _p0 *uint16
  1828. _p0, status = syscall.UTF16PtrFromString(name)
  1829. if status != nil {
  1830. return
  1831. }
  1832. return _DnsQuery(_p0, qtype, options, extra, qrs, pr)
  1833. }
  1834. func _DnsQuery(name *uint16, qtype uint16, options uint32, extra *byte, qrs **DNSRecord, pr *byte) (status error) {
  1835. 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)))
  1836. if r0 != 0 {
  1837. status = syscall.Errno(r0)
  1838. }
  1839. return
  1840. }
  1841. func DnsRecordListFree(rl *DNSRecord, freetype uint32) {
  1842. syscall.Syscall(procDnsRecordListFree.Addr(), 2, uintptr(unsafe.Pointer(rl)), uintptr(freetype), 0)
  1843. return
  1844. }
  1845. func DnsNameCompare(name1 *uint16, name2 *uint16) (same bool) {
  1846. r0, _, _ := syscall.Syscall(procDnsNameCompare_W.Addr(), 2, uintptr(unsafe.Pointer(name1)), uintptr(unsafe.Pointer(name2)), 0)
  1847. same = r0 != 0
  1848. return
  1849. }
  1850. func GetAddrInfoW(nodename *uint16, servicename *uint16, hints *AddrinfoW, result **AddrinfoW) (sockerr error) {
  1851. r0, _, _ := syscall.Syscall6(procGetAddrInfoW.Addr(), 4, uintptr(unsafe.Pointer(nodename)), uintptr(unsafe.Pointer(servicename)), uintptr(unsafe.Pointer(hints)), uintptr(unsafe.Pointer(result)), 0, 0)
  1852. if r0 != 0 {
  1853. sockerr = syscall.Errno(r0)
  1854. }
  1855. return
  1856. }
  1857. func FreeAddrInfoW(addrinfo *AddrinfoW) {
  1858. syscall.Syscall(procFreeAddrInfoW.Addr(), 1, uintptr(unsafe.Pointer(addrinfo)), 0, 0)
  1859. return
  1860. }
  1861. func GetIfEntry(pIfRow *MibIfRow) (errcode error) {
  1862. r0, _, _ := syscall.Syscall(procGetIfEntry.Addr(), 1, uintptr(unsafe.Pointer(pIfRow)), 0, 0)
  1863. if r0 != 0 {
  1864. errcode = syscall.Errno(r0)
  1865. }
  1866. return
  1867. }
  1868. func GetAdaptersInfo(ai *IpAdapterInfo, ol *uint32) (errcode error) {
  1869. r0, _, _ := syscall.Syscall(procGetAdaptersInfo.Addr(), 2, uintptr(unsafe.Pointer(ai)), uintptr(unsafe.Pointer(ol)), 0)
  1870. if r0 != 0 {
  1871. errcode = syscall.Errno(r0)
  1872. }
  1873. return
  1874. }
  1875. func SetFileCompletionNotificationModes(handle Handle, flags uint8) (err error) {
  1876. r1, _, e1 := syscall.Syscall(procSetFileCompletionNotificationModes.Addr(), 2, uintptr(handle), uintptr(flags), 0)
  1877. if r1 == 0 {
  1878. if e1 != 0 {
  1879. err = errnoErr(e1)
  1880. } else {
  1881. err = syscall.EINVAL
  1882. }
  1883. }
  1884. return
  1885. }
  1886. func WSAEnumProtocols(protocols *int32, protocolBuffer *WSAProtocolInfo, bufferLength *uint32) (n int32, err error) {
  1887. r0, _, e1 := syscall.Syscall(procWSAEnumProtocolsW.Addr(), 3, uintptr(unsafe.Pointer(protocols)), uintptr(unsafe.Pointer(protocolBuffer)), uintptr(unsafe.Pointer(bufferLength)))
  1888. n = int32(r0)
  1889. if n == -1 {
  1890. if e1 != 0 {
  1891. err = errnoErr(e1)
  1892. } else {
  1893. err = syscall.EINVAL
  1894. }
  1895. }
  1896. return
  1897. }
  1898. func GetAdaptersAddresses(family uint32, flags uint32, reserved uintptr, adapterAddresses *IpAdapterAddresses, sizePointer *uint32) (errcode error) {
  1899. r0, _, _ := syscall.Syscall6(procGetAdaptersAddresses.Addr(), 5, uintptr(family), uintptr(flags), uintptr(reserved), uintptr(unsafe.Pointer(adapterAddresses)), uintptr(unsafe.Pointer(sizePointer)), 0)
  1900. if r0 != 0 {
  1901. errcode = syscall.Errno(r0)
  1902. }
  1903. return
  1904. }
  1905. func GetACP() (acp uint32) {
  1906. r0, _, _ := syscall.Syscall(procGetACP.Addr(), 0, 0, 0, 0)
  1907. acp = uint32(r0)
  1908. return
  1909. }
  1910. func MultiByteToWideChar(codePage uint32, dwFlags uint32, str *byte, nstr int32, wchar *uint16, nwchar int32) (nwrite int32, err error) {
  1911. r0, _, e1 := syscall.Syscall6(procMultiByteToWideChar.Addr(), 6, uintptr(codePage), uintptr(dwFlags), uintptr(unsafe.Pointer(str)), uintptr(nstr), uintptr(unsafe.Pointer(wchar)), uintptr(nwchar))
  1912. nwrite = int32(r0)
  1913. if nwrite == 0 {
  1914. if e1 != 0 {
  1915. err = errnoErr(e1)
  1916. } else {
  1917. err = syscall.EINVAL
  1918. }
  1919. }
  1920. return
  1921. }
  1922. func TranslateName(accName *uint16, accNameFormat uint32, desiredNameFormat uint32, translatedName *uint16, nSize *uint32) (err error) {
  1923. r1, _, e1 := syscall.Syscall6(procTranslateNameW.Addr(), 5, uintptr(unsafe.Pointer(accName)), uintptr(accNameFormat), uintptr(desiredNameFormat), uintptr(unsafe.Pointer(translatedName)), uintptr(unsafe.Pointer(nSize)), 0)
  1924. if r1&0xff == 0 {
  1925. if e1 != 0 {
  1926. err = errnoErr(e1)
  1927. } else {
  1928. err = syscall.EINVAL
  1929. }
  1930. }
  1931. return
  1932. }
  1933. func GetUserNameEx(nameFormat uint32, nameBuffre *uint16, nSize *uint32) (err error) {
  1934. r1, _, e1 := syscall.Syscall(procGetUserNameExW.Addr(), 3, uintptr(nameFormat), uintptr(unsafe.Pointer(nameBuffre)), uintptr(unsafe.Pointer(nSize)))
  1935. if r1&0xff == 0 {
  1936. if e1 != 0 {
  1937. err = errnoErr(e1)
  1938. } else {
  1939. err = syscall.EINVAL
  1940. }
  1941. }
  1942. return
  1943. }
  1944. func NetUserGetInfo(serverName *uint16, userName *uint16, level uint32, buf **byte) (neterr error) {
  1945. r0, _, _ := syscall.Syscall6(procNetUserGetInfo.Addr(), 4, uintptr(unsafe.Pointer(serverName)), uintptr(unsafe.Pointer(userName)), uintptr(level), uintptr(unsafe.Pointer(buf)), 0, 0)
  1946. if r0 != 0 {
  1947. neterr = syscall.Errno(r0)
  1948. }
  1949. return
  1950. }
  1951. func NetGetJoinInformation(server *uint16, name **uint16, bufType *uint32) (neterr error) {
  1952. r0, _, _ := syscall.Syscall(procNetGetJoinInformation.Addr(), 3, uintptr(unsafe.Pointer(server)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(bufType)))
  1953. if r0 != 0 {
  1954. neterr = syscall.Errno(r0)
  1955. }
  1956. return
  1957. }
  1958. func NetApiBufferFree(buf *byte) (neterr error) {
  1959. r0, _, _ := syscall.Syscall(procNetApiBufferFree.Addr(), 1, uintptr(unsafe.Pointer(buf)), 0, 0)
  1960. if r0 != 0 {
  1961. neterr = syscall.Errno(r0)
  1962. }
  1963. return
  1964. }
  1965. func LookupAccountSid(systemName *uint16, sid *SID, name *uint16, nameLen *uint32, refdDomainName *uint16, refdDomainNameLen *uint32, use *uint32) (err error) {
  1966. 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)
  1967. if r1 == 0 {
  1968. if e1 != 0 {
  1969. err = errnoErr(e1)
  1970. } else {
  1971. err = syscall.EINVAL
  1972. }
  1973. }
  1974. return
  1975. }
  1976. func LookupAccountName(systemName *uint16, accountName *uint16, sid *SID, sidLen *uint32, refdDomainName *uint16, refdDomainNameLen *uint32, use *uint32) (err error) {
  1977. 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)
  1978. if r1 == 0 {
  1979. if e1 != 0 {
  1980. err = errnoErr(e1)
  1981. } else {
  1982. err = syscall.EINVAL
  1983. }
  1984. }
  1985. return
  1986. }
  1987. func ConvertSidToStringSid(sid *SID, stringSid **uint16) (err error) {
  1988. r1, _, e1 := syscall.Syscall(procConvertSidToStringSidW.Addr(), 2, uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(stringSid)), 0)
  1989. if r1 == 0 {
  1990. if e1 != 0 {
  1991. err = errnoErr(e1)
  1992. } else {
  1993. err = syscall.EINVAL
  1994. }
  1995. }
  1996. return
  1997. }
  1998. func ConvertStringSidToSid(stringSid *uint16, sid **SID) (err error) {
  1999. r1, _, e1 := syscall.Syscall(procConvertStringSidToSidW.Addr(), 2, uintptr(unsafe.Pointer(stringSid)), uintptr(unsafe.Pointer(sid)), 0)
  2000. if r1 == 0 {
  2001. if e1 != 0 {
  2002. err = errnoErr(e1)
  2003. } else {
  2004. err = syscall.EINVAL
  2005. }
  2006. }
  2007. return
  2008. }
  2009. func GetLengthSid(sid *SID) (len uint32) {
  2010. r0, _, _ := syscall.Syscall(procGetLengthSid.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0)
  2011. len = uint32(r0)
  2012. return
  2013. }
  2014. func CopySid(destSidLen uint32, destSid *SID, srcSid *SID) (err error) {
  2015. r1, _, e1 := syscall.Syscall(procCopySid.Addr(), 3, uintptr(destSidLen), uintptr(unsafe.Pointer(destSid)), uintptr(unsafe.Pointer(srcSid)))
  2016. if r1 == 0 {
  2017. if e1 != 0 {
  2018. err = errnoErr(e1)
  2019. } else {
  2020. err = syscall.EINVAL
  2021. }
  2022. }
  2023. return
  2024. }
  2025. 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) {
  2026. 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)
  2027. if r1 == 0 {
  2028. if e1 != 0 {
  2029. err = errnoErr(e1)
  2030. } else {
  2031. err = syscall.EINVAL
  2032. }
  2033. }
  2034. return
  2035. }
  2036. func FreeSid(sid *SID) (err error) {
  2037. r1, _, e1 := syscall.Syscall(procFreeSid.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0)
  2038. if r1 != 0 {
  2039. if e1 != 0 {
  2040. err = errnoErr(e1)
  2041. } else {
  2042. err = syscall.EINVAL
  2043. }
  2044. }
  2045. return
  2046. }
  2047. func EqualSid(sid1 *SID, sid2 *SID) (isEqual bool) {
  2048. r0, _, _ := syscall.Syscall(procEqualSid.Addr(), 2, uintptr(unsafe.Pointer(sid1)), uintptr(unsafe.Pointer(sid2)), 0)
  2049. isEqual = r0 != 0
  2050. return
  2051. }
  2052. func OpenProcessToken(h Handle, access uint32, token *Token) (err error) {
  2053. r1, _, e1 := syscall.Syscall(procOpenProcessToken.Addr(), 3, uintptr(h), uintptr(access), uintptr(unsafe.Pointer(token)))
  2054. if r1 == 0 {
  2055. if e1 != 0 {
  2056. err = errnoErr(e1)
  2057. } else {
  2058. err = syscall.EINVAL
  2059. }
  2060. }
  2061. return
  2062. }
  2063. func GetTokenInformation(t Token, infoClass uint32, info *byte, infoLen uint32, returnedLen *uint32) (err error) {
  2064. r1, _, e1 := syscall.Syscall6(procGetTokenInformation.Addr(), 5, uintptr(t), uintptr(infoClass), uintptr(unsafe.Pointer(info)), uintptr(infoLen), uintptr(unsafe.Pointer(returnedLen)), 0)
  2065. if r1 == 0 {
  2066. if e1 != 0 {
  2067. err = errnoErr(e1)
  2068. } else {
  2069. err = syscall.EINVAL
  2070. }
  2071. }
  2072. return
  2073. }
  2074. func GetUserProfileDirectory(t Token, dir *uint16, dirLen *uint32) (err error) {
  2075. r1, _, e1 := syscall.Syscall(procGetUserProfileDirectoryW.Addr(), 3, uintptr(t), uintptr(unsafe.Pointer(dir)), uintptr(unsafe.Pointer(dirLen)))
  2076. if r1 == 0 {
  2077. if e1 != 0 {
  2078. err = errnoErr(e1)
  2079. } else {
  2080. err = syscall.EINVAL
  2081. }
  2082. }
  2083. return
  2084. }