o
    �õ±jŒ  ã                   @   s*   d Z ddlZddlmZ G dd„ dƒZdS )aÍ  
hbin-Header
===========

Offset	Size	Contents
0x0000	D-Word	ID: ASCII-"hbin" = 0x6E696268
0x0004	D-Word	Offset from the 1st hbin-Block
0x0008	D-Word	Offset to the next hbin-Block
0x001C	D-Word	Block-size

The values in 0x0008 and 0x001C should be the same, so I don't know
if they are correct or swapped...

From offset 0x0020 inside a hbin-block data is stored with the following
format:


Offset	Size	Contents
0x0000	D-Word	Data-block size
0x0004	????	Data

é    N)ÚNTRegistryCellc                   @   sD   e Zd Zdd„ Zdd„ Zdd„ Zedd„ ƒZed	d
„ ƒZdd„ Z	dS )ÚNTRegistryHbinc                 C   s"   d| _ d | _d | _d | _g | _d S )Ns   hbin)ÚmagicÚoffset_firstÚoffset_nextÚ
block_sizeÚcells)Úself© r
   úŒ/root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/aiowinreg/filestruct/hbin.pyÚ__init__   s
   
zNTRegistryHbin.__init__c                 C   s   |   t |¡¡ d S )N)Úparse_header_bufferÚioÚBytesIO)r	   Údatar
   r
   r   Úparse_header_bytes&   s   z!NTRegistryHbin.parse_header_bytesc                 C   sb   |  d¡| _tj|  d¡ddd�| _tj|  d¡ddd�| _tj|  d¡ddd�| _|  d¡ d S )Né   ÚlittleF)Úsignedé   )Úreadr   ÚintÚ
from_bytesr   r   r   )r	   Úbufferr
   r
   r   r   )   s
   z"NTRegistryHbin.parse_header_bufferc                 Ã   s–   �t ƒ }|  d¡I d H }t|tƒr|\}}|d ur|‚n|}| |¡ t | ¡I d H }|j |¡ |j	dkrIt | ¡I d H }|j |¡ |j	dks6|S )Né    r   )
r   r   Ú
isinstanceÚtupler   r   Úareadr   ÚappendÚsize)ÚreaderÚhbinÚresÚhdr_dataÚerrÚcellr
   r
   r   r   0   s"   €
ÿ


þzNTRegistryHbin.areadc                 C   sT   t ƒ }| | ¡ t | ¡}|j |¡ |jdkr(t | ¡}|j |¡ |jdks|S )Nr   )r   r   r   r   r   r   r   )r    r!   r%   r
   r
   r   r   D   s   




þzNTRegistryHbin.readc                 C   sn   d}| j D ]/}t| j | tƒr't| j | ƒD ]\}}|d||t|ƒf 7 }qq|d|t| j | ƒf 7 }q|S )Nz== NT Registry HBIN struct ==
z   %s: %s: %sz	%s: %s 
)Ú__dict__r   ÚlistÚ	enumerateÚstr)r	   ÚtÚkÚiÚitemr
   r
   r   Ú__str__Q   s   
ÿzNTRegistryHbin.__str__N)
Ú__name__Ú
__module__Ú__qualname__r   r   r   Ústaticmethodr   r   r.   r
   r
   r
   r   r      s    

r   )Ú__doc__r   Úaiowinreg.filestruct.regcellr   r   r
   r
   r
   r   Ú<module>   s   