zsyscall_windows.go 139 KB

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