예제 #1
0
        public RamBitmap(RamMap ram)
        {
            if (ram == null)
            {
                throw new ArgumentNullException("ram");
            }

            _ram = ram;

            _width  = 0;
            _height = 0;

            _start     = 0;
            _zoomLevel = 1;
        }
예제 #2
0
파일: Replay.cs 프로젝트: skykying/traces
        public Replay(LogPrinter logger, string server, string store,
                      string writeStream, uint ramSizeInMiB)
        {
            _logger = logger;
            _server = server;
            _store  = store;

            _numWrites = new long[4];
            _streams   = new StreamCollection <Streams>();

            _screenLock = new Object();
            _state      = ReplayState.Suspend;

            // Connect to the server and open the specified store
            _log("Connecting to server '{0}'...", server);

            _session = Native.StSessionCreate(server);
            if (_session == Native.INVALID_SESSION_ID)
            {
                throw new SimutraceException();
            }

            _log("ok\n");

            try {
                // Open the specified store
                _log("Opening store '{0}'...", store);

                if (!Native.StSessionOpenStore(_session, store))
                {
                    throw new SimutraceException();
                }

                _log("ok\n");

                List <uint> ids = new List <uint>();

                // Find the memory write stream
                _log("Using memory write stream '{0}'...", writeStream);

                Guid mtype = new Guid("{6E943CDD-D2DA-4E83-984F-585C47EB0E36}");
                _streams[Streams.Write] = new Stream(_session, writeStream,
                                                     _applyWrite, mtype);
                if (!_streams[Streams.Write].IsValid)
                {
                    throw new ReplayException("Could not find memory stream.");
                }

                ids.Add(_streams[Streams.Write].Id);

                _log("ok\n");

                // Find the streams that contain dumps from the screen output
                _log("Searching for screen streams...");

                Stream screen     = new Stream(_session, "screen", _applyScreen);
                Stream screenData = new Stream(_session, "screen_data");
                if (!screen.IsValid || !screenData.IsValid)
                {
                    screen.Dispose();
                    screenData.Dispose();

                    _log("not found. Screen output not available.\n");
                }
                else
                {
                    _streams[Streams.Screen]     = screen;
                    _streams[Streams.ScreenData] = screenData;

                    ids.Add(screen.Id);

                    _log("ok\n");
                }

                // Find the stream that contains cr3 change information
                _log("Searching for page directory set stream...");

                Stream cr3 = new Stream(_session, "cpu_set_pagedirectory", _applyCr3);
                if (!cr3.IsValid)
                {
                    cr3.Dispose();

                    _log("not found\n");
                }
                else
                {
                    _streams[Streams.Cr3] = cr3;

                    ids.Add(cr3.Id);

                    _log("ok\n");
                }

                // Create multiplexer
                _streams[Streams.Multiplexer] = new Stream(_session,
                                                           NativeX.StXMultiplexerCreate(_session, "mult",
                                                                                        NativeX.MultiplexingRule.MxrCylceCount,
                                                                                        NativeX.MultiplexerFlags.MxfIndirect, ids.ToArray()));
                if (!_streams[Streams.Multiplexer].IsValid)
                {
                    throw new SimutraceException();
                }

                _streams[Streams.Multiplexer].Open();

                // Allocate a buffer that will hold the guest's RAM and a
                // ram bitmap for visualization
                _log("Configuring ram size for replay {0} MiB...", ramSizeInMiB);

                _ram       = new RamMap((ulong)ramSizeInMiB << 20, true);
                _ramBitmap = new RamBitmap(_ram);

                _log("ok\n");

                // Create the thread that will perform the replay
                _log("Creating replay thread...");

                _replayer = new Thread(_replayThreadMain);

                _log("ok\n");
            } catch (Exception) {
                _log("failed\n");
                _finalize();

                throw;
            }
        }