feat!: change signature for syscall func

This commit is contained in:
f1zm0
2023-04-24 23:47:14 +02:00
parent e040b8aadf
commit 89ce53cead
2 changed files with 14 additions and 13 deletions
+12 -11
View File
@@ -22,7 +22,7 @@ type options struct {
}
// stub for asm implementation
func execIndirectSyscall(ssn uint16, gateAddr uintptr, argh ...uintptr) (errcode uint32)
func execIndirectSyscall(ssn uint16, gateAddr uintptr, argh ...uintptr) uint32
// New returns a new Acheron instance with the given options, or an error if initialization fails.
func New(opts ...Option) (*Acheron, error) {
@@ -58,20 +58,21 @@ func (a *Acheron) HashString(s string) uint64 {
// GetSyscall returns the Syscall struct for the given function hash.
func (a *Acheron) GetSyscall(fnHash uint64) (*resolver.Syscall, error) {
if sys := a.resolver.GetSyscall(fnHash); sys == nil {
return nil, fmt.Errorf("failed with code: %d", ErrSyscallNotFound)
return nil, fmt.Errorf("failed with code: 0x%x", ErrSyscallNotFound)
} else {
return sys, nil
}
}
// Syscall executes an indirect syscall with the given function hash and arguments. Returns the error code if it fails.
func (a *Acheron) Syscall(fnHash uint64, args ...uintptr) error {
if sys := a.resolver.GetSyscall(fnHash); sys == nil {
return fmt.Errorf("failed with: %d", ErrSyscallNotFound)
} else {
if st := execIndirectSyscall(sys.SSN, sys.TrampolineAddr, args...); !NT_SUCCESS(st) {
return fmt.Errorf("failed with: %d", st)
}
// Syscall makes an indirect syscall with the provided arguments. Returns the status code and an error message if it fails.
func (a *Acheron) Syscall(fnHash uint64, args ...uintptr) (uint32, error) {
sys := a.resolver.GetSyscall(fnHash)
if sys == nil {
return ErrSyscallNotFound, fmt.Errorf("failed with: 0x%x", ErrSyscallNotFound)
}
return nil
st := execIndirectSyscall(sys.SSN, sys.TrampolineAddr, args...)
if !NT_SUCCESS(st) {
return st, fmt.Errorf("failed with code: 0x%x", st)
}
return st, nil
}
+2 -2
View File
@@ -12,8 +12,8 @@
// but we use an unsigned integer instead of LONG (int32), since working with uint types is easier in Go
// func execIndirectSyscall(ssn uint16, trampoline uintptr, argh ...uintptr) (errcode uint32)
TEXT ·execIndirectSyscall(SB),NOSPLIT, $0-144
// func execIndirectSyscall(ssn uint16, trampoline uintptr, argh ...uintptr) uint32
TEXT ·execIndirectSyscall(SB),NOSPLIT, $0-40
XORQ AX, AX
MOVW ssn+0(FP), AX