internal virtual void  readHeader(DebugHandler handler)
        {
            byte[] sig = new byte[4];

            in_Renamed.readFully(sig);

            if (sig[0] != 'F' || sig[1] != 'W' || sig[2] != 'D' || sig[3] < 6)
            {
                throw new SwfFormatException("not a Flash 6 or later SWD file");
            }

            in_Renamed.swfVersion = sig[3];

            handler.header(in_Renamed.swfVersion);
        }
        /// <summary> process any dangling line records that belong to the given module</summary>
        /// <param name="lineRecords">
        /// </param>
        /// <param name="moduleId">
        /// </param>
        /// <param name="handler">
        /// </param>
        /// <returns>
        /// </returns>
        private System.Collections.ArrayList purgeLineRecords(System.Collections.ArrayList lineRecords, int moduleId, DebugHandler handler)
        {
            System.Collections.ArrayList newLineRecords = new System.Collections.ArrayList();
            DebugModule module = (DebugModule)modules.get_Renamed(moduleId);
            int         i = 0, size = lineRecords.Count;

            while (i < size)
            {
                System.Int32 id     = (System.Int32)lineRecords[i];
                LineRecord   lr     = (LineRecord)lineRecords[i + 1];
                System.Int32 offset = (System.Int32)lineRecords[i + 2];

                if (id == moduleId)
                {
                    lr.module = module;

                    if (lr.module != null)
                    {
                        lr.module.addOffset(lr, offset);
                        handler.offset(offset, lr);
                    }
                    else
                    {
                        handler.error("Could not find kDebugScript with module ID = " + id);
                    }
                }
                else
                {
                    newLineRecords.Add(id);
                    newLineRecords.Add(lr);
                    newLineRecords.Add(offset);
                }

                i += 3;
            }

            return(newLineRecords);
        }
 public virtual void  readSwd(DebugHandler h)
 {
     readHeader(h);
     readTags(h);
 }
        public virtual void  readTags(DebugHandler handler)
        {
            System.Collections.ArrayList lineRecords = new System.Collections.ArrayList();

            do
            {
                int tag = (int)in_Renamed.readUI32();
                switch (tag)
                {
                case kDebugScript:
                    DebugModule m  = new DebugModule();
                    int         id = (int)in_Renamed.readUI32();
                    m.id     = id;
                    m.bitmap = (int)in_Renamed.readUI32();
                    m.name   = in_Renamed.readString();
                    m.Text   = in_Renamed.readString();

                    adjustModuleName(m);

                    if (modules.contains(id))
                    {
                        DebugModule m2 = (DebugModule)modules.get_Renamed(id);
                        if (!m.Equals(m2))
                        {
                            handler.error("Module '" + m2.name + "' has the same ID as Module '" + m.name + "'");
                            handler.error("Let's check for kDebugOffset that came before Module '" + m2.name + "'");
                            handler.error("Before: Number of accumulated line records: " + lineRecords.Count);
                            lineRecords = purgeLineRecords(lineRecords, id, handler);
                            handler.error("After: Number of accumulated line records: " + lineRecords.Count);
                        }
                    }
                    modules.put(id, m);
                    handler.module(m);
                    break;

                case kDebugOffset:
                    id = (int)in_Renamed.readUI32();
                    int         lineno = (int)in_Renamed.readUI32();
                    DebugModule module = (DebugModule)modules.get_Renamed(id);
                    LineRecord  lr     = new LineRecord(lineno, module);
                    int         offset = (int)in_Renamed.readUI32();

                    if (module != null)
                    {
                        // not corrupted before we add the offset and offset add fails
                        bool wasCorrupt = module.corrupt;
                        if (!module.addOffset(lr, offset) && !wasCorrupt)
                        {
                            handler.error(module.name + ":" + lineno + " does not exist for offset " + offset + ", module marked for exclusion from debugging");
                        }
                        handler.offset(offset, lr);
                    }
                    else
                    {
                        lineRecords.Add((System.Int32)id);
                        lineRecords.Add(lr);
                        lineRecords.Add((System.Int32)offset);
                    }
                    break;

                case kDebugBreakpoint:
                    handler.breakpoint((int)in_Renamed.readUI32());
                    break;

                case kDebugRegisters:
                {
                    offset = (int)in_Renamed.readUI32();
                    int            size = in_Renamed.readUI8();
                    RegisterRecord r    = new RegisterRecord(offset, size);
                    for (int i = 0; i < size; i++)
                    {
                        int    nbr  = in_Renamed.readUI8();
                        String name = in_Renamed.readString();
                        r.addRegister(nbr, name);
                    }
                    handler.registers(offset, r);
                    break;
                }


                case kDebugID:
                    FlashUUID uuid = new FlashUUID();
                    in_Renamed.readFully(uuid.bytes);
                    handler.uuid(uuid);
                    break;

                case -1:
                    break;

                default:
                    throw new SwfFormatException("Unexpected tag id " + tag);
                }

                if (tag == -1)
                {
                    break;
                }
            }while (true);

            int i2 = 0, size2 = lineRecords.Count;

            while (i2 < size2)
            {
                int        id     = ((System.Int32)lineRecords[i2]);
                LineRecord lr     = (LineRecord)lineRecords[i2 + 1];
                int        offset = ((System.Int32)lineRecords[i2 + 2]);
                lr.module = (DebugModule)modules.get_Renamed(id);

                if (lr.module != null)
                {
                    //System.out.println("updated module "+id+" out of order");
                    // not corrupted before we add the offset and offset add fails
                    bool wasCorrupt = lr.module.corrupt;
                    if (!lr.module.addOffset(lr, offset) && !wasCorrupt)
                    {
                        handler.error(lr.module.name + ":" + lr.lineno + " does not exist for offset " + offset + ", module marked for exclusion from debugging");
                    }

                    handler.offset(offset, lr);
                }
                else
                {
                    handler.error("Could not find debug module (id = " + id + ") for offset = " + offset);
                }

                i2 += 3;
            }
        }
