public void Demo_memory_reading_from_process_sample()
        {
            //	To get a process sample of the EVE Online client to use with this reading approach,
            //	see the guide at https://forum.botengine.org/t/how-to-collect-samples-for-memory-reading-development/50

            var windowsProcessMeasurementFilePath =
                System.IO.Path.Combine(
                    Environment.GetFolderPath(Environment.SpecialFolder.Desktop),
                    "BotEngine", "Sanderling.Process.Sample", "my-eve-online-client-process-sample.zip");

            var windowsProcessMeasurementZipArchive = System.IO.File.ReadAllBytes(windowsProcessMeasurementFilePath);

            var measurementId = StringIdentifierFromValue(windowsProcessMeasurementZipArchive);

            Console.WriteLine("Loaded sample " + measurementId + " from '" + windowsProcessMeasurementFilePath + "'");

            var windowsProcessMeasurement = BotEngine.Interface.Process.Snapshot.Extension.SnapshotFromZipArchive(windowsProcessMeasurementZipArchive);

            var memoryReader = new BotEngine.Interface.Process.Snapshot.SnapshotReader(windowsProcessMeasurement?.ProcessSnapshot?.MemoryBaseAddressAndListOctet);

            Console.WriteLine("I begin to search for the root of the UI tree...");

            //	The address of the root of the UI tree usually does not change in an EVE Online client process.
            //	Therefore the UI tree root search result is reused when reading the UI tree from the same process later.
            var searchForUITreeRoot = memoryReader.SearchForUITreeRoot();

            Console.WriteLine("I read the partial python model of the UI tree...");

            var memoryMeasurementPartialPythonModel = memoryReader?.ReadUITreeFromRoot(searchForUITreeRoot);

            var allNodesFromMemoryMeasurementPartialPythonModel =
                memoryMeasurementPartialPythonModel.EnumerateNodeFromTreeDFirst(node => node.GetListChild())
                .ToList();

            Console.WriteLine($"The tree in memoryMeasurementPartialPythonModel contains { allNodesFromMemoryMeasurementPartialPythonModel.Count } nodes");

            var memoryMeasurementReducedWithNamedNodes =
                Optimat.EveOnline.AuswertGbs.Extension.SensorikScnapscusKonstrukt(memoryMeasurementPartialPythonModel, null);

            var memoryMeasurementReducedWithNamedNodesParsedFurther =
                memoryMeasurementReducedWithNamedNodes.Parse();

            //	At this point, you will find in the "parsedMemoryMeasurement" variable the contents read from the process measurement as they would appear in the Sanderling API Explorer.

            Console.WriteLine("Overview window read: " + (memoryMeasurementReducedWithNamedNodesParsedFurther.WindowOverview?.Any() ?? false));

            {
                //	TODO: Improve accessibility: Move this derivation section into an artifact which can be easily referenced and executed from the Windows Console App.

                var destinationDirectoryPath =
                    System.IO.Path.Combine(
                        System.IO.Path.GetDirectoryName(windowsProcessMeasurementFilePath),
                        "derivation",
                        "from-" + measurementId);

                Console.WriteLine("I serialize the values from the different stages of memory reading and write those into files.");

                var stagesNamedValues = new[]
Esempio n. 2
0
        public void Demo_memory_reading_from_process_sample()
        {
            //	To get a process sample of the EVE Online client to use with this reading approach,
            //	see the guide at https://forum.botengine.org/t/how-to-collect-samples-for-memory-reading-development/50

            var windowsProcessMeasurementFilePath =
                Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
                .PathToFilesysChild("Sanderling.Process.Sample")
                .PathToFilesysChild("my-eve-online-client-process-sample.zip");

            var windowsProcessMeasurementZipArchive = System.IO.File.ReadAllBytes(windowsProcessMeasurementFilePath);

            var windowsProcessMeasurement = BotEngine.Interface.Process.Snapshot.Extension.SnapshotFromZipArchive(windowsProcessMeasurementZipArchive);

            var memoryReader = new BotEngine.Interface.Process.Snapshot.SnapshotReader(windowsProcessMeasurement?.ProcessSnapshot?.MemoryBaseAddressAndListOctet);

            Console.WriteLine("I begin to search for the root of the UI tree...");

            //	The address of the root of the UI tree usually does not change in an EVE Online client process.
            //	Therefore the UI tree root search result is reused when reading the UI tree from the same process later.
            var searchForUITreeRoot = memoryReader.SearchForUITreeRoot();

            Console.WriteLine("I read the partial python model of the UI tree...");

            var memoryMeasurementPartialPythonModel = memoryReader?.ReadUITreeFromRoot(searchForUITreeRoot);

            var allNodesFromMemoryMeasurementPartialPythonModel =
                memoryMeasurementPartialPythonModel.EnumerateNodeFromTreeDFirst(node => node.GetListChild())
                .ToList();

            Console.WriteLine($"The tree in memoryMeasurementPartialPythonModel contains { allNodesFromMemoryMeasurementPartialPythonModel.Count } nodes");

            var sanderlingMemoryMeasurement = Optimat.EveOnline.AuswertGbs.Extension.SensorikScnapscusKonstrukt(memoryMeasurementPartialPythonModel, null);

            var parsedMemoryMeasurement = sanderlingMemoryMeasurement.Parse();

            //	At this point, you will find in the "parsedMemoryMeasurement" variable the contents read from the process measurement as they would appear in the Sanderling API Explorer.

            Console.WriteLine("Overview window read: " + (parsedMemoryMeasurement.WindowOverview?.Any() ?? false));
        }