package windows
import "github.com/cloudfoundry/gosigar/sys/windows"
Package windows contains various Windows system call.
Index ¶
- Constants
- func CreateToolhelp32Snapshot(flags, pid uint32) (syscall.Handle, error)
- func EnableTokenPrivileges(token syscall.Token, privileges ...string) error
- func EnumProcesses() ([]uint32, error)
- func FiletimeToDuration(ft *syscall.Filetime) time.Duration
- func GetDiskFreeSpaceEx(directoryName string) (freeBytesAvailable, totalNumberOfBytes, totalNumberOfFreeBytes uint64, err error)
- func GetLogicalDriveStrings() ([]string, error)
- func GetProcessImageFileName(handle syscall.Handle) (string, error)
- func GetSystemTimes() (idle, kernel, user time.Duration, err error)
- func GetTokenPrivileges(token syscall.Token) (map[string]Privilege, error)
- func LookupPrivilegeName(systemName string, luid int64) (string, error)
- type DebugInfo
- type DriveType
- type MemoryStatusEx
- type Privilege
- type ProcessBasicInformation
- type ProcessEntry32
- func Process32First(handle syscall.Handle) (ProcessEntry32, error)
- func Process32Next(handle syscall.Handle) (ProcessEntry32, error)
- func (p ProcessEntry32) ExeFile() string
- func (p ProcessEntry32) String() string
- type ProcessMemoryCountersEx
- type SystemProcessorPerformanceInformation
- func NtQuerySystemProcessorPerformanceInformation() ([]SystemProcessorPerformanceInformation, error)
- type User
- type Version
Constants ¶
Process-specific access rights. Others are declared in the syscall package. https://msdn.microsoft.com/en-us/library/windows/desktop/ms684880(v=vs.85).aspx
const ( TH32CS_INHERIT uint32 = 0x80000000 // Indicates that the snapshot handle is to be inheritable. TH32CS_SNAPHEAPLIST uint32 = 0x00000001 // Includes all heaps of the process specified in th32ProcessID in the snapshot. TH32CS_SNAPMODULE uint32 = 0x00000008 // Includes all modules of the process specified in th32ProcessID in the snapshot. TH32CS_SNAPMODULE32 uint32 = 0x00000010 // Includes all 32-bit modules of the process specified in th32ProcessID in the snapshot when called from a 64-bit process. TH32CS_SNAPPROCESS uint32 = 0x00000002 // Includes all processes in the system in the snapshot. TH32CS_SNAPTHREAD uint32 = 0x00000004 // Includes all threads in the system in the snapshot. )
Flags that can be used with CreateToolhelp32Snapshot.
Errors returned by AdjustTokenPrivileges.
const MAX_PATH = 260
MAX_PATH is the maximum length for a path in Windows. https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx
const ( // SeDebugPrivilege is the name of the privilege used to debug programs. SeDebugPrivilege = "SeDebugPrivilege" )
Functions ¶
func CreateToolhelp32Snapshot ¶
CreateToolhelp32Snapshot takes a snapshot of the specified processes, as well as the heaps, modules, and threads used by these processes. https://msdn.microsoft.com/en-us/library/windows/desktop/ms682489(v=vs.85).aspx
func EnableTokenPrivileges ¶
EnableTokenPrivileges enables the specified privileges in the given Token. The token must have TOKEN_ADJUST_PRIVILEGES access. If the token does not already contain the privilege it cannot be enabled.
func EnumProcesses ¶
EnumProcesses retrieves the process identifier for each process object in the system. This function can return a max of 65536 PIDs. If there are more processes than that then this will not return them all. https://msdn.microsoft.com/en-us/library/windows/desktop/ms682629(v=vs.85).aspx
func FiletimeToDuration ¶
FiletimeToDuration converts a Filetime to a time.Duration. Do not use this method to convert a Filetime to an actual clock time, for that use Filetime.Nanosecond().
func GetDiskFreeSpaceEx ¶
func GetDiskFreeSpaceEx(directoryName string) (freeBytesAvailable, totalNumberOfBytes, totalNumberOfFreeBytes uint64, err error)
GetDiskFreeSpaceEx retrieves information about the amount of space that is available on a disk volume, which is the total amount of space, the total amount of free space, and the total amount of free space available to the user that is associated with the calling thread. https://msdn.microsoft.com/en-us/library/windows/desktop/aa364937(v=vs.85).aspx
func GetLogicalDriveStrings ¶
GetLogicalDriveStrings returns a list of drives in the system. https://msdn.microsoft.com/en-us/library/windows/desktop/aa364975(v=vs.85).aspx
func GetProcessImageFileName ¶
GetProcessImageFileName Retrieves the name of the executable file for the specified process. https://msdn.microsoft.com/en-us/library/windows/desktop/ms683217(v=vs.85).aspx
func GetSystemTimes ¶
GetSystemTimes retrieves system timing information. On a multiprocessor system, the values returned are the sum of the designated times across all processors. The returned kernel time does not include the system idle time. https://msdn.microsoft.com/en-us/library/windows/desktop/ms724400(v=vs.85).aspx
func GetTokenPrivileges ¶
GetTokenPrivileges returns a list of privileges associated with a token. The provided token must have at a minimum TOKEN_QUERY access. This is a wrapper around the GetTokenInformation function. https://msdn.microsoft.com/en-us/library/windows/desktop/aa446671(v=vs.85).aspx
func LookupPrivilegeName ¶
LookupPrivilegeName looks up a privilege name given a LUID value.
Types ¶
type DebugInfo ¶
type DebugInfo struct { OSVersion Version // OS version info. Arch string // Architecture of the machine. NumCPU int // Number of CPUs. User User // User that this process is running as. ProcessPrivs map[string]Privilege // Privileges held by the process. }
DebugInfo contains general debug info about the current process.
func GetDebugInfo ¶
GetDebugInfo returns general debug info about the current process.
func (DebugInfo) String ¶
type DriveType ¶
type DriveType uint32
DriveType represents a type of drive (removable, fixed, CD-ROM, RAM disk, or network drive).
const ( DRIVE_UNKNOWN DriveType = iota DRIVE_NO_ROOT_DIR DRIVE_REMOVABLE DRIVE_FIXED DRIVE_REMOTE DRIVE_CDROM DRIVE_RAMDISK )
Drive types as returned by GetDriveType. https://msdn.microsoft.com/en-us/library/windows/desktop/aa364939(v=vs.85).aspx
func GetDriveType ¶
GetDriveType Determines whether a disk drive is a removable, fixed, CD-ROM, RAM disk, or network drive. A trailing backslash is required on the rootPathName. https://msdn.microsoft.com/en-us/library/windows/desktop/aa364939
func (DriveType) String ¶
type MemoryStatusEx ¶
type MemoryStatusEx struct { MemoryLoad uint32 TotalPhys uint64 AvailPhys uint64 TotalPageFile uint64 AvailPageFile uint64 TotalVirtual uint64 AvailVirtual uint64 AvailExtendedVirtual uint64 // contains filtered or unexported fields }
MemoryStatusEx is an equivalent representation of MEMORYSTATUSEX in the Windows API. It contains information about the current state of both physical and virtual memory, including extended memory. https://msdn.microsoft.com/en-us/library/windows/desktop/aa366770
func GlobalMemoryStatusEx ¶
func GlobalMemoryStatusEx() (MemoryStatusEx, error)
GlobalMemoryStatusEx retrieves information about the system's current usage of both physical and virtual memory. https://msdn.microsoft.com/en-us/library/windows/desktop/aa366589(v=vs.85).aspx
type Privilege ¶
type Privilege struct { LUID int64 `json:"-"` // Locally unique identifier (guaranteed only until the system is restarted). Name string `json:"-"` EnabledByDefault bool `json:"enabled_by_default,omitempty"` Enabled bool `json:"enabled"` Removed bool `json:"removed,omitempty"` Used bool `json:"used,omitempty"` }
Privilege contains information about a single privilege associated with a Token.
func (Privilege) String ¶
type ProcessBasicInformation ¶
type ProcessBasicInformation struct { ExitStatus uint PebBaseAddress uintptr AffinityMask uint BasePriority uint UniqueProcessID uint InheritedFromUniqueProcessID uint }
ProcessBasicInformation is an equivalent representation of PROCESS_BASIC_INFORMATION in the Windows API. https://msdn.microsoft.com/en-us/library/windows/desktop/ms684280(v=vs.85).aspx
func NtQueryProcessBasicInformation ¶
func NtQueryProcessBasicInformation(handle syscall.Handle) (ProcessBasicInformation, error)
NtQueryProcessBasicInformation queries basic information about the process associated with the given handle (provided by OpenProcess). It uses the NtQueryInformationProcess function to collect the data. https://msdn.microsoft.com/en-us/library/windows/desktop/ms684280(v=vs.85).aspx
type ProcessEntry32 ¶
type ProcessEntry32 struct { CntUsage uint32 ProcessID uint32 DefaultHeapID uintptr ModuleID uint32 CntThreads uint32 ParentProcessID uint32 PriorityClassBase int32 Flags uint32 // contains filtered or unexported fields }
ProcessEntry32 is an equivalent representation of PROCESSENTRY32 in the Windows API. It contains a process's information. Do not modify or reorder. https://msdn.microsoft.com/en-us/library/windows/desktop/ms684839(v=vs.85).aspx
func Process32First ¶
func Process32First(handle syscall.Handle) (ProcessEntry32, error)
Process32First retrieves information about the first process encountered in a system snapshot. https://msdn.microsoft.com/en-us/library/windows/desktop/ms684834
func Process32Next ¶
func Process32Next(handle syscall.Handle) (ProcessEntry32, error)
Process32Next retrieves information about the next process recorded in a system snapshot. When there are no more processes to iterate then syscall.ERROR_NO_MORE_FILES is returned (use errors.Cause() to unwrap). https://msdn.microsoft.com/en-us/library/windows/desktop/ms684836
func (ProcessEntry32) ExeFile ¶
func (p ProcessEntry32) ExeFile() string
ExeFile returns the name of the executable file for the process. It does not contain the full path.
func (ProcessEntry32) String ¶
func (p ProcessEntry32) String() string
type ProcessMemoryCountersEx ¶
type ProcessMemoryCountersEx struct { PageFaultCount uint32 PeakWorkingSetSize uintptr WorkingSetSize uintptr QuotaPeakPagedPoolUsage uintptr QuotaPagedPoolUsage uintptr QuotaPeakNonPagedPoolUsage uintptr QuotaNonPagedPoolUsage uintptr PagefileUsage uintptr PeakPagefileUsage uintptr PrivateUsage uintptr // contains filtered or unexported fields }
ProcessMemoryCountersEx is an equivalent representation of PROCESS_MEMORY_COUNTERS_EX in the Windows API. https://msdn.microsoft.com/en-us/library/windows/desktop/ms684874(v=vs.85).aspx
func GetProcessMemoryInfo ¶
func GetProcessMemoryInfo(handle syscall.Handle) (ProcessMemoryCountersEx, error)
GetProcessMemoryInfo retrieves information about the memory usage of the specified process. https://msdn.microsoft.com/en-us/library/windows/desktop/ms683219(v=vs.85).aspx
type SystemProcessorPerformanceInformation ¶
type SystemProcessorPerformanceInformation struct { IdleTime time.Duration // Amount of time spent idle. KernelTime time.Duration // Kernel time does NOT include time spent in idle. UserTime time.Duration // Amount of time spent executing in user mode. }
SystemProcessorPerformanceInformation contains CPU performance information for a single CPU.
func NtQuerySystemProcessorPerformanceInformation ¶
func NtQuerySystemProcessorPerformanceInformation() ([]SystemProcessorPerformanceInformation, error)
NtQuerySystemProcessorPerformanceInformation queries CPU performance information for each CPU. It uses the NtQuerySystemInformation function to collect the SystemProcessorPerformanceInformation. https://msdn.microsoft.com/en-us/library/windows/desktop/ms724509(v=vs.85).aspx
type User ¶
User represent the information about a Windows account.
func GetTokenUser ¶
GetTokenUser returns the User associated with the given Token.
func (User) String ¶
type Version ¶
Version identifies a Windows version by major, minor, and build number.
func GetWindowsVersion ¶
func GetWindowsVersion() Version
GetWindowsVersion returns the Windows version information. Applications not manifested for Windows 8.1 or Windows 10 will return the Windows 8 OS version value (6.2).
For a table of version numbers see: https://msdn.microsoft.com/en-us/library/windows/desktop/ms724833(v=vs.85).aspx
func (Version) IsWindowsVistaOrGreater ¶
IsWindowsVistaOrGreater returns true if the Windows version is Vista or greater.
Source Files ¶
doc.go ntquery.go privileges.go syscall_windows.go version.go zsyscall_windows.go
- Version
- v1.3.92 (latest)
- Published
- May 7, 2025
- Platform
- windows/amd64
- Imports
- 13 packages
- Last checked
- 14 hours ago –
Tools for package owners.