zsyscall_windows.go 60 KB

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