zsyscall_windows.go 128 KB

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