zsyscall_windows.go 91 KB

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