github.com/iDigitalFlame/xmt@v0.5.4/device/winapi/c_old_syscall.go (about)

     1  //go:build windows && !go1.18
     2  // +build windows,!go1.18
     3  
     4  // Copyright (C) 2020 - 2023 iDigitalFlame
     5  //
     6  // This program is free software: you can redistribute it and/or modify
     7  // it under the terms of the GNU General Public License as published by
     8  // the Free Software Foundation, either version 3 of the License, or
     9  // any later version.
    10  //
    11  // This program is distributed in the hope that it will be useful,
    12  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    13  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    14  // GNU General Public License for more details.
    15  //
    16  // You should have received a copy of the GNU General Public License
    17  // along with this program.  If not, see <https://www.gnu.org/licenses/>.
    18  //
    19  
    20  package winapi
    21  
    22  import "syscall"
    23  
    24  func syscallN(t uintptr, a ...uintptr) (uintptr, uintptr, syscall.Errno) {
    25  	switch len(a) {
    26  	case 0:
    27  		return syscall.Syscall(t, 0, 0, 0, 0)
    28  	case 1:
    29  		return syscall.Syscall(t, 1, a[0], 0, 0)
    30  	case 2:
    31  		return syscall.Syscall(t, 2, a[0], a[1], 0)
    32  	case 3:
    33  		return syscall.Syscall(t, 3, a[0], a[1], a[2])
    34  	case 4:
    35  		return syscall.Syscall6(t, 4, a[0], a[1], a[2], a[3], 0, 0)
    36  	case 5:
    37  		return syscall.Syscall6(t, 5, a[0], a[1], a[2], a[3], a[4], 0)
    38  	case 6:
    39  		return syscall.Syscall6(t, 6, a[0], a[1], a[2], a[3], a[4], a[5])
    40  	case 7:
    41  		return syscall.Syscall9(t, 7, a[0], a[1], a[2], a[3], a[4], a[5], a[6], 0, 0)
    42  	case 8:
    43  		return syscall.Syscall9(t, 8, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], 0)
    44  	case 9:
    45  		return syscall.Syscall9(t, 9, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8])
    46  	case 10:
    47  		return syscall.Syscall12(t, 10, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], 0, 0)
    48  	case 11:
    49  		return syscall.Syscall12(t, 11, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], 0)
    50  	case 12:
    51  		return syscall.Syscall12(t, 12, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11])
    52  	case 13:
    53  		return syscall.Syscall15(t, 13, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], 0, 0)
    54  	case 14:
    55  		return syscall.Syscall15(t, 14, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], a[13], 0)
    56  	case 15:
    57  		return syscall.Syscall15(t, 15, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], a[13], a[14])
    58  	}
    59  	return 0, 0, syscall.EINVAL
    60  }