bool Plugin::Load(Platform::Path& path) { if (m_module.Open(path)) { InitializePlugin = m_module.GetFunction<InitializePlugin_t>("InitializePlugin"); TerminatePlugin = m_module.GetFunction<TerminatePlugin_t>("TerminatePlugin"); if (InitializePlugin == nullptr || TerminatePlugin == nullptr) { Log(LogSeverity::Warning, "Failed to load plugin, missing symbol exports.\n"); return false; } m_pluginInterface = CreatePluginInterface(m_manager, this); if (!InitializePlugin(m_pluginInterface)) { Log(LogSeverity::Warning, "Failed to initialize plugin.\n"); return false; } m_fileName = path.GetBaseName(); //Log(LogSeverity::Info, "\tName: %s\n", m_pluginInterface->GetName().c_str()); //Log(LogSeverity::Info, "\tDescription: %s\n", m_pluginInterface->GetDescription().c_str()); return true; } return false; }
//-------------------------------------------------------------------------- // // Initialize. // // IDA will call this function only once. // If this function returns PLUGIN_SKIP, IDA won't load it again. // If this function returns PLUGIN_KEEP, IDA will keep the plugin // in the memory. // int idaapi init(void) { // Don't use this plugin for object files // This check is just to demonstrate that you may desactive plugin for // some file types if ( inf.filetype == f_OMF ) return PLUGIN_SKIP; // Don't work in text version if ( callui(ui_get_hwnd).vptr == NULL ) return PLUGIN_SKIP; return InitializePlugin(); }
// プラグインの有効/無効が切り替わった時の処理 bool CSleepTimer::OnEnablePlugin(bool fEnable) { InitializePlugin(); if (fEnable && m_fShowSettings) { if (::DialogBoxParam(g_hinstDLL,MAKEINTRESOURCE(IDD_SETTINGS), m_pApp->GetAppWindow(),SettingsDlgProc, reinterpret_cast<LPARAM>(this))!=IDOK) return false; } m_fEnabled=fEnable; if (m_fEnabled) ::SetTimer(m_hwnd,SLEEP_TIMER_ID,m_SleepTime*1000,NULL); else ::KillTimer(m_hwnd,SLEEP_TIMER_ID); return true; }