You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

zsyscall_windows.go 112KB

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