zsyscall_windows.go 91 KB

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