zsyscall_windows.go 156 KB

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