@@ -2,6 +2,7 @@ package commands
2
2
3
3
import (
4
4
"fmt"
5
+ "log"
5
6
"os"
6
7
"rctf/theme"
7
8
)
@@ -27,7 +28,7 @@ func showLinuxAbix86() {
27
28
}
28
29
29
30
func showLinuxAbix64 () {
30
- fmt .Println (theme .ColorPurple + "\n linux 🐧 " + theme .ColorPurple + "x64" + theme .ColorReset )
31
+ fmt .Println (theme .ColorPurple + "linux 🐧 " + theme .ColorPurple + "x64" + theme .ColorReset )
31
32
32
33
fmt .Println (theme .ColorYellow + "\n scratch" + theme .ColorReset + "/" + theme .ColorYellow + "caller-save" + theme .ColorReset + "/" + theme .ColorYellow + "volatile" + theme .ColorReset + ":" )
33
34
@@ -49,7 +50,7 @@ func showLinuxAbix64() {
49
50
}
50
51
51
52
func showWindowsAbix86 () {
52
- fmt .Println (theme .ColorBlue + "\n windows 🪟 " + theme .ColorBlue + "x86" + theme .ColorReset )
53
+ fmt .Println (theme .ColorBlue + "windows 🪟 " + theme .ColorBlue + "x86" + theme .ColorReset )
53
54
54
55
fmt .Println (theme .ColorYellow + "\n scratch" + theme .ColorReset + "/" + theme .ColorYellow + "caller-save" + theme .ColorReset + "/" + theme .ColorYellow + "volatile" + theme .ColorReset + ":" )
55
56
@@ -67,7 +68,7 @@ func showWindowsAbix86() {
67
68
}
68
69
69
70
func showWindowsAbix64 () {
70
- fmt .Println (theme .ColorBlue + "\n windows 🪟 " + theme .ColorBlue + "x64" + theme .ColorReset )
71
+ fmt .Println (theme .ColorBlue + "windows 🪟 " + theme .ColorBlue + "x64" + theme .ColorReset )
71
72
72
73
fmt .Println (theme .ColorYellow + "\n scratch" + theme .ColorReset + "/" + theme .ColorYellow + "caller-save" + theme .ColorReset + "/" + theme .ColorYellow + "volatile" + theme .ColorReset + ":" )
73
74
@@ -82,23 +83,60 @@ func showWindowsAbix64() {
82
83
fmt .Println (theme .ColorCyan + " RCX/ZMM0 RDX/ZMM1 R8/ZMM2 R9/ZMM3 STACK => RAX XMM0 YMM0 ZMM0" + theme .ColorReset )
83
84
}
84
85
86
+ func abiHelp () {
87
+ fmt .Fprintf (os .Stderr , theme .ColorGreen + "usage" + theme .ColorReset + ": rctf " + theme .ColorBlue + "abi" + theme .ColorReset + " [(x86/32)/(x64/64)]" + theme .ColorReset + " [linux/windows]\n " )
88
+ fmt .Fprintf (os .Stderr , " 🤝 view abi details with rctf\n " )
89
+ }
90
+
85
91
func Abi (args []string ) {
86
92
if len (args ) > 0 {
87
93
switch args [0 ] {
88
94
case "help" :
89
- fmt .Fprintf (os .Stderr , theme .ColorGreen + "usage" + theme .ColorReset + ": rctf " + theme .ColorBlue + "abi" + theme .ColorReset + "\n " )
90
- fmt .Fprintf (os .Stderr , " 🤝 view abi details with rctf\n " )
91
- os .Exit (0 )
95
+ abiHelp ()
96
+ os .Exit (1 )
92
97
}
93
98
}
94
99
95
- showLinuxAbix86 ()
96
-
97
- showLinuxAbix64 ( )
98
-
99
- showWindowsAbix86 ()
100
+ if len ( args ) < 2 {
101
+ abiHelp ()
102
+ log . Fatalf ( "💥 " + theme . ColorRed + "error" + theme . ColorReset + ": %v missing args \n " , 2 - len ( args ) )
103
+ os . Exit ( 1 )
104
+ }
100
105
101
- showWindowsAbix64 ()
106
+ switch args [0 ] {
107
+ case "x86" :
108
+ {
109
+ if args [1 ] == "linux" {
110
+ showLinuxAbix86 ()
111
+ } else {
112
+ showWindowsAbix86 ()
113
+ }
114
+ }
115
+ case "32" :
116
+ {
117
+ if args [1 ] == "linux" {
118
+ showLinuxAbix86 ()
119
+ } else {
120
+ showWindowsAbix86 ()
121
+ }
122
+ }
123
+ case "x64" :
124
+ {
125
+ if args [1 ] == "linux" {
126
+ showLinuxAbix64 ()
127
+ } else {
128
+ showWindowsAbix64 ()
129
+ }
130
+ }
131
+ case "64" :
132
+ {
133
+ if args [1 ] == "linux" {
134
+ showLinuxAbix64 ()
135
+ } else {
136
+ showWindowsAbix64 ()
137
+ }
138
+ }
139
+ }
102
140
103
141
fmt .Println ("\n 🔗 " + theme .ColorCyan + "https://www.agner.org/optimize/calling_conventions.pdf" + theme .ColorReset )
104
142
}
0 commit comments