zsyscall_windows.go 61 KB

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