Esempio n. 5
0
		internal virtual void  readHeader(DebugHandler handler)
		{
			byte[] sig = new byte[4];
			
			in_Renamed.readFully(sig);
			
			if (sig[0] != 'F' || sig[1] != 'W' || sig[2] != 'D' || sig[3] < 6)
			{
				throw new SwfFormatException("not a Flash 6 or later SWD file");
			}
			
			in_Renamed.swfVersion = sig[3];
			
			handler.header(in_Renamed.swfVersion);
		}
Esempio n. 6
0
		public virtual void  readSwd(DebugHandler h)
		{
			readHeader(h);
			readTags(h);
		}
Esempio n. 7
0
		/// <summary> process any dangling line records that belong to the given module</summary>
		/// <param name="lineRecords">
		/// </param>
		/// <param name="moduleId">
		/// </param>
		/// <param name="handler">
		/// </param>
		/// <returns>
		/// </returns>
		private System.Collections.ArrayList purgeLineRecords(System.Collections.ArrayList lineRecords, int moduleId, DebugHandler handler)
		{
			System.Collections.ArrayList newLineRecords = new System.Collections.ArrayList();
			DebugModule module = (DebugModule) modules.get_Renamed(moduleId);
			int i = 0, size = lineRecords.Count;
			while (i < size)
			{
				System.Int32 id = (System.Int32) lineRecords[i];
				LineRecord lr = (LineRecord) lineRecords[i + 1];
				System.Int32 offset = (System.Int32) lineRecords[i + 2];
				
				if (id == moduleId)
				{
					lr.module = module;
					
					if (lr.module != null)
					{
						lr.module.addOffset(lr, offset);
						handler.offset(offset, lr);
					}
					else
					{
						handler.error("Could not find kDebugScript with module ID = " + id);
					}
				}
				else
				{
					newLineRecords.Add(id);
					newLineRecords.Add(lr);
					newLineRecords.Add(offset);
				}
				
				i += 3;
			}
			
			return newLineRecords;
		}
