
    Xf                         d dl Z d dlZd dlmZmZmZmZmZ d dlm	Z	m
Z
mZ  ej                  e      Z G d de	j                  j                         Z G d de	j                  j                         Zy)    N)AnyClassVarDictListType)
interfaces
exceptions	constantsc                        e Zd ZdZdeej                  j                     deddf fdZ	e
defd       Ze
deej                  j                     fd       Zd	edefd
Zd	edej                  j                  fdZdej                  j                  dej                  j                  ddfdZdedefdZdej*                  j,                  dej                  j.                  dej                  j                  fdZ xZS )ObjectTemplatea,  Factory class that produces objects that adhere to the Object interface
    on demand.

    This is effectively a method of currying, but adds more structure to avoid abuse.
    It also allows inspection of information that should already be known:

      * Type size
      * Members
      * etc
    object_class	type_namereturnNc                     ||d<   t        |   dd|i| | j                  j                  j                  }|j
                  D ]-  }t        | |t        j                  t        ||      |              / y )Nr   r    )
super__init__volr   VolTemplateProxy_methodssetattr	functoolspartialgetattr)selfr   r   	arguments	proxy_clsmethod_name	__class__s         Y/home/panchajanya/Development/work/volatility3/volatility3/framework/objects/templates.pyr   zObjectTemplate.__init__   ss     %1	.!:9:	:HH))::	$-- 	K!!')["A4H	    c                 `    | j                   j                  j                  j                  |       S zReturns the children of the templated object (see :class:`~volatilit
        y.framework.interfaces.objects.ObjectInterface.VolTemplateProxy`))r   r   r   sizer   s    r    r$   zObjectTemplate.size*   s%     xx$$55::4@@r!   c                 `    | j                   j                  j                  j                  |       S r#   )r   r   r   childrenr%   s    r    r'   zObjectTemplate.children0   s%     xx$$55>>tDDr!   childc                 b    | j                   j                  j                  j                  | |      S )zReturns the relative offset of a child of the templated object (see
        :class:`~volatility3.framework.interfaces.objects.ObjectInterface.VolTem
        plateProxy`))r   r   r   relative_child_offsetr   r(   s     r    r*   z$ObjectTemplate.relative_child_offset6   s(     xx$$55KKDRWXXr!   c                 b    | j                   j                  j                  j                  | |      S )zReturns the template of a child of the templated object (see
        :class:`~volatility3.framework.interfaces.objects.ObjectInterface.VolTem
        plateProxy`))r   r   r   child_templater+   s     r    r-   zObjectTemplate.child_template<   s'     xx$$55DDT5QQr!   	old_child	new_childc                 d    | j                   j                  j                  j                  | ||      S )zReplaces `old_child` for `new_child` in the templated object's child
        list (see :class:`~volatility3.framework.interfaces.objects.ObjectInterf
        ace.VolTemplateProxy`))r   r   r   replace_child)r   r.   r/   s      r    r1   zObjectTemplate.replace_childB   s.     xx$$55CC)Y
 	
r!   member_namec                 b    | j                   j                  j                  j                  | |      S )zMReturns whether the object would contain a member called
        member_name.)r   r   r   
has_member)r   r2   s     r    r4   zObjectTemplate.has_memberN   s'     xx$$55@@{SSr!   contextobject_infoc                     i }| j                   D ]  }|dk7  s	| j                   |   ||<     | j                   j                  d||d|S )zConstructs the object.

        Returns: an object adhering to the :class:`~volatility3.framework.interfaces.objects.ObjectInterface`
        r   r5   r6   r   )r   r   )r   r5   r6   r   args        r    __call__zObjectTemplate.__call__S   sb     %'	88 	/Cn$!%#	#	/ %txx$$ 

8A
 	
r!   )__name__
__module____qualname____doc__r   r   objectsObjectInterfacestrr   propertyintr$   r   Templater'   r*   r-   r1   boolr4   r5   ContextInterfaceObjectInformationr:   __classcell__)r   s   @r    r   r      sS   	:--==> 
 
" Ac A A
 E$z11::; E E
Y3 Y3 YRC RJ,>,>,G,G R

%%..

 %%..

 
	

Tc Td T

##44
  ''99
 
			+	+	
r!   r   c                   2   e Zd ZU dZedeej                  j                     fd       Z	de
fdZ ee      Zee
   ed<   eZee
   ed<   eZee
   ed<   eZee
   ed<   eZee
   ed	<   d
ej&                  j(                  dej                  j*                  fdZy)ReferenceTemplatezFactory class that produces objects based on a delayed reference type.

    Attempts to access any standard attributes of a resolved template will result in a
    :class:`~volatility3.framework.exceptions.SymbolError`.
    r   c                     g S )Nr   r%   s    r    r'   zReferenceTemplate.childrenl   s    	r!   c                     | j                   j                  j                  t        j                        }d}t        |      dk(  r|d   }|d   }t        j                  ||d| j                   j                         )zReferenced symbols must be appropriately resolved before they can
        provide information such as size This is because the size request has
        no context within which to determine the actual symbol structure.N   r   z6Template contains no information about its structure: )r   r   splitr
   BANGlenr	   SymbolError)r   argskwargsr   
table_namesymbol_names         r    _unresolvedzReferenceTemplate._unresolvedp   ss     HH&&,,Y^^<	
y>Q"1Jm$$DTXXEWEWDXY
 	
r!   r$   r1   r*   r-   r4   r5   r6   c                 t    |j                   j                  | j                  j                        } |||      S )Nr8   )symbol_spaceget_typer   r   )r   r5   r6   templates       r    r:   zReferenceTemplate.__call__   s1    
 ''001C1CD[AAr!   N)r;   r<   r=   r>   rB   r   r   r?   rD   r'   r   rW   r$   r   __annotations__r1   r*   r-   r4   r5   rF   rG   r:   r   r!   r    rJ   rJ   e   s     $z11::;  
c 
 #;/D(3-/#.M8C=.+68C=6$/NHSM/ +J+B##44B  ''99Br!   rJ   )r   loggingtypingr   r   r   r   r   volatility3.frameworkr   r	   r
   	getLoggerr;   vollogr?   rD   r   rJ   r   r!   r    <module>rb      s`      2 2 C C			8	$U
Z''00 U
p&B
**33 &Br!   