zsyscall_windows.go 88 KB

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