go.mod github.com/Microsoft/hcsshim v0.8.16
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
13
vendor/github.com/Microsoft/hcsshim/internal/winapi/devices.go
generated
vendored
Normal file
13
vendor/github.com/Microsoft/hcsshim/internal/winapi/devices.go
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
package winapi
|
||||
|
||||
import "github.com/Microsoft/go-winio/pkg/guid"
|
||||
|
||||
//sys CMGetDeviceIDListSize(pulLen *uint32, pszFilter *byte, uFlags uint32) (hr error) = cfgmgr32.CM_Get_Device_ID_List_SizeA
|
||||
//sys CMGetDeviceIDList(pszFilter *byte, buffer *byte, bufferLen uint32, uFlags uint32) (hr error)= cfgmgr32.CM_Get_Device_ID_ListA
|
||||
//sys CMLocateDevNode(pdnDevInst *uint32, pDeviceID string, uFlags uint32) (hr error) = cfgmgr32.CM_Locate_DevNodeW
|
||||
//sys CMGetDevNodeProperty(dnDevInst uint32, propertyKey *DevPropKey, propertyType *uint32, propertyBuffer *uint16, propertyBufferSize *uint32, uFlags uint32) (hr error) = cfgmgr32.CM_Get_DevNode_PropertyW
|
||||
|
||||
type DevPropKey struct {
|
||||
Fmtid guid.GUID
|
||||
Pid uint32
|
||||
}
|
15
vendor/github.com/Microsoft/hcsshim/internal/winapi/errors.go
generated
vendored
Normal file
15
vendor/github.com/Microsoft/hcsshim/internal/winapi/errors.go
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
package winapi
|
||||
|
||||
import "syscall"
|
||||
|
||||
//sys RtlNtStatusToDosError(status uint32) (winerr error) = ntdll.RtlNtStatusToDosError
|
||||
|
||||
const (
|
||||
STATUS_REPARSE_POINT_ENCOUNTERED = 0xC000050B
|
||||
ERROR_NO_MORE_ITEMS = 0x103
|
||||
ERROR_MORE_DATA syscall.Errno = 234
|
||||
)
|
||||
|
||||
func NTSuccess(status uint32) bool {
|
||||
return status == 0
|
||||
}
|
110
vendor/github.com/Microsoft/hcsshim/internal/winapi/filesystem.go
generated
vendored
Normal file
110
vendor/github.com/Microsoft/hcsshim/internal/winapi/filesystem.go
generated
vendored
Normal file
@ -0,0 +1,110 @@
|
||||
package winapi
|
||||
|
||||
//sys NtCreateFile(handle *uintptr, accessMask uint32, oa *ObjectAttributes, iosb *IOStatusBlock, allocationSize *uint64, fileAttributes uint32, shareAccess uint32, createDisposition uint32, createOptions uint32, eaBuffer *byte, eaLength uint32) (status uint32) = ntdll.NtCreateFile
|
||||
//sys NtSetInformationFile(handle uintptr, iosb *IOStatusBlock, information uintptr, length uint32, class uint32) (status uint32) = ntdll.NtSetInformationFile
|
||||
|
||||
//sys NtOpenDirectoryObject(handle *uintptr, accessMask uint32, oa *ObjectAttributes) (status uint32) = ntdll.NtOpenDirectoryObject
|
||||
//sys NtQueryDirectoryObject(handle uintptr, buffer *byte, length uint32, singleEntry bool, restartScan bool, context *uint32, returnLength *uint32)(status uint32) = ntdll.NtQueryDirectoryObject
|
||||
|
||||
const (
|
||||
FileLinkInformationClass = 11
|
||||
FileDispositionInformationExClass = 64
|
||||
|
||||
FILE_READ_ATTRIBUTES = 0x0080
|
||||
FILE_WRITE_ATTRIBUTES = 0x0100
|
||||
DELETE = 0x10000
|
||||
|
||||
FILE_OPEN = 1
|
||||
FILE_CREATE = 2
|
||||
|
||||
FILE_LIST_DIRECTORY = 0x00000001
|
||||
FILE_DIRECTORY_FILE = 0x00000001
|
||||
FILE_SYNCHRONOUS_IO_NONALERT = 0x00000020
|
||||
FILE_OPEN_FOR_BACKUP_INTENT = 0x00004000
|
||||
FILE_OPEN_REPARSE_POINT = 0x00200000
|
||||
|
||||
FILE_DISPOSITION_DELETE = 0x00000001
|
||||
|
||||
OBJ_DONT_REPARSE = 0x1000
|
||||
|
||||
STATUS_MORE_ENTRIES = 0x105
|
||||
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
|
||||
}
|
||||
|
||||
type IOStatusBlock struct {
|
||||
Status, Information uintptr
|
||||
}
|
||||
|
||||
type ObjectAttributes struct {
|
||||
Length uintptr
|
||||
RootDirectory uintptr
|
||||
ObjectName *UnicodeString
|
||||
Attributes uintptr
|
||||
SecurityDescriptor uintptr
|
||||
SecurityQoS uintptr
|
||||
}
|
||||
|
||||
type ObjectDirectoryInformation struct {
|
||||
Name UnicodeString
|
||||
TypeName UnicodeString
|
||||
}
|
||||
|
||||
type FileLinkInformation struct {
|
||||
ReplaceIfExists bool
|
||||
RootDirectory uintptr
|
||||
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)
|
215
vendor/github.com/Microsoft/hcsshim/internal/winapi/jobobject.go
generated
vendored
Normal file
215
vendor/github.com/Microsoft/hcsshim/internal/winapi/jobobject.go
generated
vendored
Normal file
@ -0,0 +1,215 @@
|
||||
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 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 uint32 = 1 << iota
|
||||
JOB_OBJECT_CPU_RATE_CONTROL_WEIGHT_BASED
|
||||
JOB_OBJECT_CPU_RATE_CONTROL_HARD_CAP
|
||||
JOB_OBJECT_CPU_RATE_CONTROL_NOTIFY
|
||||
JOB_OBJECT_CPU_RATE_CONTROL_MIN_MAX_RATE
|
||||
)
|
||||
|
||||
// JobObjectInformationClass values. Used for a call to QueryInformationJobObject
|
||||
//
|
||||
// https://docs.microsoft.com/en-us/windows/win32/api/jobapi2/nf-jobapi2-queryinformationjobobject
|
||||
const (
|
||||
JobObjectBasicAccountingInformation uint32 = 1
|
||||
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
|
||||
type JOBOBJECT_BASIC_LIMIT_INFORMATION struct {
|
||||
PerProcessUserTimeLimit int64
|
||||
PerJobUserTimeLimit int64
|
||||
LimitFlags uint32
|
||||
MinimumWorkingSetSize uintptr
|
||||
MaximumWorkingSetSize uintptr
|
||||
ActiveProcessLimit uint32
|
||||
Affinity uintptr
|
||||
PriorityClass uint32
|
||||
SchedulingClass uint32
|
||||
}
|
||||
|
||||
// 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
|
||||
Value uint32
|
||||
}
|
||||
|
||||
// https://docs.microsoft.com/en-us/windows/win32/api/jobapi2/ns-jobapi2-jobobject_io_rate_control_information
|
||||
type JOBOBJECT_IO_RATE_CONTROL_INFORMATION struct {
|
||||
MaxIops int64
|
||||
MaxBandwidth int64
|
||||
ReservationIops int64
|
||||
BaseIOSize uint32
|
||||
VolumeName string
|
||||
ControlFlags uint32
|
||||
}
|
||||
|
||||
// https://docs.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-jobobject_basic_process_id_list
|
||||
type JOBOBJECT_BASIC_PROCESS_ID_LIST struct {
|
||||
NumberOfAssignedProcesses uint32
|
||||
NumberOfProcessIdsInList uint32
|
||||
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 windows.Handle
|
||||
CompletionPort windows.Handle
|
||||
}
|
||||
|
||||
// BOOL IsProcessInJob(
|
||||
// HANDLE ProcessHandle,
|
||||
// HANDLE JobHandle,
|
||||
// PBOOL Result
|
||||
// );
|
||||
//
|
||||
//sys IsProcessInJob(procHandle windows.Handle, jobHandle windows.Handle, result *bool) (err error) = kernel32.IsProcessInJob
|
||||
|
||||
// BOOL QueryInformationJobObject(
|
||||
// HANDLE hJob,
|
||||
// JOBOBJECTINFOCLASS JobObjectInformationClass,
|
||||
// LPVOID lpJobObjectInformation,
|
||||
// DWORD cbJobObjectInformationLength,
|
||||
// LPDWORD lpReturnLength
|
||||
// );
|
||||
//
|
||||
//sys QueryInformationJobObject(jobHandle windows.Handle, infoClass uint32, jobObjectInfo uintptr, jobObjectInformationLength uint32, lpReturnLength *uint32) (err error) = kernel32.QueryInformationJobObject
|
||||
|
||||
// HANDLE OpenJobObjectW(
|
||||
// DWORD dwDesiredAccess,
|
||||
// BOOL bInheritHandle,
|
||||
// LPCWSTR lpName
|
||||
// );
|
||||
//
|
||||
//sys OpenJobObject(desiredAccess uint32, inheritHandle bool, lpName *uint16) (handle windows.Handle, err error) = kernel32.OpenJobObjectW
|
||||
|
||||
// DWORD SetIoRateControlInformationJobObject(
|
||||
// HANDLE hJob,
|
||||
// JOBOBJECT_IO_RATE_CONTROL_INFORMATION *IoRateControlInfo
|
||||
// );
|
||||
//
|
||||
//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
|
30
vendor/github.com/Microsoft/hcsshim/internal/winapi/logon.go
generated
vendored
Normal file
30
vendor/github.com/Microsoft/hcsshim/internal/winapi/logon.go
generated
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
package winapi
|
||||
|
||||
// BOOL LogonUserA(
|
||||
// LPCWSTR lpszUsername,
|
||||
// LPCWSTR lpszDomain,
|
||||
// LPCWSTR lpszPassword,
|
||||
// DWORD dwLogonType,
|
||||
// DWORD dwLogonProvider,
|
||||
// PHANDLE phToken
|
||||
// );
|
||||
//
|
||||
//sys LogonUser(username *uint16, domain *uint16, password *uint16, logonType uint32, logonProvider uint32, token *windows.Token) (err error) = advapi32.LogonUserW
|
||||
|
||||
// Logon types
|
||||
const (
|
||||
LOGON32_LOGON_INTERACTIVE uint32 = 2
|
||||
LOGON32_LOGON_NETWORK uint32 = 3
|
||||
LOGON32_LOGON_BATCH uint32 = 4
|
||||
LOGON32_LOGON_SERVICE uint32 = 5
|
||||
LOGON32_LOGON_UNLOCK uint32 = 7
|
||||
LOGON32_LOGON_NETWORK_CLEARTEXT uint32 = 8
|
||||
LOGON32_LOGON_NEW_CREDENTIALS uint32 = 9
|
||||
)
|
||||
|
||||
// Logon providers
|
||||
const (
|
||||
LOGON32_PROVIDER_DEFAULT uint32 = 0
|
||||
LOGON32_PROVIDER_WINNT40 uint32 = 2
|
||||
LOGON32_PROVIDER_WINNT50 uint32 = 3
|
||||
)
|
27
vendor/github.com/Microsoft/hcsshim/internal/winapi/memory.go
generated
vendored
Normal file
27
vendor/github.com/Microsoft/hcsshim/internal/winapi/memory.go
generated
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
package winapi
|
||||
|
||||
// VOID RtlMoveMemory(
|
||||
// _Out_ VOID UNALIGNED *Destination,
|
||||
// _In_ const VOID UNALIGNED *Source,
|
||||
// _In_ SIZE_T Length
|
||||
// );
|
||||
//sys RtlMoveMemory(destination *byte, source *byte, length uintptr) (err error) = kernel32.RtlMoveMemory
|
||||
|
||||
//sys LocalAlloc(flags uint32, size int) (ptr uintptr) = kernel32.LocalAlloc
|
||||
//sys LocalFree(ptr uintptr) = kernel32.LocalFree
|
||||
|
||||
// BOOL QueryWorkingSet(
|
||||
// HANDLE hProcess,
|
||||
// PVOID pv,
|
||||
// DWORD cb
|
||||
// );
|
||||
//sys QueryWorkingSet(handle windows.Handle, pv uintptr, cb uint32) (err error) = psapi.QueryWorkingSet
|
||||
|
||||
type PSAPI_WORKING_SET_INFORMATION struct {
|
||||
NumberOfEntries uintptr
|
||||
WorkingSetInfo [1]PSAPI_WORKING_SET_BLOCK
|
||||
}
|
||||
|
||||
type PSAPI_WORKING_SET_BLOCK struct {
|
||||
Flags uintptr
|
||||
}
|
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
|
11
vendor/github.com/Microsoft/hcsshim/internal/winapi/path.go
generated
vendored
Normal file
11
vendor/github.com/Microsoft/hcsshim/internal/winapi/path.go
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
package winapi
|
||||
|
||||
// DWORD SearchPathW(
|
||||
// LPCWSTR lpPath,
|
||||
// LPCWSTR lpFileName,
|
||||
// LPCWSTR lpExtension,
|
||||
// DWORD nBufferLength,
|
||||
// LPWSTR lpBuffer,
|
||||
// LPWSTR *lpFilePart
|
||||
// );
|
||||
//sys SearchPath(lpPath *uint16, lpFileName *uint16, lpExtension *uint16, nBufferLength uint32, lpBuffer *uint16, lpFilePath *uint16) (size uint32, err error) = kernel32.SearchPathW
|
10
vendor/github.com/Microsoft/hcsshim/internal/winapi/process.go
generated
vendored
Normal file
10
vendor/github.com/Microsoft/hcsshim/internal/winapi/process.go
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
package winapi
|
||||
|
||||
const PROCESS_ALL_ACCESS uint32 = 2097151
|
||||
|
||||
// DWORD GetProcessImageFileNameW(
|
||||
// HANDLE hProcess,
|
||||
// LPWSTR lpImageFileName,
|
||||
// DWORD nSize
|
||||
// );
|
||||
//sys GetProcessImageFileName(hProcess windows.Handle, imageFileName *uint16, nSize uint32) (size uint32, err error) = kernel32.GetProcessImageFileNameW
|
7
vendor/github.com/Microsoft/hcsshim/internal/winapi/processor.go
generated
vendored
Normal file
7
vendor/github.com/Microsoft/hcsshim/internal/winapi/processor.go
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
package winapi
|
||||
|
||||
// Get count from all processor groups.
|
||||
// https://docs.microsoft.com/en-us/windows/win32/procthread/processor-groups
|
||||
const ALL_PROCESSOR_GROUPS = 0xFFFF
|
||||
|
||||
//sys GetActiveProcessorCount(groupNumber uint16) (amount uint32) = kernel32.GetActiveProcessorCount
|
52
vendor/github.com/Microsoft/hcsshim/internal/winapi/system.go
generated
vendored
Normal file
52
vendor/github.com/Microsoft/hcsshim/internal/winapi/system.go
generated
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
package winapi
|
||||
|
||||
import "golang.org/x/sys/windows"
|
||||
|
||||
const SystemProcessInformation = 5
|
||||
|
||||
const STATUS_INFO_LENGTH_MISMATCH = 0xC0000004
|
||||
|
||||
// __kernel_entry NTSTATUS NtQuerySystemInformation(
|
||||
// SYSTEM_INFORMATION_CLASS SystemInformationClass,
|
||||
// PVOID SystemInformation,
|
||||
// ULONG SystemInformationLength,
|
||||
// PULONG ReturnLength
|
||||
// );
|
||||
//sys NtQuerySystemInformation(systemInfoClass int, systemInformation uintptr, systemInfoLength uint32, returnLength *uint32) (status uint32) = ntdll.NtQuerySystemInformation
|
||||
|
||||
type SYSTEM_PROCESS_INFORMATION struct {
|
||||
NextEntryOffset uint32 // ULONG
|
||||
NumberOfThreads uint32 // ULONG
|
||||
WorkingSetPrivateSize int64 // LARGE_INTEGER
|
||||
HardFaultCount uint32 // ULONG
|
||||
NumberOfThreadsHighWatermark uint32 // ULONG
|
||||
CycleTime uint64 // ULONGLONG
|
||||
CreateTime int64 // LARGE_INTEGER
|
||||
UserTime int64 // LARGE_INTEGER
|
||||
KernelTime int64 // LARGE_INTEGER
|
||||
ImageName UnicodeString // UNICODE_STRING
|
||||
BasePriority int32 // KPRIORITY
|
||||
UniqueProcessID windows.Handle // HANDLE
|
||||
InheritedFromUniqueProcessID windows.Handle // HANDLE
|
||||
HandleCount uint32 // ULONG
|
||||
SessionID uint32 // ULONG
|
||||
UniqueProcessKey *uint32 // ULONG_PTR
|
||||
PeakVirtualSize uintptr // SIZE_T
|
||||
VirtualSize uintptr // SIZE_T
|
||||
PageFaultCount uint32 // ULONG
|
||||
PeakWorkingSetSize uintptr // SIZE_T
|
||||
WorkingSetSize uintptr // SIZE_T
|
||||
QuotaPeakPagedPoolUsage uintptr // SIZE_T
|
||||
QuotaPagedPoolUsage uintptr // SIZE_T
|
||||
QuotaPeakNonPagedPoolUsage uintptr // SIZE_T
|
||||
QuotaNonPagedPoolUsage uintptr // SIZE_T
|
||||
PagefileUsage uintptr // SIZE_T
|
||||
PeakPagefileUsage uintptr // SIZE_T
|
||||
PrivatePageCount uintptr // SIZE_T
|
||||
ReadOperationCount int64 // LARGE_INTEGER
|
||||
WriteOperationCount int64 // LARGE_INTEGER
|
||||
OtherOperationCount int64 // LARGE_INTEGER
|
||||
ReadTransferCount int64 // LARGE_INTEGER
|
||||
WriteTransferCount int64 // LARGE_INTEGER
|
||||
OtherTransferCount int64 // LARGE_INTEGER
|
||||
}
|
12
vendor/github.com/Microsoft/hcsshim/internal/winapi/thread.go
generated
vendored
Normal file
12
vendor/github.com/Microsoft/hcsshim/internal/winapi/thread.go
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
package winapi
|
||||
|
||||
// HANDLE CreateRemoteThread(
|
||||
// HANDLE hProcess,
|
||||
// LPSECURITY_ATTRIBUTES lpThreadAttributes,
|
||||
// SIZE_T dwStackSize,
|
||||
// LPTHREAD_START_ROUTINE lpStartAddress,
|
||||
// LPVOID lpParameter,
|
||||
// DWORD dwCreationFlags,
|
||||
// LPDWORD lpThreadId
|
||||
// );
|
||||
//sys CreateRemoteThread(process windows.Handle, sa *windows.SecurityAttributes, stackSize uint32, startAddr uintptr, parameter uintptr, creationFlags uint32, threadID *uint32) (handle windows.Handle, err error) = kernel32.CreateRemoteThread
|
75
vendor/github.com/Microsoft/hcsshim/internal/winapi/utils.go
generated
vendored
Normal file
75
vendor/github.com/Microsoft/hcsshim/internal/winapi/utils.go
generated
vendored
Normal file
@ -0,0 +1,75 @@
|
||||
package winapi
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"reflect"
|
||||
"syscall"
|
||||
"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
|
||||
Buffer *uint16
|
||||
}
|
||||
|
||||
//String converts a UnicodeString to a golang string
|
||||
func (uni UnicodeString) String() string {
|
||||
// UnicodeString is not guaranteed to be null terminated, therefore
|
||||
// use the UnicodeString's Length field
|
||||
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) {
|
||||
// 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
|
||||
}
|
||||
|
||||
buf, err := windows.UTF16FromString(s)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
uni := &UnicodeString{
|
||||
Length: uint16(length * 2),
|
||||
MaximumLength: uint16(length * 2),
|
||||
Buffer: &buf[0],
|
||||
}
|
||||
return uni, nil
|
||||
}
|
||||
|
||||
// ConvertStringSetToSlice is a helper function used to convert the contents of
|
||||
// `buf` into a string slice. `buf` contains a set of null terminated strings
|
||||
// with an additional null at the end to indicate the end of the set.
|
||||
func ConvertStringSetToSlice(buf []byte) ([]string, error) {
|
||||
var results []string
|
||||
prev := 0
|
||||
for i := range buf {
|
||||
if buf[i] == 0 {
|
||||
if prev == i {
|
||||
// found two null characters in a row, return result
|
||||
return results, nil
|
||||
}
|
||||
results = append(results, string(buf[prev:i]))
|
||||
prev = i + 1
|
||||
}
|
||||
}
|
||||
return nil, errors.New("string set malformed: missing null terminator at end of buffer")
|
||||
}
|
5
vendor/github.com/Microsoft/hcsshim/internal/winapi/winapi.go
generated
vendored
Normal file
5
vendor/github.com/Microsoft/hcsshim/internal/winapi/winapi.go
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
// Package winapi contains various low-level bindings to Windows APIs. It can
|
||||
// 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 system.go net.go path.go thread.go iocp.go jobobject.go logon.go memory.go process.go processor.go devices.go filesystem.go errors.go
|
371
vendor/github.com/Microsoft/hcsshim/internal/winapi/zsyscall_windows.go
generated
vendored
Normal file
371
vendor/github.com/Microsoft/hcsshim/internal/winapi/zsyscall_windows.go
generated
vendored
Normal file
@ -0,0 +1,371 @@
|
||||
// Code generated mksyscall_windows.exe DO NOT EDIT
|
||||
|
||||
package winapi
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/sys/windows"
|
||||
)
|
||||
|
||||
var _ unsafe.Pointer
|
||||
|
||||
// Do the interface allocations only once for common
|
||||
// Errno values.
|
||||
const (
|
||||
errnoERROR_IO_PENDING = 997
|
||||
)
|
||||
|
||||
var (
|
||||
errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING)
|
||||
)
|
||||
|
||||
// errnoErr returns common boxed Errno values, to prevent
|
||||
// allocations at runtime.
|
||||
func errnoErr(e syscall.Errno) error {
|
||||
switch e {
|
||||
case 0:
|
||||
return nil
|
||||
case errnoERROR_IO_PENDING:
|
||||
return errERROR_IO_PENDING
|
||||
}
|
||||
// TODO: add more here, after collecting data on the common
|
||||
// error values see on Windows. (perhaps when running
|
||||
// all.bat?)
|
||||
return e
|
||||
}
|
||||
|
||||
var (
|
||||
modntdll = windows.NewLazySystemDLL("ntdll.dll")
|
||||
modiphlpapi = windows.NewLazySystemDLL("iphlpapi.dll")
|
||||
modkernel32 = windows.NewLazySystemDLL("kernel32.dll")
|
||||
modadvapi32 = windows.NewLazySystemDLL("advapi32.dll")
|
||||
modpsapi = windows.NewLazySystemDLL("psapi.dll")
|
||||
modcfgmgr32 = windows.NewLazySystemDLL("cfgmgr32.dll")
|
||||
|
||||
procNtQuerySystemInformation = modntdll.NewProc("NtQuerySystemInformation")
|
||||
procSetJobCompartmentId = modiphlpapi.NewProc("SetJobCompartmentId")
|
||||
procSearchPathW = modkernel32.NewProc("SearchPathW")
|
||||
procCreateRemoteThread = modkernel32.NewProc("CreateRemoteThread")
|
||||
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")
|
||||
procLogonUserW = modadvapi32.NewProc("LogonUserW")
|
||||
procRtlMoveMemory = modkernel32.NewProc("RtlMoveMemory")
|
||||
procLocalAlloc = modkernel32.NewProc("LocalAlloc")
|
||||
procLocalFree = modkernel32.NewProc("LocalFree")
|
||||
procQueryWorkingSet = modpsapi.NewProc("QueryWorkingSet")
|
||||
procGetProcessImageFileNameW = modkernel32.NewProc("GetProcessImageFileNameW")
|
||||
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 NtQuerySystemInformation(systemInfoClass int, systemInformation uintptr, systemInfoLength uint32, returnLength *uint32) (status uint32) {
|
||||
r0, _, _ := syscall.Syscall6(procNtQuerySystemInformation.Addr(), 4, uintptr(systemInfoClass), uintptr(systemInformation), uintptr(systemInfoLength), uintptr(unsafe.Pointer(returnLength)), 0, 0)
|
||||
status = uint32(r0)
|
||||
return
|
||||
}
|
||||
|
||||
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 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)
|
||||
if size == 0 {
|
||||
if e1 != 0 {
|
||||
err = errnoErr(e1)
|
||||
} else {
|
||||
err = syscall.EINVAL
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func CreateRemoteThread(process windows.Handle, sa *windows.SecurityAttributes, stackSize uint32, startAddr uintptr, parameter uintptr, creationFlags uint32, threadID *uint32) (handle windows.Handle, err error) {
|
||||
r0, _, e1 := syscall.Syscall9(procCreateRemoteThread.Addr(), 7, uintptr(process), uintptr(unsafe.Pointer(sa)), uintptr(stackSize), uintptr(startAddr), uintptr(parameter), uintptr(creationFlags), uintptr(unsafe.Pointer(threadID)), 0, 0)
|
||||
handle = windows.Handle(r0)
|
||||
if handle == 0 {
|
||||
if e1 != 0 {
|
||||
err = errnoErr(e1)
|
||||
} else {
|
||||
err = syscall.EINVAL
|
||||
}
|
||||
}
|
||||
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 {
|
||||
if e1 != 0 {
|
||||
err = errnoErr(e1)
|
||||
} else {
|
||||
err = syscall.EINVAL
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func QueryInformationJobObject(jobHandle windows.Handle, infoClass uint32, jobObjectInfo uintptr, jobObjectInformationLength uint32, lpReturnLength *uint32) (err error) {
|
||||
r1, _, e1 := syscall.Syscall6(procQueryInformationJobObject.Addr(), 5, uintptr(jobHandle), uintptr(infoClass), uintptr(jobObjectInfo), uintptr(jobObjectInformationLength), uintptr(unsafe.Pointer(lpReturnLength)), 0)
|
||||
if r1 == 0 {
|
||||
if e1 != 0 {
|
||||
err = errnoErr(e1)
|
||||
} else {
|
||||
err = syscall.EINVAL
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func OpenJobObject(desiredAccess uint32, inheritHandle bool, lpName *uint16) (handle windows.Handle, err error) {
|
||||
var _p0 uint32
|
||||
if inheritHandle {
|
||||
_p0 = 1
|
||||
} else {
|
||||
_p0 = 0
|
||||
}
|
||||
r0, _, e1 := syscall.Syscall(procOpenJobObjectW.Addr(), 3, uintptr(desiredAccess), uintptr(_p0), uintptr(unsafe.Pointer(lpName)))
|
||||
handle = windows.Handle(r0)
|
||||
if handle == 0 {
|
||||
if e1 != 0 {
|
||||
err = errnoErr(e1)
|
||||
} else {
|
||||
err = syscall.EINVAL
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func SetIoRateControlInformationJobObject(jobHandle windows.Handle, ioRateControlInfo *JOBOBJECT_IO_RATE_CONTROL_INFORMATION) (ret uint32, err error) {
|
||||
r0, _, e1 := syscall.Syscall(procSetIoRateControlInformationJobObject.Addr(), 2, uintptr(jobHandle), uintptr(unsafe.Pointer(ioRateControlInfo)), 0)
|
||||
ret = uint32(r0)
|
||||
if ret == 0 {
|
||||
if e1 != 0 {
|
||||
err = errnoErr(e1)
|
||||
} else {
|
||||
err = syscall.EINVAL
|
||||
}
|
||||
}
|
||||
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 LogonUser(username *uint16, domain *uint16, password *uint16, logonType uint32, logonProvider uint32, token *windows.Token) (err error) {
|
||||
r1, _, e1 := syscall.Syscall6(procLogonUserW.Addr(), 6, uintptr(unsafe.Pointer(username)), uintptr(unsafe.Pointer(domain)), uintptr(unsafe.Pointer(password)), uintptr(logonType), uintptr(logonProvider), uintptr(unsafe.Pointer(token)))
|
||||
if r1 == 0 {
|
||||
if e1 != 0 {
|
||||
err = errnoErr(e1)
|
||||
} else {
|
||||
err = syscall.EINVAL
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func RtlMoveMemory(destination *byte, source *byte, length uintptr) (err error) {
|
||||
r1, _, e1 := syscall.Syscall(procRtlMoveMemory.Addr(), 3, uintptr(unsafe.Pointer(destination)), uintptr(unsafe.Pointer(source)), uintptr(length))
|
||||
if r1 == 0 {
|
||||
if e1 != 0 {
|
||||
err = errnoErr(e1)
|
||||
} else {
|
||||
err = syscall.EINVAL
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func LocalAlloc(flags uint32, size int) (ptr uintptr) {
|
||||
r0, _, _ := syscall.Syscall(procLocalAlloc.Addr(), 2, uintptr(flags), uintptr(size), 0)
|
||||
ptr = uintptr(r0)
|
||||
return
|
||||
}
|
||||
|
||||
func LocalFree(ptr uintptr) {
|
||||
syscall.Syscall(procLocalFree.Addr(), 1, uintptr(ptr), 0, 0)
|
||||
return
|
||||
}
|
||||
|
||||
func QueryWorkingSet(handle windows.Handle, pv uintptr, cb uint32) (err error) {
|
||||
r1, _, e1 := syscall.Syscall(procQueryWorkingSet.Addr(), 3, uintptr(handle), uintptr(pv), uintptr(cb))
|
||||
if r1 == 0 {
|
||||
if e1 != 0 {
|
||||
err = errnoErr(e1)
|
||||
} else {
|
||||
err = syscall.EINVAL
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func GetProcessImageFileName(hProcess windows.Handle, imageFileName *uint16, nSize uint32) (size uint32, err error) {
|
||||
r0, _, e1 := syscall.Syscall(procGetProcessImageFileNameW.Addr(), 3, uintptr(hProcess), uintptr(unsafe.Pointer(imageFileName)), uintptr(nSize))
|
||||
size = uint32(r0)
|
||||
if size == 0 {
|
||||
if e1 != 0 {
|
||||
err = errnoErr(e1)
|
||||
} else {
|
||||
err = syscall.EINVAL
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func GetActiveProcessorCount(groupNumber uint16) (amount uint32) {
|
||||
r0, _, _ := syscall.Syscall(procGetActiveProcessorCount.Addr(), 1, uintptr(groupNumber), 0, 0)
|
||||
amount = uint32(r0)
|
||||
return
|
||||
}
|
||||
|
||||
func CMGetDeviceIDListSize(pulLen *uint32, pszFilter *byte, uFlags uint32) (hr error) {
|
||||
r0, _, _ := syscall.Syscall(procCM_Get_Device_ID_List_SizeA.Addr(), 3, uintptr(unsafe.Pointer(pulLen)), uintptr(unsafe.Pointer(pszFilter)), uintptr(uFlags))
|
||||
if int32(r0) < 0 {
|
||||
if r0&0x1fff0000 == 0x00070000 {
|
||||
r0 &= 0xffff
|
||||
}
|
||||
hr = syscall.Errno(r0)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func CMGetDeviceIDList(pszFilter *byte, buffer *byte, bufferLen uint32, uFlags uint32) (hr error) {
|
||||
r0, _, _ := syscall.Syscall6(procCM_Get_Device_ID_ListA.Addr(), 4, uintptr(unsafe.Pointer(pszFilter)), uintptr(unsafe.Pointer(buffer)), uintptr(bufferLen), uintptr(uFlags), 0, 0)
|
||||
if int32(r0) < 0 {
|
||||
if r0&0x1fff0000 == 0x00070000 {
|
||||
r0 &= 0xffff
|
||||
}
|
||||
hr = syscall.Errno(r0)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func CMLocateDevNode(pdnDevInst *uint32, pDeviceID string, uFlags uint32) (hr error) {
|
||||
var _p0 *uint16
|
||||
_p0, hr = syscall.UTF16PtrFromString(pDeviceID)
|
||||
if hr != nil {
|
||||
return
|
||||
}
|
||||
return _CMLocateDevNode(pdnDevInst, _p0, uFlags)
|
||||
}
|
||||
|
||||
func _CMLocateDevNode(pdnDevInst *uint32, pDeviceID *uint16, uFlags uint32) (hr error) {
|
||||
r0, _, _ := syscall.Syscall(procCM_Locate_DevNodeW.Addr(), 3, uintptr(unsafe.Pointer(pdnDevInst)), uintptr(unsafe.Pointer(pDeviceID)), uintptr(uFlags))
|
||||
if int32(r0) < 0 {
|
||||
if r0&0x1fff0000 == 0x00070000 {
|
||||
r0 &= 0xffff
|
||||
}
|
||||
hr = syscall.Errno(r0)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func CMGetDevNodeProperty(dnDevInst uint32, propertyKey *DevPropKey, propertyType *uint32, propertyBuffer *uint16, propertyBufferSize *uint32, uFlags uint32) (hr error) {
|
||||
r0, _, _ := syscall.Syscall6(procCM_Get_DevNode_PropertyW.Addr(), 6, uintptr(dnDevInst), uintptr(unsafe.Pointer(propertyKey)), uintptr(unsafe.Pointer(propertyType)), uintptr(unsafe.Pointer(propertyBuffer)), uintptr(unsafe.Pointer(propertyBufferSize)), uintptr(uFlags))
|
||||
if int32(r0) < 0 {
|
||||
if r0&0x1fff0000 == 0x00070000 {
|
||||
r0 &= 0xffff
|
||||
}
|
||||
hr = syscall.Errno(r0)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func NtCreateFile(handle *uintptr, accessMask uint32, oa *ObjectAttributes, iosb *IOStatusBlock, allocationSize *uint64, fileAttributes uint32, shareAccess uint32, createDisposition uint32, createOptions uint32, eaBuffer *byte, eaLength uint32) (status uint32) {
|
||||
r0, _, _ := syscall.Syscall12(procNtCreateFile.Addr(), 11, uintptr(unsafe.Pointer(handle)), uintptr(accessMask), uintptr(unsafe.Pointer(oa)), uintptr(unsafe.Pointer(iosb)), uintptr(unsafe.Pointer(allocationSize)), uintptr(fileAttributes), uintptr(shareAccess), uintptr(createDisposition), uintptr(createOptions), uintptr(unsafe.Pointer(eaBuffer)), uintptr(eaLength), 0)
|
||||
status = uint32(r0)
|
||||
return
|
||||
}
|
||||
|
||||
func NtSetInformationFile(handle uintptr, iosb *IOStatusBlock, information uintptr, length uint32, class uint32) (status uint32) {
|
||||
r0, _, _ := syscall.Syscall6(procNtSetInformationFile.Addr(), 5, uintptr(handle), uintptr(unsafe.Pointer(iosb)), uintptr(information), uintptr(length), uintptr(class), 0)
|
||||
status = uint32(r0)
|
||||
return
|
||||
}
|
||||
|
||||
func NtOpenDirectoryObject(handle *uintptr, accessMask uint32, oa *ObjectAttributes) (status uint32) {
|
||||
r0, _, _ := syscall.Syscall(procNtOpenDirectoryObject.Addr(), 3, uintptr(unsafe.Pointer(handle)), uintptr(accessMask), uintptr(unsafe.Pointer(oa)))
|
||||
status = uint32(r0)
|
||||
return
|
||||
}
|
||||
|
||||
func NtQueryDirectoryObject(handle uintptr, buffer *byte, length uint32, singleEntry bool, restartScan bool, context *uint32, returnLength *uint32) (status uint32) {
|
||||
var _p0 uint32
|
||||
if singleEntry {
|
||||
_p0 = 1
|
||||
} else {
|
||||
_p0 = 0
|
||||
}
|
||||
var _p1 uint32
|
||||
if restartScan {
|
||||
_p1 = 1
|
||||
} else {
|
||||
_p1 = 0
|
||||
}
|
||||
r0, _, _ := syscall.Syscall9(procNtQueryDirectoryObject.Addr(), 7, uintptr(handle), uintptr(unsafe.Pointer(buffer)), uintptr(length), uintptr(_p0), uintptr(_p1), uintptr(unsafe.Pointer(context)), uintptr(unsafe.Pointer(returnLength)), 0, 0)
|
||||
status = uint32(r0)
|
||||
return
|
||||
}
|
||||
|
||||
func RtlNtStatusToDosError(status uint32) (winerr error) {
|
||||
r0, _, _ := syscall.Syscall(procRtlNtStatusToDosError.Addr(), 1, uintptr(status), 0, 0)
|
||||
if r0 != 0 {
|
||||
winerr = syscall.Errno(r0)
|
||||
}
|
||||
return
|
||||
}
|
Reference in New Issue
Block a user