Pages

Monday, May 18, 2015

[C/C++] Lite OllyDbg 2 plugin Template.

Code snippet:   

#include <windows.h>
#include "plugin.h"

#define PLUGINNAME     L"Lite OD2 plugin Template"
#define PLUGINVERSION        L"0.00.01"

HINSTANCE pluginHandle;

int __cdecl AboutProc(t_table *pt, wchar_t *name, ulong index,int mode);
int __cdecl AllInOneFunction(t_table *pt, wchar_t *name, ulong index, int mode);

t_menu SubMenuOptions[] = {
    {L"Do Something2...", NULL,  K_NONE, AllInOneFunction, NULL, 1},
    {L"Something to do....", NULL, K_NONE, AllInOneFunction, NULL, 2},
    { NULL, NULL, K_NONE, NULL, NULL, 0}
};

t_menu MainMenu[] = {
    {L"Hide Debugger", NULL,  K_NONE, AllInOneFunction, NULL, 20},
    {L"Do Something...", NULL, K_NONE, AllInOneFunction, NULL, 21},
    {L"|Options", NULL, K_NONE, NULL, SubMenuOptions, 0},
    {L"|About", NULL, K_NONE, AboutProc, NULL, 22},
    { NULL, NULL, K_NONE, NULL, NULL, 0}
};

int __cdecl AllInOneFunction(t_table *pt, wchar_t *name, ulong index, int mode) {

    LPWSTR mainMsg = L"error!";
    if (mode == MENU_VERIFY)
        return MENU_NORMAL;
    else if (mode == MENU_EXECUTE) {

        switch (index) {
        case 1: {
            mainMsg = SubMenuOptions[0].name;
            break;
        }

        case 2: {
            mainMsg = SubMenuOptions[1].name;
            break;
        }

        case 20: {
            mainMsg = MainMenu[0].name;
            break;
        }

        case 21: {
            mainMsg = MainMenu[1].name;
            break;
        }

        }

        MessageBoxW(hwollymain, mainMsg, L"INFORMATION", MB_ICONINFORMATION);

        return MENU_NOREDRAW;
    }
    return MENU_ABSENT;
}


int AboutProc(t_table *pt, wchar_t *name, ulong index, int mode) {
    if (mode == MENU_VERIFY)
        return MENU_NORMAL;
    else if (mode == MENU_EXECUTE) {
        MessageBoxW(
            hwollymain,
            L"Lite OllyDbg 2 plugin Template v0.00.01\nRelease date 12/2013\n\n"
            "[by stigma from I3CT]\nInsid3Code Team",
            L"About",
            MB_ICONINFORMATION);

        return MENU_NOREDRAW;
    }
    return MENU_ABSENT;
}

extc t_menu * __cdecl ODBG2_Pluginmenu(PWCHAR type) {

    if (wcscmp(type, PWM_MAIN) == 0)
        return MainMenu;
    return NULL;
}

extc int __cdecl ODBG2_Pluginquery(int ollyDbgVersion, PULONG features, 
wchar_t pluginName[SHORTNAME], wchar_t pluginVersion[SHORTNAME]) {
    if (ollyDbgVersion < 201)
        return 0;

    wcscpy(pluginName, PLUGINNAME);
    wcscpy(pluginVersion, PLUGINVERSION);
    return PLUGIN_VERSION;
}

extc int __cdecl ODBG2_Plugininit(void) {

    return 0;
}

BOOLEAN __cdecl iWinMain(HINSTANCE hInstance, DWORD reason, LPVOID reserved) {
    if (reason == DLL_PROCESS_ATTACH)
        pluginHandle = hInstance;
    return true;
}

Source:
http://www.mediafire.com/download/dz4oq6m5mvmvw6i/LiteOD2Plugin.rar