예제 #1
0
void getElfInfoBySectionView(ElfInfo &info, const ElfHandle *handle){

	info.handle = handle;
	info.elf_base = (uint8_t *) handle->base;
	info.ehdr = reinterpret_cast<Elf32_Ehdr *>(info.elf_base);
	info.shdr = reinterpret_cast<Elf32_Shdr *>(info.elf_base + info.ehdr->e_shoff);
	info.phdr = reinterpret_cast<Elf32_Phdr *>(info.elf_base + info.ehdr->e_phoff);

	Elf32_Shdr *shstr = (Elf32_Shdr *)(info.shdr + info.ehdr->e_shstrndx);
	info.shstr = reinterpret_cast<char *>(info.elf_base + shstr->sh_offset);

	getSectionInfo(info, ".dynstr", NULL, NULL, &info.symstr);
	getSectionInfo(info, ".dynamic", &info.dynsz, NULL, &info.dyn);
	getSectionInfo(info, ".dynsym", &info.symsz, NULL, &info.sym);
	getSectionInfo(info, ".rel.dyn", &info.reldynsz, NULL, &info.reldyn);
	getSectionInfo(info, ".rel.plt", &info.relpltsz, NULL, &info.relplt);

	Elf32_Shdr *hash = findSectionByName(info, ".hash");
	if(hash){
		uint32_t *rawdata = reinterpret_cast<uint32_t *>(info.elf_base + hash->sh_offset);
		info.nbucket = rawdata[0];
		info.nchain = rawdata[1];
		info.bucket = rawdata + 2;
		info.chain = info.bucket + info.nbucket;
	}
}
예제 #2
0
void EmoticonFactory::createEmoticonMap(const QDomNode &root){
    if (root.isNull())
        return;

    QDomNode r = findSectionByName(root, EmoticonSectionName);

    if (r.isNull())
        return;

    DomNodeList emoNodes;
    getSubSectionsByName(r, emoNodes, EmoticonSubsectionName);

    if (emoNodes.isEmpty())
        return;

    clear();

    for (const auto &node : emoNodes){
        QString emoTheme = WSGET(WS_APP_EMOTICON_THEME);

        EmoticonObject *emot = new EmoticonObject();
        QDomElement el = node.toElement();

        emot->fileName  = el.attribute("file").toUtf8();
        emot->id        = list.size();
        emot->pixmap    = QPixmap();
        emot->pixmap.load(EmotionPath+emoTheme+QDir::separator()+emot->fileName);

        DomNodeList emoTexts;
        getSubSectionsByName(node, emoTexts, EmoticonTextSectionName);

        if (emoTexts.isEmpty()){
            delete emot;

            continue;
        }

        int registered = 0;
        for (const auto &node : emoTexts){
            QDomElement el = node.toElement();

            if (el.isNull())
                continue;

            QString text = el.attribute("text").toUtf8();

            if (text.isEmpty() || map.contains(text))
                continue;

            registered++;

            map.insert(text, emot);
        }

        if (registered > 0)
            list.push_back(emot);
        else
            delete emot;
    }
}
예제 #3
0
static inline void getSectionInfo(ElfInfo &info, const char *name, Elf32_Word *pSize, Elf32_Shdr **ppShdr, T *data){
	Elf32_Shdr *_shdr = findSectionByName(info, name);

	if(_shdr){
		SAFE_SET_VALUE(pSize, _shdr->sh_size / _shdr->sh_entsize);
		SAFE_SET_VALUE(data, reinterpret_cast<T>(info.elf_base + _shdr->sh_offset));
	}else{
		LOGE("[-] Could not found section %s\n", name);
		exit(-1);
	}

	SAFE_SET_VALUE(ppShdr, _shdr);
}