uint32_t RawSection::read(BinaryInputFile* b){
    b->setInPointer(rawDataPtr);
    setFileOffset(b->currentOffset());

    verify();
    return sizeInBytes;
}
uint32_t ProgramHeader64::read(BinaryInputFile* binaryInputFile){
    setFileOffset(binaryInputFile->currentOffset());

    if(!binaryInputFile->copyBytesIterate(&entry,Size__64_bit_Program_Header)){
        PRINT_ERROR("Program header (64) can not be read");
    }
    return Size__64_bit_Program_Header;
}
Beispiel #3
0
off_t SkPDFCatalog::setSubstituteResourcesOffsets(off_t fileOffset,
                                                  bool firstPage) {
    SkTDArray<SkPDFObject*>* targetList = getSubstituteList(firstPage);
    off_t offsetSum = fileOffset;
    for (int i = 0; i < targetList->count(); ++i) {
        offsetSum += setFileOffset((*targetList)[i], (size_t) offsetSum);
    }
    return offsetSum - fileOffset;
}
Beispiel #4
0
int DbFileOp::restoreBlock(IDBDataFile* pFile, const unsigned char* writeBuf, uint64_t fbo)
{
    if (m_chunkManager)
        return m_chunkManager->restoreBlock(pFile, writeBuf, fbo);

    if (setFileOffset(pFile, fbo*BYTE_PER_BLOCK, SEEK_SET) != NO_ERROR)
        return -1;

    return pFile->write(writeBuf, BYTE_PER_BLOCK);
}
uint32_t Symbol64::read(BinaryInputFile* binaryInputFile){
    binaryInputFile->setInPointer(symbolPtr);
    setFileOffset(binaryInputFile->currentOffset());

    if(!binaryInputFile->copyBytesIterate(&entry,Size__64_bit_Symbol)){
        PRINT_ERROR("Symbol (64) can not be read");
    }

    verify(Size__64_bit_Symbol);

    return sizeInBytes;    
}
Beispiel #6
0
int DbFileOp::readDbBlocks(IDBDataFile* pFile,
                           unsigned char* readBuf,
                           uint64_t fbo,
                           size_t n)
{
    if (m_chunkManager) {
        return m_chunkManager->readBlocks(pFile, readBuf, fbo, n);
	}

    if (setFileOffset(pFile, fbo*BYTE_PER_BLOCK, SEEK_SET) != NO_ERROR)
        return -1;
    return pFile->read(readBuf, BYTE_PER_BLOCK * n) / BYTE_PER_BLOCK;
}
uint32_t SectionHeader64::read(BinaryInputFile* binaryInputFile){

    setFileOffset(binaryInputFile->currentOffset());

    if(!binaryInputFile->copyBytesIterate(&entry,Size__64_bit_Section_Header)){
        PRINT_ERROR("Section header (64) can not be read");
    }

    setSectionType();
    verify();

    return Size__64_bit_Section_Header;
}
// Copy constructor for the user log header
UserLogHeader::UserLogHeader( const UserLogHeader &other )
{
	setId(          other.getId() );
	setSequence(    other.getSequence() );
	setCtime(       other.getCtime() );
	setSize(        other.getSize() );
	setNumEvents(   other.getNumEvents() );
	setFileOffset(  other.getFileOffset() );
	setEventOffset( other.getEventOffset() );
	setMaxRotation( other.getMaxRotation() );
	setCreatorName( other.getCreatorName() );

	m_valid = other.IsValid( );
}
Beispiel #9
0
// just don't have a good solution to consolidate with above functions
// Note: This is used with absolute FBO, no lbid involved
int DbFileOp::writeDBFileFbo(IDBDataFile* pFile, const unsigned char* writeBuf,
                             const uint64_t fbo, const int numOfBlock  )
{
    long long  fboOffset = 0;

    fboOffset = (fbo)*(long)BYTE_PER_BLOCK;
    RETURN_ON_ERROR( setFileOffset( pFile, fboOffset ) );

    for( int i = 0; i < numOfBlock; i++ ) {
        Stats::incIoBlockWrite();
        RETURN_ON_ERROR( writeFile( pFile, writeBuf, BYTE_PER_BLOCK ) );
    }

    return NO_ERROR;
}
Beispiel #10
0
/***********************************************************
 * DESCRIPTION: 
 *    Read a block from a file at specified location
 * PARAMETERS:
 *    pFile - file handle
 *    readBuf - read buffer
 *    fbo - file block offset
 * RETURN:
 *    NO_ERROR if success
 *    other number if something wrong
 ***********************************************************/
