zsyscall_windows.go 99 KB

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