fix: add involves edge from task to agent:nomos at creation
Plus sync vendor directory for Docker build compatibility.
This commit is contained in:
17
vendor/github.com/jchv/go-winloader/internal/winloader/hacks_other.go
generated
vendored
Normal file
17
vendor/github.com/jchv/go-winloader/internal/winloader/hacks_other.go
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
//go:build !windows
|
||||
// +build !windows
|
||||
|
||||
package winloader
|
||||
|
||||
import "errors"
|
||||
|
||||
// MakePEBEntryForModule is a hack that inserts an entry for the loaded module
|
||||
// into the PEB loader data to make it appear to Windows functions.
|
||||
func MakePEBEntryForModule() error {
|
||||
return errors.New("platform not supported")
|
||||
}
|
||||
|
||||
// GetProcessHInstance gets the HINSTANCE for the current process.
|
||||
func GetProcessHInstance() (uintptr, error) {
|
||||
return 0, errors.New("platform not supported")
|
||||
}
|
||||
73
vendor/github.com/jchv/go-winloader/internal/winloader/hacks_windows.go
generated
vendored
Normal file
73
vendor/github.com/jchv/go-winloader/internal/winloader/hacks_windows.go
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
package winloader
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/sys/windows"
|
||||
)
|
||||
|
||||
var (
|
||||
ntdllModule = windows.NewLazySystemDLL("ntdll")
|
||||
ntdllNtQueryInformationProcess = ntdllModule.NewProc("NtQueryInformationProcess")
|
||||
)
|
||||
|
||||
type _ProcessBasicInformation struct {
|
||||
Reserved1 uintptr
|
||||
PebBaseAddress uintptr
|
||||
Reserved2 [2]uintptr
|
||||
UniqueProcessID uintptr
|
||||
Reserved3 uintptr
|
||||
}
|
||||
|
||||
type _PEB struct {
|
||||
Reserved1 [2]byte
|
||||
BeingDebugged byte
|
||||
Reserved2 [1]byte
|
||||
Reserved3 [2]uintptr
|
||||
Ldr uintptr
|
||||
}
|
||||
|
||||
type _List struct {
|
||||
Front uintptr
|
||||
Back uintptr
|
||||
}
|
||||
|
||||
type _PEBLoaderData struct {
|
||||
Length uint32
|
||||
Initialized uint8
|
||||
Padding [3]uint8
|
||||
SsHandle uintptr
|
||||
InLoadOrderModuleList _List
|
||||
InMemoryOrderModuleList _List
|
||||
InInitializationOrderModuleList _List
|
||||
}
|
||||
|
||||
// MakePEBEntryForModule is a hack that inserts an entry for the loaded module
|
||||
// into the PEB loader data to make it appear to Windows functions.
|
||||
func MakePEBEntryForModule() error {
|
||||
process := -1
|
||||
sizeNeeded := uint32(0)
|
||||
pbi := _ProcessBasicInformation{}
|
||||
status, _, _ := ntdllNtQueryInformationProcess.Call(
|
||||
uintptr(process),
|
||||
0,
|
||||
uintptr(unsafe.Pointer(&pbi)),
|
||||
unsafe.Sizeof(pbi),
|
||||
uintptr(unsafe.Pointer(&sizeNeeded)),
|
||||
)
|
||||
if status != 0 {
|
||||
return fmt.Errorf("NtQueryInformationProcess failed: %08x", status)
|
||||
}
|
||||
|
||||
// TODO: Implement attempt to insert module entry.
|
||||
return errors.New("unimplemented")
|
||||
}
|
||||
|
||||
// GetProcessHInstance gets the HINSTANCE for the current process.
|
||||
func GetProcessHInstance() (uintptr, error) {
|
||||
var hinstance windows.Handle
|
||||
windows.GetModuleHandleEx(0, nil, &hinstance)
|
||||
return uintptr(hinstance), nil
|
||||
}
|
||||
64
vendor/github.com/jchv/go-winloader/internal/winloader/loader_windows.go
generated
vendored
Normal file
64
vendor/github.com/jchv/go-winloader/internal/winloader/loader_windows.go
generated
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
package winloader
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
|
||||
"github.com/jchv/go-winloader/internal/loader"
|
||||
"golang.org/x/sys/windows"
|
||||
)
|
||||
|
||||
// Proc is a Proc implementation using a native procedure.
|
||||
type Proc uintptr
|
||||
|
||||
// Call calls a native procedure.
|
||||
func (p Proc) Call(a ...uint64) (r1, r2 uint64, lastErr error) {
|
||||
var ua []uintptr
|
||||
for _, e := range a {
|
||||
ua = append(ua, uintptr(e))
|
||||
}
|
||||
n1, n2, lastErr := syscall.SyscallN(uintptr(p), ua...)
|
||||
return uint64(n1), uint64(n2), lastErr
|
||||
}
|
||||
|
||||
// Addr gets the native address of the procedure.
|
||||
func (p Proc) Addr() uint64 {
|
||||
return uint64(p)
|
||||
}
|
||||
|
||||
// Library is a module implementation using the native Windows loader.
|
||||
type Library windows.Handle
|
||||
|
||||
// Proc implements loader.Module
|
||||
func (l Library) Proc(name string) loader.Proc {
|
||||
proc, _ := windows.GetProcAddress(windows.Handle(l), name)
|
||||
if proc == 0 {
|
||||
return nil
|
||||
}
|
||||
return Proc(proc)
|
||||
}
|
||||
|
||||
// Ordinal implements loader.Module
|
||||
func (l Library) Ordinal(ordinal uint64) loader.Proc {
|
||||
proc, _ := windows.GetProcAddressByOrdinal(windows.Handle(l), uintptr(ordinal))
|
||||
if proc == 0 {
|
||||
return nil
|
||||
}
|
||||
return Proc(proc)
|
||||
}
|
||||
|
||||
// Free implements loader.Module
|
||||
func (l Library) Free() error {
|
||||
return windows.FreeLibrary(windows.Handle(l))
|
||||
}
|
||||
|
||||
// Loader is a loader that uses the native Windows library loader.
|
||||
type Loader struct{}
|
||||
|
||||
// Load loads a module into memory.
|
||||
func (Loader) Load(libname string) (loader.Module, error) {
|
||||
handle, err := windows.LoadLibrary(libname)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return Library(handle), nil
|
||||
}
|
||||
32
vendor/github.com/jchv/go-winloader/internal/winloader/machine_windows.go
generated
vendored
Normal file
32
vendor/github.com/jchv/go-winloader/internal/winloader/machine_windows.go
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
package winloader
|
||||
|
||||
import (
|
||||
"github.com/jchv/go-winloader/internal/loader"
|
||||
"github.com/jchv/go-winloader/internal/vmem"
|
||||
)
|
||||
|
||||
// NativeMachine is a loader.Machine implementation that uses the native
|
||||
// machine the binary is running on.
|
||||
type NativeMachine struct{}
|
||||
|
||||
// IsArchitectureSupported implements loader.Machine.
|
||||
func (NativeMachine) IsArchitectureSupported(machine int) bool {
|
||||
return machine == NativeArch
|
||||
}
|
||||
|
||||
func (NativeMachine) GetPageSize() uint64 {
|
||||
return vmem.GetPageSize()
|
||||
}
|
||||
|
||||
// Alloc implements loader.Machine.
|
||||
func (NativeMachine) Alloc(addr, size uint64, allocType, protect int) loader.Memory {
|
||||
if mem := vmem.Alloc(addr, size, allocType, protect); mem != nil {
|
||||
return mem
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// MemProc implements loader.MemProc.
|
||||
func (NativeMachine) MemProc(addr uint64) loader.Proc {
|
||||
return Proc(addr)
|
||||
}
|
||||
9
vendor/github.com/jchv/go-winloader/internal/winloader/nativearch_386.go
generated
vendored
Normal file
9
vendor/github.com/jchv/go-winloader/internal/winloader/nativearch_386.go
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
package winloader
|
||||
|
||||
import (
|
||||
"github.com/jchv/go-winloader/internal/pe"
|
||||
)
|
||||
|
||||
// NativeArch is a constant that will be equal to the PE machine type
|
||||
// enumeration value that corresponds to the arch the binary is running as.
|
||||
const NativeArch = pe.ImageFileMachinei386
|
||||
9
vendor/github.com/jchv/go-winloader/internal/winloader/nativearch_amd64.go
generated
vendored
Normal file
9
vendor/github.com/jchv/go-winloader/internal/winloader/nativearch_amd64.go
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
package winloader
|
||||
|
||||
import (
|
||||
"github.com/jchv/go-winloader/internal/pe"
|
||||
)
|
||||
|
||||
// NativeArch is a constant that will be equal to the PE machine type
|
||||
// enumeration value that corresponds to the arch the binary is running as.
|
||||
const NativeArch = pe.ImageFileMachineAMD64
|
||||
9
vendor/github.com/jchv/go-winloader/internal/winloader/nativearch_arm64.go
generated
vendored
Normal file
9
vendor/github.com/jchv/go-winloader/internal/winloader/nativearch_arm64.go
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
package winloader
|
||||
|
||||
import (
|
||||
"github.com/jchv/go-winloader/internal/pe"
|
||||
)
|
||||
|
||||
// NativeArch is a constant that will be equal to the PE machine type
|
||||
// enumeration value that corresponds to the arch the binary is running as.
|
||||
const NativeArch = pe.ImageFileMachineARM64
|
||||
Reference in New Issue
Block a user