zsyscall_windows.go 114 KB

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