zsyscall_windows.go 133 KB

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