-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
60 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,54 @@ | ||
package assembuddy | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/olekukonko/tablewriter" | ||
) | ||
|
||
func RenderNameTable(tableData []Syscall) { | ||
table := tablewriter.NewWriter(os.Stdout) | ||
table.SetHeader([]string{"ARCH", "NR", "SYSCALL", "RAX", "rdi", "rsi", "rdx", "r10", "r8", "r9"}) | ||
table.SetHeader([]string{"ARCH", "NR", "NAME", "RETURN", "ARG0", "ARG1", "ARG2", "ARG3", "ARG4", "ARG5"}) | ||
col := tablewriter.Colors{tablewriter.Bold, tablewriter.FgHiGreenColor} | ||
table.SetHeaderColor(col, col, col, col, col, col, col, col, col, col) | ||
for _, syscall := range tableData { | ||
table.Append([]string{syscall.Arch, fmt.Sprint(syscall.Nr), syscall.Name, syscall.ReturnValue, syscall.Arg0, syscall.Arg1, syscall.Arg2, syscall.Arg3, syscall.Arg4, syscall.Arg5}) | ||
} | ||
table.Render() | ||
} | ||
|
||
func RenderArchTable(tableData []Syscall) { | ||
func RenderArchTable(arch string, tableData []Syscall) { | ||
table := tablewriter.NewWriter(os.Stdout) | ||
table.SetHeader([]string{"NR", "SYSCALL", "RAX", "rdi", "rsi", "rdx", "r10", "r8", "r9"}) | ||
getArchTable(arch, *table) | ||
for _, syscall := range tableData { | ||
table.Append([]string{syscall.Name, syscall.ReturnValue, syscall.Arg0, syscall.Arg1, syscall.Arg2, syscall.Arg3, syscall.Arg4, syscall.Arg5}) | ||
} | ||
table.Render() | ||
} | ||
|
||
func getArchTable(arch string, table tablewriter.Table) { | ||
// TODO: add the ARG0 (x0) stuff to headers | ||
// | ||
// HACK: hard coding the header len as 9 for now | ||
// | ||
// INFO: I actually need the col stuff because the library needs it | ||
switch arch { | ||
case "x64": | ||
table.SetHeader([]string{"NR", "SYSCALL", "RAX", "rdi", "rsi", "rdx", "r10", "r8", "r9"}) | ||
col := tablewriter.Colors{tablewriter.Bold, tablewriter.FgHiYellowColor} | ||
table.SetHeaderColor(col, col, col, col, col, col, col, col, col) | ||
case "x86": | ||
table.SetHeader([]string{"NR", "SYSCALL", "eax", "ebx", "ecx", "edx", "esi", "edi", "ebp"}) | ||
col := tablewriter.Colors{tablewriter.Bold, tablewriter.FgHiCyanColor} | ||
table.SetHeaderColor(col, col, col, col, col, col, col, col, col) | ||
case "arm64": | ||
table.SetHeader([]string{"NR", "SYSCALL", "x8", "x0", "x1", "x2", "x3", "x4", "x5"}) | ||
col := tablewriter.Colors{tablewriter.Bold, tablewriter.FgHiRedColor} | ||
table.SetHeaderColor(col, col, col, col, col, col, col, col, col) | ||
case "arm": | ||
table.SetHeader([]string{"NR", "SYSCALL", "r7", "r0", "r1", "r2", "r3", "r4", "r5"}) | ||
col := tablewriter.Colors{tablewriter.Bold, tablewriter.FgHiMagentaColor} | ||
table.SetHeaderColor(col, col, col, col, col, col, col, col, col) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters