zsyscall_windows.go 114 KB

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