zsyscall_windows.go 90 KB

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