A lightweight mechanism to provide an *instant kickstart* to a Go web server instance upon changing any Go source files under the project directory (and its subdirectories).

zsyscall_windows.go 75KB

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