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.

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