zsyscall_windows.go 103 KB

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