
    #f                         d dl Z d dlmZ d dlmZmZmZ d dlmZ d dl	m
Z
 d dlmZ  e j        e          Z G d dej        j                  ZdS )	    N)List)	renderers
interfaces
exceptions)requirements)utility)format_hintsc                       e Zd ZdZdZdZedeej	        j
                 fd            Ze e            dfdej        j        ded	ed
edef
d            Zd Zd ZdS )IOMemz?Generates an output similar to /proc/iomem on a running system.)   r   r   )   r   r   returnc                 6    t          j        ddg d          gS )NkernelzLinux kernel)Intel32Intel64AArch64)namedescriptionarchitectures)r   ModuleRequirement)clss    [/home/panchajanya/Development/work/volatility3/volatility3/framework/plugins/linux/iomem.pyget_requirementszIOMem.get_requirements   s2     **???  
 	
    r   contextvmlinux_module_nameresource_offsetseendepthc              #     K   |j         |         }	 |                    d|d          }n5# t          j        $ r# t                              d|dd           Y dS w xY w	 t          j        |j        d          }nG# t          j        $ r5 t                              d	|dd
           t          j
                    }Y nw xY w||v r$t                              d|dd| d           dS |                    |           |||j        |j        ffV  |j        dk    r'|                     |||j        ||dz             E d{V  |j        dk    r&|                     |||j        ||          E d{V  dS dS )a  Recursively parse from a root resource to find details about all related resources.

        Args:
            context: The context to retrieve required elements (layers, symbol tables) from
            vmlinux_module_name: The name of the kernel module on which to operate
            resource_offset: The offset to the resource to be parsed
            seen: The set of resource offsets that have already been parsed
            depth: How deep into the resource structure we are

        Yields:
            Each row of output
        resourceT)absolutez$Unable to create resource object at z#xz[. This resource, its sibling, and any of it's children and will be missing from the output.N   z8Unable to follow pointer to name for resource object at z, replaced with UnreadableValuezThe resource object at z 'z' has already been processed, this should not normally occur. No further results from related resources will be displayed to protect against infinite loops.r   r   )modulesobjectr   InvalidAddressExceptionvollogwarningr   pointer_to_stringr   r   UnreadableValueaddstartendchildparse_resourcesibling)	r   r   r   r   r   r    vmlinuxr"   r   s	            r   r0   zIOMem.parse_resource   sL     * /"56	~~j/D~QQHH1 	 	 	NN]\ ] ] ]   44		/,X]C@@DD1 	/ 	/ 	/NN0?a 0 0 0   ,..DDD	/ d""NN?/d ? ? ? ? ?  
 4HH_%%% dHNHL99999 >Q))#	         q  ))#            ! s"   * .AA A; ;AB?>B?c              #   R  K   | j         d         }| j        j        |         }	 |                    d          }n# t          j        $ r d}Y nw xY w|S|                     | j        ||          D ]8\  }\  }}}||t          j        |          t          j        |          ffV  7dS dS )zGenerates an output similar to /proc/iomem on a running system

        Args:
            None

        Yields:
            Each row of output using the parse_resource function
        r   iomem_resourceN)	configr   r%   get_absolute_symbol_addressr   SymbolErrorr0   r	   Hex)selfr   r2   iomem_root_offsetr    r   r-   r.   s           r   
_generatorzIOMem._generatorm   s       #k(3,&':;	% ' C CDT U U% 	% 	% 	% $	% (-1-@-@13D. . T T))eS dL$4U$;$;\=Mc=R=RSSSSSS )(T Ts   9 AAc                 f   | j         d         }| j        j        |         }|                    d          st	          d          |                    d          st	          d          dt          fdt          j        fdt          j        fg}t          j
        ||                                           S )	Nr   r4   zThis plugin requires the iomem_resource symbol. This symbol is not present in the supplied symbol table. This means you are either analyzing an unsupported kernel version or that your symbol table is corrupt.r"   zThis plugin requires the resource type. This type is not present in the supplied symbol table. This means you are either analyzing an unsupported kernel version or that your symbol table is corrupt.NameStartEnd)r5   r   r%   
has_symbol	TypeErrorhas_typestrr	   r8   r   TreeGridr;   )r9   r   r2   columnss       r   runz	IOMem.run   s    "k(3,&':; !!"233 	 c  
 
++ 	 Y  
 SMl&'L$%

 !'4??+<+<===r   N)__name__
__module____qualname____doc___required_framework_version_versionclassmethodr   r   configurationRequirementInterfacer   setr   ContextInterfacerC   intr0   r;   rF    r   r   r   r      s        II"+H
j&>&S!T 
 
 
 [
  CEEK K#4K !K 	K
 K K K K [KZT T T:> > > > >r   r   )loggingtypingr   volatility3.frameworkr   r   r   #volatility3.framework.configurationr   volatility3.framework.objectsr   volatility3.framework.renderersr	   	getLoggerrG   r(   pluginsPluginInterfacer   rS   r   r   <module>r]      s           C C C C C C C C C C < < < < < < 1 1 1 1 1 1 8 8 8 8 8 8		8	$	$R> R> R> R> R>J. R> R> R> R> R>r   