zsyscall_windows.go 133 KB

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