zsyscall_windows.go 89 KB

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