zsyscall_windows.go 109 KB

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