zsyscall_windows.go 107 KB

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