zsyscall_windows.go 73 KB

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