zsyscall_windows.go 71 KB

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