void VMTHook::Set(ptr_t inst, uint32_t offset) { Release(); vtable_ptr = &GetVMT(inst, offset); vtable_original = *vtable_ptr; int mc = CountMethods(vtable_original); logging::Info("Hooking vtable 0x%08x with %d methods", vtable_original, mc); vtable_hooked = static_cast<method_table_t>(calloc(mc + 3, sizeof(ptr_t))); memcpy(&vtable_hooked[2], vtable_original, sizeof(ptr_t) * mc); vtable_hooked[0] = this; vtable_hooked[1] = (void *) GUARD; }
bool InterfaceRec::look_in_methods_and_events(const SString & id) { int32_t i, count = CountMethods(); for (i=0; i<count; i++) { if (MethodAt(i)->ID() == id) { return true; } } count = CountEvents(); for (i=0; i<count; i++) { if (EventAt(i)->ID() == id) { return true; } } return false; }
status_t InterfaceRec::View() { bout << "ID = " << ID() << endl; bout << "Namespace = " << Namespace() << endl; SVector<SString> rents=Parents(); for (int s=0; s<rents.CountItems(); s++) { if (s=0) { bout << "Parents = " << endl; } bout << " - " << rents.ItemAt(s) << endl; } int32_t num=CountProperties(); bout << "# of Properties = " << num << endl; for (int s=0; s< num; s++) { sptr<IDLNameType> nt=PropertyAt(s); bout << " - " << nt->m_id << endl; } num=CountMethods(); bout << "# of Methods = " << num << endl; for (int s=0; s< num; s++) { sptr<IDLMethod> m=MethodAt(s); bout << " - " << m->ID() << endl; } num=CountEvents(); bout << "# of Events = " << num << endl; for (int s=0; s< CountEvents(); s++) { sptr<IDLEvent> e=EventAt(s); bout << " - " << e->ID() << endl; } return B_OK; }