Example #1
0
func (self *Job) GetProcesses() ([]uint, error) {
	var info wrappers.JOBOBJECT_BASIC_PROCESS_ID_LIST
	err := wrappers.QueryInformationJobObject(
		self.handle,
		wrappers.JobObjectBasicProcessIdList,
		(*byte)(unsafe.Pointer(&info)),
		uint32(unsafe.Sizeof(info)),
		nil)
	if err != nil && err != wrappers.ERROR_MORE_DATA {
		return nil, NewWindowsError("QueryInformationJobObject", err)
	}
	buf := make([]byte, unsafe.Sizeof(info)+unsafe.Sizeof(info.ProcessIdList[0])*uintptr(info.NumberOfAssignedProcesses-1))
	err = wrappers.QueryInformationJobObject(
		self.handle,
		wrappers.JobObjectBasicProcessIdList,
		&buf[0],
		uint32(len(buf)),
		nil)
	if err != nil {
		return nil, NewWindowsError("QueryInformationJobObject", err)
	}
	bufInfo := (*wrappers.JOBOBJECT_BASIC_PROCESS_ID_LIST)(unsafe.Pointer(&buf[0]))
	rawPids := make([]uintptr, bufInfo.NumberOfProcessIdsInList)
	wrappers.RtlMoveMemory(
		(*byte)(unsafe.Pointer(&rawPids[0])),
		(*byte)(unsafe.Pointer(&bufInfo.ProcessIdList[0])),
		uintptr(bufInfo.NumberOfProcessIdsInList)*unsafe.Sizeof(rawPids[0]))
	pids := make([]uint, bufInfo.NumberOfProcessIdsInList)
	for i, rawPid := range rawPids {
		pids[i] = uint(rawPid)
	}
	return pids, nil
}
Example #2
0
func (self *Job) GetExtendedLimitInfo() (*JobExtendedLimitInfo, error) {
	var info wrappers.JOBOBJECT_EXTENDED_LIMIT_INFORMATION
	err := wrappers.QueryInformationJobObject(
		self.handle,
		wrappers.JobObjectExtendedLimitInformation,
		(*byte)(unsafe.Pointer(&info)),
		uint32(unsafe.Sizeof(info)),
		nil)
	if err != nil {
		return nil, NewWindowsError("QueryInformationJobObject", err)
	}
	return &JobExtendedLimitInfo{
		JobBasicLimitInfo: JobBasicLimitInfo{
			PerProcessUserTimeLimit: info.BasicLimitInformation.PerProcessUserTimeLimit,
			PerJobUserTimeLimit:     info.BasicLimitInformation.PerJobUserTimeLimit,
			LimitFlags:              JobLimitFlags(info.BasicLimitInformation.LimitFlags),
			MinimumWorkingSetSize:   info.BasicLimitInformation.MinimumWorkingSetSize,
			MaximumWorkingSetSize:   info.BasicLimitInformation.MaximumWorkingSetSize,
			ActiveProcessLimit:      uint(info.BasicLimitInformation.ActiveProcessLimit),
			Affinity:                info.BasicLimitInformation.Affinity,
			PriorityClass:           uint(info.BasicLimitInformation.PriorityClass),
			SchedulingClass:         uint(info.BasicLimitInformation.SchedulingClass),
		},
		ProcessMemoryLimit:    info.ProcessMemoryLimit,
		JobMemoryLimit:        info.JobMemoryLimit,
		PeakProcessMemoryUsed: info.PeakProcessMemoryUsed,
		PeakJobMemoryUsed:     info.PeakJobMemoryUsed,
	}, nil
}
Example #3
0
func (self *Job) GetBasicUIRestrictions() (JobUILimitFlags, error) {
	var info wrappers.JOBOBJECT_BASIC_UI_RESTRICTIONS
	err := wrappers.QueryInformationJobObject(
		self.handle,
		wrappers.JobObjectBasicUIRestrictions,
		(*byte)(unsafe.Pointer(&info)),
		uint32(unsafe.Sizeof(info)),
		nil)
	if err != nil {
		return 0, NewWindowsError("QueryInformationJobObject", err)
	}
	return JobUILimitFlags(info.UIRestrictionsClass), nil
}