zsyscall_windows.go 109 KB

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