zsyscall_windows.go 106 KB

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