mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
8
vendor/golang.org/x/sys/windows/exec_windows.go
generated
vendored
8
vendor/golang.org/x/sys/windows/exec_windows.go
generated
vendored
@@ -111,7 +111,9 @@ func NewProcThreadAttributeList(maxAttrCount uint32) (*ProcThreadAttributeList,
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
al := (*ProcThreadAttributeList)(unsafe.Pointer(&make([]byte, size)[0]))
|
||||
const psize = unsafe.Sizeof(uintptr(0))
|
||||
// size is guaranteed to be ≥1 by InitializeProcThreadAttributeList.
|
||||
al := (*ProcThreadAttributeList)(unsafe.Pointer(&make([]unsafe.Pointer, (size+psize-1)/psize)[0]))
|
||||
err = initializeProcThreadAttributeList(al, maxAttrCount, 0, &size)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -120,8 +122,8 @@ func NewProcThreadAttributeList(maxAttrCount uint32) (*ProcThreadAttributeList,
|
||||
}
|
||||
|
||||
// Update modifies the ProcThreadAttributeList using UpdateProcThreadAttribute.
|
||||
func (al *ProcThreadAttributeList) Update(attribute uintptr, flags uint32, value unsafe.Pointer, size uintptr, prevValue uintptr, returnedSize *uintptr) error {
|
||||
return updateProcThreadAttribute(al, flags, attribute, uintptr(value), size, prevValue, returnedSize)
|
||||
func (al *ProcThreadAttributeList) Update(attribute uintptr, flags uint32, value unsafe.Pointer, size uintptr, prevValue unsafe.Pointer, returnedSize *uintptr) error {
|
||||
return updateProcThreadAttribute(al, flags, attribute, value, size, prevValue, returnedSize)
|
||||
}
|
||||
|
||||
// Delete frees ProcThreadAttributeList's resources.
|
||||
|
7
vendor/golang.org/x/sys/windows/mkerrors.bash
generated
vendored
7
vendor/golang.org/x/sys/windows/mkerrors.bash
generated
vendored
@@ -9,6 +9,8 @@ shopt -s nullglob
|
||||
|
||||
winerror="$(printf '%s\n' "/mnt/c/Program Files (x86)/Windows Kits/"/*/Include/*/shared/winerror.h | sort -Vr | head -n 1)"
|
||||
[[ -n $winerror ]] || { echo "Unable to find winerror.h" >&2; exit 1; }
|
||||
ntstatus="$(printf '%s\n' "/mnt/c/Program Files (x86)/Windows Kits/"/*/Include/*/shared/ntstatus.h | sort -Vr | head -n 1)"
|
||||
[[ -n $ntstatus ]] || { echo "Unable to find ntstatus.h" >&2; exit 1; }
|
||||
|
||||
declare -A errors
|
||||
|
||||
@@ -59,5 +61,10 @@ declare -A errors
|
||||
echo "$key $vtype = $value"
|
||||
done < "$winerror"
|
||||
|
||||
while read -r line; do
|
||||
[[ $line =~ ^#define\ (STATUS_[^\s]+)\ +\(\(NTSTATUS\)((0x)?[0-9a-fA-F]+)L?\) ]] || continue
|
||||
echo "${BASH_REMATCH[1]} NTStatus = ${BASH_REMATCH[2]}"
|
||||
done < "$ntstatus"
|
||||
|
||||
echo ")"
|
||||
} | gofmt > "zerrors_windows.go"
|
||||
|
13
vendor/golang.org/x/sys/windows/security_windows.go
generated
vendored
13
vendor/golang.org/x/sys/windows/security_windows.go
generated
vendored
@@ -908,6 +908,19 @@ type SECURITY_DESCRIPTOR struct {
|
||||
dacl *ACL
|
||||
}
|
||||
|
||||
type SECURITY_QUALITY_OF_SERVICE struct {
|
||||
Length uint32
|
||||
ImpersonationLevel uint32
|
||||
ContextTrackingMode byte
|
||||
EffectiveOnly byte
|
||||
}
|
||||
|
||||
// Constants for the ContextTrackingMode field of SECURITY_QUALITY_OF_SERVICE.
|
||||
const (
|
||||
SECURITY_STATIC_TRACKING = 0
|
||||
SECURITY_DYNAMIC_TRACKING = 1
|
||||
)
|
||||
|
||||
type SecurityAttributes struct {
|
||||
Length uint32
|
||||
SecurityDescriptor *SECURITY_DESCRIPTOR
|
||||
|
100
vendor/golang.org/x/sys/windows/svc/security.go
generated
vendored
100
vendor/golang.org/x/sys/windows/svc/security.go
generated
vendored
@@ -7,8 +7,8 @@
|
||||
package svc
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"syscall"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/sys/windows"
|
||||
@@ -64,101 +64,45 @@ func IsAnInteractiveSession() (bool, error) {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
var (
|
||||
ntdll = windows.NewLazySystemDLL("ntdll.dll")
|
||||
_NtQueryInformationProcess = ntdll.NewProc("NtQueryInformationProcess")
|
||||
|
||||
kernel32 = windows.NewLazySystemDLL("kernel32.dll")
|
||||
_QueryFullProcessImageNameA = kernel32.NewProc("QueryFullProcessImageNameA")
|
||||
)
|
||||
|
||||
// IsWindowsService reports whether the process is currently executing
|
||||
// as a Windows service.
|
||||
func IsWindowsService() (bool, error) {
|
||||
// This code was copied from runtime.isWindowsService function.
|
||||
|
||||
// The below technique looks a bit hairy, but it's actually
|
||||
// exactly what the .NET framework does for the similarly named function:
|
||||
// https://github.com/dotnet/extensions/blob/f4066026ca06984b07e90e61a6390ac38152ba93/src/Hosting/WindowsServices/src/WindowsServiceHelpers.cs#L26-L31
|
||||
// Specifically, it looks up whether the parent process has session ID zero
|
||||
// and is called "services".
|
||||
const _CURRENT_PROCESS = ^uintptr(0)
|
||||
// pbi is a PROCESS_BASIC_INFORMATION struct, where we just care about
|
||||
// the 6th pointer inside of it, which contains the pid of the process
|
||||
// parent:
|
||||
// https://github.com/wine-mirror/wine/blob/42cb7d2ad1caba08de235e6319b9967296b5d554/include/winternl.h#L1294
|
||||
var pbi [6]uintptr
|
||||
var pbiLen uint32
|
||||
r0, _, _ := syscall.Syscall6(_NtQueryInformationProcess.Addr(), 5, _CURRENT_PROCESS, 0, uintptr(unsafe.Pointer(&pbi[0])), uintptr(unsafe.Sizeof(pbi)), uintptr(unsafe.Pointer(&pbiLen)), 0)
|
||||
if r0 != 0 {
|
||||
return false, errors.New("NtQueryInformationProcess failed: error=" + itoa(int(r0)))
|
||||
}
|
||||
var psid uint32
|
||||
err := windows.ProcessIdToSessionId(uint32(pbi[5]), &psid)
|
||||
|
||||
var pbi windows.PROCESS_BASIC_INFORMATION
|
||||
pbiLen := uint32(unsafe.Sizeof(pbi))
|
||||
err := windows.NtQueryInformationProcess(windows.CurrentProcess(), windows.ProcessBasicInformation, unsafe.Pointer(&pbi), pbiLen, &pbiLen)
|
||||
if err != nil {
|
||||
if err == windows.ERROR_INVALID_PARAMETER {
|
||||
// This error happens when Windows cannot find process parent.
|
||||
// Perhaps process parent exited.
|
||||
// Assume we are not running in a service, because service
|
||||
// parent process (services.exe) cannot exit.
|
||||
return false, nil
|
||||
}
|
||||
return false, err
|
||||
}
|
||||
if psid != 0 {
|
||||
// parent session id should be 0 for service process
|
||||
var psid uint32
|
||||
err = windows.ProcessIdToSessionId(uint32(pbi.InheritedFromUniqueProcessId), &psid)
|
||||
if err != nil || psid != 0 {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
pproc, err := windows.OpenProcess(windows.PROCESS_QUERY_LIMITED_INFORMATION, false, uint32(pbi[5]))
|
||||
pproc, err := windows.OpenProcess(windows.PROCESS_QUERY_LIMITED_INFORMATION, false, uint32(pbi.InheritedFromUniqueProcessId))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
defer windows.CloseHandle(pproc)
|
||||
|
||||
// exeName gets the path to the executable image of the parent process
|
||||
var exeName [261]byte
|
||||
exeNameLen := uint32(len(exeName) - 1)
|
||||
r0, _, e0 := syscall.Syscall6(_QueryFullProcessImageNameA.Addr(), 4, uintptr(pproc), 0, uintptr(unsafe.Pointer(&exeName[0])), uintptr(unsafe.Pointer(&exeNameLen)), 0, 0)
|
||||
if r0 == 0 {
|
||||
if e0 != 0 {
|
||||
return false, e0
|
||||
} else {
|
||||
return false, syscall.EINVAL
|
||||
}
|
||||
var exeNameBuf [261]uint16
|
||||
exeNameLen := uint32(len(exeNameBuf) - 1)
|
||||
err = windows.QueryFullProcessImageName(pproc, 0, &exeNameBuf[0], &exeNameLen)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
const (
|
||||
servicesLower = "services.exe"
|
||||
servicesUpper = "SERVICES.EXE"
|
||||
)
|
||||
i := int(exeNameLen) - 1
|
||||
j := len(servicesLower) - 1
|
||||
if i < j {
|
||||
exeName := windows.UTF16ToString(exeNameBuf[:exeNameLen])
|
||||
if !strings.EqualFold(filepath.Base(exeName), "services.exe") {
|
||||
return false, nil
|
||||
}
|
||||
for {
|
||||
if j == -1 {
|
||||
return i == -1 || exeName[i] == '\\', nil
|
||||
}
|
||||
if exeName[i] != servicesLower[j] && exeName[i] != servicesUpper[j] {
|
||||
return false, nil
|
||||
}
|
||||
i--
|
||||
j--
|
||||
system32, err := windows.GetSystemDirectory()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
}
|
||||
|
||||
func itoa(val int) string { // do it here rather than with fmt to avoid dependency
|
||||
if val < 0 {
|
||||
return "-" + itoa(-val)
|
||||
}
|
||||
var buf [32]byte // big enough for int64
|
||||
i := len(buf) - 1
|
||||
for val >= 10 {
|
||||
buf[i] = byte(val%10 + '0')
|
||||
i--
|
||||
val /= 10
|
||||
}
|
||||
buf[i] = byte(val + '0')
|
||||
return string(buf[i:])
|
||||
targetExeName := filepath.Join(system32, "services.exe")
|
||||
return strings.EqualFold(exeName, targetExeName), nil
|
||||
}
|
||||
|
177
vendor/golang.org/x/sys/windows/syscall_windows.go
generated
vendored
177
vendor/golang.org/x/sys/windows/syscall_windows.go
generated
vendored
@@ -8,6 +8,8 @@ package windows
|
||||
|
||||
import (
|
||||
errorspkg "errors"
|
||||
"fmt"
|
||||
"runtime"
|
||||
"sync"
|
||||
"syscall"
|
||||
"time"
|
||||
@@ -65,9 +67,8 @@ const (
|
||||
LOCKFILE_FAIL_IMMEDIATELY = 0x00000001
|
||||
LOCKFILE_EXCLUSIVE_LOCK = 0x00000002
|
||||
|
||||
// Return values of SleepEx and other APC functions
|
||||
STATUS_USER_APC = 0x000000C0
|
||||
WAIT_IO_COMPLETION = STATUS_USER_APC
|
||||
// Return value of SleepEx and other APC functions
|
||||
WAIT_IO_COMPLETION = 0x000000C0
|
||||
)
|
||||
|
||||
// StringToUTF16 is deprecated. Use UTF16FromString instead.
|
||||
@@ -180,6 +181,11 @@ func NewCallbackCDecl(fn interface{}) uintptr {
|
||||
//sys IsWow64Process(handle Handle, isWow64 *bool) (err error) = IsWow64Process
|
||||
//sys IsWow64Process2(handle Handle, processMachine *uint16, nativeMachine *uint16) (err error) = IsWow64Process2?
|
||||
//sys CreateFile(name *uint16, access uint32, mode uint32, sa *SecurityAttributes, createmode uint32, attrs uint32, templatefile Handle) (handle Handle, err error) [failretval==InvalidHandle] = CreateFileW
|
||||
//sys CreateNamedPipe(name *uint16, flags uint32, pipeMode uint32, maxInstances uint32, outSize uint32, inSize uint32, defaultTimeout uint32, sa *SecurityAttributes) (handle Handle, err error) [failretval==InvalidHandle] = CreateNamedPipeW
|
||||
//sys ConnectNamedPipe(pipe Handle, overlapped *Overlapped) (err error)
|
||||
//sys GetNamedPipeInfo(pipe Handle, flags *uint32, outSize *uint32, inSize *uint32, maxInstances *uint32) (err error)
|
||||
//sys GetNamedPipeHandleState(pipe Handle, state *uint32, curInstances *uint32, maxCollectionCount *uint32, collectDataTimeout *uint32, userName *uint16, maxUserNameSize uint32) (err error) = GetNamedPipeHandleStateW
|
||||
//sys SetNamedPipeHandleState(pipe Handle, state *uint32, maxCollectionCount *uint32, collectDataTimeout *uint32) (err error) = SetNamedPipeHandleState
|
||||
//sys ReadFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) (err error)
|
||||
//sys WriteFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) (err error)
|
||||
//sys GetOverlappedResult(handle Handle, overlapped *Overlapped, done *uint32, wait bool) (err error)
|
||||
@@ -216,7 +222,7 @@ func NewCallbackCDecl(fn interface{}) uintptr {
|
||||
//sys CreateProcess(appName *uint16, commandLine *uint16, procSecurity *SecurityAttributes, threadSecurity *SecurityAttributes, inheritHandles bool, creationFlags uint32, env *uint16, currentDir *uint16, startupInfo *StartupInfo, outProcInfo *ProcessInformation) (err error) = CreateProcessW
|
||||
//sys initializeProcThreadAttributeList(attrlist *ProcThreadAttributeList, attrcount uint32, flags uint32, size *uintptr) (err error) = InitializeProcThreadAttributeList
|
||||
//sys deleteProcThreadAttributeList(attrlist *ProcThreadAttributeList) = DeleteProcThreadAttributeList
|
||||
//sys updateProcThreadAttribute(attrlist *ProcThreadAttributeList, flags uint32, attr uintptr, value uintptr, size uintptr, prevvalue uintptr, returnedsize *uintptr) (err error) = UpdateProcThreadAttribute
|
||||
//sys updateProcThreadAttribute(attrlist *ProcThreadAttributeList, flags uint32, attr uintptr, value unsafe.Pointer, size uintptr, prevvalue unsafe.Pointer, returnedsize *uintptr) (err error) = UpdateProcThreadAttribute
|
||||
//sys OpenProcess(desiredAccess uint32, inheritHandle bool, processId uint32) (handle Handle, err error)
|
||||
//sys ShellExecute(hwnd Handle, verb *uint16, file *uint16, args *uint16, cwd *uint16, showCmd int32) (err error) [failretval<=32] = shell32.ShellExecuteW
|
||||
//sys GetWindowThreadProcessId(hwnd HWND, pid *uint32) (tid uint32, err error) = user32.GetWindowThreadProcessId
|
||||
@@ -251,13 +257,14 @@ func NewCallbackCDecl(fn interface{}) uintptr {
|
||||
//sys GetCommandLine() (cmd *uint16) = kernel32.GetCommandLineW
|
||||
//sys CommandLineToArgv(cmd *uint16, argc *int32) (argv *[8192]*[8192]uint16, err error) [failretval==nil] = shell32.CommandLineToArgvW
|
||||
//sys LocalFree(hmem Handle) (handle Handle, err error) [failretval!=0]
|
||||
//sys LocalAlloc(flags uint32, length uint32) (ptr uintptr, err error)
|
||||
//sys SetHandleInformation(handle Handle, mask uint32, flags uint32) (err error)
|
||||
//sys FlushFileBuffers(handle Handle) (err error)
|
||||
//sys GetFullPathName(path *uint16, buflen uint32, buf *uint16, fname **uint16) (n uint32, err error) = kernel32.GetFullPathNameW
|
||||
//sys GetLongPathName(path *uint16, buf *uint16, buflen uint32) (n uint32, err error) = kernel32.GetLongPathNameW
|
||||
//sys GetShortPathName(longpath *uint16, shortpath *uint16, buflen uint32) (n uint32, err error) = kernel32.GetShortPathNameW
|
||||
//sys GetFinalPathNameByHandle(file Handle, filePath *uint16, filePathSize uint32, flags uint32) (n uint32, err error) = kernel32.GetFinalPathNameByHandleW
|
||||
//sys CreateFileMapping(fhandle Handle, sa *SecurityAttributes, prot uint32, maxSizeHigh uint32, maxSizeLow uint32, name *uint16) (handle Handle, err error) = kernel32.CreateFileMappingW
|
||||
//sys CreateFileMapping(fhandle Handle, sa *SecurityAttributes, prot uint32, maxSizeHigh uint32, maxSizeLow uint32, name *uint16) (handle Handle, err error) [failretval == 0 || e1 == ERROR_ALREADY_EXISTS] = kernel32.CreateFileMappingW
|
||||
//sys MapViewOfFile(handle Handle, access uint32, offsetHigh uint32, offsetLow uint32, length uintptr) (addr uintptr, err error)
|
||||
//sys UnmapViewOfFile(addr uintptr) (err error)
|
||||
//sys FlushViewOfFile(addr uintptr, length uintptr) (err error)
|
||||
@@ -318,14 +325,14 @@ func NewCallbackCDecl(fn interface{}) uintptr {
|
||||
//sys CreateSymbolicLink(symlinkfilename *uint16, targetfilename *uint16, flags uint32) (err error) [failretval&0xff==0] = CreateSymbolicLinkW
|
||||
//sys CreateHardLink(filename *uint16, existingfilename *uint16, reserved uintptr) (err error) [failretval&0xff==0] = CreateHardLinkW
|
||||
//sys GetCurrentThreadId() (id uint32)
|
||||
//sys CreateEvent(eventAttrs *SecurityAttributes, manualReset uint32, initialState uint32, name *uint16) (handle Handle, err error) = kernel32.CreateEventW
|
||||
//sys CreateEventEx(eventAttrs *SecurityAttributes, name *uint16, flags uint32, desiredAccess uint32) (handle Handle, err error) = kernel32.CreateEventExW
|
||||
//sys CreateEvent(eventAttrs *SecurityAttributes, manualReset uint32, initialState uint32, name *uint16) (handle Handle, err error) [failretval == 0 || e1 == ERROR_ALREADY_EXISTS] = kernel32.CreateEventW
|
||||
//sys CreateEventEx(eventAttrs *SecurityAttributes, name *uint16, flags uint32, desiredAccess uint32) (handle Handle, err error) [failretval == 0 || e1 == ERROR_ALREADY_EXISTS] = kernel32.CreateEventExW
|
||||
//sys OpenEvent(desiredAccess uint32, inheritHandle bool, name *uint16) (handle Handle, err error) = kernel32.OpenEventW
|
||||
//sys SetEvent(event Handle) (err error) = kernel32.SetEvent
|
||||
//sys ResetEvent(event Handle) (err error) = kernel32.ResetEvent
|
||||
//sys PulseEvent(event Handle) (err error) = kernel32.PulseEvent
|
||||
//sys CreateMutex(mutexAttrs *SecurityAttributes, initialOwner bool, name *uint16) (handle Handle, err error) = kernel32.CreateMutexW
|
||||
//sys CreateMutexEx(mutexAttrs *SecurityAttributes, name *uint16, flags uint32, desiredAccess uint32) (handle Handle, err error) = kernel32.CreateMutexExW
|
||||
//sys CreateMutex(mutexAttrs *SecurityAttributes, initialOwner bool, name *uint16) (handle Handle, err error) [failretval == 0 || e1 == ERROR_ALREADY_EXISTS] = kernel32.CreateMutexW
|
||||
//sys CreateMutexEx(mutexAttrs *SecurityAttributes, name *uint16, flags uint32, desiredAccess uint32) (handle Handle, err error) [failretval == 0 || e1 == ERROR_ALREADY_EXISTS] = kernel32.CreateMutexExW
|
||||
//sys OpenMutex(desiredAccess uint32, inheritHandle bool, name *uint16) (handle Handle, err error) = kernel32.OpenMutexW
|
||||
//sys ReleaseMutex(mutex Handle) (err error) = kernel32.ReleaseMutex
|
||||
//sys SleepEx(milliseconds uint32, alertable bool) (ret uint32) = kernel32.SleepEx
|
||||
@@ -340,6 +347,7 @@ func NewCallbackCDecl(fn interface{}) uintptr {
|
||||
//sys SetInformationJobObject(job Handle, JobObjectInformationClass uint32, JobObjectInformation uintptr, JobObjectInformationLength uint32) (ret int, err error)
|
||||
//sys GenerateConsoleCtrlEvent(ctrlEvent uint32, processGroupID uint32) (err error)
|
||||
//sys GetProcessId(process Handle) (id uint32, err error)
|
||||
//sys QueryFullProcessImageName(proc Handle, flags uint32, exeName *uint16, size *uint32) (err error) = kernel32.QueryFullProcessImageNameW
|
||||
//sys OpenThread(desiredAccess uint32, inheritHandle bool, threadId uint32) (handle Handle, err error)
|
||||
//sys SetProcessPriorityBoost(process Handle, disable bool) (err error) = kernel32.SetProcessPriorityBoost
|
||||
//sys GetProcessWorkingSetSizeEx(hProcess Handle, lpMinimumWorkingSetSize *uintptr, lpMaximumWorkingSetSize *uintptr, flags *uint32)
|
||||
@@ -375,16 +383,36 @@ func NewCallbackCDecl(fn interface{}) uintptr {
|
||||
//sys stringFromGUID2(rguid *GUID, lpsz *uint16, cchMax int32) (chars int32) = ole32.StringFromGUID2
|
||||
//sys coCreateGuid(pguid *GUID) (ret error) = ole32.CoCreateGuid
|
||||
//sys CoTaskMemFree(address unsafe.Pointer) = ole32.CoTaskMemFree
|
||||
//sys rtlGetVersion(info *OsVersionInfoEx) (ret error) = ntdll.RtlGetVersion
|
||||
//sys rtlGetNtVersionNumbers(majorVersion *uint32, minorVersion *uint32, buildNumber *uint32) = ntdll.RtlGetNtVersionNumbers
|
||||
//sys CoInitializeEx(reserved uintptr, coInit uint32) (ret error) = ole32.CoInitializeEx
|
||||
//sys CoUninitialize() = ole32.CoUninitialize
|
||||
//sys CoGetObject(name *uint16, bindOpts *BIND_OPTS3, guid *GUID, functionTable **uintptr) (ret error) = ole32.CoGetObject
|
||||
//sys getProcessPreferredUILanguages(flags uint32, numLanguages *uint32, buf *uint16, bufSize *uint32) (err error) = kernel32.GetProcessPreferredUILanguages
|
||||
//sys getThreadPreferredUILanguages(flags uint32, numLanguages *uint32, buf *uint16, bufSize *uint32) (err error) = kernel32.GetThreadPreferredUILanguages
|
||||
//sys getUserPreferredUILanguages(flags uint32, numLanguages *uint32, buf *uint16, bufSize *uint32) (err error) = kernel32.GetUserPreferredUILanguages
|
||||
//sys getSystemPreferredUILanguages(flags uint32, numLanguages *uint32, buf *uint16, bufSize *uint32) (err error) = kernel32.GetSystemPreferredUILanguages
|
||||
//sys findResource(module Handle, name uintptr, resType uintptr) (resInfo Handle, err error) = kernel32.FindResourceW
|
||||
//sys SizeofResource(module Handle, resInfo Handle) (size uint32, err error) = kernel32.SizeofResource
|
||||
//sys LoadResource(module Handle, resInfo Handle) (resData Handle, err error) = kernel32.LoadResource
|
||||
//sys LockResource(resData Handle) (addr uintptr, err error) = kernel32.LockResource
|
||||
|
||||
// Process Status API (PSAPI)
|
||||
//sys EnumProcesses(processIds []uint32, bytesReturned *uint32) (err error) = psapi.EnumProcesses
|
||||
|
||||
// NT Native APIs
|
||||
//sys rtlNtStatusToDosErrorNoTeb(ntstatus NTStatus) (ret syscall.Errno) = ntdll.RtlNtStatusToDosErrorNoTeb
|
||||
//sys rtlGetVersion(info *OsVersionInfoEx) (ntstatus error) = ntdll.RtlGetVersion
|
||||
//sys rtlGetNtVersionNumbers(majorVersion *uint32, minorVersion *uint32, buildNumber *uint32) = ntdll.RtlGetNtVersionNumbers
|
||||
//sys RtlGetCurrentPeb() (peb *PEB) = ntdll.RtlGetCurrentPeb
|
||||
//sys RtlInitUnicodeString(destinationString *NTUnicodeString, sourceString *uint16) = ntdll.RtlInitUnicodeString
|
||||
//sys RtlInitString(destinationString *NTString, sourceString *byte) = ntdll.RtlInitString
|
||||
//sys NtCreateFile(handle *Handle, access uint32, oa *OBJECT_ATTRIBUTES, iosb *IO_STATUS_BLOCK, allocationSize *int64, attributes uint32, share uint32, disposition uint32, options uint32, eabuffer uintptr, ealength uint32) (ntstatus error) = ntdll.NtCreateFile
|
||||
//sys NtCreateNamedPipeFile(pipe *Handle, access uint32, oa *OBJECT_ATTRIBUTES, iosb *IO_STATUS_BLOCK, share uint32, disposition uint32, options uint32, typ uint32, readMode uint32, completionMode uint32, maxInstances uint32, inboundQuota uint32, outputQuota uint32, timeout *int64) (ntstatus error) = ntdll.NtCreateNamedPipeFile
|
||||
//sys RtlDosPathNameToNtPathName(dosName *uint16, ntName *NTUnicodeString, ntFileNamePart *uint16, relativeName *RTL_RELATIVE_NAME) (ntstatus error) = ntdll.RtlDosPathNameToNtPathName_U_WithStatus
|
||||
//sys RtlDosPathNameToRelativeNtPathName(dosName *uint16, ntName *NTUnicodeString, ntFileNamePart *uint16, relativeName *RTL_RELATIVE_NAME) (ntstatus error) = ntdll.RtlDosPathNameToRelativeNtPathName_U_WithStatus
|
||||
//sys RtlDefaultNpAcl(acl **ACL) (ntstatus error) = ntdll.RtlDefaultNpAcl
|
||||
//sys NtQueryInformationProcess(proc Handle, procInfoClass int32, procInfo unsafe.Pointer, procInfoLen uint32, retLen *uint32) (ntstatus error) = ntdll.NtQueryInformationProcess
|
||||
//sys NtSetInformationProcess(proc Handle, procInfoClass int32, procInfo unsafe.Pointer, procInfoLen uint32) (ntstatus error) = ntdll.NtSetInformationProcess
|
||||
|
||||
// syscall interface implementation for other packages
|
||||
|
||||
// GetCurrentProcess returns the handle for the current process.
|
||||
@@ -792,6 +820,7 @@ const socket_error = uintptr(^uint32(0))
|
||||
//sys GetAdaptersInfo(ai *IpAdapterInfo, ol *uint32) (errcode error) = iphlpapi.GetAdaptersInfo
|
||||
//sys SetFileCompletionNotificationModes(handle Handle, flags uint8) (err error) = kernel32.SetFileCompletionNotificationModes
|
||||
//sys WSAEnumProtocols(protocols *int32, protocolBuffer *WSAProtocolInfo, bufferLength *uint32) (n int32, err error) [failretval==-1] = ws2_32.WSAEnumProtocolsW
|
||||
//sys WSAGetOverlappedResult(h Handle, o *Overlapped, bytes *uint32, wait bool, flags *uint32) (err error) = ws2_32.WSAGetOverlappedResult
|
||||
//sys GetAdaptersAddresses(family uint32, flags uint32, reserved uintptr, adapterAddresses *IpAdapterAddresses, sizePointer *uint32) (errcode error) = iphlpapi.GetAdaptersAddresses
|
||||
//sys GetACP() (acp uint32) = kernel32.GetACP
|
||||
//sys MultiByteToWideChar(codePage uint32, dwFlags uint32, str *byte, nstr int32, wchar *uint16, nwchar int32) (nwrite int32, err error) = kernel32.MultiByteToWideChar
|
||||
@@ -1514,3 +1543,129 @@ func getUILanguages(flags uint32, f func(flags uint32, numLanguages *uint32, buf
|
||||
func SetConsoleCursorPosition(console Handle, position Coord) error {
|
||||
return setConsoleCursorPosition(console, *((*uint32)(unsafe.Pointer(&position))))
|
||||
}
|
||||
|
||||
func (s NTStatus) Errno() syscall.Errno {
|
||||
return rtlNtStatusToDosErrorNoTeb(s)
|
||||
}
|
||||
|
||||
func langID(pri, sub uint16) uint32 { return uint32(sub)<<10 | uint32(pri) }
|
||||
|
||||
func (s NTStatus) Error() string {
|
||||
b := make([]uint16, 300)
|
||||
n, err := FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_FROM_HMODULE|FORMAT_MESSAGE_ARGUMENT_ARRAY, modntdll.Handle(), uint32(s), langID(LANG_ENGLISH, SUBLANG_ENGLISH_US), b, nil)
|
||||
if err != nil {
|
||||
return fmt.Sprintf("NTSTATUS 0x%08x", uint32(s))
|
||||
}
|
||||
// trim terminating \r and \n
|
||||
for ; n > 0 && (b[n-1] == '\n' || b[n-1] == '\r'); n-- {
|
||||
}
|
||||
return string(utf16.Decode(b[:n]))
|
||||
}
|
||||
|
||||
// NewNTUnicodeString returns a new NTUnicodeString structure for use with native
|
||||
// NT APIs that work over the NTUnicodeString type. Note that most Windows APIs
|
||||
// do not use NTUnicodeString, and instead UTF16PtrFromString should be used for
|
||||
// the more common *uint16 string type.
|
||||
func NewNTUnicodeString(s string) (*NTUnicodeString, error) {
|
||||
var u NTUnicodeString
|
||||
s16, err := UTF16PtrFromString(s)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
RtlInitUnicodeString(&u, s16)
|
||||
return &u, nil
|
||||
}
|
||||
|
||||
// Slice returns a uint16 slice that aliases the data in the NTUnicodeString.
|
||||
func (s *NTUnicodeString) Slice() []uint16 {
|
||||
var slice []uint16
|
||||
hdr := (*unsafeheader.Slice)(unsafe.Pointer(&slice))
|
||||
hdr.Data = unsafe.Pointer(s.Buffer)
|
||||
hdr.Len = int(s.Length)
|
||||
hdr.Cap = int(s.MaximumLength)
|
||||
return slice
|
||||
}
|
||||
|
||||
func (s *NTUnicodeString) String() string {
|
||||
return UTF16ToString(s.Slice())
|
||||
}
|
||||
|
||||
// NewNTString returns a new NTString structure for use with native
|
||||
// NT APIs that work over the NTString type. Note that most Windows APIs
|
||||
// do not use NTString, and instead UTF16PtrFromString should be used for
|
||||
// the more common *uint16 string type.
|
||||
func NewNTString(s string) (*NTString, error) {
|
||||
var nts NTString
|
||||
s8, err := BytePtrFromString(s)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
RtlInitString(&nts, s8)
|
||||
return &nts, nil
|
||||
}
|
||||
|
||||
// Slice returns a byte slice that aliases the data in the NTString.
|
||||
func (s *NTString) Slice() []byte {
|
||||
var slice []byte
|
||||
hdr := (*unsafeheader.Slice)(unsafe.Pointer(&slice))
|
||||
hdr.Data = unsafe.Pointer(s.Buffer)
|
||||
hdr.Len = int(s.Length)
|
||||
hdr.Cap = int(s.MaximumLength)
|
||||
return slice
|
||||
}
|
||||
|
||||
func (s *NTString) String() string {
|
||||
return ByteSliceToString(s.Slice())
|
||||
}
|
||||
|
||||
// FindResource resolves a resource of the given name and resource type.
|
||||
func FindResource(module Handle, name, resType ResourceIDOrString) (Handle, error) {
|
||||
var namePtr, resTypePtr uintptr
|
||||
var name16, resType16 *uint16
|
||||
var err error
|
||||
resolvePtr := func(i interface{}, keep **uint16) (uintptr, error) {
|
||||
switch v := i.(type) {
|
||||
case string:
|
||||
*keep, err = UTF16PtrFromString(v)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return uintptr(unsafe.Pointer(*keep)), nil
|
||||
case ResourceID:
|
||||
return uintptr(v), nil
|
||||
}
|
||||
return 0, errorspkg.New("parameter must be a ResourceID or a string")
|
||||
}
|
||||
namePtr, err = resolvePtr(name, &name16)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
resTypePtr, err = resolvePtr(resType, &resType16)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
resInfo, err := findResource(module, namePtr, resTypePtr)
|
||||
runtime.KeepAlive(name16)
|
||||
runtime.KeepAlive(resType16)
|
||||
return resInfo, err
|
||||
}
|
||||
|
||||
func LoadResourceData(module, resInfo Handle) (data []byte, err error) {
|
||||
size, err := SizeofResource(module, resInfo)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
resData, err := LoadResource(module, resInfo)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
ptr, err := LockResource(resData)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
h := (*unsafeheader.Slice)(unsafe.Pointer(&data))
|
||||
h.Data = unsafe.Pointer(ptr)
|
||||
h.Len = int(size)
|
||||
h.Cap = int(size)
|
||||
return
|
||||
}
|
||||
|
506
vendor/golang.org/x/sys/windows/types_windows.go
generated
vendored
506
vendor/golang.org/x/sys/windows/types_windows.go
generated
vendored
@@ -10,6 +10,10 @@ import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// NTStatus corresponds with NTSTATUS, error values returned by ntdll.dll and
|
||||
// other native functions.
|
||||
type NTStatus uint32
|
||||
|
||||
const (
|
||||
// Invented values to support what package os expects.
|
||||
O_RDONLY = 0x00000
|
||||
@@ -908,7 +912,11 @@ type StartupInfoEx struct {
|
||||
// To create a *ProcThreadAttributeList, use NewProcThreadAttributeList, and
|
||||
// free its memory using ProcThreadAttributeList.Delete.
|
||||
type ProcThreadAttributeList struct {
|
||||
_ [1]byte
|
||||
// This is of type unsafe.Pointer, not of type byte or uintptr, because
|
||||
// the contents of it is mostly a list of pointers, and in most cases,
|
||||
// that's a list of pointers to Go-allocated objects. In order to keep
|
||||
// the GC from collecting these objects, we declare this as unsafe.Pointer.
|
||||
_ [1]unsafe.Pointer
|
||||
}
|
||||
|
||||
type ProcessInformation struct {
|
||||
@@ -1012,6 +1020,7 @@ const (
|
||||
|
||||
// cf. http://support.microsoft.com/default.aspx?scid=kb;en-us;257460
|
||||
|
||||
IP_HDRINCL = 0x2
|
||||
IP_TOS = 0x3
|
||||
IP_TTL = 0x4
|
||||
IP_MULTICAST_IF = 0x9
|
||||
@@ -1019,6 +1028,7 @@ const (
|
||||
IP_MULTICAST_LOOP = 0xb
|
||||
IP_ADD_MEMBERSHIP = 0xc
|
||||
IP_DROP_MEMBERSHIP = 0xd
|
||||
IP_PKTINFO = 0x13
|
||||
|
||||
IPV6_V6ONLY = 0x1b
|
||||
IPV6_UNICAST_HOPS = 0x4
|
||||
@@ -1027,6 +1037,7 @@ const (
|
||||
IPV6_MULTICAST_LOOP = 0xb
|
||||
IPV6_JOIN_GROUP = 0xc
|
||||
IPV6_LEAVE_GROUP = 0xd
|
||||
IPV6_PKTINFO = 0x13
|
||||
|
||||
MSG_OOB = 0x1
|
||||
MSG_PEEK = 0x2
|
||||
@@ -2268,3 +2279,496 @@ type CommTimeouts struct {
|
||||
WriteTotalTimeoutMultiplier uint32
|
||||
WriteTotalTimeoutConstant uint32
|
||||
}
|
||||
|
||||
// NTUnicodeString is a UTF-16 string for NT native APIs, corresponding to UNICODE_STRING.
|
||||
type NTUnicodeString struct {
|
||||
Length uint16
|
||||
MaximumLength uint16
|
||||
Buffer *uint16
|
||||
}
|
||||
|
||||
// NTString is an ANSI string for NT native APIs, corresponding to STRING.
|
||||
type NTString struct {
|
||||
Length uint16
|
||||
MaximumLength uint16
|
||||
Buffer *byte
|
||||
}
|
||||
|
||||
type LIST_ENTRY struct {
|
||||
Flink *LIST_ENTRY
|
||||
Blink *LIST_ENTRY
|
||||
}
|
||||
|
||||
type LDR_DATA_TABLE_ENTRY struct {
|
||||
reserved1 [2]uintptr
|
||||
InMemoryOrderLinks LIST_ENTRY
|
||||
reserved2 [2]uintptr
|
||||
DllBase uintptr
|
||||
reserved3 [2]uintptr
|
||||
FullDllName NTUnicodeString
|
||||
reserved4 [8]byte
|
||||
reserved5 [3]uintptr
|
||||
reserved6 uintptr
|
||||
TimeDateStamp uint32
|
||||
}
|
||||
|
||||
type PEB_LDR_DATA struct {
|
||||
reserved1 [8]byte
|
||||
reserved2 [3]uintptr
|
||||
InMemoryOrderModuleList LIST_ENTRY
|
||||
}
|
||||
|
||||
type CURDIR struct {
|
||||
DosPath NTUnicodeString
|
||||
Handle Handle
|
||||
}
|
||||
|
||||
type RTL_DRIVE_LETTER_CURDIR struct {
|
||||
Flags uint16
|
||||
Length uint16
|
||||
TimeStamp uint32
|
||||
DosPath NTString
|
||||
}
|
||||
|
||||
type RTL_USER_PROCESS_PARAMETERS struct {
|
||||
MaximumLength, Length uint32
|
||||
|
||||
Flags, DebugFlags uint32
|
||||
|
||||
ConsoleHandle Handle
|
||||
ConsoleFlags uint32
|
||||
StandardInput, StandardOutput, StandardError Handle
|
||||
|
||||
CurrentDirectory CURDIR
|
||||
DllPath NTUnicodeString
|
||||
ImagePathName NTUnicodeString
|
||||
CommandLine NTUnicodeString
|
||||
Environment unsafe.Pointer
|
||||
|
||||
StartingX, StartingY, CountX, CountY, CountCharsX, CountCharsY, FillAttribute uint32
|
||||
|
||||
WindowFlags, ShowWindowFlags uint32
|
||||
WindowTitle, DesktopInfo, ShellInfo, RuntimeData NTUnicodeString
|
||||
CurrentDirectories [32]RTL_DRIVE_LETTER_CURDIR
|
||||
|
||||
EnvironmentSize, EnvironmentVersion uintptr
|
||||
|
||||
PackageDependencyData unsafe.Pointer
|
||||
ProcessGroupId uint32
|
||||
LoaderThreads uint32
|
||||
|
||||
RedirectionDllName NTUnicodeString
|
||||
HeapPartitionName NTUnicodeString
|
||||
DefaultThreadpoolCpuSetMasks uintptr
|
||||
DefaultThreadpoolCpuSetMaskCount uint32
|
||||
}
|
||||
|
||||
type PEB struct {
|
||||
reserved1 [2]byte
|
||||
BeingDebugged byte
|
||||
BitField byte
|
||||
reserved3 uintptr
|
||||
ImageBaseAddress uintptr
|
||||
Ldr *PEB_LDR_DATA
|
||||
ProcessParameters *RTL_USER_PROCESS_PARAMETERS
|
||||
reserved4 [3]uintptr
|
||||
AtlThunkSListPtr uintptr
|
||||
reserved5 uintptr
|
||||
reserved6 uint32
|
||||
reserved7 uintptr
|
||||
reserved8 uint32
|
||||
AtlThunkSListPtr32 uint32
|
||||
reserved9 [45]uintptr
|
||||
reserved10 [96]byte
|
||||
PostProcessInitRoutine uintptr
|
||||
reserved11 [128]byte
|
||||
reserved12 [1]uintptr
|
||||
SessionId uint32
|
||||
}
|
||||
|
||||
type OBJECT_ATTRIBUTES struct {
|
||||
Length uint32
|
||||
RootDirectory Handle
|
||||
ObjectName *NTUnicodeString
|
||||
Attributes uint32
|
||||
SecurityDescriptor *SECURITY_DESCRIPTOR
|
||||
SecurityQoS *SECURITY_QUALITY_OF_SERVICE
|
||||
}
|
||||
|
||||
// Values for the Attributes member of OBJECT_ATTRIBUTES.
|
||||
const (
|
||||
OBJ_INHERIT = 0x00000002
|
||||
OBJ_PERMANENT = 0x00000010
|
||||
OBJ_EXCLUSIVE = 0x00000020
|
||||
OBJ_CASE_INSENSITIVE = 0x00000040
|
||||
OBJ_OPENIF = 0x00000080
|
||||
OBJ_OPENLINK = 0x00000100
|
||||
OBJ_KERNEL_HANDLE = 0x00000200
|
||||
OBJ_FORCE_ACCESS_CHECK = 0x00000400
|
||||
OBJ_IGNORE_IMPERSONATED_DEVICEMAP = 0x00000800
|
||||
OBJ_DONT_REPARSE = 0x00001000
|
||||
OBJ_VALID_ATTRIBUTES = 0x00001FF2
|
||||
)
|
||||
|
||||
type IO_STATUS_BLOCK struct {
|
||||
Status NTStatus
|
||||
Information uintptr
|
||||
}
|
||||
|
||||
type RTLP_CURDIR_REF struct {
|
||||
RefCount int32
|
||||
Handle Handle
|
||||
}
|
||||
|
||||
type RTL_RELATIVE_NAME struct {
|
||||
RelativeName NTUnicodeString
|
||||
ContainingDirectory Handle
|
||||
CurDirRef *RTLP_CURDIR_REF
|
||||
}
|
||||
|
||||
const (
|
||||
// CreateDisposition flags for NtCreateFile and NtCreateNamedPipeFile.
|
||||
FILE_SUPERSEDE = 0x00000000
|
||||
FILE_OPEN = 0x00000001
|
||||
FILE_CREATE = 0x00000002
|
||||
FILE_OPEN_IF = 0x00000003
|
||||
FILE_OVERWRITE = 0x00000004
|
||||
FILE_OVERWRITE_IF = 0x00000005
|
||||
FILE_MAXIMUM_DISPOSITION = 0x00000005
|
||||
|
||||
// CreateOptions flags for NtCreateFile and NtCreateNamedPipeFile.
|
||||
FILE_DIRECTORY_FILE = 0x00000001
|
||||
FILE_WRITE_THROUGH = 0x00000002
|
||||
FILE_SEQUENTIAL_ONLY = 0x00000004
|
||||
FILE_NO_INTERMEDIATE_BUFFERING = 0x00000008
|
||||
FILE_SYNCHRONOUS_IO_ALERT = 0x00000010
|
||||
FILE_SYNCHRONOUS_IO_NONALERT = 0x00000020
|
||||
FILE_NON_DIRECTORY_FILE = 0x00000040
|
||||
FILE_CREATE_TREE_CONNECTION = 0x00000080
|
||||
FILE_COMPLETE_IF_OPLOCKED = 0x00000100
|
||||
FILE_NO_EA_KNOWLEDGE = 0x00000200
|
||||
FILE_OPEN_REMOTE_INSTANCE = 0x00000400
|
||||
FILE_RANDOM_ACCESS = 0x00000800
|
||||
FILE_DELETE_ON_CLOSE = 0x00001000
|
||||
FILE_OPEN_BY_FILE_ID = 0x00002000
|
||||
FILE_OPEN_FOR_BACKUP_INTENT = 0x00004000
|
||||
FILE_NO_COMPRESSION = 0x00008000
|
||||
FILE_OPEN_REQUIRING_OPLOCK = 0x00010000
|
||||
FILE_DISALLOW_EXCLUSIVE = 0x00020000
|
||||
FILE_RESERVE_OPFILTER = 0x00100000
|
||||
FILE_OPEN_REPARSE_POINT = 0x00200000
|
||||
FILE_OPEN_NO_RECALL = 0x00400000
|
||||
FILE_OPEN_FOR_FREE_SPACE_QUERY = 0x00800000
|
||||
|
||||
// Parameter constants for NtCreateNamedPipeFile.
|
||||
|
||||
FILE_PIPE_BYTE_STREAM_TYPE = 0x00000000
|
||||
FILE_PIPE_MESSAGE_TYPE = 0x00000001
|
||||
|
||||
FILE_PIPE_ACCEPT_REMOTE_CLIENTS = 0x00000000
|
||||
FILE_PIPE_REJECT_REMOTE_CLIENTS = 0x00000002
|
||||
|
||||
FILE_PIPE_TYPE_VALID_MASK = 0x00000003
|
||||
|
||||
FILE_PIPE_BYTE_STREAM_MODE = 0x00000000
|
||||
FILE_PIPE_MESSAGE_MODE = 0x00000001
|
||||
|
||||
FILE_PIPE_QUEUE_OPERATION = 0x00000000
|
||||
FILE_PIPE_COMPLETE_OPERATION = 0x00000001
|
||||
|
||||
FILE_PIPE_INBOUND = 0x00000000
|
||||
FILE_PIPE_OUTBOUND = 0x00000001
|
||||
FILE_PIPE_FULL_DUPLEX = 0x00000002
|
||||
|
||||
FILE_PIPE_DISCONNECTED_STATE = 0x00000001
|
||||
FILE_PIPE_LISTENING_STATE = 0x00000002
|
||||
FILE_PIPE_CONNECTED_STATE = 0x00000003
|
||||
FILE_PIPE_CLOSING_STATE = 0x00000004
|
||||
|
||||
FILE_PIPE_CLIENT_END = 0x00000000
|
||||
FILE_PIPE_SERVER_END = 0x00000001
|
||||
)
|
||||
|
||||
// ProcessInformationClasses for NtQueryInformationProcess and NtSetInformationProcess.
|
||||
const (
|
||||
ProcessBasicInformation = iota
|
||||
ProcessQuotaLimits
|
||||
ProcessIoCounters
|
||||
ProcessVmCounters
|
||||
ProcessTimes
|
||||
ProcessBasePriority
|
||||
ProcessRaisePriority
|
||||
ProcessDebugPort
|
||||
ProcessExceptionPort
|
||||
ProcessAccessToken
|
||||
ProcessLdtInformation
|
||||
ProcessLdtSize
|
||||
ProcessDefaultHardErrorMode
|
||||
ProcessIoPortHandlers
|
||||
ProcessPooledUsageAndLimits
|
||||
ProcessWorkingSetWatch
|
||||
ProcessUserModeIOPL
|
||||
ProcessEnableAlignmentFaultFixup
|
||||
ProcessPriorityClass
|
||||
ProcessWx86Information
|
||||
ProcessHandleCount
|
||||
ProcessAffinityMask
|
||||
ProcessPriorityBoost
|
||||
ProcessDeviceMap
|
||||
ProcessSessionInformation
|
||||
ProcessForegroundInformation
|
||||
ProcessWow64Information
|
||||
ProcessImageFileName
|
||||
ProcessLUIDDeviceMapsEnabled
|
||||
ProcessBreakOnTermination
|
||||
ProcessDebugObjectHandle
|
||||
ProcessDebugFlags
|
||||
ProcessHandleTracing
|
||||
ProcessIoPriority
|
||||
ProcessExecuteFlags
|
||||
ProcessTlsInformation
|
||||
ProcessCookie
|
||||
ProcessImageInformation
|
||||
ProcessCycleTime
|
||||
ProcessPagePriority
|
||||
ProcessInstrumentationCallback
|
||||
ProcessThreadStackAllocation
|
||||
ProcessWorkingSetWatchEx
|
||||
ProcessImageFileNameWin32
|
||||
ProcessImageFileMapping
|
||||
ProcessAffinityUpdateMode
|
||||
ProcessMemoryAllocationMode
|
||||
ProcessGroupInformation
|
||||
ProcessTokenVirtualizationEnabled
|
||||
ProcessConsoleHostProcess
|
||||
ProcessWindowInformation
|
||||
ProcessHandleInformation
|
||||
ProcessMitigationPolicy
|
||||
ProcessDynamicFunctionTableInformation
|
||||
ProcessHandleCheckingMode
|
||||
ProcessKeepAliveCount
|
||||
ProcessRevokeFileHandles
|
||||
ProcessWorkingSetControl
|
||||
ProcessHandleTable
|
||||
ProcessCheckStackExtentsMode
|
||||
ProcessCommandLineInformation
|
||||
ProcessProtectionInformation
|
||||
ProcessMemoryExhaustion
|
||||
ProcessFaultInformation
|
||||
ProcessTelemetryIdInformation
|
||||
ProcessCommitReleaseInformation
|
||||
ProcessDefaultCpuSetsInformation
|
||||
ProcessAllowedCpuSetsInformation
|
||||
ProcessSubsystemProcess
|
||||
ProcessJobMemoryInformation
|
||||
ProcessInPrivate
|
||||
ProcessRaiseUMExceptionOnInvalidHandleClose
|
||||
ProcessIumChallengeResponse
|
||||
ProcessChildProcessInformation
|
||||
ProcessHighGraphicsPriorityInformation
|
||||
ProcessSubsystemInformation
|
||||
ProcessEnergyValues
|
||||
ProcessActivityThrottleState
|
||||
ProcessActivityThrottlePolicy
|
||||
ProcessWin32kSyscallFilterInformation
|
||||
ProcessDisableSystemAllowedCpuSets
|
||||
ProcessWakeInformation
|
||||
ProcessEnergyTrackingState
|
||||
ProcessManageWritesToExecutableMemory
|
||||
ProcessCaptureTrustletLiveDump
|
||||
ProcessTelemetryCoverage
|
||||
ProcessEnclaveInformation
|
||||
ProcessEnableReadWriteVmLogging
|
||||
ProcessUptimeInformation
|
||||
ProcessImageSection
|
||||
ProcessDebugAuthInformation
|
||||
ProcessSystemResourceManagement
|
||||
ProcessSequenceNumber
|
||||
ProcessLoaderDetour
|
||||
ProcessSecurityDomainInformation
|
||||
ProcessCombineSecurityDomainsInformation
|
||||
ProcessEnableLogging
|
||||
ProcessLeapSecondInformation
|
||||
ProcessFiberShadowStackAllocation
|
||||
ProcessFreeFiberShadowStackAllocation
|
||||
ProcessAltSystemCallInformation
|
||||
ProcessDynamicEHContinuationTargets
|
||||
ProcessDynamicEnforcedCetCompatibleRanges
|
||||
)
|
||||
|
||||
type PROCESS_BASIC_INFORMATION struct {
|
||||
ExitStatus NTStatus
|
||||
PebBaseAddress *PEB
|
||||
AffinityMask uintptr
|
||||
BasePriority int32
|
||||
UniqueProcessId uintptr
|
||||
InheritedFromUniqueProcessId uintptr
|
||||
}
|
||||
|
||||
// Constants for LocalAlloc flags.
|
||||
const (
|
||||
LMEM_FIXED = 0x0
|
||||
LMEM_MOVEABLE = 0x2
|
||||
LMEM_NOCOMPACT = 0x10
|
||||
LMEM_NODISCARD = 0x20
|
||||
LMEM_ZEROINIT = 0x40
|
||||
LMEM_MODIFY = 0x80
|
||||
LMEM_DISCARDABLE = 0xf00
|
||||
LMEM_VALID_FLAGS = 0xf72
|
||||
LMEM_INVALID_HANDLE = 0x8000
|
||||
LHND = LMEM_MOVEABLE | LMEM_ZEROINIT
|
||||
LPTR = LMEM_FIXED | LMEM_ZEROINIT
|
||||
NONZEROLHND = LMEM_MOVEABLE
|
||||
NONZEROLPTR = LMEM_FIXED
|
||||
)
|
||||
|
||||
// Constants for the CreateNamedPipe-family of functions.
|
||||
const (
|
||||
PIPE_ACCESS_INBOUND = 0x1
|
||||
PIPE_ACCESS_OUTBOUND = 0x2
|
||||
PIPE_ACCESS_DUPLEX = 0x3
|
||||
|
||||
PIPE_CLIENT_END = 0x0
|
||||
PIPE_SERVER_END = 0x1
|
||||
|
||||
PIPE_WAIT = 0x0
|
||||
PIPE_NOWAIT = 0x1
|
||||
PIPE_READMODE_BYTE = 0x0
|
||||
PIPE_READMODE_MESSAGE = 0x2
|
||||
PIPE_TYPE_BYTE = 0x0
|
||||
PIPE_TYPE_MESSAGE = 0x4
|
||||
PIPE_ACCEPT_REMOTE_CLIENTS = 0x0
|
||||
PIPE_REJECT_REMOTE_CLIENTS = 0x8
|
||||
|
||||
PIPE_UNLIMITED_INSTANCES = 255
|
||||
)
|
||||
|
||||
// Constants for security attributes when opening named pipes.
|
||||
const (
|
||||
SECURITY_ANONYMOUS = SecurityAnonymous << 16
|
||||
SECURITY_IDENTIFICATION = SecurityIdentification << 16
|
||||
SECURITY_IMPERSONATION = SecurityImpersonation << 16
|
||||
SECURITY_DELEGATION = SecurityDelegation << 16
|
||||
|
||||
SECURITY_CONTEXT_TRACKING = 0x40000
|
||||
SECURITY_EFFECTIVE_ONLY = 0x80000
|
||||
|
||||
SECURITY_SQOS_PRESENT = 0x100000
|
||||
SECURITY_VALID_SQOS_FLAGS = 0x1f0000
|
||||
)
|
||||
|
||||
// ResourceID represents a 16-bit resource identifier, traditionally created with the MAKEINTRESOURCE macro.
|
||||
type ResourceID uint16
|
||||
|
||||
// ResourceIDOrString must be either a ResourceID, to specify a resource or resource type by ID,
|
||||
// or a string, to specify a resource or resource type by name.
|
||||
type ResourceIDOrString interface{}
|
||||
|
||||
// Predefined resource names and types.
|
||||
var (
|
||||
// Predefined names.
|
||||
CREATEPROCESS_MANIFEST_RESOURCE_ID ResourceID = 1
|
||||
ISOLATIONAWARE_MANIFEST_RESOURCE_ID ResourceID = 2
|
||||
ISOLATIONAWARE_NOSTATICIMPORT_MANIFEST_RESOURCE_ID ResourceID = 3
|
||||
ISOLATIONPOLICY_MANIFEST_RESOURCE_ID ResourceID = 4
|
||||
ISOLATIONPOLICY_BROWSER_MANIFEST_RESOURCE_ID ResourceID = 5
|
||||
MINIMUM_RESERVED_MANIFEST_RESOURCE_ID ResourceID = 1 // inclusive
|
||||
MAXIMUM_RESERVED_MANIFEST_RESOURCE_ID ResourceID = 16 // inclusive
|
||||
|
||||
// Predefined types.
|
||||
RT_CURSOR ResourceID = 1
|
||||
RT_BITMAP ResourceID = 2
|
||||
RT_ICON ResourceID = 3
|
||||
RT_MENU ResourceID = 4
|
||||
RT_DIALOG ResourceID = 5
|
||||
RT_STRING ResourceID = 6
|
||||
RT_FONTDIR ResourceID = 7
|
||||
RT_FONT ResourceID = 8
|
||||
RT_ACCELERATOR ResourceID = 9
|
||||
RT_RCDATA ResourceID = 10
|
||||
RT_MESSAGETABLE ResourceID = 11
|
||||
RT_GROUP_CURSOR ResourceID = 12
|
||||
RT_GROUP_ICON ResourceID = 14
|
||||
RT_VERSION ResourceID = 16
|
||||
RT_DLGINCLUDE ResourceID = 17
|
||||
RT_PLUGPLAY ResourceID = 19
|
||||
RT_VXD ResourceID = 20
|
||||
RT_ANICURSOR ResourceID = 21
|
||||
RT_ANIICON ResourceID = 22
|
||||
RT_HTML ResourceID = 23
|
||||
RT_MANIFEST ResourceID = 24
|
||||
)
|
||||
|
||||
type COAUTHIDENTITY struct {
|
||||
User *uint16
|
||||
UserLength uint32
|
||||
Domain *uint16
|
||||
DomainLength uint32
|
||||
Password *uint16
|
||||
PasswordLength uint32
|
||||
Flags uint32
|
||||
}
|
||||
|
||||
type COAUTHINFO struct {
|
||||
AuthnSvc uint32
|
||||
AuthzSvc uint32
|
||||
ServerPrincName *uint16
|
||||
AuthnLevel uint32
|
||||
ImpersonationLevel uint32
|
||||
AuthIdentityData *COAUTHIDENTITY
|
||||
Capabilities uint32
|
||||
}
|
||||
|
||||
type COSERVERINFO struct {
|
||||
Reserved1 uint32
|
||||
Aame *uint16
|
||||
AuthInfo *COAUTHINFO
|
||||
Reserved2 uint32
|
||||
}
|
||||
|
||||
type BIND_OPTS3 struct {
|
||||
CbStruct uint32
|
||||
Flags uint32
|
||||
Mode uint32
|
||||
TickCountDeadline uint32
|
||||
TrackFlags uint32
|
||||
ClassContext uint32
|
||||
Locale uint32
|
||||
ServerInfo *COSERVERINFO
|
||||
Hwnd HWND
|
||||
}
|
||||
|
||||
const (
|
||||
CLSCTX_INPROC_SERVER = 0x1
|
||||
CLSCTX_INPROC_HANDLER = 0x2
|
||||
CLSCTX_LOCAL_SERVER = 0x4
|
||||
CLSCTX_INPROC_SERVER16 = 0x8
|
||||
CLSCTX_REMOTE_SERVER = 0x10
|
||||
CLSCTX_INPROC_HANDLER16 = 0x20
|
||||
CLSCTX_RESERVED1 = 0x40
|
||||
CLSCTX_RESERVED2 = 0x80
|
||||
CLSCTX_RESERVED3 = 0x100
|
||||
CLSCTX_RESERVED4 = 0x200
|
||||
CLSCTX_NO_CODE_DOWNLOAD = 0x400
|
||||
CLSCTX_RESERVED5 = 0x800
|
||||
CLSCTX_NO_CUSTOM_MARSHAL = 0x1000
|
||||
CLSCTX_ENABLE_CODE_DOWNLOAD = 0x2000
|
||||
CLSCTX_NO_FAILURE_LOG = 0x4000
|
||||
CLSCTX_DISABLE_AAA = 0x8000
|
||||
CLSCTX_ENABLE_AAA = 0x10000
|
||||
CLSCTX_FROM_DEFAULT_CONTEXT = 0x20000
|
||||
CLSCTX_ACTIVATE_32_BIT_SERVER = 0x40000
|
||||
CLSCTX_ACTIVATE_64_BIT_SERVER = 0x80000
|
||||
CLSCTX_ENABLE_CLOAKING = 0x100000
|
||||
CLSCTX_APPCONTAINER = 0x400000
|
||||
CLSCTX_ACTIVATE_AAA_AS_IU = 0x800000
|
||||
CLSCTX_PS_DLL = 0x80000000
|
||||
|
||||
COINIT_MULTITHREADED = 0x0
|
||||
COINIT_APARTMENTTHREADED = 0x2
|
||||
COINIT_DISABLE_OLE1DDE = 0x4
|
||||
COINIT_SPEED_OVER_MEMORY = 0x8
|
||||
)
|
||||
|
||||
// Flag for QueryFullProcessImageName.
|
||||
const PROCESS_NAME_NATIVE = 1
|
||||
|
2619
vendor/golang.org/x/sys/windows/zerrors_windows.go
generated
vendored
2619
vendor/golang.org/x/sys/windows/zerrors_windows.go
generated
vendored
File diff suppressed because it is too large
Load Diff
247
vendor/golang.org/x/sys/windows/zsyscall_windows.go
generated
vendored
247
vendor/golang.org/x/sys/windows/zsyscall_windows.go
generated
vendored
@@ -172,6 +172,7 @@ var (
|
||||
procCancelIo = modkernel32.NewProc("CancelIo")
|
||||
procCancelIoEx = modkernel32.NewProc("CancelIoEx")
|
||||
procCloseHandle = modkernel32.NewProc("CloseHandle")
|
||||
procConnectNamedPipe = modkernel32.NewProc("ConnectNamedPipe")
|
||||
procCreateDirectoryW = modkernel32.NewProc("CreateDirectoryW")
|
||||
procCreateEventExW = modkernel32.NewProc("CreateEventExW")
|
||||
procCreateEventW = modkernel32.NewProc("CreateEventW")
|
||||
@@ -182,6 +183,7 @@ var (
|
||||
procCreateJobObjectW = modkernel32.NewProc("CreateJobObjectW")
|
||||
procCreateMutexExW = modkernel32.NewProc("CreateMutexExW")
|
||||
procCreateMutexW = modkernel32.NewProc("CreateMutexW")
|
||||
procCreateNamedPipeW = modkernel32.NewProc("CreateNamedPipeW")
|
||||
procCreatePipe = modkernel32.NewProc("CreatePipe")
|
||||
procCreateProcessW = modkernel32.NewProc("CreateProcessW")
|
||||
procCreateSymbolicLinkW = modkernel32.NewProc("CreateSymbolicLinkW")
|
||||
@@ -203,6 +205,7 @@ var (
|
||||
procFindNextFileW = modkernel32.NewProc("FindNextFileW")
|
||||
procFindNextVolumeMountPointW = modkernel32.NewProc("FindNextVolumeMountPointW")
|
||||
procFindNextVolumeW = modkernel32.NewProc("FindNextVolumeW")
|
||||
procFindResourceW = modkernel32.NewProc("FindResourceW")
|
||||
procFindVolumeClose = modkernel32.NewProc("FindVolumeClose")
|
||||
procFindVolumeMountPointClose = modkernel32.NewProc("FindVolumeMountPointClose")
|
||||
procFlushFileBuffers = modkernel32.NewProc("FlushFileBuffers")
|
||||
@@ -239,6 +242,8 @@ var (
|
||||
procGetLongPathNameW = modkernel32.NewProc("GetLongPathNameW")
|
||||
procGetModuleFileNameW = modkernel32.NewProc("GetModuleFileNameW")
|
||||
procGetModuleHandleExW = modkernel32.NewProc("GetModuleHandleExW")
|
||||
procGetNamedPipeHandleStateW = modkernel32.NewProc("GetNamedPipeHandleStateW")
|
||||
procGetNamedPipeInfo = modkernel32.NewProc("GetNamedPipeInfo")
|
||||
procGetOverlappedResult = modkernel32.NewProc("GetOverlappedResult")
|
||||
procGetPriorityClass = modkernel32.NewProc("GetPriorityClass")
|
||||
procGetProcAddress = modkernel32.NewProc("GetProcAddress")
|
||||
@@ -273,8 +278,11 @@ var (
|
||||
procIsWow64Process2 = modkernel32.NewProc("IsWow64Process2")
|
||||
procLoadLibraryExW = modkernel32.NewProc("LoadLibraryExW")
|
||||
procLoadLibraryW = modkernel32.NewProc("LoadLibraryW")
|
||||
procLoadResource = modkernel32.NewProc("LoadResource")
|
||||
procLocalAlloc = modkernel32.NewProc("LocalAlloc")
|
||||
procLocalFree = modkernel32.NewProc("LocalFree")
|
||||
procLockFileEx = modkernel32.NewProc("LockFileEx")
|
||||
procLockResource = modkernel32.NewProc("LockResource")
|
||||
procMapViewOfFile = modkernel32.NewProc("MapViewOfFile")
|
||||
procMoveFileExW = modkernel32.NewProc("MoveFileExW")
|
||||
procMoveFileW = modkernel32.NewProc("MoveFileW")
|
||||
@@ -289,6 +297,7 @@ var (
|
||||
procProcessIdToSessionId = modkernel32.NewProc("ProcessIdToSessionId")
|
||||
procPulseEvent = modkernel32.NewProc("PulseEvent")
|
||||
procQueryDosDeviceW = modkernel32.NewProc("QueryDosDeviceW")
|
||||
procQueryFullProcessImageNameW = modkernel32.NewProc("QueryFullProcessImageNameW")
|
||||
procQueryInformationJobObject = modkernel32.NewProc("QueryInformationJobObject")
|
||||
procReadConsoleW = modkernel32.NewProc("ReadConsoleW")
|
||||
procReadDirectoryChangesW = modkernel32.NewProc("ReadDirectoryChangesW")
|
||||
@@ -314,6 +323,7 @@ var (
|
||||
procSetFileTime = modkernel32.NewProc("SetFileTime")
|
||||
procSetHandleInformation = modkernel32.NewProc("SetHandleInformation")
|
||||
procSetInformationJobObject = modkernel32.NewProc("SetInformationJobObject")
|
||||
procSetNamedPipeHandleState = modkernel32.NewProc("SetNamedPipeHandleState")
|
||||
procSetPriorityClass = modkernel32.NewProc("SetPriorityClass")
|
||||
procSetProcessPriorityBoost = modkernel32.NewProc("SetProcessPriorityBoost")
|
||||
procSetProcessShutdownParameters = modkernel32.NewProc("SetProcessShutdownParameters")
|
||||
@@ -321,6 +331,7 @@ var (
|
||||
procSetStdHandle = modkernel32.NewProc("SetStdHandle")
|
||||
procSetVolumeLabelW = modkernel32.NewProc("SetVolumeLabelW")
|
||||
procSetVolumeMountPointW = modkernel32.NewProc("SetVolumeMountPointW")
|
||||
procSizeofResource = modkernel32.NewProc("SizeofResource")
|
||||
procSleepEx = modkernel32.NewProc("SleepEx")
|
||||
procTerminateJobObject = modkernel32.NewProc("TerminateJobObject")
|
||||
procTerminateProcess = modkernel32.NewProc("TerminateProcess")
|
||||
@@ -344,11 +355,25 @@ var (
|
||||
procNetApiBufferFree = modnetapi32.NewProc("NetApiBufferFree")
|
||||
procNetGetJoinInformation = modnetapi32.NewProc("NetGetJoinInformation")
|
||||
procNetUserGetInfo = modnetapi32.NewProc("NetUserGetInfo")
|
||||
procNtCreateFile = modntdll.NewProc("NtCreateFile")
|
||||
procNtCreateNamedPipeFile = modntdll.NewProc("NtCreateNamedPipeFile")
|
||||
procNtQueryInformationProcess = modntdll.NewProc("NtQueryInformationProcess")
|
||||
procNtSetInformationProcess = modntdll.NewProc("NtSetInformationProcess")
|
||||
procRtlDefaultNpAcl = modntdll.NewProc("RtlDefaultNpAcl")
|
||||
procRtlDosPathNameToNtPathName_U_WithStatus = modntdll.NewProc("RtlDosPathNameToNtPathName_U_WithStatus")
|
||||
procRtlDosPathNameToRelativeNtPathName_U_WithStatus = modntdll.NewProc("RtlDosPathNameToRelativeNtPathName_U_WithStatus")
|
||||
procRtlGetCurrentPeb = modntdll.NewProc("RtlGetCurrentPeb")
|
||||
procRtlGetNtVersionNumbers = modntdll.NewProc("RtlGetNtVersionNumbers")
|
||||
procRtlGetVersion = modntdll.NewProc("RtlGetVersion")
|
||||
procRtlInitString = modntdll.NewProc("RtlInitString")
|
||||
procRtlInitUnicodeString = modntdll.NewProc("RtlInitUnicodeString")
|
||||
procRtlNtStatusToDosErrorNoTeb = modntdll.NewProc("RtlNtStatusToDosErrorNoTeb")
|
||||
procCLSIDFromString = modole32.NewProc("CLSIDFromString")
|
||||
procCoCreateGuid = modole32.NewProc("CoCreateGuid")
|
||||
procCoGetObject = modole32.NewProc("CoGetObject")
|
||||
procCoInitializeEx = modole32.NewProc("CoInitializeEx")
|
||||
procCoTaskMemFree = modole32.NewProc("CoTaskMemFree")
|
||||
procCoUninitialize = modole32.NewProc("CoUninitialize")
|
||||
procStringFromGUID2 = modole32.NewProc("StringFromGUID2")
|
||||
procEnumProcesses = modpsapi.NewProc("EnumProcesses")
|
||||
procSubscribeServiceChangeNotifications = modsechost.NewProc("SubscribeServiceChangeNotifications")
|
||||
@@ -370,6 +395,7 @@ var (
|
||||
procGetAddrInfoW = modws2_32.NewProc("GetAddrInfoW")
|
||||
procWSACleanup = modws2_32.NewProc("WSACleanup")
|
||||
procWSAEnumProtocolsW = modws2_32.NewProc("WSAEnumProtocolsW")
|
||||
procWSAGetOverlappedResult = modws2_32.NewProc("WSAGetOverlappedResult")
|
||||
procWSAIoctl = modws2_32.NewProc("WSAIoctl")
|
||||
procWSARecv = modws2_32.NewProc("WSARecv")
|
||||
procWSARecvFrom = modws2_32.NewProc("WSARecvFrom")
|
||||
@@ -1434,6 +1460,14 @@ func CloseHandle(handle Handle) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func ConnectNamedPipe(pipe Handle, overlapped *Overlapped) (err error) {
|
||||
r1, _, e1 := syscall.Syscall(procConnectNamedPipe.Addr(), 2, uintptr(pipe), uintptr(unsafe.Pointer(overlapped)), 0)
|
||||
if r1 == 0 {
|
||||
err = errnoErr(e1)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func CreateDirectory(path *uint16, sa *SecurityAttributes) (err error) {
|
||||
r1, _, e1 := syscall.Syscall(procCreateDirectoryW.Addr(), 2, uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(sa)), 0)
|
||||
if r1 == 0 {
|
||||
@@ -1445,7 +1479,7 @@ func CreateDirectory(path *uint16, sa *SecurityAttributes) (err error) {
|
||||
func CreateEventEx(eventAttrs *SecurityAttributes, name *uint16, flags uint32, desiredAccess uint32) (handle Handle, err error) {
|
||||
r0, _, e1 := syscall.Syscall6(procCreateEventExW.Addr(), 4, uintptr(unsafe.Pointer(eventAttrs)), uintptr(unsafe.Pointer(name)), uintptr(flags), uintptr(desiredAccess), 0, 0)
|
||||
handle = Handle(r0)
|
||||
if handle == 0 {
|
||||
if handle == 0 || e1 == ERROR_ALREADY_EXISTS {
|
||||
err = errnoErr(e1)
|
||||
}
|
||||
return
|
||||
@@ -1454,7 +1488,7 @@ func CreateEventEx(eventAttrs *SecurityAttributes, name *uint16, flags uint32, d
|
||||
func CreateEvent(eventAttrs *SecurityAttributes, manualReset uint32, initialState uint32, name *uint16) (handle Handle, err error) {
|
||||
r0, _, e1 := syscall.Syscall6(procCreateEventW.Addr(), 4, uintptr(unsafe.Pointer(eventAttrs)), uintptr(manualReset), uintptr(initialState), uintptr(unsafe.Pointer(name)), 0, 0)
|
||||
handle = Handle(r0)
|
||||
if handle == 0 {
|
||||
if handle == 0 || e1 == ERROR_ALREADY_EXISTS {
|
||||
err = errnoErr(e1)
|
||||
}
|
||||
return
|
||||
@@ -1463,7 +1497,7 @@ func CreateEvent(eventAttrs *SecurityAttributes, manualReset uint32, initialStat
|
||||
func CreateFileMapping(fhandle Handle, sa *SecurityAttributes, prot uint32, maxSizeHigh uint32, maxSizeLow uint32, name *uint16) (handle Handle, err error) {
|
||||
r0, _, e1 := syscall.Syscall6(procCreateFileMappingW.Addr(), 6, uintptr(fhandle), uintptr(unsafe.Pointer(sa)), uintptr(prot), uintptr(maxSizeHigh), uintptr(maxSizeLow), uintptr(unsafe.Pointer(name)))
|
||||
handle = Handle(r0)
|
||||
if handle == 0 {
|
||||
if handle == 0 || e1 == ERROR_ALREADY_EXISTS {
|
||||
err = errnoErr(e1)
|
||||
}
|
||||
return
|
||||
@@ -1507,7 +1541,7 @@ func CreateJobObject(jobAttr *SecurityAttributes, name *uint16) (handle Handle,
|
||||
func CreateMutexEx(mutexAttrs *SecurityAttributes, name *uint16, flags uint32, desiredAccess uint32) (handle Handle, err error) {
|
||||
r0, _, e1 := syscall.Syscall6(procCreateMutexExW.Addr(), 4, uintptr(unsafe.Pointer(mutexAttrs)), uintptr(unsafe.Pointer(name)), uintptr(flags), uintptr(desiredAccess), 0, 0)
|
||||
handle = Handle(r0)
|
||||
if handle == 0 {
|
||||
if handle == 0 || e1 == ERROR_ALREADY_EXISTS {
|
||||
err = errnoErr(e1)
|
||||
}
|
||||
return
|
||||
@@ -1520,7 +1554,16 @@ func CreateMutex(mutexAttrs *SecurityAttributes, initialOwner bool, name *uint16
|
||||
}
|
||||
r0, _, e1 := syscall.Syscall(procCreateMutexW.Addr(), 3, uintptr(unsafe.Pointer(mutexAttrs)), uintptr(_p0), uintptr(unsafe.Pointer(name)))
|
||||
handle = Handle(r0)
|
||||
if handle == 0 {
|
||||
if handle == 0 || e1 == ERROR_ALREADY_EXISTS {
|
||||
err = errnoErr(e1)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func CreateNamedPipe(name *uint16, flags uint32, pipeMode uint32, maxInstances uint32, outSize uint32, inSize uint32, defaultTimeout uint32, sa *SecurityAttributes) (handle Handle, err error) {
|
||||
r0, _, e1 := syscall.Syscall9(procCreateNamedPipeW.Addr(), 8, uintptr(unsafe.Pointer(name)), uintptr(flags), uintptr(pipeMode), uintptr(maxInstances), uintptr(outSize), uintptr(inSize), uintptr(defaultTimeout), uintptr(unsafe.Pointer(sa)), 0)
|
||||
handle = Handle(r0)
|
||||
if handle == InvalidHandle {
|
||||
err = errnoErr(e1)
|
||||
}
|
||||
return
|
||||
@@ -1714,6 +1757,15 @@ func FindNextVolume(findVolume Handle, volumeName *uint16, bufferLength uint32)
|
||||
return
|
||||
}
|
||||
|
||||
func findResource(module Handle, name uintptr, resType uintptr) (resInfo Handle, err error) {
|
||||
r0, _, e1 := syscall.Syscall(procFindResourceW.Addr(), 3, uintptr(module), uintptr(name), uintptr(resType))
|
||||
resInfo = Handle(r0)
|
||||
if resInfo == 0 {
|
||||
err = errnoErr(e1)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func FindVolumeClose(findVolume Handle) (err error) {
|
||||
r1, _, e1 := syscall.Syscall(procFindVolumeClose.Addr(), 1, uintptr(findVolume), 0, 0)
|
||||
if r1 == 0 {
|
||||
@@ -2008,6 +2060,22 @@ func GetModuleHandleEx(flags uint32, moduleName *uint16, module *Handle) (err er
|
||||
return
|
||||
}
|
||||
|
||||
func GetNamedPipeHandleState(pipe Handle, state *uint32, curInstances *uint32, maxCollectionCount *uint32, collectDataTimeout *uint32, userName *uint16, maxUserNameSize uint32) (err error) {
|
||||
r1, _, e1 := syscall.Syscall9(procGetNamedPipeHandleStateW.Addr(), 7, uintptr(pipe), uintptr(unsafe.Pointer(state)), uintptr(unsafe.Pointer(curInstances)), uintptr(unsafe.Pointer(maxCollectionCount)), uintptr(unsafe.Pointer(collectDataTimeout)), uintptr(unsafe.Pointer(userName)), uintptr(maxUserNameSize), 0, 0)
|
||||
if r1 == 0 {
|
||||
err = errnoErr(e1)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func GetNamedPipeInfo(pipe Handle, flags *uint32, outSize *uint32, inSize *uint32, maxInstances *uint32) (err error) {
|
||||
r1, _, e1 := syscall.Syscall6(procGetNamedPipeInfo.Addr(), 5, uintptr(pipe), uintptr(unsafe.Pointer(flags)), uintptr(unsafe.Pointer(outSize)), uintptr(unsafe.Pointer(inSize)), uintptr(unsafe.Pointer(maxInstances)), 0)
|
||||
if r1 == 0 {
|
||||
err = errnoErr(e1)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func GetOverlappedResult(handle Handle, overlapped *Overlapped, done *uint32, wait bool) (err error) {
|
||||
var _p0 uint32
|
||||
if wait {
|
||||
@@ -2322,6 +2390,24 @@ func _LoadLibrary(libname *uint16) (handle Handle, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func LoadResource(module Handle, resInfo Handle) (resData Handle, err error) {
|
||||
r0, _, e1 := syscall.Syscall(procLoadResource.Addr(), 2, uintptr(module), uintptr(resInfo), 0)
|
||||
resData = Handle(r0)
|
||||
if resData == 0 {
|
||||
err = errnoErr(e1)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func LocalAlloc(flags uint32, length uint32) (ptr uintptr, err error) {
|
||||
r0, _, e1 := syscall.Syscall(procLocalAlloc.Addr(), 2, uintptr(flags), uintptr(length), 0)
|
||||
ptr = uintptr(r0)
|
||||
if ptr == 0 {
|
||||
err = errnoErr(e1)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func LocalFree(hmem Handle) (handle Handle, err error) {
|
||||
r0, _, e1 := syscall.Syscall(procLocalFree.Addr(), 1, uintptr(hmem), 0, 0)
|
||||
handle = Handle(r0)
|
||||
@@ -2339,6 +2425,15 @@ func LockFileEx(file Handle, flags uint32, reserved uint32, bytesLow uint32, byt
|
||||
return
|
||||
}
|
||||
|
||||
func LockResource(resData Handle) (addr uintptr, err error) {
|
||||
r0, _, e1 := syscall.Syscall(procLockResource.Addr(), 1, uintptr(resData), 0, 0)
|
||||
addr = uintptr(r0)
|
||||
if addr == 0 {
|
||||
err = errnoErr(e1)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func MapViewOfFile(handle Handle, access uint32, offsetHigh uint32, offsetLow uint32, length uintptr) (addr uintptr, err error) {
|
||||
r0, _, e1 := syscall.Syscall6(procMapViewOfFile.Addr(), 5, uintptr(handle), uintptr(access), uintptr(offsetHigh), uintptr(offsetLow), uintptr(length), 0)
|
||||
addr = uintptr(r0)
|
||||
@@ -2474,6 +2569,14 @@ func QueryDosDevice(deviceName *uint16, targetPath *uint16, max uint32) (n uint3
|
||||
return
|
||||
}
|
||||
|
||||
func QueryFullProcessImageName(proc Handle, flags uint32, exeName *uint16, size *uint32) (err error) {
|
||||
r1, _, e1 := syscall.Syscall6(procQueryFullProcessImageNameW.Addr(), 4, uintptr(proc), uintptr(flags), uintptr(unsafe.Pointer(exeName)), uintptr(unsafe.Pointer(size)), 0, 0)
|
||||
if r1 == 0 {
|
||||
err = errnoErr(e1)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func QueryInformationJobObject(job Handle, JobObjectInformationClass int32, JobObjectInformation uintptr, JobObjectInformationLength uint32, retlen *uint32) (err error) {
|
||||
r1, _, e1 := syscall.Syscall6(procQueryInformationJobObject.Addr(), 5, uintptr(job), uintptr(JobObjectInformationClass), uintptr(JobObjectInformation), uintptr(JobObjectInformationLength), uintptr(unsafe.Pointer(retlen)), 0)
|
||||
if r1 == 0 {
|
||||
@@ -2692,6 +2795,14 @@ func SetInformationJobObject(job Handle, JobObjectInformationClass uint32, JobOb
|
||||
return
|
||||
}
|
||||
|
||||
func SetNamedPipeHandleState(pipe Handle, state *uint32, maxCollectionCount *uint32, collectDataTimeout *uint32) (err error) {
|
||||
r1, _, e1 := syscall.Syscall6(procSetNamedPipeHandleState.Addr(), 4, uintptr(pipe), uintptr(unsafe.Pointer(state)), uintptr(unsafe.Pointer(maxCollectionCount)), uintptr(unsafe.Pointer(collectDataTimeout)), 0, 0)
|
||||
if r1 == 0 {
|
||||
err = errnoErr(e1)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func SetPriorityClass(process Handle, priorityClass uint32) (err error) {
|
||||
r1, _, e1 := syscall.Syscall(procSetPriorityClass.Addr(), 2, uintptr(process), uintptr(priorityClass), 0)
|
||||
if r1 == 0 {
|
||||
@@ -2752,6 +2863,15 @@ func SetVolumeMountPoint(volumeMountPoint *uint16, volumeName *uint16) (err erro
|
||||
return
|
||||
}
|
||||
|
||||
func SizeofResource(module Handle, resInfo Handle) (size uint32, err error) {
|
||||
r0, _, e1 := syscall.Syscall(procSizeofResource.Addr(), 2, uintptr(module), uintptr(resInfo), 0)
|
||||
size = uint32(r0)
|
||||
if size == 0 {
|
||||
err = errnoErr(e1)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func SleepEx(milliseconds uint32, alertable bool) (ret uint32) {
|
||||
var _p0 uint32
|
||||
if alertable {
|
||||
@@ -2810,7 +2930,7 @@ func UnmapViewOfFile(addr uintptr) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func updateProcThreadAttribute(attrlist *ProcThreadAttributeList, flags uint32, attr uintptr, value uintptr, size uintptr, prevvalue uintptr, returnedsize *uintptr) (err error) {
|
||||
func updateProcThreadAttribute(attrlist *ProcThreadAttributeList, flags uint32, attr uintptr, value unsafe.Pointer, size uintptr, prevvalue unsafe.Pointer, returnedsize *uintptr) (err error) {
|
||||
r1, _, e1 := syscall.Syscall9(procUpdateProcThreadAttribute.Addr(), 7, uintptr(unsafe.Pointer(attrlist)), uintptr(flags), uintptr(attr), uintptr(value), uintptr(size), uintptr(prevvalue), uintptr(unsafe.Pointer(returnedsize)), 0, 0)
|
||||
if r1 == 0 {
|
||||
err = errnoErr(e1)
|
||||
@@ -2946,19 +3066,97 @@ func NetUserGetInfo(serverName *uint16, userName *uint16, level uint32, buf **by
|
||||
return
|
||||
}
|
||||
|
||||
func NtCreateFile(handle *Handle, access uint32, oa *OBJECT_ATTRIBUTES, iosb *IO_STATUS_BLOCK, allocationSize *int64, attributes uint32, share uint32, disposition uint32, options uint32, eabuffer uintptr, ealength uint32) (ntstatus error) {
|
||||
r0, _, _ := syscall.Syscall12(procNtCreateFile.Addr(), 11, uintptr(unsafe.Pointer(handle)), uintptr(access), uintptr(unsafe.Pointer(oa)), uintptr(unsafe.Pointer(iosb)), uintptr(unsafe.Pointer(allocationSize)), uintptr(attributes), uintptr(share), uintptr(disposition), uintptr(options), uintptr(eabuffer), uintptr(ealength), 0)
|
||||
if r0 != 0 {
|
||||
ntstatus = NTStatus(r0)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func NtCreateNamedPipeFile(pipe *Handle, access uint32, oa *OBJECT_ATTRIBUTES, iosb *IO_STATUS_BLOCK, share uint32, disposition uint32, options uint32, typ uint32, readMode uint32, completionMode uint32, maxInstances uint32, inboundQuota uint32, outputQuota uint32, timeout *int64) (ntstatus error) {
|
||||
r0, _, _ := syscall.Syscall15(procNtCreateNamedPipeFile.Addr(), 14, uintptr(unsafe.Pointer(pipe)), uintptr(access), uintptr(unsafe.Pointer(oa)), uintptr(unsafe.Pointer(iosb)), uintptr(share), uintptr(disposition), uintptr(options), uintptr(typ), uintptr(readMode), uintptr(completionMode), uintptr(maxInstances), uintptr(inboundQuota), uintptr(outputQuota), uintptr(unsafe.Pointer(timeout)), 0)
|
||||
if r0 != 0 {
|
||||
ntstatus = NTStatus(r0)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func NtQueryInformationProcess(proc Handle, procInfoClass int32, procInfo unsafe.Pointer, procInfoLen uint32, retLen *uint32) (ntstatus error) {
|
||||
r0, _, _ := syscall.Syscall6(procNtQueryInformationProcess.Addr(), 5, uintptr(proc), uintptr(procInfoClass), uintptr(procInfo), uintptr(procInfoLen), uintptr(unsafe.Pointer(retLen)), 0)
|
||||
if r0 != 0 {
|
||||
ntstatus = NTStatus(r0)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func NtSetInformationProcess(proc Handle, procInfoClass int32, procInfo unsafe.Pointer, procInfoLen uint32) (ntstatus error) {
|
||||
r0, _, _ := syscall.Syscall6(procNtSetInformationProcess.Addr(), 4, uintptr(proc), uintptr(procInfoClass), uintptr(procInfo), uintptr(procInfoLen), 0, 0)
|
||||
if r0 != 0 {
|
||||
ntstatus = NTStatus(r0)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func RtlDefaultNpAcl(acl **ACL) (ntstatus error) {
|
||||
r0, _, _ := syscall.Syscall(procRtlDefaultNpAcl.Addr(), 1, uintptr(unsafe.Pointer(acl)), 0, 0)
|
||||
if r0 != 0 {
|
||||
ntstatus = NTStatus(r0)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func RtlDosPathNameToNtPathName(dosName *uint16, ntName *NTUnicodeString, ntFileNamePart *uint16, relativeName *RTL_RELATIVE_NAME) (ntstatus error) {
|
||||
r0, _, _ := syscall.Syscall6(procRtlDosPathNameToNtPathName_U_WithStatus.Addr(), 4, uintptr(unsafe.Pointer(dosName)), uintptr(unsafe.Pointer(ntName)), uintptr(unsafe.Pointer(ntFileNamePart)), uintptr(unsafe.Pointer(relativeName)), 0, 0)
|
||||
if r0 != 0 {
|
||||
ntstatus = NTStatus(r0)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func RtlDosPathNameToRelativeNtPathName(dosName *uint16, ntName *NTUnicodeString, ntFileNamePart *uint16, relativeName *RTL_RELATIVE_NAME) (ntstatus error) {
|
||||
r0, _, _ := syscall.Syscall6(procRtlDosPathNameToRelativeNtPathName_U_WithStatus.Addr(), 4, uintptr(unsafe.Pointer(dosName)), uintptr(unsafe.Pointer(ntName)), uintptr(unsafe.Pointer(ntFileNamePart)), uintptr(unsafe.Pointer(relativeName)), 0, 0)
|
||||
if r0 != 0 {
|
||||
ntstatus = NTStatus(r0)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func RtlGetCurrentPeb() (peb *PEB) {
|
||||
r0, _, _ := syscall.Syscall(procRtlGetCurrentPeb.Addr(), 0, 0, 0, 0)
|
||||
peb = (*PEB)(unsafe.Pointer(r0))
|
||||
return
|
||||
}
|
||||
|
||||
func rtlGetNtVersionNumbers(majorVersion *uint32, minorVersion *uint32, buildNumber *uint32) {
|
||||
syscall.Syscall(procRtlGetNtVersionNumbers.Addr(), 3, uintptr(unsafe.Pointer(majorVersion)), uintptr(unsafe.Pointer(minorVersion)), uintptr(unsafe.Pointer(buildNumber)))
|
||||
return
|
||||
}
|
||||
|
||||
func rtlGetVersion(info *OsVersionInfoEx) (ret error) {
|
||||
func rtlGetVersion(info *OsVersionInfoEx) (ntstatus error) {
|
||||
r0, _, _ := syscall.Syscall(procRtlGetVersion.Addr(), 1, uintptr(unsafe.Pointer(info)), 0, 0)
|
||||
if r0 != 0 {
|
||||
ret = syscall.Errno(r0)
|
||||
ntstatus = NTStatus(r0)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func RtlInitString(destinationString *NTString, sourceString *byte) {
|
||||
syscall.Syscall(procRtlInitString.Addr(), 2, uintptr(unsafe.Pointer(destinationString)), uintptr(unsafe.Pointer(sourceString)), 0)
|
||||
return
|
||||
}
|
||||
|
||||
func RtlInitUnicodeString(destinationString *NTUnicodeString, sourceString *uint16) {
|
||||
syscall.Syscall(procRtlInitUnicodeString.Addr(), 2, uintptr(unsafe.Pointer(destinationString)), uintptr(unsafe.Pointer(sourceString)), 0)
|
||||
return
|
||||
}
|
||||
|
||||
func rtlNtStatusToDosErrorNoTeb(ntstatus NTStatus) (ret syscall.Errno) {
|
||||
r0, _, _ := syscall.Syscall(procRtlNtStatusToDosErrorNoTeb.Addr(), 1, uintptr(ntstatus), 0, 0)
|
||||
ret = syscall.Errno(r0)
|
||||
return
|
||||
}
|
||||
|
||||
func clsidFromString(lpsz *uint16, pclsid *GUID) (ret error) {
|
||||
r0, _, _ := syscall.Syscall(procCLSIDFromString.Addr(), 2, uintptr(unsafe.Pointer(lpsz)), uintptr(unsafe.Pointer(pclsid)), 0)
|
||||
if r0 != 0 {
|
||||
@@ -2975,11 +3173,32 @@ func coCreateGuid(pguid *GUID) (ret error) {
|
||||
return
|
||||
}
|
||||
|
||||
func CoGetObject(name *uint16, bindOpts *BIND_OPTS3, guid *GUID, functionTable **uintptr) (ret error) {
|
||||
r0, _, _ := syscall.Syscall6(procCoGetObject.Addr(), 4, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(bindOpts)), uintptr(unsafe.Pointer(guid)), uintptr(unsafe.Pointer(functionTable)), 0, 0)
|
||||
if r0 != 0 {
|
||||
ret = syscall.Errno(r0)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func CoInitializeEx(reserved uintptr, coInit uint32) (ret error) {
|
||||
r0, _, _ := syscall.Syscall(procCoInitializeEx.Addr(), 2, uintptr(reserved), uintptr(coInit), 0)
|
||||
if r0 != 0 {
|
||||
ret = syscall.Errno(r0)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func CoTaskMemFree(address unsafe.Pointer) {
|
||||
syscall.Syscall(procCoTaskMemFree.Addr(), 1, uintptr(address), 0, 0)
|
||||
return
|
||||
}
|
||||
|
||||
func CoUninitialize() {
|
||||
syscall.Syscall(procCoUninitialize.Addr(), 0, 0, 0, 0)
|
||||
return
|
||||
}
|
||||
|
||||
func stringFromGUID2(rguid *GUID, lpsz *uint16, cchMax int32) (chars int32) {
|
||||
r0, _, _ := syscall.Syscall(procStringFromGUID2.Addr(), 3, uintptr(unsafe.Pointer(rguid)), uintptr(unsafe.Pointer(lpsz)), uintptr(cchMax))
|
||||
chars = int32(r0)
|
||||
@@ -3158,6 +3377,18 @@ func WSAEnumProtocols(protocols *int32, protocolBuffer *WSAProtocolInfo, bufferL
|
||||
return
|
||||
}
|
||||
|
||||
func WSAGetOverlappedResult(h Handle, o *Overlapped, bytes *uint32, wait bool, flags *uint32) (err error) {
|
||||
var _p0 uint32
|
||||
if wait {
|
||||
_p0 = 1
|
||||
}
|
||||
r1, _, e1 := syscall.Syscall6(procWSAGetOverlappedResult.Addr(), 5, uintptr(h), uintptr(unsafe.Pointer(o)), uintptr(unsafe.Pointer(bytes)), uintptr(_p0), uintptr(unsafe.Pointer(flags)), 0)
|
||||
if r1 == 0 {
|
||||
err = errnoErr(e1)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func WSAIoctl(s Handle, iocc uint32, inbuf *byte, cbif uint32, outbuf *byte, cbob uint32, cbbr *uint32, overlapped *Overlapped, completionRoutine uintptr) (err error) {
|
||||
r1, _, e1 := syscall.Syscall9(procWSAIoctl.Addr(), 9, uintptr(s), uintptr(iocc), uintptr(unsafe.Pointer(inbuf)), uintptr(cbif), uintptr(unsafe.Pointer(outbuf)), uintptr(cbob), uintptr(unsafe.Pointer(cbbr)), uintptr(unsafe.Pointer(overlapped)), uintptr(completionRoutine))
|
||||
if r1 == socket_error {
|
||||
|
Reference in New Issue
Block a user