Ejemplo n.º 1
0
bool CHuffman::readDictionaryNumber( const CExeFile& ExeFile,
                                     const int dictnum,
                                     const unsigned int dictOffset )
{
    uint8_t dictnumleft = dictnum;

    if( dictOffset == 0) // don't seek to offset
    {
        uint8_t *data_ptr = ExeFile.getRawData();

        for( Uint32 i=0; i<ExeFile.getExeDataSize() ; i++ )
        {
            if( memcmp(data_ptr, DICTSIG, DICT_SIG_BYTES) == 0 )
            {
                if(dictnumleft == 0)
                {
                    uint8_t *dictdata = data_ptr-(DICT_SIZE*sizeof(nodestruct))+DICT_SIG_BYTES;
                    const Uint32 size = DICT_SIZE*sizeof(nodestruct);
                    memcpy(m_nodes, dictdata, size);
                    return true;
                }
                dictnumleft--;
            }
            data_ptr++;
        }
        return false;
    }
    else // Otherwise copy the dictionary normally
    {
        uint8_t *dictdata = (byte*)(ExeFile.getHeaderData())+dictOffset;
        memcpy(reinterpret_cast<char*>(m_nodes), dictdata, DICT_SIZE*sizeof(nodestruct));
        return true;
    }
}
Ejemplo n.º 2
0
bool CHuffman::readDictionaryNumberfromEnd(const CExeFile& ExeFile)
{        
    const uint32_t bytesToCheck = ExeFile.getExeDataSize()-DICT_SIG_BYTES;

    uint8_t *data_ptr = static_cast<uint8_t*>(ExeFile.getHeaderData())+bytesToCheck;

    for( Uint32 i=0; i<bytesToCheck ; i++ )
    {
        data_ptr--;
        if( memcmp(data_ptr, DICTSIG, DICT_SIG_BYTES) == 0 )
        {
       		uint8_t *dictdata = data_ptr-(DICT_SIZE*sizeof(nodestruct))+DICT_SIG_BYTES;
       		const Uint32 size = DICT_SIZE*sizeof(nodestruct);
       		memcpy(m_nodes, dictdata, size);

            //dumpToExternalFile("dump.huffmann");

       		return true;
        }
    }



    return false;
}
Ejemplo n.º 3
0
bool CHuffman::readDictionaryNumber( const CExeFile& ExeFile, const int dictnum )
{
	uint8_t dictnumleft = dictnum;
    uint8_t *data_ptr = ExeFile.getRawData();

    for( Uint32 i=0; i<ExeFile.getExeDataSize() ; i++ )
    {
        if( memcmp(data_ptr,DICTSIG, DICT_SIG_BYTES) == 0 )
        {
        	if(dictnumleft == 0)
        	{
        		uint8_t *dictdata = data_ptr-(DICT_SIZE*sizeof(nodestruct))+DICT_SIG_BYTES;
        		const Uint32 size = DICT_SIZE*sizeof(nodestruct);
        		memcpy(m_nodes, dictdata, size);
        		return true;
        	}
        	dictnumleft--;
        }
        data_ptr++;
    }
    return false;
}