zsyscall_windows.go 135 KB

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