zsyscall_windows.go 100 KB

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