zsyscall_windows.go 108 KB

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