zsyscall_windows.go 73 KB

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