Switch remote deploy to vendored source builds
Move remote deployment to a vendored source bundle built on the target host via Docker so redeploys no longer require local cross-compilation or host Go installation. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
16
vendor/github.com/jchv/go-winloader/internal/winloader/hacks_other.go
generated
vendored
Normal file
16
vendor/github.com/jchv/go-winloader/internal/winloader/hacks_other.go
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
// +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 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
|
||||
}
|
||||
96
vendor/github.com/jchv/go-winloader/internal/winloader/loader_windows.go
generated
vendored
Normal file
96
vendor/github.com/jchv/go-winloader/internal/winloader/loader_windows.go
generated
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
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 n1, n2 uintptr
|
||||
switch len(a) {
|
||||
case 0:
|
||||
n1, n2, lastErr = syscall.Syscall(uintptr(p), 0, 0, 0, 0)
|
||||
case 1:
|
||||
n1, n2, lastErr = syscall.Syscall(uintptr(p), 1, uintptr(a[0]), 0, 0)
|
||||
case 2:
|
||||
n1, n2, lastErr = syscall.Syscall(uintptr(p), 2, uintptr(a[0]), uintptr(a[1]), 0)
|
||||
case 3:
|
||||
n1, n2, lastErr = syscall.Syscall(uintptr(p), 3, uintptr(a[0]), uintptr(a[1]), uintptr(a[2]))
|
||||
case 4:
|
||||
n1, n2, lastErr = syscall.Syscall6(uintptr(p), 4, uintptr(a[0]), uintptr(a[1]), uintptr(a[2]), uintptr(a[3]), 0, 0)
|
||||
case 5:
|
||||
n1, n2, lastErr = syscall.Syscall6(uintptr(p), 5, uintptr(a[0]), uintptr(a[1]), uintptr(a[2]), uintptr(a[3]), uintptr(a[4]), 0)
|
||||
case 6:
|
||||
n1, n2, lastErr = syscall.Syscall6(uintptr(p), 6, uintptr(a[0]), uintptr(a[1]), uintptr(a[2]), uintptr(a[3]), uintptr(a[4]), uintptr(a[5]))
|
||||
case 7:
|
||||
n1, n2, lastErr = syscall.Syscall9(uintptr(p), 7, uintptr(a[0]), uintptr(a[1]), uintptr(a[2]), uintptr(a[3]), uintptr(a[4]), uintptr(a[5]), uintptr(a[6]), 0, 0)
|
||||
case 8:
|
||||
n1, n2, lastErr = syscall.Syscall9(uintptr(p), 8, uintptr(a[0]), uintptr(a[1]), uintptr(a[2]), uintptr(a[3]), uintptr(a[4]), uintptr(a[5]), uintptr(a[6]), uintptr(a[7]), 0)
|
||||
case 9:
|
||||
n1, n2, lastErr = syscall.Syscall9(uintptr(p), 9, uintptr(a[0]), uintptr(a[1]), uintptr(a[2]), uintptr(a[3]), uintptr(a[4]), uintptr(a[5]), uintptr(a[6]), uintptr(a[7]), uintptr(a[8]))
|
||||
case 10:
|
||||
n1, n2, lastErr = syscall.Syscall12(uintptr(p), 10, uintptr(a[0]), uintptr(a[1]), uintptr(a[2]), uintptr(a[3]), uintptr(a[4]), uintptr(a[5]), uintptr(a[6]), uintptr(a[7]), uintptr(a[8]), uintptr(a[9]), 0, 0)
|
||||
case 11:
|
||||
n1, n2, lastErr = syscall.Syscall12(uintptr(p), 11, uintptr(a[0]), uintptr(a[1]), uintptr(a[2]), uintptr(a[3]), uintptr(a[4]), uintptr(a[5]), uintptr(a[6]), uintptr(a[7]), uintptr(a[8]), uintptr(a[9]), uintptr(a[10]), 0)
|
||||
case 12:
|
||||
n1, n2, lastErr = syscall.Syscall12(uintptr(p), 12, uintptr(a[0]), uintptr(a[1]), uintptr(a[2]), uintptr(a[3]), uintptr(a[4]), uintptr(a[5]), uintptr(a[6]), uintptr(a[7]), uintptr(a[8]), uintptr(a[9]), uintptr(a[10]), uintptr(a[11]))
|
||||
case 13:
|
||||
n1, n2, lastErr = syscall.Syscall15(uintptr(p), 13, uintptr(a[0]), uintptr(a[1]), uintptr(a[2]), uintptr(a[3]), uintptr(a[4]), uintptr(a[5]), uintptr(a[6]), uintptr(a[7]), uintptr(a[8]), uintptr(a[9]), uintptr(a[10]), uintptr(a[11]), uintptr(a[12]), 0, 0)
|
||||
case 14:
|
||||
n1, n2, lastErr = syscall.Syscall15(uintptr(p), 14, uintptr(a[0]), uintptr(a[1]), uintptr(a[2]), uintptr(a[3]), uintptr(a[4]), uintptr(a[5]), uintptr(a[6]), uintptr(a[7]), uintptr(a[8]), uintptr(a[9]), uintptr(a[10]), uintptr(a[11]), uintptr(a[12]), uintptr(a[13]), 0)
|
||||
case 15:
|
||||
n1, n2, lastErr = syscall.Syscall15(uintptr(p), 15, uintptr(a[0]), uintptr(a[1]), uintptr(a[2]), uintptr(a[3]), uintptr(a[4]), uintptr(a[5]), uintptr(a[6]), uintptr(a[7]), uintptr(a[8]), uintptr(a[9]), uintptr(a[10]), uintptr(a[11]), uintptr(a[12]), uintptr(a[13]), uintptr(a[14]))
|
||||
default:
|
||||
panic("too many arguments")
|
||||
}
|
||||
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