zsyscall_windows.go 135 KB

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