zsyscall_windows.go 105 KB

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