int DbFileOp::readDBFile( IDBDataFile* pFile,
                          unsigned char* readBuf,
                          const uint64_t lbid,
                          const bool isFbo )
{
    long long  fboOffset = 0;

    if( !isFbo ) {
        RETURN_ON_ERROR( setFileOffsetBlock( pFile, lbid ) );
    }
    else {  
        fboOffset = (lbid)*(long)BYTE_PER_BLOCK;                 
        RETURN_ON_ERROR( setFileOffset( pFile, fboOffset ) );
    }

    return readFile( pFile, readBuf, BYTE_PER_BLOCK );
}
uint32_t SymbolTable::read(BinaryInputFile* binaryInputFile){
    
    binaryInputFile->setInPointer(getFilePointer());
    setFileOffset(binaryInputFile->currentOffset());

    uint32_t totalBytesRead = 0;

    uint32_t numberOfSymbols = sizeInBytes / symbolSize;
    for (uint32_t i = 0; i < numberOfSymbols; i++){
        if (elfFile->is64Bit()){
            symbols.append(new Symbol64(this, getFilePointer() + (i * Size__64_bit_Symbol), i));
        } else {
            symbols.append(new Symbol32(this, getFilePointer() + (i * Size__32_bit_Symbol), i));
        }
        totalBytesRead += symbols[i]->read(binaryInputFile);
    }

    ASSERT(sizeInBytes == totalBytesRead && "size read from file does not match theorietical size of Symbol Table");
    return sizeInBytes;
}
uint32_t LineInfoTable::read(BinaryInputFile* binaryInputFile){
    binaryInputFile->setInPointer(rawDataPtr);
    setFileOffset(binaryInputFile->currentOffset());

    uint32_t currByte = 0;

    uint32_t firstWord = 0;
    if (!binaryInputFile->copyBytesIterate(&firstWord,sizeof(uint32_t))){
        PRINT_ERROR("Line info section header cannot be read");
    }
    currByte += sizeof(uint32_t);
    if (firstWord >= DWARF2_FIRSTBYTE_LO){
        if (firstWord == DWARF2_FIRSTBYTE_64BIT_FORMAT){
            format = DebugFormat_DWARF2_64bit;
        } else {
            PRINT_ERROR("The first word %d of this debug section is not an understood DWARF2 format", firstWord);
        }
    } else {
        format = DebugFormat_DWARF2_32bit;
    }

    ASSERT(format && "The format of this debug section is unknown");
    PRINT_DEBUG_LINEINFO("The format of the debug section is %d", format);

    // get the line info header
    if (format == DebugFormat_DWARF2_64bit){
        if(!binaryInputFile->copyBytesIterate(&entry.li_length,sizeof(uint64_t))){
            PRINT_ERROR("Line info section header cannot be read");
        }
        currByte += sizeof(uint64_t);
    } else {
        entry.li_length = firstWord;
    }
    if(!binaryInputFile->copyBytesIterate(&entry.li_version,sizeof(uint16_t))){
        PRINT_ERROR("Line info section header cannot be read");
    }
    currByte += sizeof(uint16_t);
    if (format == DebugFormat_DWARF2_64bit){
        if(!binaryInputFile->copyBytesIterate(&entry.li_prologue_length,sizeof(uint64_t))){
            PRINT_ERROR("Line info section header cannot be read");
        }
        currByte += sizeof(uint64_t);
    } else {
        if(!binaryInputFile->copyBytesIterate(&firstWord,sizeof(uint32_t))){
            PRINT_ERROR("Line info section header cannot be read");
        }
        currByte += sizeof(uint32_t);
        entry.li_prologue_length = firstWord;
    }
    if(!binaryInputFile->copyBytesIterate(&entry.li_min_insn_length,sizeof(uint8_t))){
        PRINT_ERROR("Line info section header cannot be read");
    }
    currByte += sizeof(uint8_t);
    if(!binaryInputFile->copyBytesIterate(&entry.li_default_is_stmt,sizeof(uint8_t))){
        PRINT_ERROR("Line info section header cannot be read");
    }
    currByte += sizeof(uint8_t);
    if(!binaryInputFile->copyBytesIterate(&entry.li_line_base,sizeof(uint8_t))){
        PRINT_ERROR("Line info section header cannot be read");
    }
    currByte += sizeof(uint8_t);
    if(!binaryInputFile->copyBytesIterate(&entry.li_line_range,sizeof(uint8_t))){
        PRINT_ERROR("Line info section header cannot be read");
    }
    currByte += sizeof(uint8_t);
    if(!binaryInputFile->copyBytesIterate(&entry.li_opcode_base,sizeof(uint8_t))){
        PRINT_ERROR("Line info section header cannot be read");
    }
    currByte += sizeof(uint8_t);

    sizeInBytes = GET(li_length) + sizeof(uint32_t);
    if (format == DebugFormat_DWARF2_64bit){
        sizeInBytes += 8;
    }

    DEBUG_LINEINFO(dwarfLineInfoSection->printBytes(0,0,0);)