Esempio n. 8
0
		public virtual void  readTags(DebugHandler handler)
		{
			System.Collections.ArrayList lineRecords = new System.Collections.ArrayList();
			
			do 
			{
				int tag = (int) in_Renamed.readUI32();
				switch (tag)
				{
					
					case kDebugScript: 
						DebugModule m = new DebugModule();
						int id = (int) in_Renamed.readUI32();
						m.id = id;
						m.bitmap = (int) in_Renamed.readUI32();
						m.name = in_Renamed.readString();
						m.Text = in_Renamed.readString();
						
						adjustModuleName(m);
						
						if (modules.contains(id))
						{
							DebugModule m2 = (DebugModule) modules.get_Renamed(id);
							if (!m.Equals(m2))
							{
								handler.error("Module '" + m2.name + "' has the same ID as Module '" + m.name + "'");
								handler.error("Let's check for kDebugOffset that came before Module '" + m2.name + "'");
								handler.error("Before: Number of accumulated line records: " + lineRecords.Count);
								lineRecords = purgeLineRecords(lineRecords, id, handler);
								handler.error("After: Number of accumulated line records: " + lineRecords.Count);
							}
						}
						modules.put(id, m);
						handler.module(m);
						break;
					
					case kDebugOffset: 
						id = (int) in_Renamed.readUI32();
						int lineno = (int) in_Renamed.readUI32();
						DebugModule module = (DebugModule) modules.get_Renamed(id);
						LineRecord lr = new LineRecord(lineno, module);
						int offset = (int) in_Renamed.readUI32();
						
						if (module != null)
						{
							// not corrupted before we add the offset and offset add fails
							bool wasCorrupt = module.corrupt;
							if (!module.addOffset(lr, offset) && !wasCorrupt)
								handler.error(module.name + ":" + lineno + " does not exist for offset " + offset + ", module marked for exclusion from debugging");
							handler.offset(offset, lr);
						}
						else
						{
							lineRecords.Add((System.Int32) id);
							lineRecords.Add(lr);
							lineRecords.Add((System.Int32) offset);
						}
						break;
					
					case kDebugBreakpoint: 
						handler.breakpoint((int) in_Renamed.readUI32());
						break;
					
					case kDebugRegisters: 
					{
						offset = (int) in_Renamed.readUI32();
						int size = in_Renamed.readUI8();
						RegisterRecord r = new RegisterRecord(offset, size);
						for (int i = 0; i < size; i++)
						{
							int nbr = in_Renamed.readUI8();
							String name = in_Renamed.readString();
							r.addRegister(nbr, name);
						}
						handler.registers(offset, r);
						break;
					}
					
					
					case kDebugID: 
						FlashUUID uuid = new FlashUUID();
						in_Renamed.readFully(uuid.bytes);
						handler.uuid(uuid);
						break;
					
					case - 1: 
						break;
					
					default: 
						throw new SwfFormatException("Unexpected tag id " + tag);
					
				}
				
				if (tag == - 1)
				{
					break;
				}
			}
			while (true);
			
			int i2 = 0, size2 = lineRecords.Count;
			while (i2 < size2)
			{
				int id = ((System.Int32) lineRecords[i2]);
				LineRecord lr = (LineRecord) lineRecords[i2 + 1];
				int offset = ((System.Int32) lineRecords[i2 + 2]);
				lr.module = (DebugModule) modules.get_Renamed(id);
				
				if (lr.module != null)
				{
					//System.out.println("updated module "+id+" out of order");
					// not corrupted before we add the offset and offset add fails
					bool wasCorrupt = lr.module.corrupt;
					if (!lr.module.addOffset(lr, offset) && !wasCorrupt)
						handler.error(lr.module.name + ":" + lr.lineno + " does not exist for offset " + offset + ", module marked for exclusion from debugging");
					
					handler.offset(offset, lr);
				}
				else
				{
					handler.error("Could not find debug module (id = " + id + ") for offset = " + offset);
				}
				
				i2 += 3;
			}
		}