zsyscall_windows.go 77 KB

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