feat(go): profiles are now configured by an info.json file

This commit is contained in:
phaneron 2024-11-27 01:55:46 -05:00
parent e591b8b17d
commit 9053d61b6b
13 changed files with 222 additions and 111 deletions

View file

@ -0,0 +1,37 @@
package cmd
import (
"fmt"
"os"
"github.com/spf13/cobra"
"github.com/thunderbrewhq/binana/go/profile"
)
var generate = &cobra.Command{
Use: "generate",
Short: "Convert source files into various tool formats",
Run: generate_func,
}
func generate_func(cmd *cobra.Command, args []string) {
compress, err := cmd.Flags().GetBool("compress")
if err != nil {
panic(err)
}
game_profile_directory, err := cmd.Flags().GetString("profile")
if err != nil {
panic(err)
}
game_profile, err := profile.Open(game_profile_directory)
if err != nil {
panic(err)
}
if err = game_profile.Generate(compress); err != nil {
fmt.Println(err)
os.Exit(1)
}
}

View file

@ -1,38 +0,0 @@
package cmd
import (
"fmt"
"os"
"github.com/spf13/cobra"
"github.com/thunderbrewhq/binana/go/profile"
)
var ida_gen = &cobra.Command{
Use: "ida-gen",
Short: "Generate IDC file using symbol file",
Run: ida_gen_func,
}
func ida_gen_func(cmd *cobra.Command, args []string) {
// get command line arguments
// module_name, err := cmd.Flags().GetString("module-name")
// if err != nil {
// panic(err)
// }
game_profile_directory, err := cmd.Flags().GetString("game")
if err != nil {
panic(err)
}
game_profile, err := profile.Open(game_profile_directory)
if err != nil {
panic(err)
}
if err = game_profile.CreateIDAFiles(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}

View file

@ -35,13 +35,10 @@ func init() {
// when this action is called directly.
// rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
ida_gen.Flags().StringP("game", "g", "3.3.5a", "the game profile")
rootCmd.AddCommand(ida_gen)
generate.Flags().StringP("profile", "p", "3.3.5a", "the game profile")
generate.Flags().BoolP("compress", "c", true, "enable/disable compression of the x64dbg database file")
x64dbg_gen.Flags().StringP("game", "g", "3.3.5a", "the game profile")
x64dbg_gen.Flags().StringP("module-name", "m", "wow.exe", "the name of the module")
x64dbg_gen.Flags().StringP("base-address", "b", "00400000", "the base address of the module")
rootCmd.AddCommand(generate)
rootCmd.AddCommand(x64dbg_gen)
rootCmd.AddCommand(x64dbg_typesort)
}

View file

@ -1,50 +0,0 @@
package cmd
import (
"fmt"
"os"
"strconv"
"github.com/spf13/cobra"
"github.com/thunderbrewhq/binana/go/profile"
)
var x64dbg_gen = &cobra.Command{
Use: "x64dbg-gen",
Short: "Generate x64dbg database using a symfile",
Run: x64dbg_gen_func,
}
func x64dbg_gen_func(cmd *cobra.Command, args []string) {
// get command line arguments
module_name, err := cmd.Flags().GetString("module-name")
if err != nil {
panic(err)
}
base_address_s, err := cmd.Flags().GetString("base-address")
if err != nil {
panic(err)
}
// parse the base address of game EXE
base_address, err := strconv.ParseUint(base_address_s, 16, 64)
if err != nil {
panic(err)
}
game_profile_directory, err := cmd.Flags().GetString("game")
if err != nil {
panic(err)
}
game_profile, err := profile.Open(game_profile_directory)
if err != nil {
panic(err)
}
if err = game_profile.CreateX64dbgFiles(module_name, base_address); err != nil {
fmt.Println(err)
os.Exit(1)
}
}