mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-14 07:27:07 +08:00
vendor: update buildkit to 8effd45b
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
51
vendor/github.com/Microsoft/hcsshim/internal/winapi/filesystem.go
generated
vendored
51
vendor/github.com/Microsoft/hcsshim/internal/winapi/filesystem.go
generated
vendored
@ -31,6 +31,43 @@ const (
|
||||
STATUS_NO_MORE_ENTRIES = 0x8000001a
|
||||
)
|
||||
|
||||
// Select entries from FILE_INFO_BY_HANDLE_CLASS.
|
||||
//
|
||||
// C declaration:
|
||||
// typedef enum _FILE_INFO_BY_HANDLE_CLASS {
|
||||
// FileBasicInfo,
|
||||
// FileStandardInfo,
|
||||
// FileNameInfo,
|
||||
// FileRenameInfo,
|
||||
// FileDispositionInfo,
|
||||
// FileAllocationInfo,
|
||||
// FileEndOfFileInfo,
|
||||
// FileStreamInfo,
|
||||
// FileCompressionInfo,
|
||||
// FileAttributeTagInfo,
|
||||
// FileIdBothDirectoryInfo,
|
||||
// FileIdBothDirectoryRestartInfo,
|
||||
// FileIoPriorityHintInfo,
|
||||
// FileRemoteProtocolInfo,
|
||||
// FileFullDirectoryInfo,
|
||||
// FileFullDirectoryRestartInfo,
|
||||
// FileStorageInfo,
|
||||
// FileAlignmentInfo,
|
||||
// FileIdInfo,
|
||||
// FileIdExtdDirectoryInfo,
|
||||
// FileIdExtdDirectoryRestartInfo,
|
||||
// FileDispositionInfoEx,
|
||||
// FileRenameInfoEx,
|
||||
// FileCaseSensitiveInfo,
|
||||
// FileNormalizedNameInfo,
|
||||
// MaximumFileInfoByHandleClass
|
||||
// } FILE_INFO_BY_HANDLE_CLASS, *PFILE_INFO_BY_HANDLE_CLASS;
|
||||
//
|
||||
// Documentation: https://docs.microsoft.com/en-us/windows/win32/api/minwinbase/ne-minwinbase-file_info_by_handle_class
|
||||
const (
|
||||
FileIdInfo = 18
|
||||
)
|
||||
|
||||
type FileDispositionInformationEx struct {
|
||||
Flags uintptr
|
||||
}
|
||||
@ -42,7 +79,7 @@ type IOStatusBlock struct {
|
||||
type ObjectAttributes struct {
|
||||
Length uintptr
|
||||
RootDirectory uintptr
|
||||
ObjectName uintptr
|
||||
ObjectName *UnicodeString
|
||||
Attributes uintptr
|
||||
SecurityDescriptor uintptr
|
||||
SecurityQoS uintptr
|
||||
@ -59,3 +96,15 @@ type FileLinkInformation struct {
|
||||
FileNameLength uint32
|
||||
FileName [1]uint16
|
||||
}
|
||||
|
||||
// C declaration:
|
||||
// typedef struct _FILE_ID_INFO {
|
||||
// ULONGLONG VolumeSerialNumber;
|
||||
// FILE_ID_128 FileId;
|
||||
// } FILE_ID_INFO, *PFILE_ID_INFO;
|
||||
//
|
||||
// Documentation: https://docs.microsoft.com/en-us/windows/win32/api/winbase/ns-winbase-file_id_info
|
||||
type FILE_ID_INFO struct {
|
||||
VolumeSerialNumber uint64
|
||||
FileID [16]byte
|
||||
}
|
||||
|
3
vendor/github.com/Microsoft/hcsshim/internal/winapi/iocp.go
generated
vendored
Normal file
3
vendor/github.com/Microsoft/hcsshim/internal/winapi/iocp.go
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
package winapi
|
||||
|
||||
//sys GetQueuedCompletionStatus(cphandle windows.Handle, qty *uint32, key *uintptr, overlapped **windows.Overlapped, timeout uint32) (err error)
|
121
vendor/github.com/Microsoft/hcsshim/internal/winapi/jobobject.go
generated
vendored
121
vendor/github.com/Microsoft/hcsshim/internal/winapi/jobobject.go
generated
vendored
@ -1,32 +1,41 @@
|
||||
package winapi
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/sys/windows"
|
||||
)
|
||||
|
||||
// Messages that can be received from an assigned io completion port.
|
||||
// https://docs.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-jobobject_associate_completion_port
|
||||
const (
|
||||
JOB_OBJECT_MSG_END_OF_JOB_TIME = 1
|
||||
JOB_OBJECT_MSG_END_OF_PROCESS_TIME = 2
|
||||
JOB_OBJECT_MSG_ACTIVE_PROCESS_LIMIT = 3
|
||||
JOB_OBJECT_MSG_ACTIVE_PROCESS_ZERO = 4
|
||||
JOB_OBJECT_MSG_NEW_PROCESS = 6
|
||||
JOB_OBJECT_MSG_EXIT_PROCESS = 7
|
||||
JOB_OBJECT_MSG_ABNORMAL_EXIT_PROCESS = 8
|
||||
JOB_OBJECT_MSG_PROCESS_MEMORY_LIMIT = 9
|
||||
JOB_OBJECT_MSG_JOB_MEMORY_LIMIT = 10
|
||||
JOB_OBJECT_MSG_NOTIFICATION_LIMIT = 11
|
||||
JOB_OBJECT_MSG_END_OF_JOB_TIME uint32 = 1
|
||||
JOB_OBJECT_MSG_END_OF_PROCESS_TIME uint32 = 2
|
||||
JOB_OBJECT_MSG_ACTIVE_PROCESS_LIMIT uint32 = 3
|
||||
JOB_OBJECT_MSG_ACTIVE_PROCESS_ZERO uint32 = 4
|
||||
JOB_OBJECT_MSG_NEW_PROCESS uint32 = 6
|
||||
JOB_OBJECT_MSG_EXIT_PROCESS uint32 = 7
|
||||
JOB_OBJECT_MSG_ABNORMAL_EXIT_PROCESS uint32 = 8
|
||||
JOB_OBJECT_MSG_PROCESS_MEMORY_LIMIT uint32 = 9
|
||||
JOB_OBJECT_MSG_JOB_MEMORY_LIMIT uint32 = 10
|
||||
JOB_OBJECT_MSG_NOTIFICATION_LIMIT uint32 = 11
|
||||
)
|
||||
|
||||
// Access rights for creating or opening job objects.
|
||||
//
|
||||
// https://docs.microsoft.com/en-us/windows/win32/procthread/job-object-security-and-access-rights
|
||||
const JOB_OBJECT_ALL_ACCESS = 0x1F001F
|
||||
|
||||
// IO limit flags
|
||||
//
|
||||
// https://docs.microsoft.com/en-us/windows/win32/api/jobapi2/ns-jobapi2-jobobject_io_rate_control_information
|
||||
const JOB_OBJECT_IO_RATE_CONTROL_ENABLE = 0x1
|
||||
|
||||
const JOBOBJECT_IO_ATTRIBUTION_CONTROL_ENABLE uint32 = 0x1
|
||||
|
||||
// https://docs.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-jobobject_cpu_rate_control_information
|
||||
const (
|
||||
JOB_OBJECT_CPU_RATE_CONTROL_ENABLE = 1 << iota
|
||||
JOB_OBJECT_CPU_RATE_CONTROL_ENABLE uint32 = 1 << iota
|
||||
JOB_OBJECT_CPU_RATE_CONTROL_WEIGHT_BASED
|
||||
JOB_OBJECT_CPU_RATE_CONTROL_HARD_CAP
|
||||
JOB_OBJECT_CPU_RATE_CONTROL_NOTIFY
|
||||
@ -41,7 +50,9 @@ const (
|
||||
JobObjectBasicProcessIdList uint32 = 3
|
||||
JobObjectBasicAndIoAccountingInformation uint32 = 8
|
||||
JobObjectLimitViolationInformation uint32 = 13
|
||||
JobObjectMemoryUsageInformation uint32 = 28
|
||||
JobObjectNotificationLimitInformation2 uint32 = 33
|
||||
JobObjectIoAttribution uint32 = 42
|
||||
)
|
||||
|
||||
// https://docs.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-jobobject_basic_limit_information
|
||||
@ -60,7 +71,7 @@ type JOBOBJECT_BASIC_LIMIT_INFORMATION struct {
|
||||
// https://docs.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-jobobject_cpu_rate_control_information
|
||||
type JOBOBJECT_CPU_RATE_CONTROL_INFORMATION struct {
|
||||
ControlFlags uint32
|
||||
Rate uint32
|
||||
Value uint32
|
||||
}
|
||||
|
||||
// https://docs.microsoft.com/en-us/windows/win32/api/jobapi2/ns-jobapi2-jobobject_io_rate_control_information
|
||||
@ -80,9 +91,68 @@ type JOBOBJECT_BASIC_PROCESS_ID_LIST struct {
|
||||
ProcessIdList [1]uintptr
|
||||
}
|
||||
|
||||
// AllPids returns all the process Ids in the job object.
|
||||
func (p *JOBOBJECT_BASIC_PROCESS_ID_LIST) AllPids() []uintptr {
|
||||
return (*[(1 << 27) - 1]uintptr)(unsafe.Pointer(&p.ProcessIdList[0]))[:p.NumberOfProcessIdsInList]
|
||||
}
|
||||
|
||||
// https://docs.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-jobobject_basic_accounting_information
|
||||
type JOBOBJECT_BASIC_ACCOUNTING_INFORMATION struct {
|
||||
TotalUserTime int64
|
||||
TotalKernelTime int64
|
||||
ThisPeriodTotalUserTime int64
|
||||
ThisPeriodTotalKernelTime int64
|
||||
TotalPageFaultCount uint32
|
||||
TotalProcesses uint32
|
||||
ActiveProcesses uint32
|
||||
TotalTerminateProcesses uint32
|
||||
}
|
||||
|
||||
//https://docs.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-jobobject_basic_and_io_accounting_information
|
||||
type JOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION struct {
|
||||
BasicInfo JOBOBJECT_BASIC_ACCOUNTING_INFORMATION
|
||||
IoInfo windows.IO_COUNTERS
|
||||
}
|
||||
|
||||
// typedef struct _JOBOBJECT_MEMORY_USAGE_INFORMATION {
|
||||
// ULONG64 JobMemory;
|
||||
// ULONG64 PeakJobMemoryUsed;
|
||||
// } JOBOBJECT_MEMORY_USAGE_INFORMATION, *PJOBOBJECT_MEMORY_USAGE_INFORMATION;
|
||||
//
|
||||
type JOBOBJECT_MEMORY_USAGE_INFORMATION struct {
|
||||
JobMemory uint64
|
||||
PeakJobMemoryUsed uint64
|
||||
}
|
||||
|
||||
// typedef struct _JOBOBJECT_IO_ATTRIBUTION_STATS {
|
||||
// ULONG_PTR IoCount;
|
||||
// ULONGLONG TotalNonOverlappedQueueTime;
|
||||
// ULONGLONG TotalNonOverlappedServiceTime;
|
||||
// ULONGLONG TotalSize;
|
||||
// } JOBOBJECT_IO_ATTRIBUTION_STATS, *PJOBOBJECT_IO_ATTRIBUTION_STATS;
|
||||
//
|
||||
type JOBOBJECT_IO_ATTRIBUTION_STATS struct {
|
||||
IoCount uintptr
|
||||
TotalNonOverlappedQueueTime uint64
|
||||
TotalNonOverlappedServiceTime uint64
|
||||
TotalSize uint64
|
||||
}
|
||||
|
||||
// typedef struct _JOBOBJECT_IO_ATTRIBUTION_INFORMATION {
|
||||
// ULONG ControlFlags;
|
||||
// JOBOBJECT_IO_ATTRIBUTION_STATS ReadStats;
|
||||
// JOBOBJECT_IO_ATTRIBUTION_STATS WriteStats;
|
||||
// } JOBOBJECT_IO_ATTRIBUTION_INFORMATION, *PJOBOBJECT_IO_ATTRIBUTION_INFORMATION;
|
||||
//
|
||||
type JOBOBJECT_IO_ATTRIBUTION_INFORMATION struct {
|
||||
ControlFlags uint32
|
||||
ReadStats JOBOBJECT_IO_ATTRIBUTION_STATS
|
||||
WriteStats JOBOBJECT_IO_ATTRIBUTION_STATS
|
||||
}
|
||||
|
||||
// https://docs.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-jobobject_associate_completion_port
|
||||
type JOBOBJECT_ASSOCIATE_COMPLETION_PORT struct {
|
||||
CompletionKey uintptr
|
||||
CompletionKey windows.Handle
|
||||
CompletionPort windows.Handle
|
||||
}
|
||||
|
||||
@ -118,3 +188,28 @@ type JOBOBJECT_ASSOCIATE_COMPLETION_PORT struct {
|
||||
// );
|
||||
//
|
||||
//sys SetIoRateControlInformationJobObject(jobHandle windows.Handle, ioRateControlInfo *JOBOBJECT_IO_RATE_CONTROL_INFORMATION) (ret uint32, err error) = kernel32.SetIoRateControlInformationJobObject
|
||||
|
||||
// DWORD QueryIoRateControlInformationJobObject(
|
||||
// HANDLE hJob,
|
||||
// PCWSTR VolumeName,
|
||||
// JOBOBJECT_IO_RATE_CONTROL_INFORMATION **InfoBlocks,
|
||||
// ULONG *InfoBlockCount
|
||||
// );
|
||||
//sys QueryIoRateControlInformationJobObject(jobHandle windows.Handle, volumeName *uint16, ioRateControlInfo **JOBOBJECT_IO_RATE_CONTROL_INFORMATION, infoBlockCount *uint32) (ret uint32, err error) = kernel32.QueryIoRateControlInformationJobObject
|
||||
|
||||
// NTSTATUS
|
||||
// NtOpenJobObject (
|
||||
// _Out_ PHANDLE JobHandle,
|
||||
// _In_ ACCESS_MASK DesiredAccess,
|
||||
// _In_ POBJECT_ATTRIBUTES ObjectAttributes
|
||||
// );
|
||||
//sys NtOpenJobObject(jobHandle *windows.Handle, desiredAccess uint32, objAttributes *ObjectAttributes) (status uint32) = ntdll.NtOpenJobObject
|
||||
|
||||
// NTSTATUS
|
||||
// NTAPI
|
||||
// NtCreateJobObject (
|
||||
// _Out_ PHANDLE JobHandle,
|
||||
// _In_ ACCESS_MASK DesiredAccess,
|
||||
// _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes
|
||||
// );
|
||||
//sys NtCreateJobObject(jobHandle *windows.Handle, desiredAccess uint32, objAttributes *ObjectAttributes) (status uint32) = ntdll.NtCreateJobObject
|
||||
|
3
vendor/github.com/Microsoft/hcsshim/internal/winapi/net.go
generated
vendored
Normal file
3
vendor/github.com/Microsoft/hcsshim/internal/winapi/net.go
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
package winapi
|
||||
|
||||
//sys SetJobCompartmentId(handle windows.Handle, compartmentId uint32) (win32Err error) = iphlpapi.SetJobCompartmentId
|
39
vendor/github.com/Microsoft/hcsshim/internal/winapi/utils.go
generated
vendored
39
vendor/github.com/Microsoft/hcsshim/internal/winapi/utils.go
generated
vendored
@ -2,11 +2,24 @@ package winapi
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"reflect"
|
||||
"syscall"
|
||||
"unicode/utf16"
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/sys/windows"
|
||||
)
|
||||
|
||||
// Uint16BufferToSlice wraps a uint16 pointer-and-length into a slice
|
||||
// for easier interop with Go APIs
|
||||
func Uint16BufferToSlice(buffer *uint16, bufferLength int) (result []uint16) {
|
||||
hdr := (*reflect.SliceHeader)(unsafe.Pointer(&result))
|
||||
hdr.Data = uintptr(unsafe.Pointer(buffer))
|
||||
hdr.Cap = bufferLength
|
||||
hdr.Len = bufferLength
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
type UnicodeString struct {
|
||||
Length uint16
|
||||
MaximumLength uint16
|
||||
@ -15,28 +28,30 @@ type UnicodeString struct {
|
||||
|
||||
//String converts a UnicodeString to a golang string
|
||||
func (uni UnicodeString) String() string {
|
||||
p := (*[0xffff]uint16)(unsafe.Pointer(uni.Buffer))
|
||||
|
||||
// UnicodeString is not guaranteed to be null terminated, therefore
|
||||
// use the UnicodeString's Length field
|
||||
lengthInChars := uni.Length / 2
|
||||
return syscall.UTF16ToString(p[:lengthInChars])
|
||||
return syscall.UTF16ToString(Uint16BufferToSlice(uni.Buffer, int(uni.Length/2)))
|
||||
}
|
||||
|
||||
// NewUnicodeString allocates a new UnicodeString and copies `s` into
|
||||
// the buffer of the new UnicodeString.
|
||||
func NewUnicodeString(s string) (*UnicodeString, error) {
|
||||
ws := utf16.Encode(([]rune)(s))
|
||||
if len(ws) > 32767 {
|
||||
// Get length of original `s` to use in the UnicodeString since the `buf`
|
||||
// created later will have an additional trailing null character
|
||||
length := len(s)
|
||||
if length > 32767 {
|
||||
return nil, syscall.ENAMETOOLONG
|
||||
}
|
||||
|
||||
uni := &UnicodeString{
|
||||
Length: uint16(len(ws) * 2),
|
||||
MaximumLength: uint16(len(ws) * 2),
|
||||
Buffer: &make([]uint16, len(ws))[0],
|
||||
buf, err := windows.UTF16FromString(s)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
uni := &UnicodeString{
|
||||
Length: uint16(length * 2),
|
||||
MaximumLength: uint16(length * 2),
|
||||
Buffer: &buf[0],
|
||||
}
|
||||
copy((*[32768]uint16)(unsafe.Pointer(uni.Buffer))[:], ws)
|
||||
return uni, nil
|
||||
}
|
||||
|
||||
|
2
vendor/github.com/Microsoft/hcsshim/internal/winapi/winapi.go
generated
vendored
2
vendor/github.com/Microsoft/hcsshim/internal/winapi/winapi.go
generated
vendored
@ -2,4 +2,4 @@
|
||||
// be thought of as an extension to golang.org/x/sys/windows.
|
||||
package winapi
|
||||
|
||||
//go:generate go run ..\..\mksyscall_windows.go -output zsyscall_windows.go jobobject.go path.go logon.go memory.go processor.go devices.go filesystem.go errors.go
|
||||
//go:generate go run ..\..\mksyscall_windows.go -output zsyscall_windows.go net.go iocp.go jobobject.go path.go logon.go memory.go processor.go devices.go filesystem.go errors.go
|
||||
|
91
vendor/github.com/Microsoft/hcsshim/internal/winapi/zsyscall_windows.go
generated
vendored
91
vendor/github.com/Microsoft/hcsshim/internal/winapi/zsyscall_windows.go
generated
vendored
@ -37,32 +37,58 @@ func errnoErr(e syscall.Errno) error {
|
||||
}
|
||||
|
||||
var (
|
||||
modiphlpapi = windows.NewLazySystemDLL("iphlpapi.dll")
|
||||
modkernel32 = windows.NewLazySystemDLL("kernel32.dll")
|
||||
modntdll = windows.NewLazySystemDLL("ntdll.dll")
|
||||
modadvapi32 = windows.NewLazySystemDLL("advapi32.dll")
|
||||
modcfgmgr32 = windows.NewLazySystemDLL("cfgmgr32.dll")
|
||||
modntdll = windows.NewLazySystemDLL("ntdll.dll")
|
||||
|
||||
procIsProcessInJob = modkernel32.NewProc("IsProcessInJob")
|
||||
procQueryInformationJobObject = modkernel32.NewProc("QueryInformationJobObject")
|
||||
procOpenJobObjectW = modkernel32.NewProc("OpenJobObjectW")
|
||||
procSetIoRateControlInformationJobObject = modkernel32.NewProc("SetIoRateControlInformationJobObject")
|
||||
procSearchPathW = modkernel32.NewProc("SearchPathW")
|
||||
procLogonUserW = modadvapi32.NewProc("LogonUserW")
|
||||
procRtlMoveMemory = modkernel32.NewProc("RtlMoveMemory")
|
||||
procLocalAlloc = modkernel32.NewProc("LocalAlloc")
|
||||
procLocalFree = modkernel32.NewProc("LocalFree")
|
||||
procGetActiveProcessorCount = modkernel32.NewProc("GetActiveProcessorCount")
|
||||
procCM_Get_Device_ID_List_SizeA = modcfgmgr32.NewProc("CM_Get_Device_ID_List_SizeA")
|
||||
procCM_Get_Device_ID_ListA = modcfgmgr32.NewProc("CM_Get_Device_ID_ListA")
|
||||
procCM_Locate_DevNodeW = modcfgmgr32.NewProc("CM_Locate_DevNodeW")
|
||||
procCM_Get_DevNode_PropertyW = modcfgmgr32.NewProc("CM_Get_DevNode_PropertyW")
|
||||
procNtCreateFile = modntdll.NewProc("NtCreateFile")
|
||||
procNtSetInformationFile = modntdll.NewProc("NtSetInformationFile")
|
||||
procNtOpenDirectoryObject = modntdll.NewProc("NtOpenDirectoryObject")
|
||||
procNtQueryDirectoryObject = modntdll.NewProc("NtQueryDirectoryObject")
|
||||
procRtlNtStatusToDosError = modntdll.NewProc("RtlNtStatusToDosError")
|
||||
procSetJobCompartmentId = modiphlpapi.NewProc("SetJobCompartmentId")
|
||||
procGetQueuedCompletionStatus = modkernel32.NewProc("GetQueuedCompletionStatus")
|
||||
procIsProcessInJob = modkernel32.NewProc("IsProcessInJob")
|
||||
procQueryInformationJobObject = modkernel32.NewProc("QueryInformationJobObject")
|
||||
procOpenJobObjectW = modkernel32.NewProc("OpenJobObjectW")
|
||||
procSetIoRateControlInformationJobObject = modkernel32.NewProc("SetIoRateControlInformationJobObject")
|
||||
procQueryIoRateControlInformationJobObject = modkernel32.NewProc("QueryIoRateControlInformationJobObject")
|
||||
procNtOpenJobObject = modntdll.NewProc("NtOpenJobObject")
|
||||
procNtCreateJobObject = modntdll.NewProc("NtCreateJobObject")
|
||||
procSearchPathW = modkernel32.NewProc("SearchPathW")
|
||||
procLogonUserW = modadvapi32.NewProc("LogonUserW")
|
||||
procRtlMoveMemory = modkernel32.NewProc("RtlMoveMemory")
|
||||
procLocalAlloc = modkernel32.NewProc("LocalAlloc")
|
||||
procLocalFree = modkernel32.NewProc("LocalFree")
|
||||
procGetActiveProcessorCount = modkernel32.NewProc("GetActiveProcessorCount")
|
||||
procCM_Get_Device_ID_List_SizeA = modcfgmgr32.NewProc("CM_Get_Device_ID_List_SizeA")
|
||||
procCM_Get_Device_ID_ListA = modcfgmgr32.NewProc("CM_Get_Device_ID_ListA")
|
||||
procCM_Locate_DevNodeW = modcfgmgr32.NewProc("CM_Locate_DevNodeW")
|
||||
procCM_Get_DevNode_PropertyW = modcfgmgr32.NewProc("CM_Get_DevNode_PropertyW")
|
||||
procNtCreateFile = modntdll.NewProc("NtCreateFile")
|
||||
procNtSetInformationFile = modntdll.NewProc("NtSetInformationFile")
|
||||
procNtOpenDirectoryObject = modntdll.NewProc("NtOpenDirectoryObject")
|
||||
procNtQueryDirectoryObject = modntdll.NewProc("NtQueryDirectoryObject")
|
||||
procRtlNtStatusToDosError = modntdll.NewProc("RtlNtStatusToDosError")
|
||||
)
|
||||
|
||||
func SetJobCompartmentId(handle windows.Handle, compartmentId uint32) (win32Err error) {
|
||||
r0, _, _ := syscall.Syscall(procSetJobCompartmentId.Addr(), 2, uintptr(handle), uintptr(compartmentId), 0)
|
||||
if r0 != 0 {
|
||||
win32Err = syscall.Errno(r0)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func GetQueuedCompletionStatus(cphandle windows.Handle, qty *uint32, key *uintptr, overlapped **windows.Overlapped, timeout uint32) (err error) {
|
||||
r1, _, e1 := syscall.Syscall6(procGetQueuedCompletionStatus.Addr(), 5, uintptr(cphandle), uintptr(unsafe.Pointer(qty)), uintptr(unsafe.Pointer(key)), uintptr(unsafe.Pointer(overlapped)), uintptr(timeout), 0)
|
||||
if r1 == 0 {
|
||||
if e1 != 0 {
|
||||
err = errnoErr(e1)
|
||||
} else {
|
||||
err = syscall.EINVAL
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func IsProcessInJob(procHandle windows.Handle, jobHandle windows.Handle, result *bool) (err error) {
|
||||
r1, _, e1 := syscall.Syscall(procIsProcessInJob.Addr(), 3, uintptr(procHandle), uintptr(jobHandle), uintptr(unsafe.Pointer(result)))
|
||||
if r1 == 0 {
|
||||
@ -119,6 +145,31 @@ func SetIoRateControlInformationJobObject(jobHandle windows.Handle, ioRateContro
|
||||
return
|
||||
}
|
||||
|
||||
func QueryIoRateControlInformationJobObject(jobHandle windows.Handle, volumeName *uint16, ioRateControlInfo **JOBOBJECT_IO_RATE_CONTROL_INFORMATION, infoBlockCount *uint32) (ret uint32, err error) {
|
||||
r0, _, e1 := syscall.Syscall6(procQueryIoRateControlInformationJobObject.Addr(), 4, uintptr(jobHandle), uintptr(unsafe.Pointer(volumeName)), uintptr(unsafe.Pointer(ioRateControlInfo)), uintptr(unsafe.Pointer(infoBlockCount)), 0, 0)
|
||||
ret = uint32(r0)
|
||||
if ret == 0 {
|
||||
if e1 != 0 {
|
||||
err = errnoErr(e1)
|
||||
} else {
|
||||
err = syscall.EINVAL
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func NtOpenJobObject(jobHandle *windows.Handle, desiredAccess uint32, objAttributes *ObjectAttributes) (status uint32) {
|
||||
r0, _, _ := syscall.Syscall(procNtOpenJobObject.Addr(), 3, uintptr(unsafe.Pointer(jobHandle)), uintptr(desiredAccess), uintptr(unsafe.Pointer(objAttributes)))
|
||||
status = uint32(r0)
|
||||
return
|
||||
}
|
||||
|
||||
func NtCreateJobObject(jobHandle *windows.Handle, desiredAccess uint32, objAttributes *ObjectAttributes) (status uint32) {
|
||||
r0, _, _ := syscall.Syscall(procNtCreateJobObject.Addr(), 3, uintptr(unsafe.Pointer(jobHandle)), uintptr(desiredAccess), uintptr(unsafe.Pointer(objAttributes)))
|
||||
status = uint32(r0)
|
||||
return
|
||||
}
|
||||
|
||||
func SearchPath(lpPath *uint16, lpFileName *uint16, lpExtension *uint16, nBufferLength uint32, lpBuffer *uint16, lpFilePath **uint16) (size uint32, err error) {
|
||||
r0, _, e1 := syscall.Syscall6(procSearchPathW.Addr(), 6, uintptr(unsafe.Pointer(lpPath)), uintptr(unsafe.Pointer(lpFileName)), uintptr(unsafe.Pointer(lpExtension)), uintptr(nBufferLength), uintptr(unsafe.Pointer(lpBuffer)), uintptr(unsafe.Pointer(lpFilePath)))
|
||||
size = uint32(r0)
|
||||
|
Reference in New Issue
Block a user