zsyscall_windows.go 110 KB

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