zsyscall_windows_386.go 59 KB

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