github.com/tomatome/win@v0.3.1/psapi.go (about)

     1  // This file was automatically generated by https://github.com/kbinani/win/blob/generator/internal/cmd/gen/gen.go
     2  // go run internal/cmd/gen/gen.go
     3  
     4  // +build windows
     5  
     6  package win
     7  
     8  import (
     9  	"syscall"
    10  	"unsafe"
    11  )
    12  
    13  var (
    14  	// Library
    15  	libpsapi uintptr
    16  
    17  	// Functions
    18  	emptyWorkingSet             uintptr
    19  	enumDeviceDrivers           uintptr
    20  	enumPageFiles               uintptr
    21  	enumProcessModules          uintptr
    22  	enumProcessModulesEx        uintptr
    23  	enumProcesses               uintptr
    24  	getDeviceDriverBaseName     uintptr
    25  	getDeviceDriverFileName     uintptr
    26  	getMappedFileName           uintptr
    27  	getModuleBaseName           uintptr
    28  	getModuleFileNameEx         uintptr
    29  	getModuleInformation        uintptr
    30  	getPerformanceInfo          uintptr
    31  	getProcessImageFileName     uintptr
    32  	getProcessMemoryInfo        uintptr
    33  	getWsChanges                uintptr
    34  	getWsChangesEx              uintptr
    35  	initializeProcessForWsWatch uintptr
    36  	queryWorkingSet             uintptr
    37  	queryWorkingSetEx           uintptr
    38  )
    39  
    40  func init() {
    41  	// Library
    42  	libpsapi = doLoadLibrary("psapi.dll")
    43  
    44  	// Functions
    45  	emptyWorkingSet = doGetProcAddress(libpsapi, "EmptyWorkingSet")
    46  	enumDeviceDrivers = doGetProcAddress(libpsapi, "EnumDeviceDrivers")
    47  	enumPageFiles = doGetProcAddress(libpsapi, "EnumPageFilesW")
    48  	enumProcessModules = doGetProcAddress(libpsapi, "EnumProcessModules")
    49  	enumProcessModulesEx = doGetProcAddress(libpsapi, "EnumProcessModulesEx")
    50  	enumProcesses = doGetProcAddress(libpsapi, "EnumProcesses")
    51  	getDeviceDriverBaseName = doGetProcAddress(libpsapi, "GetDeviceDriverBaseNameW")
    52  	getDeviceDriverFileName = doGetProcAddress(libpsapi, "GetDeviceDriverFileNameW")
    53  	getMappedFileName = doGetProcAddress(libpsapi, "GetMappedFileNameW")
    54  	getModuleBaseName = doGetProcAddress(libpsapi, "GetModuleBaseNameW")
    55  	getModuleFileNameEx = doGetProcAddress(libpsapi, "GetModuleFileNameExW")
    56  	getModuleInformation = doGetProcAddress(libpsapi, "GetModuleInformation")
    57  	getPerformanceInfo = doGetProcAddress(libpsapi, "GetPerformanceInfo")
    58  	getProcessImageFileName = doGetProcAddress(libpsapi, "GetProcessImageFileNameW")
    59  	getProcessMemoryInfo = doGetProcAddress(libpsapi, "GetProcessMemoryInfo")
    60  	getWsChanges = doGetProcAddress(libpsapi, "GetWsChanges")
    61  	getWsChangesEx = doGetProcAddress(libpsapi, "GetWsChangesEx")
    62  	initializeProcessForWsWatch = doGetProcAddress(libpsapi, "InitializeProcessForWsWatch")
    63  	queryWorkingSet = doGetProcAddress(libpsapi, "QueryWorkingSet")
    64  	queryWorkingSetEx = doGetProcAddress(libpsapi, "QueryWorkingSetEx")
    65  }
    66  
    67  func EmptyWorkingSet(hProcess HANDLE) bool {
    68  	ret1 := syscall3(emptyWorkingSet, 1,
    69  		uintptr(hProcess),
    70  		0,
    71  		0)
    72  	return ret1 != 0
    73  }
    74  
    75  func EnumDeviceDrivers(lpImageBase *LPVOID, cb DWORD, lpcbNeeded *uint32) bool {
    76  	ret1 := syscall3(enumDeviceDrivers, 3,
    77  		uintptr(unsafe.Pointer(lpImageBase)),
    78  		uintptr(cb),
    79  		uintptr(unsafe.Pointer(lpcbNeeded)))
    80  	return ret1 != 0
    81  }
    82  
    83  func EnumPageFiles(pCallBackRoutine PENUM_PAGE_FILE_CALLBACK, pContext LPVOID) bool {
    84  	pCallBackRoutineCallback := syscall.NewCallback(func(pContextRawArg LPVOID, pPageFileInfoRawArg PENUM_PAGE_FILE_INFORMATION, lpFilenameRawArg /*const*/ *uint16) uintptr {
    85  		lpFilename := stringFromUnicode16(lpFilenameRawArg)
    86  		ret := pCallBackRoutine(pContextRawArg, pPageFileInfoRawArg, lpFilename)
    87  		return uintptr(ret)
    88  	})
    89  	ret1 := syscall3(enumPageFiles, 2,
    90  		pCallBackRoutineCallback,
    91  		uintptr(unsafe.Pointer(pContext)),
    92  		0)
    93  	return ret1 != 0
    94  }
    95  
    96  func EnumProcessModules(hProcess HANDLE, lphModule *HMODULE, cb DWORD, lpcbNeeded *uint32) bool {
    97  	ret1 := syscall6(enumProcessModules, 4,
    98  		uintptr(hProcess),
    99  		uintptr(unsafe.Pointer(lphModule)),
   100  		uintptr(cb),
   101  		uintptr(unsafe.Pointer(lpcbNeeded)),
   102  		0,
   103  		0)
   104  	return ret1 != 0
   105  }
   106  
   107  func EnumProcessModulesEx(hProcess HANDLE, lphModule *HMODULE, cb DWORD, lpcbNeeded *uint32, dwFilterFlag DWORD) bool {
   108  	ret1 := syscall6(enumProcessModulesEx, 5,
   109  		uintptr(hProcess),
   110  		uintptr(unsafe.Pointer(lphModule)),
   111  		uintptr(cb),
   112  		uintptr(unsafe.Pointer(lpcbNeeded)),
   113  		uintptr(dwFilterFlag),
   114  		0)
   115  	return ret1 != 0
   116  }
   117  
   118  func EnumProcesses(lpidProcess *uint32, cb DWORD, cbNeeded *uint32) bool {
   119  	ret1 := syscall3(enumProcesses, 3,
   120  		uintptr(unsafe.Pointer(lpidProcess)),
   121  		uintptr(cb),
   122  		uintptr(unsafe.Pointer(cbNeeded)))
   123  	return ret1 != 0
   124  }
   125  
   126  func GetDeviceDriverBaseName(imageBase LPVOID, lpBaseName LPWSTR, nSize DWORD) DWORD {
   127  	ret1 := syscall3(getDeviceDriverBaseName, 3,
   128  		uintptr(unsafe.Pointer(imageBase)),
   129  		uintptr(unsafe.Pointer(lpBaseName)),
   130  		uintptr(nSize))
   131  	return DWORD(ret1)
   132  }
   133  
   134  func GetDeviceDriverFileName(imageBase LPVOID, lpFilename LPWSTR, nSize DWORD) DWORD {
   135  	ret1 := syscall3(getDeviceDriverFileName, 3,
   136  		uintptr(unsafe.Pointer(imageBase)),
   137  		uintptr(unsafe.Pointer(lpFilename)),
   138  		uintptr(nSize))
   139  	return DWORD(ret1)
   140  }
   141  
   142  func GetMappedFileName(hProcess HANDLE, lpv LPVOID, lpFilename LPWSTR, nSize DWORD) DWORD {
   143  	ret1 := syscall6(getMappedFileName, 4,
   144  		uintptr(hProcess),
   145  		uintptr(unsafe.Pointer(lpv)),
   146  		uintptr(unsafe.Pointer(lpFilename)),
   147  		uintptr(nSize),
   148  		0,
   149  		0)
   150  	return DWORD(ret1)
   151  }
   152  
   153  func GetModuleBaseName(hProcess HANDLE, hModule HMODULE, lpBaseName LPWSTR, nSize DWORD) DWORD {
   154  	ret1 := syscall6(getModuleBaseName, 4,
   155  		uintptr(hProcess),
   156  		uintptr(hModule),
   157  		uintptr(unsafe.Pointer(lpBaseName)),
   158  		uintptr(nSize),
   159  		0,
   160  		0)
   161  	return DWORD(ret1)
   162  }
   163  
   164  func GetModuleFileNameEx(hProcess HANDLE, hModule HMODULE, lpFilename LPWSTR, nSize DWORD) DWORD {
   165  	ret1 := syscall6(getModuleFileNameEx, 4,
   166  		uintptr(hProcess),
   167  		uintptr(hModule),
   168  		uintptr(unsafe.Pointer(lpFilename)),
   169  		uintptr(nSize),
   170  		0,
   171  		0)
   172  	return DWORD(ret1)
   173  }
   174  
   175  func GetModuleInformation(hProcess HANDLE, hModule HMODULE, lpmodinfo *MODULEINFO, cb DWORD) bool {
   176  	ret1 := syscall6(getModuleInformation, 4,
   177  		uintptr(hProcess),
   178  		uintptr(hModule),
   179  		uintptr(unsafe.Pointer(lpmodinfo)),
   180  		uintptr(cb),
   181  		0,
   182  		0)
   183  	return ret1 != 0
   184  }
   185  
   186  func GetPerformanceInfo(pPerformanceInformation PPERFORMACE_INFORMATION, cb DWORD) bool {
   187  	ret1 := syscall3(getPerformanceInfo, 2,
   188  		uintptr(unsafe.Pointer(pPerformanceInformation)),
   189  		uintptr(cb),
   190  		0)
   191  	return ret1 != 0
   192  }
   193  
   194  func GetProcessImageFileName(hProcess HANDLE, lpImageFileName LPWSTR, nSize DWORD) DWORD {
   195  	ret1 := syscall3(getProcessImageFileName, 3,
   196  		uintptr(hProcess),
   197  		uintptr(unsafe.Pointer(lpImageFileName)),
   198  		uintptr(nSize))
   199  	return DWORD(ret1)
   200  }
   201  
   202  func GetProcessMemoryInfo(process HANDLE, ppsmemCounters PPROCESS_MEMORY_COUNTERS, cb DWORD) bool {
   203  	ret1 := syscall3(getProcessMemoryInfo, 3,
   204  		uintptr(process),
   205  		uintptr(unsafe.Pointer(ppsmemCounters)),
   206  		uintptr(cb))
   207  	return ret1 != 0
   208  }
   209  
   210  func GetWsChanges(hProcess HANDLE, lpWatchInfo PPSAPI_WS_WATCH_INFORMATION, cb DWORD) bool {
   211  	ret1 := syscall3(getWsChanges, 3,
   212  		uintptr(hProcess),
   213  		uintptr(unsafe.Pointer(lpWatchInfo)),
   214  		uintptr(cb))
   215  	return ret1 != 0
   216  }
   217  
   218  func GetWsChangesEx(hProcess HANDLE, lpWatchInfoEx PPSAPI_WS_WATCH_INFORMATION_EX, cb DWORD) bool {
   219  	ret1 := syscall3(getWsChangesEx, 3,
   220  		uintptr(hProcess),
   221  		uintptr(unsafe.Pointer(lpWatchInfoEx)),
   222  		uintptr(cb))
   223  	return ret1 != 0
   224  }
   225  
   226  func InitializeProcessForWsWatch(hProcess HANDLE) bool {
   227  	ret1 := syscall3(initializeProcessForWsWatch, 1,
   228  		uintptr(hProcess),
   229  		0,
   230  		0)
   231  	return ret1 != 0
   232  }
   233  
   234  func QueryWorkingSet(hProcess HANDLE, pv uintptr, cb DWORD) bool {
   235  	ret1 := syscall3(queryWorkingSet, 3,
   236  		uintptr(hProcess),
   237  		pv,
   238  		uintptr(cb))
   239  	return ret1 != 0
   240  }
   241  
   242  func QueryWorkingSetEx(hProcess HANDLE, pv uintptr, cb DWORD) bool {
   243  	ret1 := syscall3(queryWorkingSetEx, 3,
   244  		uintptr(hProcess),
   245  		pv,
   246  		uintptr(cb))
   247  	return ret1 != 0
   248  }