zsyscall_windows.go 109 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338
  1. // Code generated by 'go generate'; 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. moduserenv = NewLazySystemDLL("userenv.dll")
  35. modmswsock = NewLazySystemDLL("mswsock.dll")
  36. modcrypt32 = NewLazySystemDLL("crypt32.dll")
  37. moduser32 = NewLazySystemDLL("user32.dll")
  38. modole32 = NewLazySystemDLL("ole32.dll")
  39. modntdll = NewLazySystemDLL("ntdll.dll")
  40. modws2_32 = NewLazySystemDLL("ws2_32.dll")
  41. moddnsapi = NewLazySystemDLL("dnsapi.dll")
  42. modiphlpapi = NewLazySystemDLL("iphlpapi.dll")
  43. modsecur32 = NewLazySystemDLL("secur32.dll")
  44. modnetapi32 = NewLazySystemDLL("netapi32.dll")
  45. modwtsapi32 = NewLazySystemDLL("wtsapi32.dll")
  46. procRegisterEventSourceW = modadvapi32.NewProc("RegisterEventSourceW")
  47. procDeregisterEventSource = modadvapi32.NewProc("DeregisterEventSource")
  48. procReportEventW = modadvapi32.NewProc("ReportEventW")
  49. procOpenSCManagerW = modadvapi32.NewProc("OpenSCManagerW")
  50. procCloseServiceHandle = modadvapi32.NewProc("CloseServiceHandle")
  51. procCreateServiceW = modadvapi32.NewProc("CreateServiceW")
  52. procOpenServiceW = modadvapi32.NewProc("OpenServiceW")
  53. procDeleteService = modadvapi32.NewProc("DeleteService")
  54. procStartServiceW = modadvapi32.NewProc("StartServiceW")
  55. procQueryServiceStatus = modadvapi32.NewProc("QueryServiceStatus")
  56. procQueryServiceLockStatusW = modadvapi32.NewProc("QueryServiceLockStatusW")
  57. procControlService = modadvapi32.NewProc("ControlService")
  58. procStartServiceCtrlDispatcherW = modadvapi32.NewProc("StartServiceCtrlDispatcherW")
  59. procSetServiceStatus = modadvapi32.NewProc("SetServiceStatus")
  60. procChangeServiceConfigW = modadvapi32.NewProc("ChangeServiceConfigW")
  61. procQueryServiceConfigW = modadvapi32.NewProc("QueryServiceConfigW")
  62. procChangeServiceConfig2W = modadvapi32.NewProc("ChangeServiceConfig2W")
  63. procQueryServiceConfig2W = modadvapi32.NewProc("QueryServiceConfig2W")
  64. procEnumServicesStatusExW = modadvapi32.NewProc("EnumServicesStatusExW")
  65. procQueryServiceStatusEx = modadvapi32.NewProc("QueryServiceStatusEx")
  66. procNotifyServiceStatusChangeW = modadvapi32.NewProc("NotifyServiceStatusChangeW")
  67. procGetLastError = modkernel32.NewProc("GetLastError")
  68. procLoadLibraryW = modkernel32.NewProc("LoadLibraryW")
  69. procLoadLibraryExW = modkernel32.NewProc("LoadLibraryExW")
  70. procFreeLibrary = modkernel32.NewProc("FreeLibrary")
  71. procGetProcAddress = modkernel32.NewProc("GetProcAddress")
  72. procGetVersion = modkernel32.NewProc("GetVersion")
  73. procFormatMessageW = modkernel32.NewProc("FormatMessageW")
  74. procExitProcess = modkernel32.NewProc("ExitProcess")
  75. procIsWow64Process = modkernel32.NewProc("IsWow64Process")
  76. procCreateFileW = modkernel32.NewProc("CreateFileW")
  77. procReadFile = modkernel32.NewProc("ReadFile")
  78. procWriteFile = modkernel32.NewProc("WriteFile")
  79. procGetOverlappedResult = modkernel32.NewProc("GetOverlappedResult")
  80. procSetFilePointer = modkernel32.NewProc("SetFilePointer")
  81. procCloseHandle = modkernel32.NewProc("CloseHandle")
  82. procGetStdHandle = modkernel32.NewProc("GetStdHandle")
  83. procSetStdHandle = modkernel32.NewProc("SetStdHandle")
  84. procFindFirstFileW = modkernel32.NewProc("FindFirstFileW")
  85. procFindNextFileW = modkernel32.NewProc("FindNextFileW")
  86. procFindClose = modkernel32.NewProc("FindClose")
  87. procGetFileInformationByHandle = modkernel32.NewProc("GetFileInformationByHandle")
  88. procGetFileInformationByHandleEx = modkernel32.NewProc("GetFileInformationByHandleEx")
  89. procGetCurrentDirectoryW = modkernel32.NewProc("GetCurrentDirectoryW")
  90. procSetCurrentDirectoryW = modkernel32.NewProc("SetCurrentDirectoryW")
  91. procCreateDirectoryW = modkernel32.NewProc("CreateDirectoryW")
  92. procRemoveDirectoryW = modkernel32.NewProc("RemoveDirectoryW")
  93. procDeleteFileW = modkernel32.NewProc("DeleteFileW")
  94. procMoveFileW = modkernel32.NewProc("MoveFileW")
  95. procMoveFileExW = modkernel32.NewProc("MoveFileExW")
  96. procGetComputerNameW = modkernel32.NewProc("GetComputerNameW")
  97. procGetComputerNameExW = modkernel32.NewProc("GetComputerNameExW")
  98. procSetEndOfFile = modkernel32.NewProc("SetEndOfFile")
  99. procGetSystemTimeAsFileTime = modkernel32.NewProc("GetSystemTimeAsFileTime")
  100. procGetSystemTimePreciseAsFileTime = modkernel32.NewProc("GetSystemTimePreciseAsFileTime")
  101. procGetTimeZoneInformation = modkernel32.NewProc("GetTimeZoneInformation")
  102. procCreateIoCompletionPort = modkernel32.NewProc("CreateIoCompletionPort")
  103. procGetQueuedCompletionStatus = modkernel32.NewProc("GetQueuedCompletionStatus")
  104. procPostQueuedCompletionStatus = modkernel32.NewProc("PostQueuedCompletionStatus")
  105. procCancelIo = modkernel32.NewProc("CancelIo")
  106. procCancelIoEx = modkernel32.NewProc("CancelIoEx")
  107. procCreateProcessW = modkernel32.NewProc("CreateProcessW")
  108. procOpenProcess = modkernel32.NewProc("OpenProcess")
  109. procShellExecuteW = modshell32.NewProc("ShellExecuteW")
  110. procSHGetKnownFolderPath = modshell32.NewProc("SHGetKnownFolderPath")
  111. procTerminateProcess = modkernel32.NewProc("TerminateProcess")
  112. procGetExitCodeProcess = modkernel32.NewProc("GetExitCodeProcess")
  113. procGetStartupInfoW = modkernel32.NewProc("GetStartupInfoW")
  114. procGetCurrentProcess = modkernel32.NewProc("GetCurrentProcess")
  115. procGetCurrentThread = modkernel32.NewProc("GetCurrentThread")
  116. procGetProcessTimes = modkernel32.NewProc("GetProcessTimes")
  117. procDuplicateHandle = modkernel32.NewProc("DuplicateHandle")
  118. procWaitForSingleObject = modkernel32.NewProc("WaitForSingleObject")
  119. procWaitForMultipleObjects = modkernel32.NewProc("WaitForMultipleObjects")
  120. procGetTempPathW = modkernel32.NewProc("GetTempPathW")
  121. procCreatePipe = modkernel32.NewProc("CreatePipe")
  122. procGetFileType = modkernel32.NewProc("GetFileType")
  123. procCryptAcquireContextW = modadvapi32.NewProc("CryptAcquireContextW")
  124. procCryptReleaseContext = modadvapi32.NewProc("CryptReleaseContext")
  125. procCryptGenRandom = modadvapi32.NewProc("CryptGenRandom")
  126. procGetEnvironmentStringsW = modkernel32.NewProc("GetEnvironmentStringsW")
  127. procFreeEnvironmentStringsW = modkernel32.NewProc("FreeEnvironmentStringsW")
  128. procGetEnvironmentVariableW = modkernel32.NewProc("GetEnvironmentVariableW")
  129. procSetEnvironmentVariableW = modkernel32.NewProc("SetEnvironmentVariableW")
  130. procCreateEnvironmentBlock = moduserenv.NewProc("CreateEnvironmentBlock")
  131. procDestroyEnvironmentBlock = moduserenv.NewProc("DestroyEnvironmentBlock")
  132. procGetTickCount64 = modkernel32.NewProc("GetTickCount64")
  133. procSetFileTime = modkernel32.NewProc("SetFileTime")
  134. procGetFileAttributesW = modkernel32.NewProc("GetFileAttributesW")
  135. procSetFileAttributesW = modkernel32.NewProc("SetFileAttributesW")
  136. procGetFileAttributesExW = modkernel32.NewProc("GetFileAttributesExW")
  137. procGetCommandLineW = modkernel32.NewProc("GetCommandLineW")
  138. procCommandLineToArgvW = modshell32.NewProc("CommandLineToArgvW")
  139. procLocalFree = modkernel32.NewProc("LocalFree")
  140. procSetHandleInformation = modkernel32.NewProc("SetHandleInformation")
  141. procFlushFileBuffers = modkernel32.NewProc("FlushFileBuffers")
  142. procGetFullPathNameW = modkernel32.NewProc("GetFullPathNameW")
  143. procGetLongPathNameW = modkernel32.NewProc("GetLongPathNameW")
  144. procGetShortPathNameW = modkernel32.NewProc("GetShortPathNameW")
  145. procCreateFileMappingW = modkernel32.NewProc("CreateFileMappingW")
  146. procMapViewOfFile = modkernel32.NewProc("MapViewOfFile")
  147. procUnmapViewOfFile = modkernel32.NewProc("UnmapViewOfFile")
  148. procFlushViewOfFile = modkernel32.NewProc("FlushViewOfFile")
  149. procVirtualLock = modkernel32.NewProc("VirtualLock")
  150. procVirtualUnlock = modkernel32.NewProc("VirtualUnlock")
  151. procVirtualAlloc = modkernel32.NewProc("VirtualAlloc")
  152. procVirtualFree = modkernel32.NewProc("VirtualFree")
  153. procVirtualProtect = modkernel32.NewProc("VirtualProtect")
  154. procTransmitFile = modmswsock.NewProc("TransmitFile")
  155. procReadDirectoryChangesW = modkernel32.NewProc("ReadDirectoryChangesW")
  156. procCertOpenSystemStoreW = modcrypt32.NewProc("CertOpenSystemStoreW")
  157. procCertOpenStore = modcrypt32.NewProc("CertOpenStore")
  158. procCertEnumCertificatesInStore = modcrypt32.NewProc("CertEnumCertificatesInStore")
  159. procCertAddCertificateContextToStore = modcrypt32.NewProc("CertAddCertificateContextToStore")
  160. procCertCloseStore = modcrypt32.NewProc("CertCloseStore")
  161. procCertGetCertificateChain = modcrypt32.NewProc("CertGetCertificateChain")
  162. procCertFreeCertificateChain = modcrypt32.NewProc("CertFreeCertificateChain")
  163. procCertCreateCertificateContext = modcrypt32.NewProc("CertCreateCertificateContext")
  164. procCertFreeCertificateContext = modcrypt32.NewProc("CertFreeCertificateContext")
  165. procCertVerifyCertificateChainPolicy = modcrypt32.NewProc("CertVerifyCertificateChainPolicy")
  166. procRegOpenKeyExW = modadvapi32.NewProc("RegOpenKeyExW")
  167. procRegCloseKey = modadvapi32.NewProc("RegCloseKey")
  168. procRegQueryInfoKeyW = modadvapi32.NewProc("RegQueryInfoKeyW")
  169. procRegEnumKeyExW = modadvapi32.NewProc("RegEnumKeyExW")
  170. procRegQueryValueExW = modadvapi32.NewProc("RegQueryValueExW")
  171. procGetCurrentProcessId = modkernel32.NewProc("GetCurrentProcessId")
  172. procGetConsoleMode = modkernel32.NewProc("GetConsoleMode")
  173. procSetConsoleMode = modkernel32.NewProc("SetConsoleMode")
  174. procGetConsoleScreenBufferInfo = modkernel32.NewProc("GetConsoleScreenBufferInfo")
  175. procWriteConsoleW = modkernel32.NewProc("WriteConsoleW")
  176. procReadConsoleW = modkernel32.NewProc("ReadConsoleW")
  177. procCreateToolhelp32Snapshot = modkernel32.NewProc("CreateToolhelp32Snapshot")
  178. procProcess32FirstW = modkernel32.NewProc("Process32FirstW")
  179. procProcess32NextW = modkernel32.NewProc("Process32NextW")
  180. procThread32First = modkernel32.NewProc("Thread32First")
  181. procThread32Next = modkernel32.NewProc("Thread32Next")
  182. procDeviceIoControl = modkernel32.NewProc("DeviceIoControl")
  183. procCreateSymbolicLinkW = modkernel32.NewProc("CreateSymbolicLinkW")
  184. procCreateHardLinkW = modkernel32.NewProc("CreateHardLinkW")
  185. procGetCurrentThreadId = modkernel32.NewProc("GetCurrentThreadId")
  186. procCreateEventW = modkernel32.NewProc("CreateEventW")
  187. procCreateEventExW = modkernel32.NewProc("CreateEventExW")
  188. procOpenEventW = modkernel32.NewProc("OpenEventW")
  189. procSetEvent = modkernel32.NewProc("SetEvent")
  190. procResetEvent = modkernel32.NewProc("ResetEvent")
  191. procPulseEvent = modkernel32.NewProc("PulseEvent")
  192. procSleepEx = modkernel32.NewProc("SleepEx")
  193. procCreateJobObjectW = modkernel32.NewProc("CreateJobObjectW")
  194. procAssignProcessToJobObject = modkernel32.NewProc("AssignProcessToJobObject")
  195. procTerminateJobObject = modkernel32.NewProc("TerminateJobObject")
  196. procSetErrorMode = modkernel32.NewProc("SetErrorMode")
  197. procResumeThread = modkernel32.NewProc("ResumeThread")
  198. procSetPriorityClass = modkernel32.NewProc("SetPriorityClass")
  199. procGetPriorityClass = modkernel32.NewProc("GetPriorityClass")
  200. procSetInformationJobObject = modkernel32.NewProc("SetInformationJobObject")
  201. procGenerateConsoleCtrlEvent = modkernel32.NewProc("GenerateConsoleCtrlEvent")
  202. procGetProcessId = modkernel32.NewProc("GetProcessId")
  203. procOpenThread = modkernel32.NewProc("OpenThread")
  204. procDefineDosDeviceW = modkernel32.NewProc("DefineDosDeviceW")
  205. procDeleteVolumeMountPointW = modkernel32.NewProc("DeleteVolumeMountPointW")
  206. procFindFirstVolumeW = modkernel32.NewProc("FindFirstVolumeW")
  207. procFindFirstVolumeMountPointW = modkernel32.NewProc("FindFirstVolumeMountPointW")
  208. procFindNextVolumeW = modkernel32.NewProc("FindNextVolumeW")
  209. procFindNextVolumeMountPointW = modkernel32.NewProc("FindNextVolumeMountPointW")
  210. procFindVolumeClose = modkernel32.NewProc("FindVolumeClose")
  211. procFindVolumeMountPointClose = modkernel32.NewProc("FindVolumeMountPointClose")
  212. procGetDriveTypeW = modkernel32.NewProc("GetDriveTypeW")
  213. procGetLogicalDrives = modkernel32.NewProc("GetLogicalDrives")
  214. procGetLogicalDriveStringsW = modkernel32.NewProc("GetLogicalDriveStringsW")
  215. procGetVolumeInformationW = modkernel32.NewProc("GetVolumeInformationW")
  216. procGetVolumeInformationByHandleW = modkernel32.NewProc("GetVolumeInformationByHandleW")
  217. procGetVolumeNameForVolumeMountPointW = modkernel32.NewProc("GetVolumeNameForVolumeMountPointW")
  218. procGetVolumePathNameW = modkernel32.NewProc("GetVolumePathNameW")
  219. procGetVolumePathNamesForVolumeNameW = modkernel32.NewProc("GetVolumePathNamesForVolumeNameW")
  220. procQueryDosDeviceW = modkernel32.NewProc("QueryDosDeviceW")
  221. procSetVolumeLabelW = modkernel32.NewProc("SetVolumeLabelW")
  222. procSetVolumeMountPointW = modkernel32.NewProc("SetVolumeMountPointW")
  223. procMessageBoxW = moduser32.NewProc("MessageBoxW")
  224. procCLSIDFromString = modole32.NewProc("CLSIDFromString")
  225. procStringFromGUID2 = modole32.NewProc("StringFromGUID2")
  226. procCoCreateGuid = modole32.NewProc("CoCreateGuid")
  227. procCoTaskMemFree = modole32.NewProc("CoTaskMemFree")
  228. procRtlGetVersion = modntdll.NewProc("RtlGetVersion")
  229. procWSAStartup = modws2_32.NewProc("WSAStartup")
  230. procWSACleanup = modws2_32.NewProc("WSACleanup")
  231. procWSAIoctl = modws2_32.NewProc("WSAIoctl")
  232. procsocket = modws2_32.NewProc("socket")
  233. procsetsockopt = modws2_32.NewProc("setsockopt")
  234. procgetsockopt = modws2_32.NewProc("getsockopt")
  235. procbind = modws2_32.NewProc("bind")
  236. procconnect = modws2_32.NewProc("connect")
  237. procgetsockname = modws2_32.NewProc("getsockname")
  238. procgetpeername = modws2_32.NewProc("getpeername")
  239. proclisten = modws2_32.NewProc("listen")
  240. procshutdown = modws2_32.NewProc("shutdown")
  241. procclosesocket = modws2_32.NewProc("closesocket")
  242. procAcceptEx = modmswsock.NewProc("AcceptEx")
  243. procGetAcceptExSockaddrs = modmswsock.NewProc("GetAcceptExSockaddrs")
  244. procWSARecv = modws2_32.NewProc("WSARecv")
  245. procWSASend = modws2_32.NewProc("WSASend")
  246. procWSARecvFrom = modws2_32.NewProc("WSARecvFrom")
  247. procWSASendTo = modws2_32.NewProc("WSASendTo")
  248. procgethostbyname = modws2_32.NewProc("gethostbyname")
  249. procgetservbyname = modws2_32.NewProc("getservbyname")
  250. procntohs = modws2_32.NewProc("ntohs")
  251. procgetprotobyname = modws2_32.NewProc("getprotobyname")
  252. procDnsQuery_W = moddnsapi.NewProc("DnsQuery_W")
  253. procDnsRecordListFree = moddnsapi.NewProc("DnsRecordListFree")
  254. procDnsNameCompare_W = moddnsapi.NewProc("DnsNameCompare_W")
  255. procGetAddrInfoW = modws2_32.NewProc("GetAddrInfoW")
  256. procFreeAddrInfoW = modws2_32.NewProc("FreeAddrInfoW")
  257. procGetIfEntry = modiphlpapi.NewProc("GetIfEntry")
  258. procGetAdaptersInfo = modiphlpapi.NewProc("GetAdaptersInfo")
  259. procSetFileCompletionNotificationModes = modkernel32.NewProc("SetFileCompletionNotificationModes")
  260. procWSAEnumProtocolsW = modws2_32.NewProc("WSAEnumProtocolsW")
  261. procGetAdaptersAddresses = modiphlpapi.NewProc("GetAdaptersAddresses")
  262. procGetACP = modkernel32.NewProc("GetACP")
  263. procMultiByteToWideChar = modkernel32.NewProc("MultiByteToWideChar")
  264. procTranslateNameW = modsecur32.NewProc("TranslateNameW")
  265. procGetUserNameExW = modsecur32.NewProc("GetUserNameExW")
  266. procNetUserGetInfo = modnetapi32.NewProc("NetUserGetInfo")
  267. procNetGetJoinInformation = modnetapi32.NewProc("NetGetJoinInformation")
  268. procNetApiBufferFree = modnetapi32.NewProc("NetApiBufferFree")
  269. procLookupAccountSidW = modadvapi32.NewProc("LookupAccountSidW")
  270. procLookupAccountNameW = modadvapi32.NewProc("LookupAccountNameW")
  271. procConvertSidToStringSidW = modadvapi32.NewProc("ConvertSidToStringSidW")
  272. procConvertStringSidToSidW = modadvapi32.NewProc("ConvertStringSidToSidW")
  273. procGetLengthSid = modadvapi32.NewProc("GetLengthSid")
  274. procCopySid = modadvapi32.NewProc("CopySid")
  275. procAllocateAndInitializeSid = modadvapi32.NewProc("AllocateAndInitializeSid")
  276. procCreateWellKnownSid = modadvapi32.NewProc("CreateWellKnownSid")
  277. procIsWellKnownSid = modadvapi32.NewProc("IsWellKnownSid")
  278. procFreeSid = modadvapi32.NewProc("FreeSid")
  279. procEqualSid = modadvapi32.NewProc("EqualSid")
  280. procGetSidIdentifierAuthority = modadvapi32.NewProc("GetSidIdentifierAuthority")
  281. procGetSidSubAuthorityCount = modadvapi32.NewProc("GetSidSubAuthorityCount")
  282. procGetSidSubAuthority = modadvapi32.NewProc("GetSidSubAuthority")
  283. procIsValidSid = modadvapi32.NewProc("IsValidSid")
  284. procCheckTokenMembership = modadvapi32.NewProc("CheckTokenMembership")
  285. procOpenProcessToken = modadvapi32.NewProc("OpenProcessToken")
  286. procOpenThreadToken = modadvapi32.NewProc("OpenThreadToken")
  287. procImpersonateSelf = modadvapi32.NewProc("ImpersonateSelf")
  288. procRevertToSelf = modadvapi32.NewProc("RevertToSelf")
  289. procSetThreadToken = modadvapi32.NewProc("SetThreadToken")
  290. procLookupPrivilegeValueW = modadvapi32.NewProc("LookupPrivilegeValueW")
  291. procAdjustTokenPrivileges = modadvapi32.NewProc("AdjustTokenPrivileges")
  292. procAdjustTokenGroups = modadvapi32.NewProc("AdjustTokenGroups")
  293. procGetTokenInformation = modadvapi32.NewProc("GetTokenInformation")
  294. procSetTokenInformation = modadvapi32.NewProc("SetTokenInformation")
  295. procDuplicateTokenEx = modadvapi32.NewProc("DuplicateTokenEx")
  296. procGetUserProfileDirectoryW = moduserenv.NewProc("GetUserProfileDirectoryW")
  297. procGetSystemDirectoryW = modkernel32.NewProc("GetSystemDirectoryW")
  298. procWTSQueryUserToken = modwtsapi32.NewProc("WTSQueryUserToken")
  299. procWTSEnumerateSessionsW = modwtsapi32.NewProc("WTSEnumerateSessionsW")
  300. procWTSFreeMemory = modwtsapi32.NewProc("WTSFreeMemory")
  301. )
  302. func RegisterEventSource(uncServerName *uint16, sourceName *uint16) (handle Handle, err error) {
  303. r0, _, e1 := syscall.Syscall(procRegisterEventSourceW.Addr(), 2, uintptr(unsafe.Pointer(uncServerName)), uintptr(unsafe.Pointer(sourceName)), 0)
  304. handle = Handle(r0)
  305. if handle == 0 {
  306. if e1 != 0 {
  307. err = errnoErr(e1)
  308. } else {
  309. err = syscall.EINVAL
  310. }
  311. }
  312. return
  313. }
  314. func DeregisterEventSource(handle Handle) (err error) {
  315. r1, _, e1 := syscall.Syscall(procDeregisterEventSource.Addr(), 1, uintptr(handle), 0, 0)
  316. if r1 == 0 {
  317. if e1 != 0 {
  318. err = errnoErr(e1)
  319. } else {
  320. err = syscall.EINVAL
  321. }
  322. }
  323. return
  324. }
  325. func ReportEvent(log Handle, etype uint16, category uint16, eventId uint32, usrSId uintptr, numStrings uint16, dataSize uint32, strings **uint16, rawData *byte) (err error) {
  326. 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)))
  327. if r1 == 0 {
  328. if e1 != 0 {
  329. err = errnoErr(e1)
  330. } else {
  331. err = syscall.EINVAL
  332. }
  333. }
  334. return
  335. }
  336. func OpenSCManager(machineName *uint16, databaseName *uint16, access uint32) (handle Handle, err error) {
  337. r0, _, e1 := syscall.Syscall(procOpenSCManagerW.Addr(), 3, uintptr(unsafe.Pointer(machineName)), uintptr(unsafe.Pointer(databaseName)), uintptr(access))
  338. handle = Handle(r0)
  339. if handle == 0 {
  340. if e1 != 0 {
  341. err = errnoErr(e1)
  342. } else {
  343. err = syscall.EINVAL
  344. }
  345. }
  346. return
  347. }
  348. func CloseServiceHandle(handle Handle) (err error) {
  349. r1, _, e1 := syscall.Syscall(procCloseServiceHandle.Addr(), 1, uintptr(handle), 0, 0)
  350. if r1 == 0 {
  351. if e1 != 0 {
  352. err = errnoErr(e1)
  353. } else {
  354. err = syscall.EINVAL
  355. }
  356. }
  357. return
  358. }
  359. 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) {
  360. 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)
  361. handle = Handle(r0)
  362. if handle == 0 {
  363. if e1 != 0 {
  364. err = errnoErr(e1)
  365. } else {
  366. err = syscall.EINVAL
  367. }
  368. }
  369. return
  370. }
  371. func OpenService(mgr Handle, serviceName *uint16, access uint32) (handle Handle, err error) {
  372. r0, _, e1 := syscall.Syscall(procOpenServiceW.Addr(), 3, uintptr(mgr), uintptr(unsafe.Pointer(serviceName)), uintptr(access))
  373. handle = Handle(r0)
  374. if handle == 0 {
  375. if e1 != 0 {
  376. err = errnoErr(e1)
  377. } else {
  378. err = syscall.EINVAL
  379. }
  380. }
  381. return
  382. }
  383. func DeleteService(service Handle) (err error) {
  384. r1, _, e1 := syscall.Syscall(procDeleteService.Addr(), 1, uintptr(service), 0, 0)
  385. if r1 == 0 {
  386. if e1 != 0 {
  387. err = errnoErr(e1)
  388. } else {
  389. err = syscall.EINVAL
  390. }
  391. }
  392. return
  393. }
  394. func StartService(service Handle, numArgs uint32, argVectors **uint16) (err error) {
  395. r1, _, e1 := syscall.Syscall(procStartServiceW.Addr(), 3, uintptr(service), uintptr(numArgs), uintptr(unsafe.Pointer(argVectors)))
  396. if r1 == 0 {
  397. if e1 != 0 {
  398. err = errnoErr(e1)
  399. } else {
  400. err = syscall.EINVAL
  401. }
  402. }
  403. return
  404. }
  405. func QueryServiceStatus(service Handle, status *SERVICE_STATUS) (err error) {
  406. r1, _, e1 := syscall.Syscall(procQueryServiceStatus.Addr(), 2, uintptr(service), uintptr(unsafe.Pointer(status)), 0)
  407. if r1 == 0 {
  408. if e1 != 0 {
  409. err = errnoErr(e1)
  410. } else {
  411. err = syscall.EINVAL
  412. }
  413. }
  414. return
  415. }
  416. func QueryServiceLockStatus(mgr Handle, lockStatus *QUERY_SERVICE_LOCK_STATUS, bufSize uint32, bytesNeeded *uint32) (err error) {
  417. r1, _, e1 := syscall.Syscall6(procQueryServiceLockStatusW.Addr(), 4, uintptr(mgr), uintptr(unsafe.Pointer(lockStatus)), uintptr(bufSize), uintptr(unsafe.Pointer(bytesNeeded)), 0, 0)
  418. if r1 == 0 {
  419. if e1 != 0 {
  420. err = errnoErr(e1)
  421. } else {
  422. err = syscall.EINVAL
  423. }
  424. }
  425. return
  426. }
  427. func ControlService(service Handle, control uint32, status *SERVICE_STATUS) (err error) {
  428. r1, _, e1 := syscall.Syscall(procControlService.Addr(), 3, uintptr(service), uintptr(control), uintptr(unsafe.Pointer(status)))
  429. if r1 == 0 {
  430. if e1 != 0 {
  431. err = errnoErr(e1)
  432. } else {
  433. err = syscall.EINVAL
  434. }
  435. }
  436. return
  437. }
  438. func StartServiceCtrlDispatcher(serviceTable *SERVICE_TABLE_ENTRY) (err error) {
  439. r1, _, e1 := syscall.Syscall(procStartServiceCtrlDispatcherW.Addr(), 1, uintptr(unsafe.Pointer(serviceTable)), 0, 0)
  440. if r1 == 0 {
  441. if e1 != 0 {
  442. err = errnoErr(e1)
  443. } else {
  444. err = syscall.EINVAL
  445. }
  446. }
  447. return
  448. }
  449. func SetServiceStatus(service Handle, serviceStatus *SERVICE_STATUS) (err error) {
  450. r1, _, e1 := syscall.Syscall(procSetServiceStatus.Addr(), 2, uintptr(service), uintptr(unsafe.Pointer(serviceStatus)), 0)
  451. if r1 == 0 {
  452. if e1 != 0 {
  453. err = errnoErr(e1)
  454. } else {
  455. err = syscall.EINVAL
  456. }
  457. }
  458. return
  459. }
  460. 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) {
  461. 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)
  462. if r1 == 0 {
  463. if e1 != 0 {
  464. err = errnoErr(e1)
  465. } else {
  466. err = syscall.EINVAL
  467. }
  468. }
  469. return
  470. }
  471. func QueryServiceConfig(service Handle, serviceConfig *QUERY_SERVICE_CONFIG, bufSize uint32, bytesNeeded *uint32) (err error) {
  472. r1, _, e1 := syscall.Syscall6(procQueryServiceConfigW.Addr(), 4, uintptr(service), uintptr(unsafe.Pointer(serviceConfig)), uintptr(bufSize), uintptr(unsafe.Pointer(bytesNeeded)), 0, 0)
  473. if r1 == 0 {
  474. if e1 != 0 {
  475. err = errnoErr(e1)
  476. } else {
  477. err = syscall.EINVAL
  478. }
  479. }
  480. return
  481. }
  482. func ChangeServiceConfig2(service Handle, infoLevel uint32, info *byte) (err error) {
  483. r1, _, e1 := syscall.Syscall(procChangeServiceConfig2W.Addr(), 3, uintptr(service), uintptr(infoLevel), uintptr(unsafe.Pointer(info)))
  484. if r1 == 0 {
  485. if e1 != 0 {
  486. err = errnoErr(e1)
  487. } else {
  488. err = syscall.EINVAL
  489. }
  490. }
  491. return
  492. }
  493. func QueryServiceConfig2(service Handle, infoLevel uint32, buff *byte, buffSize uint32, bytesNeeded *uint32) (err error) {
  494. r1, _, e1 := syscall.Syscall6(procQueryServiceConfig2W.Addr(), 5, uintptr(service), uintptr(infoLevel), uintptr(unsafe.Pointer(buff)), uintptr(buffSize), uintptr(unsafe.Pointer(bytesNeeded)), 0)
  495. if r1 == 0 {
  496. if e1 != 0 {
  497. err = errnoErr(e1)
  498. } else {
  499. err = syscall.EINVAL
  500. }
  501. }
  502. return
  503. }
  504. func EnumServicesStatusEx(mgr Handle, infoLevel uint32, serviceType uint32, serviceState uint32, services *byte, bufSize uint32, bytesNeeded *uint32, servicesReturned *uint32, resumeHandle *uint32, groupName *uint16) (err error) {
  505. 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)
  506. if r1 == 0 {
  507. if e1 != 0 {
  508. err = errnoErr(e1)
  509. } else {
  510. err = syscall.EINVAL
  511. }
  512. }
  513. return
  514. }
  515. func QueryServiceStatusEx(service Handle, infoLevel uint32, buff *byte, buffSize uint32, bytesNeeded *uint32) (err error) {
  516. r1, _, e1 := syscall.Syscall6(procQueryServiceStatusEx.Addr(), 5, uintptr(service), uintptr(infoLevel), uintptr(unsafe.Pointer(buff)), uintptr(buffSize), uintptr(unsafe.Pointer(bytesNeeded)), 0)
  517. if r1 == 0 {
  518. if e1 != 0 {
  519. err = errnoErr(e1)
  520. } else {
  521. err = syscall.EINVAL
  522. }
  523. }
  524. return
  525. }
  526. func NotifyServiceStatusChange(service Handle, notifyMask uint32, notifier *SERVICE_NOTIFY) (ret error) {
  527. r0, _, _ := syscall.Syscall(procNotifyServiceStatusChangeW.Addr(), 3, uintptr(service), uintptr(notifyMask), uintptr(unsafe.Pointer(notifier)))
  528. if r0 != 0 {
  529. ret = syscall.Errno(r0)
  530. }
  531. return
  532. }
  533. func GetLastError() (lasterr error) {
  534. r0, _, _ := syscall.Syscall(procGetLastError.Addr(), 0, 0, 0, 0)
  535. if r0 != 0 {
  536. lasterr = syscall.Errno(r0)
  537. }
  538. return
  539. }
  540. func LoadLibrary(libname string) (handle Handle, err error) {
  541. var _p0 *uint16
  542. _p0, err = syscall.UTF16PtrFromString(libname)
  543. if err != nil {
  544. return
  545. }
  546. return _LoadLibrary(_p0)
  547. }
  548. func _LoadLibrary(libname *uint16) (handle Handle, err error) {
  549. r0, _, e1 := syscall.Syscall(procLoadLibraryW.Addr(), 1, uintptr(unsafe.Pointer(libname)), 0, 0)
  550. handle = Handle(r0)
  551. if handle == 0 {
  552. if e1 != 0 {
  553. err = errnoErr(e1)
  554. } else {
  555. err = syscall.EINVAL
  556. }
  557. }
  558. return
  559. }
  560. func LoadLibraryEx(libname string, zero Handle, flags uintptr) (handle Handle, err error) {
  561. var _p0 *uint16
  562. _p0, err = syscall.UTF16PtrFromString(libname)
  563. if err != nil {
  564. return
  565. }
  566. return _LoadLibraryEx(_p0, zero, flags)
  567. }
  568. func _LoadLibraryEx(libname *uint16, zero Handle, flags uintptr) (handle Handle, err error) {
  569. r0, _, e1 := syscall.Syscall(procLoadLibraryExW.Addr(), 3, uintptr(unsafe.Pointer(libname)), uintptr(zero), uintptr(flags))
  570. handle = Handle(r0)
  571. if handle == 0 {
  572. if e1 != 0 {
  573. err = errnoErr(e1)
  574. } else {
  575. err = syscall.EINVAL
  576. }
  577. }
  578. return
  579. }
  580. func FreeLibrary(handle Handle) (err error) {
  581. r1, _, e1 := syscall.Syscall(procFreeLibrary.Addr(), 1, uintptr(handle), 0, 0)
  582. if r1 == 0 {
  583. if e1 != 0 {
  584. err = errnoErr(e1)
  585. } else {
  586. err = syscall.EINVAL
  587. }
  588. }
  589. return
  590. }
  591. func GetProcAddress(module Handle, procname string) (proc uintptr, err error) {
  592. var _p0 *byte
  593. _p0, err = syscall.BytePtrFromString(procname)
  594. if err != nil {
  595. return
  596. }
  597. return _GetProcAddress(module, _p0)
  598. }
  599. func _GetProcAddress(module Handle, procname *byte) (proc uintptr, err error) {
  600. r0, _, e1 := syscall.Syscall(procGetProcAddress.Addr(), 2, uintptr(module), uintptr(unsafe.Pointer(procname)), 0)
  601. proc = uintptr(r0)
  602. if proc == 0 {
  603. if e1 != 0 {
  604. err = errnoErr(e1)
  605. } else {
  606. err = syscall.EINVAL
  607. }
  608. }
  609. return
  610. }
  611. func GetVersion() (ver uint32, err error) {
  612. r0, _, e1 := syscall.Syscall(procGetVersion.Addr(), 0, 0, 0, 0)
  613. ver = uint32(r0)
  614. if ver == 0 {
  615. if e1 != 0 {
  616. err = errnoErr(e1)
  617. } else {
  618. err = syscall.EINVAL
  619. }
  620. }
  621. return
  622. }
  623. func FormatMessage(flags uint32, msgsrc uintptr, msgid uint32, langid uint32, buf []uint16, args *byte) (n uint32, err error) {
  624. var _p0 *uint16
  625. if len(buf) > 0 {
  626. _p0 = &buf[0]
  627. }
  628. 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)
  629. n = uint32(r0)
  630. if n == 0 {
  631. if e1 != 0 {
  632. err = errnoErr(e1)
  633. } else {
  634. err = syscall.EINVAL
  635. }
  636. }
  637. return
  638. }
  639. func ExitProcess(exitcode uint32) {
  640. syscall.Syscall(procExitProcess.Addr(), 1, uintptr(exitcode), 0, 0)
  641. return
  642. }
  643. func IsWow64Process(handle Handle, isWow64 *bool) (err error) {
  644. r1, _, e1 := syscall.Syscall(procIsWow64Process.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(isWow64)), 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 CreateFile(name *uint16, access uint32, mode uint32, sa *SecurityAttributes, createmode uint32, attrs uint32, templatefile Handle) (handle Handle, err error) {
  655. 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)
  656. handle = Handle(r0)
  657. if handle == InvalidHandle {
  658. if e1 != 0 {
  659. err = errnoErr(e1)
  660. } else {
  661. err = syscall.EINVAL
  662. }
  663. }
  664. return
  665. }
  666. func ReadFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) (err error) {
  667. var _p0 *byte
  668. if len(buf) > 0 {
  669. _p0 = &buf[0]
  670. }
  671. 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)
  672. if r1 == 0 {
  673. if e1 != 0 {
  674. err = errnoErr(e1)
  675. } else {
  676. err = syscall.EINVAL
  677. }
  678. }
  679. return
  680. }
  681. func WriteFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) (err error) {
  682. var _p0 *byte
  683. if len(buf) > 0 {
  684. _p0 = &buf[0]
  685. }
  686. 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)
  687. if r1 == 0 {
  688. if e1 != 0 {
  689. err = errnoErr(e1)
  690. } else {
  691. err = syscall.EINVAL
  692. }
  693. }
  694. return
  695. }
  696. func GetOverlappedResult(handle Handle, overlapped *Overlapped, done *uint32, wait bool) (err error) {
  697. var _p0 uint32
  698. if wait {
  699. _p0 = 1
  700. } else {
  701. _p0 = 0
  702. }
  703. r1, _, e1 := syscall.Syscall6(procGetOverlappedResult.Addr(), 4, uintptr(handle), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(done)), uintptr(_p0), 0, 0)
  704. if r1 == 0 {
  705. if e1 != 0 {
  706. err = errnoErr(e1)
  707. } else {
  708. err = syscall.EINVAL
  709. }
  710. }
  711. return
  712. }
  713. func SetFilePointer(handle Handle, lowoffset int32, highoffsetptr *int32, whence uint32) (newlowoffset uint32, err error) {
  714. r0, _, e1 := syscall.Syscall6(procSetFilePointer.Addr(), 4, uintptr(handle), uintptr(lowoffset), uintptr(unsafe.Pointer(highoffsetptr)), uintptr(whence), 0, 0)
  715. newlowoffset = uint32(r0)
  716. if newlowoffset == 0xffffffff {
  717. if e1 != 0 {
  718. err = errnoErr(e1)
  719. } else {
  720. err = syscall.EINVAL
  721. }
  722. }
  723. return
  724. }
  725. func CloseHandle(handle Handle) (err error) {
  726. r1, _, e1 := syscall.Syscall(procCloseHandle.Addr(), 1, uintptr(handle), 0, 0)
  727. if r1 == 0 {
  728. if e1 != 0 {
  729. err = errnoErr(e1)
  730. } else {
  731. err = syscall.EINVAL
  732. }
  733. }
  734. return
  735. }
  736. func GetStdHandle(stdhandle uint32) (handle Handle, err error) {
  737. r0, _, e1 := syscall.Syscall(procGetStdHandle.Addr(), 1, uintptr(stdhandle), 0, 0)
  738. handle = Handle(r0)
  739. if handle == InvalidHandle {
  740. if e1 != 0 {
  741. err = errnoErr(e1)
  742. } else {
  743. err = syscall.EINVAL
  744. }
  745. }
  746. return
  747. }
  748. func SetStdHandle(stdhandle uint32, handle Handle) (err error) {
  749. r1, _, e1 := syscall.Syscall(procSetStdHandle.Addr(), 2, uintptr(stdhandle), uintptr(handle), 0)
  750. if r1 == 0 {
  751. if e1 != 0 {
  752. err = errnoErr(e1)
  753. } else {
  754. err = syscall.EINVAL
  755. }
  756. }
  757. return
  758. }
  759. func findFirstFile1(name *uint16, data *win32finddata1) (handle Handle, err error) {
  760. r0, _, e1 := syscall.Syscall(procFindFirstFileW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(data)), 0)
  761. handle = Handle(r0)
  762. if handle == InvalidHandle {
  763. if e1 != 0 {
  764. err = errnoErr(e1)
  765. } else {
  766. err = syscall.EINVAL
  767. }
  768. }
  769. return
  770. }
  771. func findNextFile1(handle Handle, data *win32finddata1) (err error) {
  772. r1, _, e1 := syscall.Syscall(procFindNextFileW.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(data)), 0)
  773. if r1 == 0 {
  774. if e1 != 0 {
  775. err = errnoErr(e1)
  776. } else {
  777. err = syscall.EINVAL
  778. }
  779. }
  780. return
  781. }
  782. func FindClose(handle Handle) (err error) {
  783. r1, _, e1 := syscall.Syscall(procFindClose.Addr(), 1, uintptr(handle), 0, 0)
  784. if r1 == 0 {
  785. if e1 != 0 {
  786. err = errnoErr(e1)
  787. } else {
  788. err = syscall.EINVAL
  789. }
  790. }
  791. return
  792. }
  793. func GetFileInformationByHandle(handle Handle, data *ByHandleFileInformation) (err error) {
  794. r1, _, e1 := syscall.Syscall(procGetFileInformationByHandle.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(data)), 0)
  795. if r1 == 0 {
  796. if e1 != 0 {
  797. err = errnoErr(e1)
  798. } else {
  799. err = syscall.EINVAL
  800. }
  801. }
  802. return
  803. }
  804. func GetFileInformationByHandleEx(handle Handle, class uint32, outBuffer *byte, outBufferLen uint32) (err error) {
  805. r1, _, e1 := syscall.Syscall6(procGetFileInformationByHandleEx.Addr(), 4, uintptr(handle), uintptr(class), uintptr(unsafe.Pointer(outBuffer)), uintptr(outBufferLen), 0, 0)
  806. if r1 == 0 {
  807. if e1 != 0 {
  808. err = errnoErr(e1)
  809. } else {
  810. err = syscall.EINVAL
  811. }
  812. }
  813. return
  814. }
  815. func GetCurrentDirectory(buflen uint32, buf *uint16) (n uint32, err error) {
  816. r0, _, e1 := syscall.Syscall(procGetCurrentDirectoryW.Addr(), 2, uintptr(buflen), uintptr(unsafe.Pointer(buf)), 0)
  817. n = uint32(r0)
  818. if n == 0 {
  819. if e1 != 0 {
  820. err = errnoErr(e1)
  821. } else {
  822. err = syscall.EINVAL
  823. }
  824. }
  825. return
  826. }
  827. func SetCurrentDirectory(path *uint16) (err error) {
  828. r1, _, e1 := syscall.Syscall(procSetCurrentDirectoryW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0)
  829. if r1 == 0 {
  830. if e1 != 0 {
  831. err = errnoErr(e1)
  832. } else {
  833. err = syscall.EINVAL
  834. }
  835. }
  836. return
  837. }
  838. func CreateDirectory(path *uint16, sa *SecurityAttributes) (err error) {
  839. r1, _, e1 := syscall.Syscall(procCreateDirectoryW.Addr(), 2, uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(sa)), 0)
  840. if r1 == 0 {
  841. if e1 != 0 {
  842. err = errnoErr(e1)
  843. } else {
  844. err = syscall.EINVAL
  845. }
  846. }
  847. return
  848. }
  849. func RemoveDirectory(path *uint16) (err error) {
  850. r1, _, e1 := syscall.Syscall(procRemoveDirectoryW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0)
  851. if r1 == 0 {
  852. if e1 != 0 {
  853. err = errnoErr(e1)
  854. } else {
  855. err = syscall.EINVAL
  856. }
  857. }
  858. return
  859. }
  860. func DeleteFile(path *uint16) (err error) {
  861. r1, _, e1 := syscall.Syscall(procDeleteFileW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0)
  862. if r1 == 0 {
  863. if e1 != 0 {
  864. err = errnoErr(e1)
  865. } else {
  866. err = syscall.EINVAL
  867. }
  868. }
  869. return
  870. }
  871. func MoveFile(from *uint16, to *uint16) (err error) {
  872. r1, _, e1 := syscall.Syscall(procMoveFileW.Addr(), 2, uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(to)), 0)
  873. if r1 == 0 {
  874. if e1 != 0 {
  875. err = errnoErr(e1)
  876. } else {
  877. err = syscall.EINVAL
  878. }
  879. }
  880. return
  881. }
  882. func MoveFileEx(from *uint16, to *uint16, flags uint32) (err error) {
  883. r1, _, e1 := syscall.Syscall(procMoveFileExW.Addr(), 3, uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(to)), uintptr(flags))
  884. if r1 == 0 {
  885. if e1 != 0 {
  886. err = errnoErr(e1)
  887. } else {
  888. err = syscall.EINVAL
  889. }
  890. }
  891. return
  892. }
  893. func GetComputerName(buf *uint16, n *uint32) (err error) {
  894. r1, _, e1 := syscall.Syscall(procGetComputerNameW.Addr(), 2, uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(n)), 0)
  895. if r1 == 0 {
  896. if e1 != 0 {
  897. err = errnoErr(e1)
  898. } else {
  899. err = syscall.EINVAL
  900. }
  901. }
  902. return
  903. }
  904. func GetComputerNameEx(nametype uint32, buf *uint16, n *uint32) (err error) {
  905. r1, _, e1 := syscall.Syscall(procGetComputerNameExW.Addr(), 3, uintptr(nametype), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(n)))
  906. if r1 == 0 {
  907. if e1 != 0 {
  908. err = errnoErr(e1)
  909. } else {
  910. err = syscall.EINVAL
  911. }
  912. }
  913. return
  914. }
  915. func SetEndOfFile(handle Handle) (err error) {
  916. r1, _, e1 := syscall.Syscall(procSetEndOfFile.Addr(), 1, uintptr(handle), 0, 0)
  917. if r1 == 0 {
  918. if e1 != 0 {
  919. err = errnoErr(e1)
  920. } else {
  921. err = syscall.EINVAL
  922. }
  923. }
  924. return
  925. }
  926. func GetSystemTimeAsFileTime(time *Filetime) {
  927. syscall.Syscall(procGetSystemTimeAsFileTime.Addr(), 1, uintptr(unsafe.Pointer(time)), 0, 0)
  928. return
  929. }
  930. func GetSystemTimePreciseAsFileTime(time *Filetime) {
  931. syscall.Syscall(procGetSystemTimePreciseAsFileTime.Addr(), 1, uintptr(unsafe.Pointer(time)), 0, 0)
  932. return
  933. }
  934. func GetTimeZoneInformation(tzi *Timezoneinformation) (rc uint32, err error) {
  935. r0, _, e1 := syscall.Syscall(procGetTimeZoneInformation.Addr(), 1, uintptr(unsafe.Pointer(tzi)), 0, 0)
  936. rc = uint32(r0)
  937. if rc == 0xffffffff {
  938. if e1 != 0 {
  939. err = errnoErr(e1)
  940. } else {
  941. err = syscall.EINVAL
  942. }
  943. }
  944. return
  945. }
  946. func CreateIoCompletionPort(filehandle Handle, cphandle Handle, key uint32, threadcnt uint32) (handle Handle, err error) {
  947. r0, _, e1 := syscall.Syscall6(procCreateIoCompletionPort.Addr(), 4, uintptr(filehandle), uintptr(cphandle), uintptr(key), uintptr(threadcnt), 0, 0)
  948. handle = Handle(r0)
  949. if handle == 0 {
  950. if e1 != 0 {
  951. err = errnoErr(e1)
  952. } else {
  953. err = syscall.EINVAL
  954. }
  955. }
  956. return
  957. }
  958. func GetQueuedCompletionStatus(cphandle Handle, qty *uint32, key *uint32, overlapped **Overlapped, timeout uint32) (err error) {
  959. r1, _, e1 := syscall.Syscall6(procGetQueuedCompletionStatus.Addr(), 5, uintptr(cphandle), uintptr(unsafe.Pointer(qty)), uintptr(unsafe.Pointer(key)), uintptr(unsafe.Pointer(overlapped)), uintptr(timeout), 0)
  960. if r1 == 0 {
  961. if e1 != 0 {
  962. err = errnoErr(e1)
  963. } else {
  964. err = syscall.EINVAL
  965. }
  966. }
  967. return
  968. }
  969. func PostQueuedCompletionStatus(cphandle Handle, qty uint32, key uint32, overlapped *Overlapped) (err error) {
  970. r1, _, e1 := syscall.Syscall6(procPostQueuedCompletionStatus.Addr(), 4, uintptr(cphandle), uintptr(qty), uintptr(key), uintptr(unsafe.Pointer(overlapped)), 0, 0)
  971. if r1 == 0 {
  972. if e1 != 0 {
  973. err = errnoErr(e1)
  974. } else {
  975. err = syscall.EINVAL
  976. }
  977. }
  978. return
  979. }
  980. func CancelIo(s Handle) (err error) {
  981. r1, _, e1 := syscall.Syscall(procCancelIo.Addr(), 1, uintptr(s), 0, 0)
  982. if r1 == 0 {
  983. if e1 != 0 {
  984. err = errnoErr(e1)
  985. } else {
  986. err = syscall.EINVAL
  987. }
  988. }
  989. return
  990. }
  991. func CancelIoEx(s Handle, o *Overlapped) (err error) {
  992. r1, _, e1 := syscall.Syscall(procCancelIoEx.Addr(), 2, uintptr(s), uintptr(unsafe.Pointer(o)), 0)
  993. if r1 == 0 {
  994. if e1 != 0 {
  995. err = errnoErr(e1)
  996. } else {
  997. err = syscall.EINVAL
  998. }
  999. }
  1000. return
  1001. }
  1002. func CreateProcess(appName *uint16, commandLine *uint16, procSecurity *SecurityAttributes, threadSecurity *SecurityAttributes, inheritHandles bool, creationFlags uint32, env *uint16, currentDir *uint16, startupInfo *StartupInfo, outProcInfo *ProcessInformation) (err error) {
  1003. var _p0 uint32
  1004. if inheritHandles {
  1005. _p0 = 1
  1006. } else {
  1007. _p0 = 0
  1008. }
  1009. 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)
  1010. if r1 == 0 {
  1011. if e1 != 0 {
  1012. err = errnoErr(e1)
  1013. } else {
  1014. err = syscall.EINVAL
  1015. }
  1016. }
  1017. return
  1018. }
  1019. func OpenProcess(desiredAccess uint32, inheritHandle bool, processId uint32) (handle Handle, err error) {
  1020. var _p0 uint32
  1021. if inheritHandle {
  1022. _p0 = 1
  1023. } else {
  1024. _p0 = 0
  1025. }
  1026. r0, _, e1 := syscall.Syscall(procOpenProcess.Addr(), 3, uintptr(desiredAccess), uintptr(_p0), uintptr(processId))
  1027. handle = Handle(r0)
  1028. if handle == 0 {
  1029. if e1 != 0 {
  1030. err = errnoErr(e1)
  1031. } else {
  1032. err = syscall.EINVAL
  1033. }
  1034. }
  1035. return
  1036. }
  1037. func ShellExecute(hwnd Handle, verb *uint16, file *uint16, args *uint16, cwd *uint16, showCmd int32) (err error) {
  1038. r1, _, e1 := syscall.Syscall6(procShellExecuteW.Addr(), 6, uintptr(hwnd), uintptr(unsafe.Pointer(verb)), uintptr(unsafe.Pointer(file)), uintptr(unsafe.Pointer(args)), uintptr(unsafe.Pointer(cwd)), uintptr(showCmd))
  1039. if r1 == 0 {
  1040. if e1 != 0 {
  1041. err = errnoErr(e1)
  1042. } else {
  1043. err = syscall.EINVAL
  1044. }
  1045. }
  1046. return
  1047. }
  1048. func shGetKnownFolderPath(id *KNOWNFOLDERID, flags uint32, token Token, path **uint16) (ret error) {
  1049. r0, _, _ := syscall.Syscall6(procSHGetKnownFolderPath.Addr(), 4, uintptr(unsafe.Pointer(id)), uintptr(flags), uintptr(token), uintptr(unsafe.Pointer(path)), 0, 0)
  1050. if r0 != 0 {
  1051. ret = syscall.Errno(r0)
  1052. }
  1053. return
  1054. }
  1055. func TerminateProcess(handle Handle, exitcode uint32) (err error) {
  1056. r1, _, e1 := syscall.Syscall(procTerminateProcess.Addr(), 2, uintptr(handle), uintptr(exitcode), 0)
  1057. if r1 == 0 {
  1058. if e1 != 0 {
  1059. err = errnoErr(e1)
  1060. } else {
  1061. err = syscall.EINVAL
  1062. }
  1063. }
  1064. return
  1065. }
  1066. func GetExitCodeProcess(handle Handle, exitcode *uint32) (err error) {
  1067. r1, _, e1 := syscall.Syscall(procGetExitCodeProcess.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(exitcode)), 0)
  1068. if r1 == 0 {
  1069. if e1 != 0 {
  1070. err = errnoErr(e1)
  1071. } else {
  1072. err = syscall.EINVAL
  1073. }
  1074. }
  1075. return
  1076. }
  1077. func GetStartupInfo(startupInfo *StartupInfo) (err error) {
  1078. r1, _, e1 := syscall.Syscall(procGetStartupInfoW.Addr(), 1, uintptr(unsafe.Pointer(startupInfo)), 0, 0)
  1079. if r1 == 0 {
  1080. if e1 != 0 {
  1081. err = errnoErr(e1)
  1082. } else {
  1083. err = syscall.EINVAL
  1084. }
  1085. }
  1086. return
  1087. }
  1088. func GetCurrentProcess() (pseudoHandle Handle, err error) {
  1089. r0, _, e1 := syscall.Syscall(procGetCurrentProcess.Addr(), 0, 0, 0, 0)
  1090. pseudoHandle = Handle(r0)
  1091. if pseudoHandle == 0 {
  1092. if e1 != 0 {
  1093. err = errnoErr(e1)
  1094. } else {
  1095. err = syscall.EINVAL
  1096. }
  1097. }
  1098. return
  1099. }
  1100. func GetCurrentThread() (pseudoHandle Handle, err error) {
  1101. r0, _, e1 := syscall.Syscall(procGetCurrentThread.Addr(), 0, 0, 0, 0)
  1102. pseudoHandle = Handle(r0)
  1103. if pseudoHandle == 0 {
  1104. if e1 != 0 {
  1105. err = errnoErr(e1)
  1106. } else {
  1107. err = syscall.EINVAL
  1108. }
  1109. }
  1110. return
  1111. }
  1112. func GetProcessTimes(handle Handle, creationTime *Filetime, exitTime *Filetime, kernelTime *Filetime, userTime *Filetime) (err error) {
  1113. 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)
  1114. if r1 == 0 {
  1115. if e1 != 0 {
  1116. err = errnoErr(e1)
  1117. } else {
  1118. err = syscall.EINVAL
  1119. }
  1120. }
  1121. return
  1122. }
  1123. func DuplicateHandle(hSourceProcessHandle Handle, hSourceHandle Handle, hTargetProcessHandle Handle, lpTargetHandle *Handle, dwDesiredAccess uint32, bInheritHandle bool, dwOptions uint32) (err error) {
  1124. var _p0 uint32
  1125. if bInheritHandle {
  1126. _p0 = 1
  1127. } else {
  1128. _p0 = 0
  1129. }
  1130. 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)
  1131. if r1 == 0 {
  1132. if e1 != 0 {
  1133. err = errnoErr(e1)
  1134. } else {
  1135. err = syscall.EINVAL
  1136. }
  1137. }
  1138. return
  1139. }
  1140. func WaitForSingleObject(handle Handle, waitMilliseconds uint32) (event uint32, err error) {
  1141. r0, _, e1 := syscall.Syscall(procWaitForSingleObject.Addr(), 2, uintptr(handle), uintptr(waitMilliseconds), 0)
  1142. event = uint32(r0)
  1143. if event == 0xffffffff {
  1144. if e1 != 0 {
  1145. err = errnoErr(e1)
  1146. } else {
  1147. err = syscall.EINVAL
  1148. }
  1149. }
  1150. return
  1151. }
  1152. func waitForMultipleObjects(count uint32, handles uintptr, waitAll bool, waitMilliseconds uint32) (event uint32, err error) {
  1153. var _p0 uint32
  1154. if waitAll {
  1155. _p0 = 1
  1156. } else {
  1157. _p0 = 0
  1158. }
  1159. r0, _, e1 := syscall.Syscall6(procWaitForMultipleObjects.Addr(), 4, uintptr(count), uintptr(handles), uintptr(_p0), uintptr(waitMilliseconds), 0, 0)
  1160. event = uint32(r0)
  1161. if event == 0xffffffff {
  1162. if e1 != 0 {
  1163. err = errnoErr(e1)
  1164. } else {
  1165. err = syscall.EINVAL
  1166. }
  1167. }
  1168. return
  1169. }
  1170. func GetTempPath(buflen uint32, buf *uint16) (n uint32, err error) {
  1171. r0, _, e1 := syscall.Syscall(procGetTempPathW.Addr(), 2, uintptr(buflen), uintptr(unsafe.Pointer(buf)), 0)
  1172. n = uint32(r0)
  1173. if n == 0 {
  1174. if e1 != 0 {
  1175. err = errnoErr(e1)
  1176. } else {
  1177. err = syscall.EINVAL
  1178. }
  1179. }
  1180. return
  1181. }
  1182. func CreatePipe(readhandle *Handle, writehandle *Handle, sa *SecurityAttributes, size uint32) (err error) {
  1183. r1, _, e1 := syscall.Syscall6(procCreatePipe.Addr(), 4, uintptr(unsafe.Pointer(readhandle)), uintptr(unsafe.Pointer(writehandle)), uintptr(unsafe.Pointer(sa)), uintptr(size), 0, 0)
  1184. if r1 == 0 {
  1185. if e1 != 0 {
  1186. err = errnoErr(e1)
  1187. } else {
  1188. err = syscall.EINVAL
  1189. }
  1190. }
  1191. return
  1192. }
  1193. func GetFileType(filehandle Handle) (n uint32, err error) {
  1194. r0, _, e1 := syscall.Syscall(procGetFileType.Addr(), 1, uintptr(filehandle), 0, 0)
  1195. n = uint32(r0)
  1196. if n == 0 {
  1197. if e1 != 0 {
  1198. err = errnoErr(e1)
  1199. } else {
  1200. err = syscall.EINVAL
  1201. }
  1202. }
  1203. return
  1204. }
  1205. func CryptAcquireContext(provhandle *Handle, container *uint16, provider *uint16, provtype uint32, flags uint32) (err error) {
  1206. r1, _, e1 := syscall.Syscall6(procCryptAcquireContextW.Addr(), 5, uintptr(unsafe.Pointer(provhandle)), uintptr(unsafe.Pointer(container)), uintptr(unsafe.Pointer(provider)), uintptr(provtype), uintptr(flags), 0)
  1207. if r1 == 0 {
  1208. if e1 != 0 {
  1209. err = errnoErr(e1)
  1210. } else {
  1211. err = syscall.EINVAL
  1212. }
  1213. }
  1214. return
  1215. }
  1216. func CryptReleaseContext(provhandle Handle, flags uint32) (err error) {
  1217. r1, _, e1 := syscall.Syscall(procCryptReleaseContext.Addr(), 2, uintptr(provhandle), uintptr(flags), 0)
  1218. if r1 == 0 {
  1219. if e1 != 0 {
  1220. err = errnoErr(e1)
  1221. } else {
  1222. err = syscall.EINVAL
  1223. }
  1224. }
  1225. return
  1226. }
  1227. func CryptGenRandom(provhandle Handle, buflen uint32, buf *byte) (err error) {
  1228. r1, _, e1 := syscall.Syscall(procCryptGenRandom.Addr(), 3, uintptr(provhandle), uintptr(buflen), uintptr(unsafe.Pointer(buf)))
  1229. if r1 == 0 {
  1230. if e1 != 0 {
  1231. err = errnoErr(e1)
  1232. } else {
  1233. err = syscall.EINVAL
  1234. }
  1235. }
  1236. return
  1237. }
  1238. func GetEnvironmentStrings() (envs *uint16, err error) {
  1239. r0, _, e1 := syscall.Syscall(procGetEnvironmentStringsW.Addr(), 0, 0, 0, 0)
  1240. envs = (*uint16)(unsafe.Pointer(r0))
  1241. if envs == nil {
  1242. if e1 != 0 {
  1243. err = errnoErr(e1)
  1244. } else {
  1245. err = syscall.EINVAL
  1246. }
  1247. }
  1248. return
  1249. }
  1250. func FreeEnvironmentStrings(envs *uint16) (err error) {
  1251. r1, _, e1 := syscall.Syscall(procFreeEnvironmentStringsW.Addr(), 1, uintptr(unsafe.Pointer(envs)), 0, 0)
  1252. if r1 == 0 {
  1253. if e1 != 0 {
  1254. err = errnoErr(e1)
  1255. } else {
  1256. err = syscall.EINVAL
  1257. }
  1258. }
  1259. return
  1260. }
  1261. func GetEnvironmentVariable(name *uint16, buffer *uint16, size uint32) (n uint32, err error) {
  1262. r0, _, e1 := syscall.Syscall(procGetEnvironmentVariableW.Addr(), 3, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(buffer)), uintptr(size))
  1263. n = uint32(r0)
  1264. if n == 0 {
  1265. if e1 != 0 {
  1266. err = errnoErr(e1)
  1267. } else {
  1268. err = syscall.EINVAL
  1269. }
  1270. }
  1271. return
  1272. }
  1273. func SetEnvironmentVariable(name *uint16, value *uint16) (err error) {
  1274. r1, _, e1 := syscall.Syscall(procSetEnvironmentVariableW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(value)), 0)
  1275. if r1 == 0 {
  1276. if e1 != 0 {
  1277. err = errnoErr(e1)
  1278. } else {
  1279. err = syscall.EINVAL
  1280. }
  1281. }
  1282. return
  1283. }
  1284. func CreateEnvironmentBlock(block **uint16, token Token, inheritExisting bool) (err error) {
  1285. var _p0 uint32
  1286. if inheritExisting {
  1287. _p0 = 1
  1288. } else {
  1289. _p0 = 0
  1290. }
  1291. r1, _, e1 := syscall.Syscall(procCreateEnvironmentBlock.Addr(), 3, uintptr(unsafe.Pointer(block)), uintptr(token), uintptr(_p0))
  1292. if r1 == 0 {
  1293. if e1 != 0 {
  1294. err = errnoErr(e1)
  1295. } else {
  1296. err = syscall.EINVAL
  1297. }
  1298. }
  1299. return
  1300. }
  1301. func DestroyEnvironmentBlock(block *uint16) (err error) {
  1302. r1, _, e1 := syscall.Syscall(procDestroyEnvironmentBlock.Addr(), 1, uintptr(unsafe.Pointer(block)), 0, 0)
  1303. if r1 == 0 {
  1304. if e1 != 0 {
  1305. err = errnoErr(e1)
  1306. } else {
  1307. err = syscall.EINVAL
  1308. }
  1309. }
  1310. return
  1311. }
  1312. func getTickCount64() (ms uint64) {
  1313. r0, _, _ := syscall.Syscall(procGetTickCount64.Addr(), 0, 0, 0, 0)
  1314. ms = uint64(r0)
  1315. return
  1316. }
  1317. func SetFileTime(handle Handle, ctime *Filetime, atime *Filetime, wtime *Filetime) (err error) {
  1318. r1, _, e1 := syscall.Syscall6(procSetFileTime.Addr(), 4, uintptr(handle), uintptr(unsafe.Pointer(ctime)), uintptr(unsafe.Pointer(atime)), uintptr(unsafe.Pointer(wtime)), 0, 0)
  1319. if r1 == 0 {
  1320. if e1 != 0 {
  1321. err = errnoErr(e1)
  1322. } else {
  1323. err = syscall.EINVAL
  1324. }
  1325. }
  1326. return
  1327. }
  1328. func GetFileAttributes(name *uint16) (attrs uint32, err error) {
  1329. r0, _, e1 := syscall.Syscall(procGetFileAttributesW.Addr(), 1, uintptr(unsafe.Pointer(name)), 0, 0)
  1330. attrs = uint32(r0)
  1331. if attrs == INVALID_FILE_ATTRIBUTES {
  1332. if e1 != 0 {
  1333. err = errnoErr(e1)
  1334. } else {
  1335. err = syscall.EINVAL
  1336. }
  1337. }
  1338. return
  1339. }
  1340. func SetFileAttributes(name *uint16, attrs uint32) (err error) {
  1341. r1, _, e1 := syscall.Syscall(procSetFileAttributesW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(attrs), 0)
  1342. if r1 == 0 {
  1343. if e1 != 0 {
  1344. err = errnoErr(e1)
  1345. } else {
  1346. err = syscall.EINVAL
  1347. }
  1348. }
  1349. return
  1350. }
  1351. func GetFileAttributesEx(name *uint16, level uint32, info *byte) (err error) {
  1352. r1, _, e1 := syscall.Syscall(procGetFileAttributesExW.Addr(), 3, uintptr(unsafe.Pointer(name)), uintptr(level), uintptr(unsafe.Pointer(info)))
  1353. if r1 == 0 {
  1354. if e1 != 0 {
  1355. err = errnoErr(e1)
  1356. } else {
  1357. err = syscall.EINVAL
  1358. }
  1359. }
  1360. return
  1361. }
  1362. func GetCommandLine() (cmd *uint16) {
  1363. r0, _, _ := syscall.Syscall(procGetCommandLineW.Addr(), 0, 0, 0, 0)
  1364. cmd = (*uint16)(unsafe.Pointer(r0))
  1365. return
  1366. }
  1367. func CommandLineToArgv(cmd *uint16, argc *int32) (argv *[8192]*[8192]uint16, err error) {
  1368. r0, _, e1 := syscall.Syscall(procCommandLineToArgvW.Addr(), 2, uintptr(unsafe.Pointer(cmd)), uintptr(unsafe.Pointer(argc)), 0)
  1369. argv = (*[8192]*[8192]uint16)(unsafe.Pointer(r0))
  1370. if argv == nil {
  1371. if e1 != 0 {
  1372. err = errnoErr(e1)
  1373. } else {
  1374. err = syscall.EINVAL
  1375. }
  1376. }
  1377. return
  1378. }
  1379. func LocalFree(hmem Handle) (handle Handle, err error) {
  1380. r0, _, e1 := syscall.Syscall(procLocalFree.Addr(), 1, uintptr(hmem), 0, 0)
  1381. handle = Handle(r0)
  1382. if handle != 0 {
  1383. if e1 != 0 {
  1384. err = errnoErr(e1)
  1385. } else {
  1386. err = syscall.EINVAL
  1387. }
  1388. }
  1389. return
  1390. }
  1391. func SetHandleInformation(handle Handle, mask uint32, flags uint32) (err error) {
  1392. r1, _, e1 := syscall.Syscall(procSetHandleInformation.Addr(), 3, uintptr(handle), uintptr(mask), uintptr(flags))
  1393. if r1 == 0 {
  1394. if e1 != 0 {
  1395. err = errnoErr(e1)
  1396. } else {
  1397. err = syscall.EINVAL
  1398. }
  1399. }
  1400. return
  1401. }
  1402. func FlushFileBuffers(handle Handle) (err error) {
  1403. r1, _, e1 := syscall.Syscall(procFlushFileBuffers.Addr(), 1, uintptr(handle), 0, 0)
  1404. if r1 == 0 {
  1405. if e1 != 0 {
  1406. err = errnoErr(e1)
  1407. } else {
  1408. err = syscall.EINVAL
  1409. }
  1410. }
  1411. return
  1412. }
  1413. func GetFullPathName(path *uint16, buflen uint32, buf *uint16, fname **uint16) (n uint32, err error) {
  1414. r0, _, e1 := syscall.Syscall6(procGetFullPathNameW.Addr(), 4, uintptr(unsafe.Pointer(path)), uintptr(buflen), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(fname)), 0, 0)
  1415. n = uint32(r0)
  1416. if n == 0 {
  1417. if e1 != 0 {
  1418. err = errnoErr(e1)
  1419. } else {
  1420. err = syscall.EINVAL
  1421. }
  1422. }
  1423. return
  1424. }
  1425. func GetLongPathName(path *uint16, buf *uint16, buflen uint32) (n uint32, err error) {
  1426. r0, _, e1 := syscall.Syscall(procGetLongPathNameW.Addr(), 3, uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(buf)), uintptr(buflen))
  1427. n = uint32(r0)
  1428. if n == 0 {
  1429. if e1 != 0 {
  1430. err = errnoErr(e1)
  1431. } else {
  1432. err = syscall.EINVAL
  1433. }
  1434. }
  1435. return
  1436. }
  1437. func GetShortPathName(longpath *uint16, shortpath *uint16, buflen uint32) (n uint32, err error) {
  1438. r0, _, e1 := syscall.Syscall(procGetShortPathNameW.Addr(), 3, uintptr(unsafe.Pointer(longpath)), uintptr(unsafe.Pointer(shortpath)), uintptr(buflen))
  1439. n = uint32(r0)
  1440. if n == 0 {
  1441. if e1 != 0 {
  1442. err = errnoErr(e1)
  1443. } else {
  1444. err = syscall.EINVAL
  1445. }
  1446. }
  1447. return
  1448. }
  1449. func CreateFileMapping(fhandle Handle, sa *SecurityAttributes, prot uint32, maxSizeHigh uint32, maxSizeLow uint32, name *uint16) (handle Handle, err error) {
  1450. r0, _, e1 := syscall.Syscall6(procCreateFileMappingW.Addr(), 6, uintptr(fhandle), uintptr(unsafe.Pointer(sa)), uintptr(prot), uintptr(maxSizeHigh), uintptr(maxSizeLow), uintptr(unsafe.Pointer(name)))
  1451. handle = Handle(r0)
  1452. if handle == 0 {
  1453. if e1 != 0 {
  1454. err = errnoErr(e1)
  1455. } else {
  1456. err = syscall.EINVAL
  1457. }
  1458. }
  1459. return
  1460. }
  1461. func MapViewOfFile(handle Handle, access uint32, offsetHigh uint32, offsetLow uint32, length uintptr) (addr uintptr, err error) {
  1462. r0, _, e1 := syscall.Syscall6(procMapViewOfFile.Addr(), 5, uintptr(handle), uintptr(access), uintptr(offsetHigh), uintptr(offsetLow), uintptr(length), 0)
  1463. addr = uintptr(r0)
  1464. if addr == 0 {
  1465. if e1 != 0 {
  1466. err = errnoErr(e1)
  1467. } else {
  1468. err = syscall.EINVAL
  1469. }
  1470. }
  1471. return
  1472. }
  1473. func UnmapViewOfFile(addr uintptr) (err error) {
  1474. r1, _, e1 := syscall.Syscall(procUnmapViewOfFile.Addr(), 1, uintptr(addr), 0, 0)
  1475. if r1 == 0 {
  1476. if e1 != 0 {
  1477. err = errnoErr(e1)
  1478. } else {
  1479. err = syscall.EINVAL
  1480. }
  1481. }
  1482. return
  1483. }
  1484. func FlushViewOfFile(addr uintptr, length uintptr) (err error) {
  1485. r1, _, e1 := syscall.Syscall(procFlushViewOfFile.Addr(), 2, uintptr(addr), uintptr(length), 0)
  1486. if r1 == 0 {
  1487. if e1 != 0 {
  1488. err = errnoErr(e1)
  1489. } else {
  1490. err = syscall.EINVAL
  1491. }
  1492. }
  1493. return
  1494. }
  1495. func VirtualLock(addr uintptr, length uintptr) (err error) {
  1496. r1, _, e1 := syscall.Syscall(procVirtualLock.Addr(), 2, uintptr(addr), uintptr(length), 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 VirtualUnlock(addr uintptr, length uintptr) (err error) {
  1507. r1, _, e1 := syscall.Syscall(procVirtualUnlock.Addr(), 2, uintptr(addr), uintptr(length), 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 VirtualAlloc(address uintptr, size uintptr, alloctype uint32, protect uint32) (value uintptr, err error) {
  1518. r0, _, e1 := syscall.Syscall6(procVirtualAlloc.Addr(), 4, uintptr(address), uintptr(size), uintptr(alloctype), uintptr(protect), 0, 0)
  1519. value = uintptr(r0)
  1520. if value == 0 {
  1521. if e1 != 0 {
  1522. err = errnoErr(e1)
  1523. } else {
  1524. err = syscall.EINVAL
  1525. }
  1526. }
  1527. return
  1528. }
  1529. func VirtualFree(address uintptr, size uintptr, freetype uint32) (err error) {
  1530. r1, _, e1 := syscall.Syscall(procVirtualFree.Addr(), 3, uintptr(address), uintptr(size), uintptr(freetype))
  1531. if r1 == 0 {
  1532. if e1 != 0 {
  1533. err = errnoErr(e1)
  1534. } else {
  1535. err = syscall.EINVAL
  1536. }
  1537. }
  1538. return
  1539. }
  1540. func VirtualProtect(address uintptr, size uintptr, newprotect uint32, oldprotect *uint32) (err error) {
  1541. r1, _, e1 := syscall.Syscall6(procVirtualProtect.Addr(), 4, uintptr(address), uintptr(size), uintptr(newprotect), uintptr(unsafe.Pointer(oldprotect)), 0, 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 TransmitFile(s Handle, handle Handle, bytesToWrite uint32, bytsPerSend uint32, overlapped *Overlapped, transmitFileBuf *TransmitFileBuffers, flags uint32) (err error) {
  1552. 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)
  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 ReadDirectoryChanges(handle Handle, buf *byte, buflen uint32, watchSubTree bool, mask uint32, retlen *uint32, overlapped *Overlapped, completionRoutine uintptr) (err error) {
  1563. var _p0 uint32
  1564. if watchSubTree {
  1565. _p0 = 1
  1566. } else {
  1567. _p0 = 0
  1568. }
  1569. 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)
  1570. if r1 == 0 {
  1571. if e1 != 0 {
  1572. err = errnoErr(e1)
  1573. } else {
  1574. err = syscall.EINVAL
  1575. }
  1576. }
  1577. return
  1578. }
  1579. func CertOpenSystemStore(hprov Handle, name *uint16) (store Handle, err error) {
  1580. r0, _, e1 := syscall.Syscall(procCertOpenSystemStoreW.Addr(), 2, uintptr(hprov), uintptr(unsafe.Pointer(name)), 0)
  1581. store = Handle(r0)
  1582. if store == 0 {
  1583. if e1 != 0 {
  1584. err = errnoErr(e1)
  1585. } else {
  1586. err = syscall.EINVAL
  1587. }
  1588. }
  1589. return
  1590. }
  1591. func CertOpenStore(storeProvider uintptr, msgAndCertEncodingType uint32, cryptProv uintptr, flags uint32, para uintptr) (handle Handle, err error) {
  1592. r0, _, e1 := syscall.Syscall6(procCertOpenStore.Addr(), 5, uintptr(storeProvider), uintptr(msgAndCertEncodingType), uintptr(cryptProv), uintptr(flags), uintptr(para), 0)
  1593. handle = Handle(r0)
  1594. if handle == InvalidHandle {
  1595. if e1 != 0 {
  1596. err = errnoErr(e1)
  1597. } else {
  1598. err = syscall.EINVAL
  1599. }
  1600. }
  1601. return
  1602. }
  1603. func CertEnumCertificatesInStore(store Handle, prevContext *CertContext) (context *CertContext, err error) {
  1604. r0, _, e1 := syscall.Syscall(procCertEnumCertificatesInStore.Addr(), 2, uintptr(store), uintptr(unsafe.Pointer(prevContext)), 0)
  1605. context = (*CertContext)(unsafe.Pointer(r0))
  1606. if context == nil {
  1607. if e1 != 0 {
  1608. err = errnoErr(e1)
  1609. } else {
  1610. err = syscall.EINVAL
  1611. }
  1612. }
  1613. return
  1614. }
  1615. func CertAddCertificateContextToStore(store Handle, certContext *CertContext, addDisposition uint32, storeContext **CertContext) (err error) {
  1616. r1, _, e1 := syscall.Syscall6(procCertAddCertificateContextToStore.Addr(), 4, uintptr(store), uintptr(unsafe.Pointer(certContext)), uintptr(addDisposition), uintptr(unsafe.Pointer(storeContext)), 0, 0)
  1617. if r1 == 0 {
  1618. if e1 != 0 {
  1619. err = errnoErr(e1)
  1620. } else {
  1621. err = syscall.EINVAL
  1622. }
  1623. }
  1624. return
  1625. }
  1626. func CertCloseStore(store Handle, flags uint32) (err error) {
  1627. r1, _, e1 := syscall.Syscall(procCertCloseStore.Addr(), 2, uintptr(store), uintptr(flags), 0)
  1628. if r1 == 0 {
  1629. if e1 != 0 {
  1630. err = errnoErr(e1)
  1631. } else {
  1632. err = syscall.EINVAL
  1633. }
  1634. }
  1635. return
  1636. }
  1637. func CertGetCertificateChain(engine Handle, leaf *CertContext, time *Filetime, additionalStore Handle, para *CertChainPara, flags uint32, reserved uintptr, chainCtx **CertChainContext) (err error) {
  1638. 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)
  1639. if r1 == 0 {
  1640. if e1 != 0 {
  1641. err = errnoErr(e1)
  1642. } else {
  1643. err = syscall.EINVAL
  1644. }
  1645. }
  1646. return
  1647. }
  1648. func CertFreeCertificateChain(ctx *CertChainContext) {
  1649. syscall.Syscall(procCertFreeCertificateChain.Addr(), 1, uintptr(unsafe.Pointer(ctx)), 0, 0)
  1650. return
  1651. }
  1652. func CertCreateCertificateContext(certEncodingType uint32, certEncoded *byte, encodedLen uint32) (context *CertContext, err error) {
  1653. r0, _, e1 := syscall.Syscall(procCertCreateCertificateContext.Addr(), 3, uintptr(certEncodingType), uintptr(unsafe.Pointer(certEncoded)), uintptr(encodedLen))
  1654. context = (*CertContext)(unsafe.Pointer(r0))
  1655. if context == nil {
  1656. if e1 != 0 {
  1657. err = errnoErr(e1)
  1658. } else {
  1659. err = syscall.EINVAL
  1660. }
  1661. }
  1662. return
  1663. }
  1664. func CertFreeCertificateContext(ctx *CertContext) (err error) {
  1665. r1, _, e1 := syscall.Syscall(procCertFreeCertificateContext.Addr(), 1, uintptr(unsafe.Pointer(ctx)), 0, 0)
  1666. if r1 == 0 {
  1667. if e1 != 0 {
  1668. err = errnoErr(e1)
  1669. } else {
  1670. err = syscall.EINVAL
  1671. }
  1672. }
  1673. return
  1674. }
  1675. func CertVerifyCertificateChainPolicy(policyOID uintptr, chain *CertChainContext, para *CertChainPolicyPara, status *CertChainPolicyStatus) (err error) {
  1676. r1, _, e1 := syscall.Syscall6(procCertVerifyCertificateChainPolicy.Addr(), 4, uintptr(policyOID), uintptr(unsafe.Pointer(chain)), uintptr(unsafe.Pointer(para)), uintptr(unsafe.Pointer(status)), 0, 0)
  1677. if r1 == 0 {
  1678. if e1 != 0 {
  1679. err = errnoErr(e1)
  1680. } else {
  1681. err = syscall.EINVAL
  1682. }
  1683. }
  1684. return
  1685. }
  1686. func RegOpenKeyEx(key Handle, subkey *uint16, options uint32, desiredAccess uint32, result *Handle) (regerrno error) {
  1687. r0, _, _ := syscall.Syscall6(procRegOpenKeyExW.Addr(), 5, uintptr(key), uintptr(unsafe.Pointer(subkey)), uintptr(options), uintptr(desiredAccess), uintptr(unsafe.Pointer(result)), 0)
  1688. if r0 != 0 {
  1689. regerrno = syscall.Errno(r0)
  1690. }
  1691. return
  1692. }
  1693. func RegCloseKey(key Handle) (regerrno error) {
  1694. r0, _, _ := syscall.Syscall(procRegCloseKey.Addr(), 1, uintptr(key), 0, 0)
  1695. if r0 != 0 {
  1696. regerrno = syscall.Errno(r0)
  1697. }
  1698. return
  1699. }
  1700. 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) {
  1701. 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)))
  1702. if r0 != 0 {
  1703. regerrno = syscall.Errno(r0)
  1704. }
  1705. return
  1706. }
  1707. func RegEnumKeyEx(key Handle, index uint32, name *uint16, nameLen *uint32, reserved *uint32, class *uint16, classLen *uint32, lastWriteTime *Filetime) (regerrno error) {
  1708. 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)
  1709. if r0 != 0 {
  1710. regerrno = syscall.Errno(r0)
  1711. }
  1712. return
  1713. }
  1714. func RegQueryValueEx(key Handle, name *uint16, reserved *uint32, valtype *uint32, buf *byte, buflen *uint32) (regerrno error) {
  1715. 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)))
  1716. if r0 != 0 {
  1717. regerrno = syscall.Errno(r0)
  1718. }
  1719. return
  1720. }
  1721. func GetCurrentProcessId() (pid uint32) {
  1722. r0, _, _ := syscall.Syscall(procGetCurrentProcessId.Addr(), 0, 0, 0, 0)
  1723. pid = uint32(r0)
  1724. return
  1725. }
  1726. func GetConsoleMode(console Handle, mode *uint32) (err error) {
  1727. r1, _, e1 := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(console), uintptr(unsafe.Pointer(mode)), 0)
  1728. if r1 == 0 {
  1729. if e1 != 0 {
  1730. err = errnoErr(e1)
  1731. } else {
  1732. err = syscall.EINVAL
  1733. }
  1734. }
  1735. return
  1736. }
  1737. func SetConsoleMode(console Handle, mode uint32) (err error) {
  1738. r1, _, e1 := syscall.Syscall(procSetConsoleMode.Addr(), 2, uintptr(console), uintptr(mode), 0)
  1739. if r1 == 0 {
  1740. if e1 != 0 {
  1741. err = errnoErr(e1)
  1742. } else {
  1743. err = syscall.EINVAL
  1744. }
  1745. }
  1746. return
  1747. }
  1748. func GetConsoleScreenBufferInfo(console Handle, info *ConsoleScreenBufferInfo) (err error) {
  1749. r1, _, e1 := syscall.Syscall(procGetConsoleScreenBufferInfo.Addr(), 2, uintptr(console), uintptr(unsafe.Pointer(info)), 0)
  1750. if r1 == 0 {
  1751. if e1 != 0 {
  1752. err = errnoErr(e1)
  1753. } else {
  1754. err = syscall.EINVAL
  1755. }
  1756. }
  1757. return
  1758. }
  1759. func WriteConsole(console Handle, buf *uint16, towrite uint32, written *uint32, reserved *byte) (err error) {
  1760. r1, _, e1 := syscall.Syscall6(procWriteConsoleW.Addr(), 5, uintptr(console), uintptr(unsafe.Pointer(buf)), uintptr(towrite), uintptr(unsafe.Pointer(written)), uintptr(unsafe.Pointer(reserved)), 0)
  1761. if r1 == 0 {
  1762. if e1 != 0 {
  1763. err = errnoErr(e1)
  1764. } else {
  1765. err = syscall.EINVAL
  1766. }
  1767. }
  1768. return
  1769. }
  1770. func ReadConsole(console Handle, buf *uint16, toread uint32, read *uint32, inputControl *byte) (err error) {
  1771. r1, _, e1 := syscall.Syscall6(procReadConsoleW.Addr(), 5, uintptr(console), uintptr(unsafe.Pointer(buf)), uintptr(toread), uintptr(unsafe.Pointer(read)), uintptr(unsafe.Pointer(inputControl)), 0)
  1772. if r1 == 0 {
  1773. if e1 != 0 {
  1774. err = errnoErr(e1)
  1775. } else {
  1776. err = syscall.EINVAL
  1777. }
  1778. }
  1779. return
  1780. }
  1781. func CreateToolhelp32Snapshot(flags uint32, processId uint32) (handle Handle, err error) {
  1782. r0, _, e1 := syscall.Syscall(procCreateToolhelp32Snapshot.Addr(), 2, uintptr(flags), uintptr(processId), 0)
  1783. handle = Handle(r0)
  1784. if handle == InvalidHandle {
  1785. if e1 != 0 {
  1786. err = errnoErr(e1)
  1787. } else {
  1788. err = syscall.EINVAL
  1789. }
  1790. }
  1791. return
  1792. }
  1793. func Process32First(snapshot Handle, procEntry *ProcessEntry32) (err error) {
  1794. r1, _, e1 := syscall.Syscall(procProcess32FirstW.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(procEntry)), 0)
  1795. if r1 == 0 {
  1796. if e1 != 0 {
  1797. err = errnoErr(e1)
  1798. } else {
  1799. err = syscall.EINVAL
  1800. }
  1801. }
  1802. return
  1803. }
  1804. func Process32Next(snapshot Handle, procEntry *ProcessEntry32) (err error) {
  1805. r1, _, e1 := syscall.Syscall(procProcess32NextW.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(procEntry)), 0)
  1806. if r1 == 0 {
  1807. if e1 != 0 {
  1808. err = errnoErr(e1)
  1809. } else {
  1810. err = syscall.EINVAL
  1811. }
  1812. }
  1813. return
  1814. }
  1815. func Thread32First(snapshot Handle, threadEntry *ThreadEntry32) (err error) {
  1816. r1, _, e1 := syscall.Syscall(procThread32First.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(threadEntry)), 0)
  1817. if r1 == 0 {
  1818. if e1 != 0 {
  1819. err = errnoErr(e1)
  1820. } else {
  1821. err = syscall.EINVAL
  1822. }
  1823. }
  1824. return
  1825. }
  1826. func Thread32Next(snapshot Handle, threadEntry *ThreadEntry32) (err error) {
  1827. r1, _, e1 := syscall.Syscall(procThread32Next.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(threadEntry)), 0)
  1828. if r1 == 0 {
  1829. if e1 != 0 {
  1830. err = errnoErr(e1)
  1831. } else {
  1832. err = syscall.EINVAL
  1833. }
  1834. }
  1835. return
  1836. }
  1837. func DeviceIoControl(handle Handle, ioControlCode uint32, inBuffer *byte, inBufferSize uint32, outBuffer *byte, outBufferSize uint32, bytesReturned *uint32, overlapped *Overlapped) (err error) {
  1838. 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)
  1839. if r1 == 0 {
  1840. if e1 != 0 {
  1841. err = errnoErr(e1)
  1842. } else {
  1843. err = syscall.EINVAL
  1844. }
  1845. }
  1846. return
  1847. }
  1848. func CreateSymbolicLink(symlinkfilename *uint16, targetfilename *uint16, flags uint32) (err error) {
  1849. r1, _, e1 := syscall.Syscall(procCreateSymbolicLinkW.Addr(), 3, uintptr(unsafe.Pointer(symlinkfilename)), uintptr(unsafe.Pointer(targetfilename)), uintptr(flags))
  1850. if r1&0xff == 0 {
  1851. if e1 != 0 {
  1852. err = errnoErr(e1)
  1853. } else {
  1854. err = syscall.EINVAL
  1855. }
  1856. }
  1857. return
  1858. }
  1859. func CreateHardLink(filename *uint16, existingfilename *uint16, reserved uintptr) (err error) {
  1860. r1, _, e1 := syscall.Syscall(procCreateHardLinkW.Addr(), 3, uintptr(unsafe.Pointer(filename)), uintptr(unsafe.Pointer(existingfilename)), uintptr(reserved))
  1861. if r1&0xff == 0 {
  1862. if e1 != 0 {
  1863. err = errnoErr(e1)
  1864. } else {
  1865. err = syscall.EINVAL
  1866. }
  1867. }
  1868. return
  1869. }
  1870. func GetCurrentThreadId() (id uint32) {
  1871. r0, _, _ := syscall.Syscall(procGetCurrentThreadId.Addr(), 0, 0, 0, 0)
  1872. id = uint32(r0)
  1873. return
  1874. }
  1875. func CreateEvent(eventAttrs *SecurityAttributes, manualReset uint32, initialState uint32, name *uint16) (handle Handle, err error) {
  1876. r0, _, e1 := syscall.Syscall6(procCreateEventW.Addr(), 4, uintptr(unsafe.Pointer(eventAttrs)), uintptr(manualReset), uintptr(initialState), uintptr(unsafe.Pointer(name)), 0, 0)
  1877. handle = Handle(r0)
  1878. if handle == 0 {
  1879. if e1 != 0 {
  1880. err = errnoErr(e1)
  1881. } else {
  1882. err = syscall.EINVAL
  1883. }
  1884. }
  1885. return
  1886. }
  1887. func CreateEventEx(eventAttrs *SecurityAttributes, name *uint16, flags uint32, desiredAccess uint32) (handle Handle, err error) {
  1888. r0, _, e1 := syscall.Syscall6(procCreateEventExW.Addr(), 4, uintptr(unsafe.Pointer(eventAttrs)), uintptr(unsafe.Pointer(name)), uintptr(flags), uintptr(desiredAccess), 0, 0)
  1889. handle = Handle(r0)
  1890. if handle == 0 {
  1891. if e1 != 0 {
  1892. err = errnoErr(e1)
  1893. } else {
  1894. err = syscall.EINVAL
  1895. }
  1896. }
  1897. return
  1898. }
  1899. func OpenEvent(desiredAccess uint32, inheritHandle bool, name *uint16) (handle Handle, err error) {
  1900. var _p0 uint32
  1901. if inheritHandle {
  1902. _p0 = 1
  1903. } else {
  1904. _p0 = 0
  1905. }
  1906. r0, _, e1 := syscall.Syscall(procOpenEventW.Addr(), 3, uintptr(desiredAccess), uintptr(_p0), uintptr(unsafe.Pointer(name)))
  1907. handle = Handle(r0)
  1908. if handle == 0 {
  1909. if e1 != 0 {
  1910. err = errnoErr(e1)
  1911. } else {
  1912. err = syscall.EINVAL
  1913. }
  1914. }
  1915. return
  1916. }
  1917. func SetEvent(event Handle) (err error) {
  1918. r1, _, e1 := syscall.Syscall(procSetEvent.Addr(), 1, uintptr(event), 0, 0)
  1919. if r1 == 0 {
  1920. if e1 != 0 {
  1921. err = errnoErr(e1)
  1922. } else {
  1923. err = syscall.EINVAL
  1924. }
  1925. }
  1926. return
  1927. }
  1928. func ResetEvent(event Handle) (err error) {
  1929. r1, _, e1 := syscall.Syscall(procResetEvent.Addr(), 1, uintptr(event), 0, 0)
  1930. if r1 == 0 {
  1931. if e1 != 0 {
  1932. err = errnoErr(e1)
  1933. } else {
  1934. err = syscall.EINVAL
  1935. }
  1936. }
  1937. return
  1938. }
  1939. func PulseEvent(event Handle) (err error) {
  1940. r1, _, e1 := syscall.Syscall(procPulseEvent.Addr(), 1, uintptr(event), 0, 0)
  1941. if r1 == 0 {
  1942. if e1 != 0 {
  1943. err = errnoErr(e1)
  1944. } else {
  1945. err = syscall.EINVAL
  1946. }
  1947. }
  1948. return
  1949. }
  1950. func SleepEx(milliseconds uint32, alertable bool) (ret uint32) {
  1951. var _p0 uint32
  1952. if alertable {
  1953. _p0 = 1
  1954. } else {
  1955. _p0 = 0
  1956. }
  1957. r0, _, _ := syscall.Syscall(procSleepEx.Addr(), 2, uintptr(milliseconds), uintptr(_p0), 0)
  1958. ret = uint32(r0)
  1959. return
  1960. }
  1961. func CreateJobObject(jobAttr *SecurityAttributes, name *uint16) (handle Handle, err error) {
  1962. r0, _, e1 := syscall.Syscall(procCreateJobObjectW.Addr(), 2, uintptr(unsafe.Pointer(jobAttr)), uintptr(unsafe.Pointer(name)), 0)
  1963. handle = Handle(r0)
  1964. if handle == 0 {
  1965. if e1 != 0 {
  1966. err = errnoErr(e1)
  1967. } else {
  1968. err = syscall.EINVAL
  1969. }
  1970. }
  1971. return
  1972. }
  1973. func AssignProcessToJobObject(job Handle, process Handle) (err error) {
  1974. r1, _, e1 := syscall.Syscall(procAssignProcessToJobObject.Addr(), 2, uintptr(job), uintptr(process), 0)
  1975. if r1 == 0 {
  1976. if e1 != 0 {
  1977. err = errnoErr(e1)
  1978. } else {
  1979. err = syscall.EINVAL
  1980. }
  1981. }
  1982. return
  1983. }
  1984. func TerminateJobObject(job Handle, exitCode uint32) (err error) {
  1985. r1, _, e1 := syscall.Syscall(procTerminateJobObject.Addr(), 2, uintptr(job), uintptr(exitCode), 0)
  1986. if r1 == 0 {
  1987. if e1 != 0 {
  1988. err = errnoErr(e1)
  1989. } else {
  1990. err = syscall.EINVAL
  1991. }
  1992. }
  1993. return
  1994. }
  1995. func SetErrorMode(mode uint32) (ret uint32) {
  1996. r0, _, _ := syscall.Syscall(procSetErrorMode.Addr(), 1, uintptr(mode), 0, 0)
  1997. ret = uint32(r0)
  1998. return
  1999. }
  2000. func ResumeThread(thread Handle) (ret uint32, err error) {
  2001. r0, _, e1 := syscall.Syscall(procResumeThread.Addr(), 1, uintptr(thread), 0, 0)
  2002. ret = uint32(r0)
  2003. if ret == 0xffffffff {
  2004. if e1 != 0 {
  2005. err = errnoErr(e1)
  2006. } else {
  2007. err = syscall.EINVAL
  2008. }
  2009. }
  2010. return
  2011. }
  2012. func SetPriorityClass(process Handle, priorityClass uint32) (err error) {
  2013. r1, _, e1 := syscall.Syscall(procSetPriorityClass.Addr(), 2, uintptr(process), uintptr(priorityClass), 0)
  2014. if r1 == 0 {
  2015. if e1 != 0 {
  2016. err = errnoErr(e1)
  2017. } else {
  2018. err = syscall.EINVAL
  2019. }
  2020. }
  2021. return
  2022. }
  2023. func GetPriorityClass(process Handle) (ret uint32, err error) {
  2024. r0, _, e1 := syscall.Syscall(procGetPriorityClass.Addr(), 1, uintptr(process), 0, 0)
  2025. ret = uint32(r0)
  2026. if ret == 0 {
  2027. if e1 != 0 {
  2028. err = errnoErr(e1)
  2029. } else {
  2030. err = syscall.EINVAL
  2031. }
  2032. }
  2033. return
  2034. }
  2035. func SetInformationJobObject(job Handle, JobObjectInformationClass uint32, JobObjectInformation uintptr, JobObjectInformationLength uint32) (ret int, err error) {
  2036. r0, _, e1 := syscall.Syscall6(procSetInformationJobObject.Addr(), 4, uintptr(job), uintptr(JobObjectInformationClass), uintptr(JobObjectInformation), uintptr(JobObjectInformationLength), 0, 0)
  2037. ret = int(r0)
  2038. if ret == 0 {
  2039. if e1 != 0 {
  2040. err = errnoErr(e1)
  2041. } else {
  2042. err = syscall.EINVAL
  2043. }
  2044. }
  2045. return
  2046. }
  2047. func GenerateConsoleCtrlEvent(ctrlEvent uint32, processGroupID uint32) (err error) {
  2048. r1, _, e1 := syscall.Syscall(procGenerateConsoleCtrlEvent.Addr(), 2, uintptr(ctrlEvent), uintptr(processGroupID), 0)
  2049. if r1 == 0 {
  2050. if e1 != 0 {
  2051. err = errnoErr(e1)
  2052. } else {
  2053. err = syscall.EINVAL
  2054. }
  2055. }
  2056. return
  2057. }
  2058. func GetProcessId(process Handle) (id uint32, err error) {
  2059. r0, _, e1 := syscall.Syscall(procGetProcessId.Addr(), 1, uintptr(process), 0, 0)
  2060. id = uint32(r0)
  2061. if id == 0 {
  2062. if e1 != 0 {
  2063. err = errnoErr(e1)
  2064. } else {
  2065. err = syscall.EINVAL
  2066. }
  2067. }
  2068. return
  2069. }
  2070. func OpenThread(desiredAccess uint32, inheritHandle bool, threadId uint32) (handle Handle, err error) {
  2071. var _p0 uint32
  2072. if inheritHandle {
  2073. _p0 = 1
  2074. } else {
  2075. _p0 = 0
  2076. }
  2077. r0, _, e1 := syscall.Syscall(procOpenThread.Addr(), 3, uintptr(desiredAccess), uintptr(_p0), uintptr(threadId))
  2078. handle = Handle(r0)
  2079. if handle == 0 {
  2080. if e1 != 0 {
  2081. err = errnoErr(e1)
  2082. } else {
  2083. err = syscall.EINVAL
  2084. }
  2085. }
  2086. return
  2087. }
  2088. func DefineDosDevice(flags uint32, deviceName *uint16, targetPath *uint16) (err error) {
  2089. r1, _, e1 := syscall.Syscall(procDefineDosDeviceW.Addr(), 3, uintptr(flags), uintptr(unsafe.Pointer(deviceName)), uintptr(unsafe.Pointer(targetPath)))
  2090. if r1 == 0 {
  2091. if e1 != 0 {
  2092. err = errnoErr(e1)
  2093. } else {
  2094. err = syscall.EINVAL
  2095. }
  2096. }
  2097. return
  2098. }
  2099. func DeleteVolumeMountPoint(volumeMountPoint *uint16) (err error) {
  2100. r1, _, e1 := syscall.Syscall(procDeleteVolumeMountPointW.Addr(), 1, uintptr(unsafe.Pointer(volumeMountPoint)), 0, 0)
  2101. if r1 == 0 {
  2102. if e1 != 0 {
  2103. err = errnoErr(e1)
  2104. } else {
  2105. err = syscall.EINVAL
  2106. }
  2107. }
  2108. return
  2109. }
  2110. func FindFirstVolume(volumeName *uint16, bufferLength uint32) (handle Handle, err error) {
  2111. r0, _, e1 := syscall.Syscall(procFindFirstVolumeW.Addr(), 2, uintptr(unsafe.Pointer(volumeName)), uintptr(bufferLength), 0)
  2112. handle = Handle(r0)
  2113. if handle == InvalidHandle {
  2114. if e1 != 0 {
  2115. err = errnoErr(e1)
  2116. } else {
  2117. err = syscall.EINVAL
  2118. }
  2119. }
  2120. return
  2121. }
  2122. func FindFirstVolumeMountPoint(rootPathName *uint16, volumeMountPoint *uint16, bufferLength uint32) (handle Handle, err error) {
  2123. r0, _, e1 := syscall.Syscall(procFindFirstVolumeMountPointW.Addr(), 3, uintptr(unsafe.Pointer(rootPathName)), uintptr(unsafe.Pointer(volumeMountPoint)), uintptr(bufferLength))
  2124. handle = Handle(r0)
  2125. if handle == InvalidHandle {
  2126. if e1 != 0 {
  2127. err = errnoErr(e1)
  2128. } else {
  2129. err = syscall.EINVAL
  2130. }
  2131. }
  2132. return
  2133. }
  2134. func FindNextVolume(findVolume Handle, volumeName *uint16, bufferLength uint32) (err error) {
  2135. r1, _, e1 := syscall.Syscall(procFindNextVolumeW.Addr(), 3, uintptr(findVolume), uintptr(unsafe.Pointer(volumeName)), uintptr(bufferLength))
  2136. if r1 == 0 {
  2137. if e1 != 0 {
  2138. err = errnoErr(e1)
  2139. } else {
  2140. err = syscall.EINVAL
  2141. }
  2142. }
  2143. return
  2144. }
  2145. func FindNextVolumeMountPoint(findVolumeMountPoint Handle, volumeMountPoint *uint16, bufferLength uint32) (err error) {
  2146. r1, _, e1 := syscall.Syscall(procFindNextVolumeMountPointW.Addr(), 3, uintptr(findVolumeMountPoint), uintptr(unsafe.Pointer(volumeMountPoint)), uintptr(bufferLength))
  2147. if r1 == 0 {
  2148. if e1 != 0 {
  2149. err = errnoErr(e1)
  2150. } else {
  2151. err = syscall.EINVAL
  2152. }
  2153. }
  2154. return
  2155. }
  2156. func FindVolumeClose(findVolume Handle) (err error) {
  2157. r1, _, e1 := syscall.Syscall(procFindVolumeClose.Addr(), 1, uintptr(findVolume), 0, 0)
  2158. if r1 == 0 {
  2159. if e1 != 0 {
  2160. err = errnoErr(e1)
  2161. } else {
  2162. err = syscall.EINVAL
  2163. }
  2164. }
  2165. return
  2166. }
  2167. func FindVolumeMountPointClose(findVolumeMountPoint Handle) (err error) {
  2168. r1, _, e1 := syscall.Syscall(procFindVolumeMountPointClose.Addr(), 1, uintptr(findVolumeMountPoint), 0, 0)
  2169. if r1 == 0 {
  2170. if e1 != 0 {
  2171. err = errnoErr(e1)
  2172. } else {
  2173. err = syscall.EINVAL
  2174. }
  2175. }
  2176. return
  2177. }
  2178. func GetDriveType(rootPathName *uint16) (driveType uint32) {
  2179. r0, _, _ := syscall.Syscall(procGetDriveTypeW.Addr(), 1, uintptr(unsafe.Pointer(rootPathName)), 0, 0)
  2180. driveType = uint32(r0)
  2181. return
  2182. }
  2183. func GetLogicalDrives() (drivesBitMask uint32, err error) {
  2184. r0, _, e1 := syscall.Syscall(procGetLogicalDrives.Addr(), 0, 0, 0, 0)
  2185. drivesBitMask = uint32(r0)
  2186. if drivesBitMask == 0 {
  2187. if e1 != 0 {
  2188. err = errnoErr(e1)
  2189. } else {
  2190. err = syscall.EINVAL
  2191. }
  2192. }
  2193. return
  2194. }
  2195. func GetLogicalDriveStrings(bufferLength uint32, buffer *uint16) (n uint32, err error) {
  2196. r0, _, e1 := syscall.Syscall(procGetLogicalDriveStringsW.Addr(), 2, uintptr(bufferLength), uintptr(unsafe.Pointer(buffer)), 0)
  2197. n = uint32(r0)
  2198. if n == 0 {
  2199. if e1 != 0 {
  2200. err = errnoErr(e1)
  2201. } else {
  2202. err = syscall.EINVAL
  2203. }
  2204. }
  2205. return
  2206. }
  2207. func GetVolumeInformation(rootPathName *uint16, volumeNameBuffer *uint16, volumeNameSize uint32, volumeNameSerialNumber *uint32, maximumComponentLength *uint32, fileSystemFlags *uint32, fileSystemNameBuffer *uint16, fileSystemNameSize uint32) (err error) {
  2208. r1, _, e1 := syscall.Syscall9(procGetVolumeInformationW.Addr(), 8, uintptr(unsafe.Pointer(rootPathName)), uintptr(unsafe.Pointer(volumeNameBuffer)), uintptr(volumeNameSize), uintptr(unsafe.Pointer(volumeNameSerialNumber)), uintptr(unsafe.Pointer(maximumComponentLength)), uintptr(unsafe.Pointer(fileSystemFlags)), uintptr(unsafe.Pointer(fileSystemNameBuffer)), uintptr(fileSystemNameSize), 0)
  2209. if r1 == 0 {
  2210. if e1 != 0 {
  2211. err = errnoErr(e1)
  2212. } else {
  2213. err = syscall.EINVAL
  2214. }
  2215. }
  2216. return
  2217. }
  2218. func GetVolumeInformationByHandle(file Handle, volumeNameBuffer *uint16, volumeNameSize uint32, volumeNameSerialNumber *uint32, maximumComponentLength *uint32, fileSystemFlags *uint32, fileSystemNameBuffer *uint16, fileSystemNameSize uint32) (err error) {
  2219. r1, _, e1 := syscall.Syscall9(procGetVolumeInformationByHandleW.Addr(), 8, uintptr(file), uintptr(unsafe.Pointer(volumeNameBuffer)), uintptr(volumeNameSize), uintptr(unsafe.Pointer(volumeNameSerialNumber)), uintptr(unsafe.Pointer(maximumComponentLength)), uintptr(unsafe.Pointer(fileSystemFlags)), uintptr(unsafe.Pointer(fileSystemNameBuffer)), uintptr(fileSystemNameSize), 0)
  2220. if r1 == 0 {
  2221. if e1 != 0 {
  2222. err = errnoErr(e1)
  2223. } else {
  2224. err = syscall.EINVAL
  2225. }
  2226. }
  2227. return
  2228. }
  2229. func GetVolumeNameForVolumeMountPoint(volumeMountPoint *uint16, volumeName *uint16, bufferlength uint32) (err error) {
  2230. r1, _, e1 := syscall.Syscall(procGetVolumeNameForVolumeMountPointW.Addr(), 3, uintptr(unsafe.Pointer(volumeMountPoint)), uintptr(unsafe.Pointer(volumeName)), uintptr(bufferlength))
  2231. if r1 == 0 {
  2232. if e1 != 0 {
  2233. err = errnoErr(e1)
  2234. } else {
  2235. err = syscall.EINVAL
  2236. }
  2237. }
  2238. return
  2239. }
  2240. func GetVolumePathName(fileName *uint16, volumePathName *uint16, bufferLength uint32) (err error) {
  2241. r1, _, e1 := syscall.Syscall(procGetVolumePathNameW.Addr(), 3, uintptr(unsafe.Pointer(fileName)), uintptr(unsafe.Pointer(volumePathName)), uintptr(bufferLength))
  2242. if r1 == 0 {
  2243. if e1 != 0 {
  2244. err = errnoErr(e1)
  2245. } else {
  2246. err = syscall.EINVAL
  2247. }
  2248. }
  2249. return
  2250. }
  2251. func GetVolumePathNamesForVolumeName(volumeName *uint16, volumePathNames *uint16, bufferLength uint32, returnLength *uint32) (err error) {
  2252. r1, _, e1 := syscall.Syscall6(procGetVolumePathNamesForVolumeNameW.Addr(), 4, uintptr(unsafe.Pointer(volumeName)), uintptr(unsafe.Pointer(volumePathNames)), uintptr(bufferLength), uintptr(unsafe.Pointer(returnLength)), 0, 0)
  2253. if r1 == 0 {
  2254. if e1 != 0 {
  2255. err = errnoErr(e1)
  2256. } else {
  2257. err = syscall.EINVAL
  2258. }
  2259. }
  2260. return
  2261. }
  2262. func QueryDosDevice(deviceName *uint16, targetPath *uint16, max uint32) (n uint32, err error) {
  2263. r0, _, e1 := syscall.Syscall(procQueryDosDeviceW.Addr(), 3, uintptr(unsafe.Pointer(deviceName)), uintptr(unsafe.Pointer(targetPath)), uintptr(max))
  2264. n = uint32(r0)
  2265. if n == 0 {
  2266. if e1 != 0 {
  2267. err = errnoErr(e1)
  2268. } else {
  2269. err = syscall.EINVAL
  2270. }
  2271. }
  2272. return
  2273. }
  2274. func SetVolumeLabel(rootPathName *uint16, volumeName *uint16) (err error) {
  2275. r1, _, e1 := syscall.Syscall(procSetVolumeLabelW.Addr(), 2, uintptr(unsafe.Pointer(rootPathName)), uintptr(unsafe.Pointer(volumeName)), 0)
  2276. if r1 == 0 {
  2277. if e1 != 0 {
  2278. err = errnoErr(e1)
  2279. } else {
  2280. err = syscall.EINVAL
  2281. }
  2282. }
  2283. return
  2284. }
  2285. func SetVolumeMountPoint(volumeMountPoint *uint16, volumeName *uint16) (err error) {
  2286. r1, _, e1 := syscall.Syscall(procSetVolumeMountPointW.Addr(), 2, uintptr(unsafe.Pointer(volumeMountPoint)), uintptr(unsafe.Pointer(volumeName)), 0)
  2287. if r1 == 0 {
  2288. if e1 != 0 {
  2289. err = errnoErr(e1)
  2290. } else {
  2291. err = syscall.EINVAL
  2292. }
  2293. }
  2294. return
  2295. }
  2296. func MessageBox(hwnd Handle, text *uint16, caption *uint16, boxtype uint32) (ret int32, err error) {
  2297. r0, _, e1 := syscall.Syscall6(procMessageBoxW.Addr(), 4, uintptr(hwnd), uintptr(unsafe.Pointer(text)), uintptr(unsafe.Pointer(caption)), uintptr(boxtype), 0, 0)
  2298. ret = int32(r0)
  2299. if ret == 0 {
  2300. if e1 != 0 {
  2301. err = errnoErr(e1)
  2302. } else {
  2303. err = syscall.EINVAL
  2304. }
  2305. }
  2306. return
  2307. }
  2308. func clsidFromString(lpsz *uint16, pclsid *GUID) (ret error) {
  2309. r0, _, _ := syscall.Syscall(procCLSIDFromString.Addr(), 2, uintptr(unsafe.Pointer(lpsz)), uintptr(unsafe.Pointer(pclsid)), 0)
  2310. if r0 != 0 {
  2311. ret = syscall.Errno(r0)
  2312. }
  2313. return
  2314. }
  2315. func stringFromGUID2(rguid *GUID, lpsz *uint16, cchMax int32) (chars int32) {
  2316. r0, _, _ := syscall.Syscall(procStringFromGUID2.Addr(), 3, uintptr(unsafe.Pointer(rguid)), uintptr(unsafe.Pointer(lpsz)), uintptr(cchMax))
  2317. chars = int32(r0)
  2318. return
  2319. }
  2320. func coCreateGuid(pguid *GUID) (ret error) {
  2321. r0, _, _ := syscall.Syscall(procCoCreateGuid.Addr(), 1, uintptr(unsafe.Pointer(pguid)), 0, 0)
  2322. if r0 != 0 {
  2323. ret = syscall.Errno(r0)
  2324. }
  2325. return
  2326. }
  2327. func CoTaskMemFree(address unsafe.Pointer) {
  2328. syscall.Syscall(procCoTaskMemFree.Addr(), 1, uintptr(address), 0, 0)
  2329. return
  2330. }
  2331. func rtlGetVersion(info *OsVersionInfoEx) (ret error) {
  2332. r0, _, _ := syscall.Syscall(procRtlGetVersion.Addr(), 1, uintptr(unsafe.Pointer(info)), 0, 0)
  2333. if r0 != 0 {
  2334. ret = syscall.Errno(r0)
  2335. }
  2336. return
  2337. }
  2338. func WSAStartup(verreq uint32, data *WSAData) (sockerr error) {
  2339. r0, _, _ := syscall.Syscall(procWSAStartup.Addr(), 2, uintptr(verreq), uintptr(unsafe.Pointer(data)), 0)
  2340. if r0 != 0 {
  2341. sockerr = syscall.Errno(r0)
  2342. }
  2343. return
  2344. }
  2345. func WSACleanup() (err error) {
  2346. r1, _, e1 := syscall.Syscall(procWSACleanup.Addr(), 0, 0, 0, 0)
  2347. if r1 == socket_error {
  2348. if e1 != 0 {
  2349. err = errnoErr(e1)
  2350. } else {
  2351. err = syscall.EINVAL
  2352. }
  2353. }
  2354. return
  2355. }
  2356. func WSAIoctl(s Handle, iocc uint32, inbuf *byte, cbif uint32, outbuf *byte, cbob uint32, cbbr *uint32, overlapped *Overlapped, completionRoutine uintptr) (err error) {
  2357. 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))
  2358. if r1 == socket_error {
  2359. if e1 != 0 {
  2360. err = errnoErr(e1)
  2361. } else {
  2362. err = syscall.EINVAL
  2363. }
  2364. }
  2365. return
  2366. }
  2367. func socket(af int32, typ int32, protocol int32) (handle Handle, err error) {
  2368. r0, _, e1 := syscall.Syscall(procsocket.Addr(), 3, uintptr(af), uintptr(typ), uintptr(protocol))
  2369. handle = Handle(r0)
  2370. if handle == InvalidHandle {
  2371. if e1 != 0 {
  2372. err = errnoErr(e1)
  2373. } else {
  2374. err = syscall.EINVAL
  2375. }
  2376. }
  2377. return
  2378. }
  2379. func Setsockopt(s Handle, level int32, optname int32, optval *byte, optlen int32) (err error) {
  2380. r1, _, e1 := syscall.Syscall6(procsetsockopt.Addr(), 5, uintptr(s), uintptr(level), uintptr(optname), uintptr(unsafe.Pointer(optval)), uintptr(optlen), 0)
  2381. if r1 == socket_error {
  2382. if e1 != 0 {
  2383. err = errnoErr(e1)
  2384. } else {
  2385. err = syscall.EINVAL
  2386. }
  2387. }
  2388. return
  2389. }
  2390. func Getsockopt(s Handle, level int32, optname int32, optval *byte, optlen *int32) (err error) {
  2391. r1, _, e1 := syscall.Syscall6(procgetsockopt.Addr(), 5, uintptr(s), uintptr(level), uintptr(optname), uintptr(unsafe.Pointer(optval)), uintptr(unsafe.Pointer(optlen)), 0)
  2392. if r1 == socket_error {
  2393. if e1 != 0 {
  2394. err = errnoErr(e1)
  2395. } else {
  2396. err = syscall.EINVAL
  2397. }
  2398. }
  2399. return
  2400. }
  2401. func bind(s Handle, name unsafe.Pointer, namelen int32) (err error) {
  2402. r1, _, e1 := syscall.Syscall(procbind.Addr(), 3, uintptr(s), uintptr(name), uintptr(namelen))
  2403. if r1 == socket_error {
  2404. if e1 != 0 {
  2405. err = errnoErr(e1)
  2406. } else {
  2407. err = syscall.EINVAL
  2408. }
  2409. }
  2410. return
  2411. }
  2412. func connect(s Handle, name unsafe.Pointer, namelen int32) (err error) {
  2413. r1, _, e1 := syscall.Syscall(procconnect.Addr(), 3, uintptr(s), uintptr(name), uintptr(namelen))
  2414. if r1 == socket_error {
  2415. if e1 != 0 {
  2416. err = errnoErr(e1)
  2417. } else {
  2418. err = syscall.EINVAL
  2419. }
  2420. }
  2421. return
  2422. }
  2423. func getsockname(s Handle, rsa *RawSockaddrAny, addrlen *int32) (err error) {
  2424. r1, _, e1 := syscall.Syscall(procgetsockname.Addr(), 3, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
  2425. if r1 == socket_error {
  2426. if e1 != 0 {
  2427. err = errnoErr(e1)
  2428. } else {
  2429. err = syscall.EINVAL
  2430. }
  2431. }
  2432. return
  2433. }
  2434. func getpeername(s Handle, rsa *RawSockaddrAny, addrlen *int32) (err error) {
  2435. r1, _, e1 := syscall.Syscall(procgetpeername.Addr(), 3, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
  2436. if r1 == socket_error {
  2437. if e1 != 0 {
  2438. err = errnoErr(e1)
  2439. } else {
  2440. err = syscall.EINVAL
  2441. }
  2442. }
  2443. return
  2444. }
  2445. func listen(s Handle, backlog int32) (err error) {
  2446. r1, _, e1 := syscall.Syscall(proclisten.Addr(), 2, uintptr(s), uintptr(backlog), 0)
  2447. if r1 == socket_error {
  2448. if e1 != 0 {
  2449. err = errnoErr(e1)
  2450. } else {
  2451. err = syscall.EINVAL
  2452. }
  2453. }
  2454. return
  2455. }
  2456. func shutdown(s Handle, how int32) (err error) {
  2457. r1, _, e1 := syscall.Syscall(procshutdown.Addr(), 2, uintptr(s), uintptr(how), 0)
  2458. if r1 == socket_error {
  2459. if e1 != 0 {
  2460. err = errnoErr(e1)
  2461. } else {
  2462. err = syscall.EINVAL
  2463. }
  2464. }
  2465. return
  2466. }
  2467. func Closesocket(s Handle) (err error) {
  2468. r1, _, e1 := syscall.Syscall(procclosesocket.Addr(), 1, uintptr(s), 0, 0)
  2469. if r1 == socket_error {
  2470. if e1 != 0 {
  2471. err = errnoErr(e1)
  2472. } else {
  2473. err = syscall.EINVAL
  2474. }
  2475. }
  2476. return
  2477. }
  2478. func AcceptEx(ls Handle, as Handle, buf *byte, rxdatalen uint32, laddrlen uint32, raddrlen uint32, recvd *uint32, overlapped *Overlapped) (err error) {
  2479. 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)
  2480. if r1 == 0 {
  2481. if e1 != 0 {
  2482. err = errnoErr(e1)
  2483. } else {
  2484. err = syscall.EINVAL
  2485. }
  2486. }
  2487. return
  2488. }
  2489. func GetAcceptExSockaddrs(buf *byte, rxdatalen uint32, laddrlen uint32, raddrlen uint32, lrsa **RawSockaddrAny, lrsalen *int32, rrsa **RawSockaddrAny, rrsalen *int32) {
  2490. 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)
  2491. return
  2492. }
  2493. func WSARecv(s Handle, bufs *WSABuf, bufcnt uint32, recvd *uint32, flags *uint32, overlapped *Overlapped, croutine *byte) (err error) {
  2494. 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)
  2495. if r1 == socket_error {
  2496. if e1 != 0 {
  2497. err = errnoErr(e1)
  2498. } else {
  2499. err = syscall.EINVAL
  2500. }
  2501. }
  2502. return
  2503. }
  2504. func WSASend(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, overlapped *Overlapped, croutine *byte) (err error) {
  2505. 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)
  2506. if r1 == socket_error {
  2507. if e1 != 0 {
  2508. err = errnoErr(e1)
  2509. } else {
  2510. err = syscall.EINVAL
  2511. }
  2512. }
  2513. return
  2514. }
  2515. func WSARecvFrom(s Handle, bufs *WSABuf, bufcnt uint32, recvd *uint32, flags *uint32, from *RawSockaddrAny, fromlen *int32, overlapped *Overlapped, croutine *byte) (err error) {
  2516. 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)))
  2517. if r1 == socket_error {
  2518. if e1 != 0 {
  2519. err = errnoErr(e1)
  2520. } else {
  2521. err = syscall.EINVAL
  2522. }
  2523. }
  2524. return
  2525. }
  2526. func WSASendTo(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, to *RawSockaddrAny, tolen int32, overlapped *Overlapped, croutine *byte) (err error) {
  2527. 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)))
  2528. if r1 == socket_error {
  2529. if e1 != 0 {
  2530. err = errnoErr(e1)
  2531. } else {
  2532. err = syscall.EINVAL
  2533. }
  2534. }
  2535. return
  2536. }
  2537. func GetHostByName(name string) (h *Hostent, err error) {
  2538. var _p0 *byte
  2539. _p0, err = syscall.BytePtrFromString(name)
  2540. if err != nil {
  2541. return
  2542. }
  2543. return _GetHostByName(_p0)
  2544. }
  2545. func _GetHostByName(name *byte) (h *Hostent, err error) {
  2546. r0, _, e1 := syscall.Syscall(procgethostbyname.Addr(), 1, uintptr(unsafe.Pointer(name)), 0, 0)
  2547. h = (*Hostent)(unsafe.Pointer(r0))
  2548. if h == nil {
  2549. if e1 != 0 {
  2550. err = errnoErr(e1)
  2551. } else {
  2552. err = syscall.EINVAL
  2553. }
  2554. }
  2555. return
  2556. }
  2557. func GetServByName(name string, proto string) (s *Servent, err error) {
  2558. var _p0 *byte
  2559. _p0, err = syscall.BytePtrFromString(name)
  2560. if err != nil {
  2561. return
  2562. }
  2563. var _p1 *byte
  2564. _p1, err = syscall.BytePtrFromString(proto)
  2565. if err != nil {
  2566. return
  2567. }
  2568. return _GetServByName(_p0, _p1)
  2569. }
  2570. func _GetServByName(name *byte, proto *byte) (s *Servent, err error) {
  2571. r0, _, e1 := syscall.Syscall(procgetservbyname.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(proto)), 0)
  2572. s = (*Servent)(unsafe.Pointer(r0))
  2573. if s == nil {
  2574. if e1 != 0 {
  2575. err = errnoErr(e1)
  2576. } else {
  2577. err = syscall.EINVAL
  2578. }
  2579. }
  2580. return
  2581. }
  2582. func Ntohs(netshort uint16) (u uint16) {
  2583. r0, _, _ := syscall.Syscall(procntohs.Addr(), 1, uintptr(netshort), 0, 0)
  2584. u = uint16(r0)
  2585. return
  2586. }
  2587. func GetProtoByName(name string) (p *Protoent, err error) {
  2588. var _p0 *byte
  2589. _p0, err = syscall.BytePtrFromString(name)
  2590. if err != nil {
  2591. return
  2592. }
  2593. return _GetProtoByName(_p0)
  2594. }
  2595. func _GetProtoByName(name *byte) (p *Protoent, err error) {
  2596. r0, _, e1 := syscall.Syscall(procgetprotobyname.Addr(), 1, uintptr(unsafe.Pointer(name)), 0, 0)
  2597. p = (*Protoent)(unsafe.Pointer(r0))
  2598. if p == nil {
  2599. if e1 != 0 {
  2600. err = errnoErr(e1)
  2601. } else {
  2602. err = syscall.EINVAL
  2603. }
  2604. }
  2605. return
  2606. }
  2607. func DnsQuery(name string, qtype uint16, options uint32, extra *byte, qrs **DNSRecord, pr *byte) (status error) {
  2608. var _p0 *uint16
  2609. _p0, status = syscall.UTF16PtrFromString(name)
  2610. if status != nil {
  2611. return
  2612. }
  2613. return _DnsQuery(_p0, qtype, options, extra, qrs, pr)
  2614. }
  2615. func _DnsQuery(name *uint16, qtype uint16, options uint32, extra *byte, qrs **DNSRecord, pr *byte) (status error) {
  2616. 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)))
  2617. if r0 != 0 {
  2618. status = syscall.Errno(r0)
  2619. }
  2620. return
  2621. }
  2622. func DnsRecordListFree(rl *DNSRecord, freetype uint32) {
  2623. syscall.Syscall(procDnsRecordListFree.Addr(), 2, uintptr(unsafe.Pointer(rl)), uintptr(freetype), 0)
  2624. return
  2625. }
  2626. func DnsNameCompare(name1 *uint16, name2 *uint16) (same bool) {
  2627. r0, _, _ := syscall.Syscall(procDnsNameCompare_W.Addr(), 2, uintptr(unsafe.Pointer(name1)), uintptr(unsafe.Pointer(name2)), 0)
  2628. same = r0 != 0
  2629. return
  2630. }
  2631. func GetAddrInfoW(nodename *uint16, servicename *uint16, hints *AddrinfoW, result **AddrinfoW) (sockerr error) {
  2632. r0, _, _ := syscall.Syscall6(procGetAddrInfoW.Addr(), 4, uintptr(unsafe.Pointer(nodename)), uintptr(unsafe.Pointer(servicename)), uintptr(unsafe.Pointer(hints)), uintptr(unsafe.Pointer(result)), 0, 0)
  2633. if r0 != 0 {
  2634. sockerr = syscall.Errno(r0)
  2635. }
  2636. return
  2637. }
  2638. func FreeAddrInfoW(addrinfo *AddrinfoW) {
  2639. syscall.Syscall(procFreeAddrInfoW.Addr(), 1, uintptr(unsafe.Pointer(addrinfo)), 0, 0)
  2640. return
  2641. }
  2642. func GetIfEntry(pIfRow *MibIfRow) (errcode error) {
  2643. r0, _, _ := syscall.Syscall(procGetIfEntry.Addr(), 1, uintptr(unsafe.Pointer(pIfRow)), 0, 0)
  2644. if r0 != 0 {
  2645. errcode = syscall.Errno(r0)
  2646. }
  2647. return
  2648. }
  2649. func GetAdaptersInfo(ai *IpAdapterInfo, ol *uint32) (errcode error) {
  2650. r0, _, _ := syscall.Syscall(procGetAdaptersInfo.Addr(), 2, uintptr(unsafe.Pointer(ai)), uintptr(unsafe.Pointer(ol)), 0)
  2651. if r0 != 0 {
  2652. errcode = syscall.Errno(r0)
  2653. }
  2654. return
  2655. }
  2656. func SetFileCompletionNotificationModes(handle Handle, flags uint8) (err error) {
  2657. r1, _, e1 := syscall.Syscall(procSetFileCompletionNotificationModes.Addr(), 2, uintptr(handle), uintptr(flags), 0)
  2658. if r1 == 0 {
  2659. if e1 != 0 {
  2660. err = errnoErr(e1)
  2661. } else {
  2662. err = syscall.EINVAL
  2663. }
  2664. }
  2665. return
  2666. }
  2667. func WSAEnumProtocols(protocols *int32, protocolBuffer *WSAProtocolInfo, bufferLength *uint32) (n int32, err error) {
  2668. r0, _, e1 := syscall.Syscall(procWSAEnumProtocolsW.Addr(), 3, uintptr(unsafe.Pointer(protocols)), uintptr(unsafe.Pointer(protocolBuffer)), uintptr(unsafe.Pointer(bufferLength)))
  2669. n = int32(r0)
  2670. if n == -1 {
  2671. if e1 != 0 {
  2672. err = errnoErr(e1)
  2673. } else {
  2674. err = syscall.EINVAL
  2675. }
  2676. }
  2677. return
  2678. }
  2679. func GetAdaptersAddresses(family uint32, flags uint32, reserved uintptr, adapterAddresses *IpAdapterAddresses, sizePointer *uint32) (errcode error) {
  2680. r0, _, _ := syscall.Syscall6(procGetAdaptersAddresses.Addr(), 5, uintptr(family), uintptr(flags), uintptr(reserved), uintptr(unsafe.Pointer(adapterAddresses)), uintptr(unsafe.Pointer(sizePointer)), 0)
  2681. if r0 != 0 {
  2682. errcode = syscall.Errno(r0)
  2683. }
  2684. return
  2685. }
  2686. func GetACP() (acp uint32) {
  2687. r0, _, _ := syscall.Syscall(procGetACP.Addr(), 0, 0, 0, 0)
  2688. acp = uint32(r0)
  2689. return
  2690. }
  2691. func MultiByteToWideChar(codePage uint32, dwFlags uint32, str *byte, nstr int32, wchar *uint16, nwchar int32) (nwrite int32, err error) {
  2692. r0, _, e1 := syscall.Syscall6(procMultiByteToWideChar.Addr(), 6, uintptr(codePage), uintptr(dwFlags), uintptr(unsafe.Pointer(str)), uintptr(nstr), uintptr(unsafe.Pointer(wchar)), uintptr(nwchar))
  2693. nwrite = int32(r0)
  2694. if nwrite == 0 {
  2695. if e1 != 0 {
  2696. err = errnoErr(e1)
  2697. } else {
  2698. err = syscall.EINVAL
  2699. }
  2700. }
  2701. return
  2702. }
  2703. func TranslateName(accName *uint16, accNameFormat uint32, desiredNameFormat uint32, translatedName *uint16, nSize *uint32) (err error) {
  2704. r1, _, e1 := syscall.Syscall6(procTranslateNameW.Addr(), 5, uintptr(unsafe.Pointer(accName)), uintptr(accNameFormat), uintptr(desiredNameFormat), uintptr(unsafe.Pointer(translatedName)), uintptr(unsafe.Pointer(nSize)), 0)
  2705. if r1&0xff == 0 {
  2706. if e1 != 0 {
  2707. err = errnoErr(e1)
  2708. } else {
  2709. err = syscall.EINVAL
  2710. }
  2711. }
  2712. return
  2713. }
  2714. func GetUserNameEx(nameFormat uint32, nameBuffre *uint16, nSize *uint32) (err error) {
  2715. r1, _, e1 := syscall.Syscall(procGetUserNameExW.Addr(), 3, uintptr(nameFormat), uintptr(unsafe.Pointer(nameBuffre)), uintptr(unsafe.Pointer(nSize)))
  2716. if r1&0xff == 0 {
  2717. if e1 != 0 {
  2718. err = errnoErr(e1)
  2719. } else {
  2720. err = syscall.EINVAL
  2721. }
  2722. }
  2723. return
  2724. }
  2725. func NetUserGetInfo(serverName *uint16, userName *uint16, level uint32, buf **byte) (neterr error) {
  2726. r0, _, _ := syscall.Syscall6(procNetUserGetInfo.Addr(), 4, uintptr(unsafe.Pointer(serverName)), uintptr(unsafe.Pointer(userName)), uintptr(level), uintptr(unsafe.Pointer(buf)), 0, 0)
  2727. if r0 != 0 {
  2728. neterr = syscall.Errno(r0)
  2729. }
  2730. return
  2731. }
  2732. func NetGetJoinInformation(server *uint16, name **uint16, bufType *uint32) (neterr error) {
  2733. r0, _, _ := syscall.Syscall(procNetGetJoinInformation.Addr(), 3, uintptr(unsafe.Pointer(server)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(bufType)))
  2734. if r0 != 0 {
  2735. neterr = syscall.Errno(r0)
  2736. }
  2737. return
  2738. }
  2739. func NetApiBufferFree(buf *byte) (neterr error) {
  2740. r0, _, _ := syscall.Syscall(procNetApiBufferFree.Addr(), 1, uintptr(unsafe.Pointer(buf)), 0, 0)
  2741. if r0 != 0 {
  2742. neterr = syscall.Errno(r0)
  2743. }
  2744. return
  2745. }
  2746. func LookupAccountSid(systemName *uint16, sid *SID, name *uint16, nameLen *uint32, refdDomainName *uint16, refdDomainNameLen *uint32, use *uint32) (err error) {
  2747. 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)
  2748. if r1 == 0 {
  2749. if e1 != 0 {
  2750. err = errnoErr(e1)
  2751. } else {
  2752. err = syscall.EINVAL
  2753. }
  2754. }
  2755. return
  2756. }
  2757. func LookupAccountName(systemName *uint16, accountName *uint16, sid *SID, sidLen *uint32, refdDomainName *uint16, refdDomainNameLen *uint32, use *uint32) (err error) {
  2758. 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)
  2759. if r1 == 0 {
  2760. if e1 != 0 {
  2761. err = errnoErr(e1)
  2762. } else {
  2763. err = syscall.EINVAL
  2764. }
  2765. }
  2766. return
  2767. }
  2768. func ConvertSidToStringSid(sid *SID, stringSid **uint16) (err error) {
  2769. r1, _, e1 := syscall.Syscall(procConvertSidToStringSidW.Addr(), 2, uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(stringSid)), 0)
  2770. if r1 == 0 {
  2771. if e1 != 0 {
  2772. err = errnoErr(e1)
  2773. } else {
  2774. err = syscall.EINVAL
  2775. }
  2776. }
  2777. return
  2778. }
  2779. func ConvertStringSidToSid(stringSid *uint16, sid **SID) (err error) {
  2780. r1, _, e1 := syscall.Syscall(procConvertStringSidToSidW.Addr(), 2, uintptr(unsafe.Pointer(stringSid)), uintptr(unsafe.Pointer(sid)), 0)
  2781. if r1 == 0 {
  2782. if e1 != 0 {
  2783. err = errnoErr(e1)
  2784. } else {
  2785. err = syscall.EINVAL
  2786. }
  2787. }
  2788. return
  2789. }
  2790. func GetLengthSid(sid *SID) (len uint32) {
  2791. r0, _, _ := syscall.Syscall(procGetLengthSid.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0)
  2792. len = uint32(r0)
  2793. return
  2794. }
  2795. func CopySid(destSidLen uint32, destSid *SID, srcSid *SID) (err error) {
  2796. r1, _, e1 := syscall.Syscall(procCopySid.Addr(), 3, uintptr(destSidLen), uintptr(unsafe.Pointer(destSid)), uintptr(unsafe.Pointer(srcSid)))
  2797. if r1 == 0 {
  2798. if e1 != 0 {
  2799. err = errnoErr(e1)
  2800. } else {
  2801. err = syscall.EINVAL
  2802. }
  2803. }
  2804. return
  2805. }
  2806. 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) {
  2807. 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)
  2808. if r1 == 0 {
  2809. if e1 != 0 {
  2810. err = errnoErr(e1)
  2811. } else {
  2812. err = syscall.EINVAL
  2813. }
  2814. }
  2815. return
  2816. }
  2817. func createWellKnownSid(sidType WELL_KNOWN_SID_TYPE, domainSid *SID, sid *SID, sizeSid *uint32) (err error) {
  2818. r1, _, e1 := syscall.Syscall6(procCreateWellKnownSid.Addr(), 4, uintptr(sidType), uintptr(unsafe.Pointer(domainSid)), uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(sizeSid)), 0, 0)
  2819. if r1 == 0 {
  2820. if e1 != 0 {
  2821. err = errnoErr(e1)
  2822. } else {
  2823. err = syscall.EINVAL
  2824. }
  2825. }
  2826. return
  2827. }
  2828. func isWellKnownSid(sid *SID, sidType WELL_KNOWN_SID_TYPE) (isWellKnown bool) {
  2829. r0, _, _ := syscall.Syscall(procIsWellKnownSid.Addr(), 2, uintptr(unsafe.Pointer(sid)), uintptr(sidType), 0)
  2830. isWellKnown = r0 != 0
  2831. return
  2832. }
  2833. func FreeSid(sid *SID) (err error) {
  2834. r1, _, e1 := syscall.Syscall(procFreeSid.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0)
  2835. if r1 != 0 {
  2836. if e1 != 0 {
  2837. err = errnoErr(e1)
  2838. } else {
  2839. err = syscall.EINVAL
  2840. }
  2841. }
  2842. return
  2843. }
  2844. func EqualSid(sid1 *SID, sid2 *SID) (isEqual bool) {
  2845. r0, _, _ := syscall.Syscall(procEqualSid.Addr(), 2, uintptr(unsafe.Pointer(sid1)), uintptr(unsafe.Pointer(sid2)), 0)
  2846. isEqual = r0 != 0
  2847. return
  2848. }
  2849. func getSidIdentifierAuthority(sid *SID) (authority *SidIdentifierAuthority) {
  2850. r0, _, _ := syscall.Syscall(procGetSidIdentifierAuthority.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0)
  2851. authority = (*SidIdentifierAuthority)(unsafe.Pointer(r0))
  2852. return
  2853. }
  2854. func getSidSubAuthorityCount(sid *SID) (count *uint8) {
  2855. r0, _, _ := syscall.Syscall(procGetSidSubAuthorityCount.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0)
  2856. count = (*uint8)(unsafe.Pointer(r0))
  2857. return
  2858. }
  2859. func getSidSubAuthority(sid *SID, index uint32) (subAuthority *uint32) {
  2860. r0, _, _ := syscall.Syscall(procGetSidSubAuthority.Addr(), 2, uintptr(unsafe.Pointer(sid)), uintptr(index), 0)
  2861. subAuthority = (*uint32)(unsafe.Pointer(r0))
  2862. return
  2863. }
  2864. func isValidSid(sid *SID) (isValid bool) {
  2865. r0, _, _ := syscall.Syscall(procIsValidSid.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0)
  2866. isValid = r0 != 0
  2867. return
  2868. }
  2869. func checkTokenMembership(tokenHandle Token, sidToCheck *SID, isMember *int32) (err error) {
  2870. r1, _, e1 := syscall.Syscall(procCheckTokenMembership.Addr(), 3, uintptr(tokenHandle), uintptr(unsafe.Pointer(sidToCheck)), uintptr(unsafe.Pointer(isMember)))
  2871. if r1 == 0 {
  2872. if e1 != 0 {
  2873. err = errnoErr(e1)
  2874. } else {
  2875. err = syscall.EINVAL
  2876. }
  2877. }
  2878. return
  2879. }
  2880. func OpenProcessToken(process Handle, access uint32, token *Token) (err error) {
  2881. r1, _, e1 := syscall.Syscall(procOpenProcessToken.Addr(), 3, uintptr(process), uintptr(access), uintptr(unsafe.Pointer(token)))
  2882. if r1 == 0 {
  2883. if e1 != 0 {
  2884. err = errnoErr(e1)
  2885. } else {
  2886. err = syscall.EINVAL
  2887. }
  2888. }
  2889. return
  2890. }
  2891. func OpenThreadToken(thread Handle, access uint32, openAsSelf bool, token *Token) (err error) {
  2892. var _p0 uint32
  2893. if openAsSelf {
  2894. _p0 = 1
  2895. } else {
  2896. _p0 = 0
  2897. }
  2898. r1, _, e1 := syscall.Syscall6(procOpenThreadToken.Addr(), 4, uintptr(thread), uintptr(access), uintptr(_p0), uintptr(unsafe.Pointer(token)), 0, 0)
  2899. if r1 == 0 {
  2900. if e1 != 0 {
  2901. err = errnoErr(e1)
  2902. } else {
  2903. err = syscall.EINVAL
  2904. }
  2905. }
  2906. return
  2907. }
  2908. func ImpersonateSelf(impersonationlevel uint32) (err error) {
  2909. r1, _, e1 := syscall.Syscall(procImpersonateSelf.Addr(), 1, uintptr(impersonationlevel), 0, 0)
  2910. if r1 == 0 {
  2911. if e1 != 0 {
  2912. err = errnoErr(e1)
  2913. } else {
  2914. err = syscall.EINVAL
  2915. }
  2916. }
  2917. return
  2918. }
  2919. func RevertToSelf() (err error) {
  2920. r1, _, e1 := syscall.Syscall(procRevertToSelf.Addr(), 0, 0, 0, 0)
  2921. if r1 == 0 {
  2922. if e1 != 0 {
  2923. err = errnoErr(e1)
  2924. } else {
  2925. err = syscall.EINVAL
  2926. }
  2927. }
  2928. return
  2929. }
  2930. func SetThreadToken(thread *Handle, token Token) (err error) {
  2931. r1, _, e1 := syscall.Syscall(procSetThreadToken.Addr(), 2, uintptr(unsafe.Pointer(thread)), uintptr(token), 0)
  2932. if r1 == 0 {
  2933. if e1 != 0 {
  2934. err = errnoErr(e1)
  2935. } else {
  2936. err = syscall.EINVAL
  2937. }
  2938. }
  2939. return
  2940. }
  2941. func LookupPrivilegeValue(systemname *uint16, name *uint16, luid *LUID) (err error) {
  2942. r1, _, e1 := syscall.Syscall(procLookupPrivilegeValueW.Addr(), 3, uintptr(unsafe.Pointer(systemname)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(luid)))
  2943. if r1 == 0 {
  2944. if e1 != 0 {
  2945. err = errnoErr(e1)
  2946. } else {
  2947. err = syscall.EINVAL
  2948. }
  2949. }
  2950. return
  2951. }
  2952. func AdjustTokenPrivileges(token Token, disableAllPrivileges bool, newstate *Tokenprivileges, buflen uint32, prevstate *Tokenprivileges, returnlen *uint32) (err error) {
  2953. var _p0 uint32
  2954. if disableAllPrivileges {
  2955. _p0 = 1
  2956. } else {
  2957. _p0 = 0
  2958. }
  2959. r1, _, e1 := syscall.Syscall6(procAdjustTokenPrivileges.Addr(), 6, uintptr(token), uintptr(_p0), uintptr(unsafe.Pointer(newstate)), uintptr(buflen), uintptr(unsafe.Pointer(prevstate)), uintptr(unsafe.Pointer(returnlen)))
  2960. if r1 == 0 {
  2961. if e1 != 0 {
  2962. err = errnoErr(e1)
  2963. } else {
  2964. err = syscall.EINVAL
  2965. }
  2966. }
  2967. return
  2968. }
  2969. func AdjustTokenGroups(token Token, resetToDefault bool, newstate *Tokengroups, buflen uint32, prevstate *Tokengroups, returnlen *uint32) (err error) {
  2970. var _p0 uint32
  2971. if resetToDefault {
  2972. _p0 = 1
  2973. } else {
  2974. _p0 = 0
  2975. }
  2976. r1, _, e1 := syscall.Syscall6(procAdjustTokenGroups.Addr(), 6, uintptr(token), uintptr(_p0), uintptr(unsafe.Pointer(newstate)), uintptr(buflen), uintptr(unsafe.Pointer(prevstate)), uintptr(unsafe.Pointer(returnlen)))
  2977. if r1 == 0 {
  2978. if e1 != 0 {
  2979. err = errnoErr(e1)
  2980. } else {
  2981. err = syscall.EINVAL
  2982. }
  2983. }
  2984. return
  2985. }
  2986. func GetTokenInformation(token Token, infoClass uint32, info *byte, infoLen uint32, returnedLen *uint32) (err error) {
  2987. r1, _, e1 := syscall.Syscall6(procGetTokenInformation.Addr(), 5, uintptr(token), uintptr(infoClass), uintptr(unsafe.Pointer(info)), uintptr(infoLen), uintptr(unsafe.Pointer(returnedLen)), 0)
  2988. if r1 == 0 {
  2989. if e1 != 0 {
  2990. err = errnoErr(e1)
  2991. } else {
  2992. err = syscall.EINVAL
  2993. }
  2994. }
  2995. return
  2996. }
  2997. func SetTokenInformation(token Token, infoClass uint32, info *byte, infoLen uint32) (err error) {
  2998. r1, _, e1 := syscall.Syscall6(procSetTokenInformation.Addr(), 4, uintptr(token), uintptr(infoClass), uintptr(unsafe.Pointer(info)), uintptr(infoLen), 0, 0)
  2999. if r1 == 0 {
  3000. if e1 != 0 {
  3001. err = errnoErr(e1)
  3002. } else {
  3003. err = syscall.EINVAL
  3004. }
  3005. }
  3006. return
  3007. }
  3008. func DuplicateTokenEx(existingToken Token, desiredAccess uint32, tokenAttributes *SecurityAttributes, impersonationLevel uint32, tokenType uint32, newToken *Token) (err error) {
  3009. r1, _, e1 := syscall.Syscall6(procDuplicateTokenEx.Addr(), 6, uintptr(existingToken), uintptr(desiredAccess), uintptr(unsafe.Pointer(tokenAttributes)), uintptr(impersonationLevel), uintptr(tokenType), uintptr(unsafe.Pointer(newToken)))
  3010. if r1 == 0 {
  3011. if e1 != 0 {
  3012. err = errnoErr(e1)
  3013. } else {
  3014. err = syscall.EINVAL
  3015. }
  3016. }
  3017. return
  3018. }
  3019. func GetUserProfileDirectory(t Token, dir *uint16, dirLen *uint32) (err error) {
  3020. r1, _, e1 := syscall.Syscall(procGetUserProfileDirectoryW.Addr(), 3, uintptr(t), uintptr(unsafe.Pointer(dir)), uintptr(unsafe.Pointer(dirLen)))
  3021. if r1 == 0 {
  3022. if e1 != 0 {
  3023. err = errnoErr(e1)
  3024. } else {
  3025. err = syscall.EINVAL
  3026. }
  3027. }
  3028. return
  3029. }
  3030. func getSystemDirectory(dir *uint16, dirLen uint32) (len uint32, err error) {
  3031. r0, _, e1 := syscall.Syscall(procGetSystemDirectoryW.Addr(), 2, uintptr(unsafe.Pointer(dir)), uintptr(dirLen), 0)
  3032. len = uint32(r0)
  3033. if len == 0 {
  3034. if e1 != 0 {
  3035. err = errnoErr(e1)
  3036. } else {
  3037. err = syscall.EINVAL
  3038. }
  3039. }
  3040. return
  3041. }
  3042. func WTSQueryUserToken(session uint32, token *Token) (err error) {
  3043. r1, _, e1 := syscall.Syscall(procWTSQueryUserToken.Addr(), 2, uintptr(session), uintptr(unsafe.Pointer(token)), 0)
  3044. if r1 == 0 {
  3045. if e1 != 0 {
  3046. err = errnoErr(e1)
  3047. } else {
  3048. err = syscall.EINVAL
  3049. }
  3050. }
  3051. return
  3052. }
  3053. func WTSEnumerateSessions(handle Handle, reserved uint32, version uint32, sessions **WTS_SESSION_INFO, count *uint32) (err error) {
  3054. r1, _, e1 := syscall.Syscall6(procWTSEnumerateSessionsW.Addr(), 5, uintptr(handle), uintptr(reserved), uintptr(version), uintptr(unsafe.Pointer(sessions)), uintptr(unsafe.Pointer(count)), 0)
  3055. if r1 == 0 {
  3056. if e1 != 0 {
  3057. err = errnoErr(e1)
  3058. } else {
  3059. err = syscall.EINVAL
  3060. }
  3061. }
  3062. return
  3063. }
  3064. func WTSFreeMemory(ptr uintptr) {
  3065. syscall.Syscall(procWTSFreeMemory.Addr(), 1, uintptr(ptr), 0, 0)
  3066. return
  3067. }