Beispiel #1
0
void
trie_reset_search (trie_t *trie)
{
        trie->len = 0;

        trie_walk (trie, trienode_reset, NULL, 0);
}
Beispiel #2
0
int
trie_measure_vec (trie_t *trie, const char *word, struct trienodevec *nodevec)
{
        struct trienodevec_w nodevec_w = {0,};
        int ret = 0;

        trie->len = strlen (word);

        trienodevec_clear (nodevec);
        nodevec_w.vec = nodevec;
        nodevec_w.word = word;

        ret = trie_walk (trie, collect_closest, &nodevec_w, 0);
        if (ret > 0)
                ret = 0;

        return ret;
}
bool MachObject::findExportedSymbolCompressed(const char* symbol, Symbol* sym)
{
    /*
     This is a slightly tidier version of 'findExportedSymbol'
     from dyld. Still no f*****g idea what the semantics of it
     are since I suck at CS (lol, wtf is a trie?!).
     */

    /* export table sanity */
    if (fDyldInfo->export_size == 0)
        return false;

    const uint8_t* start = addUintPtr2(fLinkEditBase, fDyldInfo->export_off);
    const uint8_t* end = addUintPtr3(fLinkEditBase, fDyldInfo->export_off, fDyldInfo->export_size);

    const uint8_t* foundNodeStart = trie_walk(start, end, symbol);

    if (foundNodeStart != NULL) {
        const uint8_t* p = foundNodeStart;
        const uint32_t flags = read_uleb128(p, end);

        if (flags & EXPORT_SYMBOL_FLAGS_REEXPORT) {
            lnk::halt("no f*****g idea, honestly");
            return false;
        }
        else {
            sym->addr = (void*)foundNodeStart;
            sym->inImage = (void*)this;

            return true;
        }
    }
    else {
        return false;
    }
}