You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

zsyscall_windows.go 130KB

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