machine_windows.go 826 B

1234567891011121314151617181920212223242526272829303132
  1. package winloader
  2. import (
  3. "github.com/jchv/go-winloader/internal/loader"
  4. "github.com/jchv/go-winloader/internal/vmem"
  5. )
  6. // NativeMachine is a loader.Machine implementation that uses the native
  7. // machine the binary is running on.
  8. type NativeMachine struct{}
  9. // IsArchitectureSupported implements loader.Machine.
  10. func (NativeMachine) IsArchitectureSupported(machine int) bool {
  11. return machine == NativeArch
  12. }
  13. func (NativeMachine) GetPageSize() uint64 {
  14. return vmem.GetPageSize()
  15. }
  16. // Alloc implements loader.Machine.
  17. func (NativeMachine) Alloc(addr, size uint64, allocType, protect int) loader.Memory {
  18. if mem := vmem.Alloc(addr, size, allocType, protect); mem != nil {
  19. return mem
  20. }
  21. return nil
  22. }
  23. // MemProc implements loader.MemProc.
  24. func (NativeMachine) MemProc(addr uint64) loader.Proc {
  25. return Proc(addr)
  26. }