zsyscall_windows.go 104 KB

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