Exemplo n.º 1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Processes one section.
        /// </summary>
        /// <param name="addressVirtual">The address when loaded.</param>
        /// <param name="sizeVirtual">The virtual size (size on disk).</param>
        /// ------------------------------------------------------------------------------------
        private void ProcessSection(int addressVirtual, int sizeVirtual)
        {
            long nSectionBase = m_stream.Position;

            foreach (DictionaryEntry entry in m_htDirectories)
            {
                m_stream.Position = nSectionBase;
                ImageDataDirectory dir = (ImageDataDirectory)entry.Value;
                if (dir.VirtualAddress >= addressVirtual &&
                    dir.VirtualAddress < addressVirtual + sizeVirtual)
                {
                    m_stream.Position = dir.VirtualAddress - addressVirtual + nSectionBase;

                    switch (dir.Index)
                    {
                    case 0:                             // Export Table
                    case 1:                             // Import Table
                        m_stream.Position += 4;
                        OverwriteTimestamp();
                        break;

                    case 2:                             // Resource Table
                        ResourceProcessor resourceProcessor = new ResourceProcessor(m_stream,
                                                                                    m_reader, m_writer);
                        resourceProcessor.ProcessResourceSection(dir.VirtualAddress);
                        break;

                    case 6:                             // Debug
                        ProcessDebugInfo();
                        break;

                    case 14:                             // CLI Header
                        CLIFileProcessor cliFileProcessor = new CLIFileProcessor(m_stream,
                                                                                 m_reader, m_writer);
                        cliFileProcessor.ProcessCLIHeader(nSectionBase, addressVirtual);
                        break;

                    default:
                        break;
                    }
                }
            }
        }
Exemplo n.º 2
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Processes one section.
		/// </summary>
		/// <param name="addressVirtual">The address when loaded.</param>
		/// <param name="sizeVirtual">The virtual size (size on disk).</param>
		/// ------------------------------------------------------------------------------------
		private void ProcessSection(int addressVirtual, int sizeVirtual)
		{
			long nSectionBase = m_stream.Position;

			foreach (DictionaryEntry entry in m_htDirectories)
			{
				m_stream.Position = nSectionBase;
				ImageDataDirectory dir = (ImageDataDirectory)entry.Value;
				if (dir.VirtualAddress >= addressVirtual &&
					dir.VirtualAddress < addressVirtual + sizeVirtual)
				{
					m_stream.Position = dir.VirtualAddress - addressVirtual + nSectionBase;

					switch (dir.Index)
					{
						case 0: // Export Table
						case 1: // Import Table
							m_stream.Position += 4;
							OverwriteTimestamp();
							break;
						case 2: // Resource Table
							ResourceProcessor resourceProcessor = new ResourceProcessor(m_stream,
								m_reader, m_writer);
							resourceProcessor.ProcessResourceSection(dir.VirtualAddress);
							break;
						case 6: // Debug
							ProcessDebugInfo();
							break;
						case 14: // CLI Header
							CLIFileProcessor cliFileProcessor = new CLIFileProcessor(m_stream,
								m_reader, m_writer);
							cliFileProcessor.ProcessCLIHeader(nSectionBase, addressVirtual);
							break;
						default:
							break;
					}
				}
			}
		}