zsyscall_windows.go 96 KB

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