To compile your own plugin, you need some C or C++ compiler (together with linker and run-time libraries). Plugin interface (file plugin.h) is compatible at least with following compilers:
- Borland's C++ 5.5 - command line compiler, available for free from www.borland.com (requires registration);
- Borland's C++ Builder 5 - based on the same C++ 5.5;
- Microsoft's Visual C++ 5.0 - rather old but solid and stable.
Plugin Development Kit includes source code for two fully functional sample plugins: bookmark, that allows to set up to 10 bookmarks in debugged application, and command line, that implements command line interface. Plugins are well documented. You can use them as a template for your own plugins. They are freeware, i.e. your rights to modify and re-use their source code are not limited in any way.
Following compiler settings are required for correct communication between plugin and OllyDbg. For compilers listed above, plugin.h forces or checks some of these rules:
- Export all callback functions by name, NOT by ordinal;
- If you use C++ compiler, disable name mangling on all callback functions (declare them as extern "C");
- Force standard C-style passing of parameters to all API and callback functions (declare them as cdecl);
- Force BYTE alignment of all structures declared in plugin.h;
- Set default character type to UNSIGNED.
Use static run-time libraries linked directly into your plugin, otherwise differences between versions of run-time DLLs will make OllyDbg unstable. Do not split your plugin unnecessarily into several DLLs. If you need data files that are not modifiable by user, try to place this data directly into your plugin as a resource.
To link your plugin to OllyDbg, you also need import library ollydbg.lib. Some compilers (Borland) include utility called implib that scans executable file (in our case, ollydbg.exe) and produces a special kind of library with a list of all exported functions. Some other products, like MSVC, can generate import library from the definition file (ollydbg.def). Similar products from other vendors are also available. For details, please consult documentation.
And, last but not least, don't waste resources! Don't export unused
callback functions and make your program fast! OllyDbg in current
supports up to 32 plugins. If each of them will take only 50 ms to
a global shortcut, then 50 ms for window-specific shortcut... you DO
what I mean, don't you?
Contents of plug110.zip
Plugin kit archive contains following files:
cmdexec.c - source of command line plugin
command.c - source of command line plugin
cmdline.rtf - RTF source of help (.hlp) file for command line plugin
ollydbg.def - OllyDbg definition file, some compilers need it to produce import library ollydbg.lib
plugin.h - header with definitions of plugin interface
plugins.hlp - this help file
sample.cpp - main file for sample.bpr
bookmark.mak - make file for BC 5.5, produces bookmark.dll
cmdline.bpr - project file for BCB 5, produces cmdline.dll
cmdline.cpp - main file for cmdline.bpr
cmdline.mak - make file for BC 5.5, produces cmdline.dll
ollydbg.lib - OllyDbg import library in OMF format
bookmark.dsw - project file for Visual Studio 97, produces bookmark.dll
bookmark.mak - make file for VC 5.0, produces bookmark.dll
cmdline.dsp - project file for Visual Studio 97, produces cmdline.dll
cmdline.dsw - project file for Visual Studio 97, produces cmdline.dll
cmdline.mak - make file for VC 5.0, produces cmdline.dll
ollydbg.lib - OllyDbg import library in COFF format
To build sample DLLs with BC 5.5, please do the following:
1. Copy files bookmark.c, cmdexec.c, command.c, plugin.h, bc55\bookmark.mak, bc55\cmdline.mak, bc55\ollydbg.lib to same directory;
2. Assuming that your BC 5.5 compiler is installed to c:\bc55, issue following commands:
c:\bc55\bin\make -f cmdline.mak
OBJFILES = a.obj b.obj
RESFILES = c.rc
BCB projects must contain main C++ program with the same name as project and extention .cpp. For this reason, bookmark plugin created with Builder is called sample.dll. Of course, this has no influence on its functionality.
To build sample.dll, please do the following:
1. Copy files bookmark.c, plugin.h, bc55\sample.bpr, bc55\sample.cpp and bc55\ollydbg.lib to the same directory;
2. Open sample.bpr in Builder and make project.
To build cmdline.dll, please do the following:
1. Copy files cmdexec.c, command.c, plugin.h, bc55\cmdline.bpr, bc55\cmdline.cpp and bc55\ollydbg.lib to the same directory;
2. Open cmdline.bpr in Builder and make project.
Making sample plugins with VC 5.0 from the command line
To build sample DLLs with VC 5.0, please do the following:
1. Copy files bookmark.c, cmdexec.c, command.c, plugin.h, vc50\bookmark.mak, vc50\cmdline.mak and vc50\ollydbg.lib to the same directory;
2. In .mak files, edit lines
3. Assuming that your VC compiler, cl.exe, and make utility, nmake.exe, reside in c:\vc\bin, execute following commands:
c:\vc\bin\nmake -f cmdline.mak
To build bookmark.dll:
1. Copy files bookmark.c, plugin.h, vc50\bookmark.dsp, vc50\bookmark.dsw and vc50\ollydbg.lib to the same directory;
2. Open project bookmark in Visual Studio and make it.
To build cmdline.dll:
1. Copy files cmdexec.c, command.c, plugin.h, vc50\cmdline.dsp, vc50\cmdline.dsw and vc50\ollydbg.lib to the same directory;
2. Open project cmdline in Visual Studio and make it.