zsyscall_windows.go 134 KB

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