zsyscall_windows.go 155 KB

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