// OllyDbg calls this obligatory function once during startup. I place all // one-time initializations here. Parameter features is reserved for future // extentions, do not use it. extc int _export cdecl ODBG_Plugininit(int ollydbgversion, HWND hw, ulong *features) { HINSTANCE hinst; if(ollydbgversion < PLUGIN_VERSION) { MessageBox(hwndOllyDbg(), "Incompatible Ollydbg Version !", "ODbgScript", MB_OK | MB_ICONERROR | MB_TOPMOST); return -1; } // Report plugin in the log window. Addtolist(0, 0, "ODbgScript v%i.%i.%i",VERSIONHI,VERSIONLO,VERSIONST); Addtolist(0, -1," http://odbgscript.sf.net"); ollylang = new OllyLang(); if (Createsorteddata(&ollylang->wndProg.data,"ODbgScript Data", sizeof(t_wndprog_data),50, (SORTFUNC *)wndprog_sort_function,NULL)!=0) return -1; if (Createsorteddata(&ollylang->wndLog.data,"ODbgScript Log", sizeof(t_wndlog_data),20, (SORTFUNC *)wndlog_sort_function,NULL)!=0) return -1; hinst = hinstModule(); if (Registerpluginclass(wndprogclass,NULL,hinst,wndprog_winproc)<0) { return -1; } if (Registerpluginclass(wndlogclass,NULL,hinst,wndlog_winproc)<0) { return -1; } if (Plugingetvalue(VAL_RESTOREWINDOWPOS)!=0 && Pluginreadintfromini(hinst,"Restore Script Log",0)!=0) initLogWindow(); if (Plugingetvalue(VAL_RESTOREWINDOWPOS)!=0 && Pluginreadintfromini(hinst,"Restore Script window",0)!=0) initProgTable(); return 0; }
// OllyDbg calls this obligatory function once during startup. Place all // one-time initializations here. If all resources are successfully allocated, // function must return 0. On error, it must free partially allocated resources // and return -1, in this case plugin will be removed. Parameter ollydbgversion // is the version of OllyDbg, use it to assure that it is compatible with your // plugin; hw is the handle of main OllyDbg window, keep it if necessary. // Parameter features is reserved for future extentions, do not use it. extc int _export cdecl ODBG_Plugininit(int ollydbgversion, HWND hw, ulong *features) { // This plugin uses all the newest features, check that version of OllyDbg is // correct. I will try to keep backward compatibility at least to v1.99. if (ollydbgversion < PLUGIN_VERSION) return -1; // Keep handle of main OllyDbg window. This handle is necessary, for example, // to display message box. hwmain = hw; // Initialize bookmark data. Data consists of elements of type t_bookmark, // we reserve space for 10 elements. If necessary, table will allocate more // space, but in our case maximal number of bookmarks is 10. Elements do not // allocate memory or other resources, so destructor is not necessary. if (Createsorteddata(&(bookmark.data), "Bookmarks", sizeof(t_bookmark), 10, (SORTFUNC *)Bookmarksortfunc, NULL) != 0) return -1; // Unable to allocate bookmark data // Register window class for MDI window that will display plugins. Please // note that formally this class belongs to instance of main OllyDbg program, // not a plugin DLL. String bookmarkwinclass gets unique name of new class. // Keep it to create window and unregister on shutdown. if (Registerpluginclass(bookmarkwinclass, NULL, hinst, Bookmarkwinproc) < 0) { // Failure! Destroy sorted data and exit. Destroysorteddata(&(bookmark.data)); return -1; }; // Plugin successfully initialized. Now is the best time to report this fact // to the log window. To conform OllyDbg look and feel, please use two lines. // The first, in black, should describe plugin, the second, gray and indented // by two characters, bears copyright notice. Addtolist(0, 0, "Bookmarks sample plugin v1.10 (plugin demo)"); Addtolist(0, -1, " Copyright (C) 2001-2004 Oleh Yuschuk & Piérrot !"); // OllyDbg saves positions of plugin windows with attribute TABLE_SAVEPOS to // the .ini file but does not automatically restore them. Let us add this // functionality here. I keep information whether window was open when // OllyDbg terminated also in ollydbg.ini. This information is saved in // ODBG_Pluginclose. To conform to OllyDbg norms, window is restored only // if corresponding option is enabled. if (Plugingetvalue(VAL_RESTOREWINDOWPOS) != 0 && Pluginreadintfromini(hinst, "Restore bookmarks window", 0) != 0) Createbookmarkwindow(); return 0; };