zsyscall_windows.go 140 KB

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