zsyscall_windows.go 160 KB

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