예제 #1
0
        static void DecompileHardcodedStringCollection(IDecompiler decompiler, byte[] rom, string name,
                                                       params int[] pointers)
        {
            var hardcodedRefs = new List <HardcodedString>();

            foreach (int pointer in pointers)
            {
                string str        = decompiler.DecompileString(rom, pointer, false);
                var    references = new List <int>();

                // Search for all references
                for (int refAddress = 0; refAddress < 0x100000; refAddress += 4)
                {
                    int value = rom.ReadGbaPointer(refAddress);
                    if (value == pointer)
                    {
                        references.Add(refAddress);
                    }
                }

                var hardcodedRef = new HardcodedString
                {
                    Old = str,
                    New = "",
                    PointerLocations = references.ToArray(),
                    OldPointer       = pointer
                };

                hardcodedRefs.Add(hardcodedRef);
            }

            File.WriteAllText(Path.Combine(options.WorkingDirectory, name + ".json"),
                              JsonConvert.SerializeObject(hardcodedRefs, Formatting.Indented));
        }
예제 #2
0
        static void DecompileFixedStringCollection(IDecompiler decompiler, byte[] rom, string name, FixedStringCollection fixedStringCollection)
        {
            // Decompile the strings
            foreach (var fixedStringRef in fixedStringCollection.StringRefs)
            {
                fixedStringRef.Old     =
                    fixedStringRef.New =
                        decompiler.DecompileString(rom, fixedStringRef.OldPointer, false);
            }

            // Write JSON
            File.WriteAllText(Path.Combine(options.WorkingDirectory, name + ".json"),
                              JsonConvert.SerializeObject(fixedStringCollection, Formatting.Indented));
        }