zsyscall_windows.go 61 KB

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