zsyscall_windows.go 89 KB

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