zsyscall_windows.go 103 KB

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