mirror of
https://github.com/golang/sys.git
synced 2026-02-08 19:56:04 +03:00
windows: add functions for priority class
took const value from https://docs.microsoft.com/en-us/windows/desktop/api/processthreadsapi/nf-processthreadsapi-setpriorityclass https://docs.microsoft.com/en-us/windows/desktop/api/processthreadsapi/nf-processthreadsapi-getpriorityclass Change-Id: I376bb8e1f5de8968177512857d60169cb7b7c776 Reviewed-on: https://go-review.googlesource.com/c/sys/+/179038 Reviewed-by: Alex Brainman <alex.brainman@gmail.com> Run-TryBot: Alex Brainman <alex.brainman@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
committed by
Alex Brainman
parent
3626398d77
commit
854af27f14
@@ -258,6 +258,8 @@ func NewCallbackCDecl(fn interface{}) uintptr {
|
||||
//sys TerminateJobObject(job Handle, exitCode uint32) (err error) = kernel32.TerminateJobObject
|
||||
//sys SetErrorMode(mode uint32) (ret uint32) = kernel32.SetErrorMode
|
||||
//sys ResumeThread(thread Handle) (ret uint32, err error) [failretval==0xffffffff] = kernel32.ResumeThread
|
||||
//sys SetPriorityClass(process Handle, priorityClass uint32) (err error) = kernel32.SetPriorityClass
|
||||
//sys GetPriorityClass(process Handle) (ret uint32, err error) = kernel32.GetPriorityClass
|
||||
|
||||
// Volume Management Functions
|
||||
//sys DefineDosDevice(flags uint32, deviceName *uint16, targetPath *uint16) (err error) = DefineDosDeviceW
|
||||
|
||||
@@ -408,6 +408,18 @@ const (
|
||||
SEM_NOOPENFILEERRORBOX = 0x8000
|
||||
)
|
||||
|
||||
const (
|
||||
// Priority class.
|
||||
ABOVE_NORMAL_PRIORITY_CLASS = 0x00008000
|
||||
BELOW_NORMAL_PRIORITY_CLASS = 0x00004000
|
||||
HIGH_PRIORITY_CLASS = 0x00000080
|
||||
IDLE_PRIORITY_CLASS = 0x00000040
|
||||
NORMAL_PRIORITY_CLASS = 0x00000020
|
||||
PROCESS_MODE_BACKGROUND_BEGIN = 0x00100000
|
||||
PROCESS_MODE_BACKGROUND_END = 0x00200000
|
||||
REALTIME_PRIORITY_CLASS = 0x00000100
|
||||
)
|
||||
|
||||
var (
|
||||
OID_PKIX_KP_SERVER_AUTH = []byte("1.3.6.1.5.5.7.3.1\x00")
|
||||
OID_SERVER_GATED_CRYPTO = []byte("1.3.6.1.4.1.311.10.3.3\x00")
|
||||
|
||||
@@ -196,6 +196,8 @@ var (
|
||||
procTerminateJobObject = modkernel32.NewProc("TerminateJobObject")
|
||||
procSetErrorMode = modkernel32.NewProc("SetErrorMode")
|
||||
procResumeThread = modkernel32.NewProc("ResumeThread")
|
||||
procSetPriorityClass = modkernel32.NewProc("SetPriorityClass")
|
||||
procGetPriorityClass = modkernel32.NewProc("GetPriorityClass")
|
||||
procDefineDosDeviceW = modkernel32.NewProc("DefineDosDeviceW")
|
||||
procDeleteVolumeMountPointW = modkernel32.NewProc("DeleteVolumeMountPointW")
|
||||
procFindFirstVolumeW = modkernel32.NewProc("FindFirstVolumeW")
|
||||
@@ -2105,6 +2107,31 @@ func ResumeThread(thread Handle) (ret uint32, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func SetPriorityClass(process Handle, priorityClass uint32) (err error) {
|
||||
r1, _, e1 := syscall.Syscall(procSetPriorityClass.Addr(), 2, uintptr(process), uintptr(priorityClass), 0)
|
||||
if r1 == 0 {
|
||||
if e1 != 0 {
|
||||
err = errnoErr(e1)
|
||||
} else {
|
||||
err = syscall.EINVAL
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func GetPriorityClass(process Handle) (ret uint32, err error) {
|
||||
r0, _, e1 := syscall.Syscall(procGetPriorityClass.Addr(), 1, uintptr(process), 0, 0)
|
||||
ret = uint32(r0)
|
||||
if ret == 0 {
|
||||
if e1 != 0 {
|
||||
err = errnoErr(e1)
|
||||
} else {
|
||||
err = syscall.EINVAL
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func DefineDosDevice(flags uint32, deviceName *uint16, targetPath *uint16) (err error) {
|
||||
r1, _, e1 := syscall.Syscall(procDefineDosDeviceW.Addr(), 3, uintptr(flags), uintptr(unsafe.Pointer(deviceName)), uintptr(unsafe.Pointer(targetPath)))
|
||||
if r1 == 0 {
|
||||
|
||||
Reference in New Issue
Block a user