zsyscall_windows.go 128 KB

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