HRESULT hippoLoadTypeInfo(const WCHAR *libraryName, ...) { HippoPtr<ITypeLib> typeLib; va_list vap; HRESULT hr; HMODULE module = GetModuleHandle(libraryName); if (!module) return E_FAIL; WCHAR moduleFile[MAX_PATH]; DWORD length = GetModuleFileName(module, moduleFile, MAX_PATH); if (length == 0 || length > MAX_PATH - 1) return E_FAIL; va_start(vap, libraryName); clearArgs(vap); va_end(vap); hr = LoadTypeLib(moduleFile, &typeLib); if (FAILED(hr)) goto out; va_start(vap, libraryName); hr = loadTypeInfoFromTypelib(typeLib, vap); va_end(vap); out: if (FAILED(hr)) { va_start(vap, libraryName); freeArgs(vap); va_end(vap); hippoDebugDialog(L"Failed to load type info from %ls (%x)", libraryName, hr); } return hr; }
HRESULT hippoLoadRegTypeInfo(const GUID &libraryId, unsigned short majorVersion, unsigned short minorVersion ...) { HippoPtr<ITypeLib> typeLib; va_list vap; HRESULT hr; va_start(vap, minorVersion); clearArgs(vap); va_end(vap); hr = LoadRegTypeLib(libraryId, majorVersion, minorVersion, 0, /* LCID */ &typeLib); if (FAILED(hr)) goto out; va_start(vap, minorVersion); hr = loadTypeInfoFromTypelib(typeLib, vap); va_end(vap); out: if (FAILED(hr)) { va_start(vap, minorVersion); freeArgs(vap); va_end(vap); hippoDebugLogW(L"Failed to load type info (%x)", hr); } return hr; }
int EdifyFunc::replaceOffendings(std::list<EdifyElement*> **parentList, std::list<EdifyElement*>::iterator& lastNewlineRef) { int res = 0; if(m_name == "mount" || m_name == "unmount" || m_name == "format") { lastNewlineRef = (*parentList)->insert(++lastNewlineRef, new EdifyValue( std::string("# MultiROM removed function ") + m_name + "(" + getArgsStr() + std::string(") from following line."))); lastNewlineRef = (*parentList)->insert(++lastNewlineRef, new EdifyNewline()); if(m_name == "format") { for(std::list<EdifyElement*>::iterator itr = m_args.begin(); itr != m_args.end(); ++itr) { if((*itr)->getType() != EDF_VALUE) continue; if(((EdifyValue*)(*itr))->getText().find("/system") != std::string::npos) { res |= OFF_FORMAT_SYSTEM; break; } } } res |= OFF_CHANGED; m_name = "ui_print"; clearArgs(); addArg(new EdifyValue("\"\"")); return res; } else if(m_name == "block_image_update") { res |= OFF_BLOCK_UPDATES; } else if(m_name == "run_program") { bool rem = false; for(std::list<EdifyElement*>::iterator itr = m_args.begin(); itr != m_args.end(); ++itr) { if((*itr)->getType() != EDF_VALUE) continue; const std::string& t = ((EdifyValue*)(*itr))->getText(); if(t.find("mount") != std::string::npos) { rem = true; break; } else if(t.find("boot.img") != NPOS || t.find(MultiROM::getBootDev()) != NPOS || t.find("zImage") != NPOS || t.find("bootimg") != NPOS) { rem = false; break; } else if(t.find("/dev/block") != NPOS) rem = true; } if(rem) { std::string info = "# MultiROM replaced run_program("; info += getArgsStr(); info += ") with \"/sbin/true\""; lastNewlineRef = (*parentList)->insert(++lastNewlineRef, new EdifyValue(info)); lastNewlineRef = (*parentList)->insert(++lastNewlineRef, new EdifyNewline()); res |= OFF_CHANGED; clearArgs(); addArg(new EdifyValue("\"/sbin/true\"")); } } else if(m_name == "package_extract_file" && m_args.size() >= 2) { int st = 0; static const char * const forbidden_images[] = { "radio", "bootloader", "NON-HLOS.bin", "emmc_appsboot.mbn", "rpm.mbn", "logo.bin", "sdi.mbn", "tz.mbn", "sbl1.mbn", NULL }; for(std::list<EdifyElement*>::iterator itr = m_args.begin(); itr != m_args.end(); ++itr) { if((*itr)->getType() != EDF_VALUE) continue; if(st == 0) { for(int i = 0; forbidden_images[i]; ++i) { if(((EdifyValue*)(*itr))->getText().find(forbidden_images[i]) != NPOS) { st = 1; break; } } } else if(st == 1 && (((EdifyValue*)(*itr))->getText().find("/dev/block/") <= 1)) { st = 2; break; } } if(st == 2) { lastNewlineRef = (*parentList)->insert(++lastNewlineRef, new EdifyValue( std::string("# MultiROM removed function ") + m_name + "(" + getArgsStr() + std::string(") from following line."))); lastNewlineRef = (*parentList)->insert(++lastNewlineRef, new EdifyNewline()); res |= OFF_CHANGED; m_name = "ui_print"; clearArgs(); addArg(new EdifyValue("\"\"")); } } for(std::list<EdifyElement*>::iterator itr = m_args.begin(); itr != m_args.end(); ++itr) { if((*itr)->getType() == EDF_FUNC) res |= ((EdifyFunc*)(*itr))->replaceOffendings(parentList, lastNewlineRef); else if((*itr)->getType() == EDF_NEWLINE) { *parentList = &m_args; lastNewlineRef = itr; } } return res; }
EdifyFunc::~EdifyFunc() { clearArgs(); }
OSCMessage::~OSCMessage() { clearArgs(); }