Ejemplo n.º 1
0
        public CodePatternContext(MiniDumpMemoryReader dump, PEHeaderReader pe)
        {
            Dump = dump;
            _pe  = pe;

            Text      = new Range(Dump.ImageBase, _pe.ImageSectionHeaders.First(s => new string(s.Name).StartsWith(".text")));
            Data      = new Range(Dump.ImageBase, _pe.ImageSectionHeaders.First(s => new string(s.Name).StartsWith(".data")));
            Resources = new Range(Dump.ImageBase, _pe.ImageSectionHeaders.First(s => new string(s.Name).StartsWith(".rdata")));

            TextBuffer      = Dump.ReadBytes(Text.Start, (int)Text.Size);
            DataBuffer      = Dump.ReadBytes(Data.Start, (int)Data.Size);
            ResourcesBuffer = Dump.ReadBytes(Resources.Start, (int)Resources.Size);
        }
Ejemplo n.º 2
0
        public static void Run()
        {
            var path = Environment.ExpandEnvironmentVariables(@"%TEMP%\Diablo III.DMP");
            var dump = new MiniDumpMemoryReader(path);
            var pe   = new PEHeaderReader(dump.ReadBytes(dump.ImageBase, 1024));

            _ctx = new CodePatternContext(dump, pe);

            _symbols                     = new SymbolTable();
            _symbols.Version             = dump.MainModuleVersion;
            _symbols.DataSegment.Address = _ctx.Data.Start;

            FindObjectManager();
            FindActors();
            FindACDs();
            FindSNOs();
            FindAttributeDescriptors();
            FindApplicationCore();
            FindLevelArea();
            FindPreferences();
            FindMapActId();
            FindContainerManager();
            FindMessageDescriptors();
            FindPlayerData();

            var dir = new DirectoryInfo("enigma-d3-memory-" + new Version(_symbols.Version.ToString()));

            dir.Create();
            WriteObjectPtrFile(dir);
            WriteGlobalsFile(dir);

            var project = new SharedProject("862a67ee-9ceb-42fe-9406-d7feafc55b00", "Enigma.D3.Memory");

            project.AddCompileFile(Path.Combine(dir.FullName, "Globals.cs"));
            //project.AddCompileFile(Path.Combine(dir.FullName, "MethodPtr.cs"));
            project.AddCompileFile(Path.Combine(dir.FullName, "ObjectPtr.cs"));
            project.Save(Path.Combine(dir.FullName, "Enigma.D3.Memory.Generated.*"));

            if (Program.DeployGeneratedCode)
            {
                project.Deploy(
                    dir,
                    Program.SolutionDirectory.CreateSubdirectory(project.RootNamespace + ".Generated"));
            }
        }