zsyscall_windows.go 109 KB

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