zsyscall_windows.go 78 KB

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