zsyscall_windows.go 134 KB

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