zsyscall_windows.go 106 KB

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