zsyscall_windows.go 106 KB

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