diff --git a/main.go b/main.go index 19b3422..167a723 100644 --- a/main.go +++ b/main.go @@ -112,7 +112,15 @@ func main() { // if apiset dump option, load apisetschema.dll and dump all apisets if options.ApisetDump { - path, err := util.SearchFile([]string{"C:\\Windows\\System32", "os/win10_32/windows/system32"}, "apisetschema.dll") + rootFolder := "os/win10_32/" + if options.Config != "" { + conf, err := util.ReadGenericConfig(options.Config) + if err != nil { + log.Fatal(err) + } + rootFolder = conf.Root + } + path, err := util.SearchFile([]string{"C:\\Windows\\System32", rootFolder + "windows/system32"}, "apisetschema.dll") if err != nil { log.Fatal(err) } @@ -128,7 +136,15 @@ func main() { // if apiset lookup, load apisetschema.dll and look up the apiset name if options.ApisetLookup != "" { - path, err := util.SearchFile([]string{"C:\\Windows\\System32", "os/win10_32/windows/system32"}, "apisetschema.dll") + rootFolder := "os/win10_32/" + if options.Config != "" { + conf, err := util.ReadGenericConfig(options.Config) + if err != nil { + log.Fatal(err) + } + rootFolder = conf.Root + } + path, err := util.SearchFile([]string{"C:\\Windows\\System32", rootFolder + "windows/system32"}, "apisetschema.dll") if err != nil { log.Fatal(err) } diff --git a/util/config.go b/util/config.go new file mode 100644 index 0000000..b2e6b7a --- /dev/null +++ b/util/config.go @@ -0,0 +1,16 @@ +package util + +import "gopkg.in/yaml.v2" +import "io/ioutil" + +type GenericConfig struct { + Root string `yaml:"root"` +} + +func ReadGenericConfig(config string) (conf GenericConfig, err error) { + var buf []byte + if buf, err = ioutil.ReadFile(config); err == nil { + err = yaml.Unmarshal(buf, &conf) + } + return +}