commit 4294a7e85753a8e8574192ca2dcf2f018553af88 Author: sandyx Date: Thu May 30 17:04:42 2024 -0500 the files diff --git a/config.cfg b/config.cfg new file mode 100644 index 0000000..5152af1 --- /dev/null +++ b/config.cfg @@ -0,0 +1,16 @@ +unbindall +bind "A" "+jump" +bind "B" "+reload" +bind "X" "save a;load a" +bind "Y" "+use" +bind "UP" "slot1" +bind "DOWN" "slot3" +bind "LEFT" "slot4" +bind "RIGHT" "slot2" +bind "WHITE" "save b" +bind "BLACK" "load b" +bind "STICK1" "+duck" +bind "STICK2" "+speed" +bind "R TRIGGER" "+attack" +bind "L TRIGGER" "+attack2" +bind "BACK" "exec the_config.cfg" diff --git a/insert.go b/insert.go new file mode 100644 index 0000000..51c5f0b --- /dev/null +++ b/insert.go @@ -0,0 +1,91 @@ +package main + +import ( + "bytes" + _ "embed" + "errors" + "fmt" + "log" + "os" +) + +const offset = 0x26DB27 //where the default config is located +const maxSize = 0x44D //safe size so i don't overwrite anything else + +func usage() error { + return errors.New("Usage: ") +} + +func inject(in []byte, orig []byte) []byte { + return bytes.Join( + [][]byte{ + bytes.Clone(orig[:offset]), + in, + bytes.Clone(orig[offset+maxSize:]), + }, + + []byte{}, + ) +} + +func open(path string) (*os.File, int64) { + file, err := os.Open(path) + if err != nil { + log.Fatal(err) + } + + stat, err := file.Stat() + if err != nil { + log.Fatal(err) + } + return file, stat.Size() +} + +func main() { + if len(os.Args) <= 2 { + err := usage() + log.Fatal(err) + } + + cfg, cfgSize := open(os.Args[1]) + defer cfg.Close() + + orig, origSize := open(os.Args[2]) + defer orig.Close() + + if cfgSize > maxSize { + decSize := fmt.Sprintf("%d", maxSize) + err := errors.New("config file too large, max size " + decSize + " bytes") + log.Fatal(err) + } + + cfgData := make([]byte, maxSize) + cfg.Read(cfgData) + + origData := make([]byte, origSize) + orig.Read(origData) + + modified := inject(cfgData, origData) + + xzp, err := os.Create("modified.xzp") + if err != nil { + log.Fatal(err) + } + defer xzp.Close() + + xzp.Write(modified) + + modStat, err := xzp.Stat() + if err != nil { + log.Fatal(err) + } + + if modStat.Size() != origSize { + err = errors.New("modified file not correct size") + log.Fatal(err) + } + + fmt.Println(string(modified[offset : offset+maxSize])) + + log.Println("now just rename the file to zip0_xbox.xzp :3") +} diff --git a/the_config.cfg b/the_config.cfg new file mode 100644 index 0000000..54b79b4 --- /dev/null +++ b/the_config.cfg @@ -0,0 +1,18 @@ +alias "w" "wait" +alias "w2" "w;w" +alias "w4" "w2;w2" +alias "w8" "w4;w4" +alias "w16" "w8;w8" +alias "w32" "w16;w16" +alias "w64" "w32;w32" +alias "w128" "w64;w64" +alias "w256" "w128;w128" +alias "w512" "w256;w256" +alias "w1024" "w512;w512" +alias "w2048" "w1024;1024" +alias "w4096" "w2048;w2048" +bind "DOWN" "w4096" +bind "LEFT" "sv_cheats 1;noclip;god;shake;createhairball;createflashlight" +bind "UP" "map d2_coast_01" +bind "RIGHT" "say uwu" +sv_unlockedchapters "15" \ No newline at end of file