由于大多数用的都是1.0版本的OD,所以,以下编写的是OLLYDBG1.0的插件

OllyDbg重命名插件编写

前置知识

日志窗口输出并关联指定地址 _Addtolist(指定地址,1,“字符串”);

反汇编 _Disasm

读取内存 _Readmemory

读取当前地址标签内容 _Findlabel

读取用户名输入的字符串 _Gettext

插件名称 _Insertname

函数模板

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
//======================================必须导出的函数=======================================================

//************************************
// Method:菜单中显示的插件名
// Description: 必须的导出函数
//************************************
extern "C" __declspec(dllexport) cdecl int ODBG_Plugindata(char* shortname)
{
const char * pluginName = "插件名";
strcpy_s(shortname, strlen(pluginName) + 1, pluginName);
return PLUGIN_VERSION;
}

//OD主界面句柄
HWND g_hOllyDbg;
//************************************
// Method:插件初始化,用于判断当前OD版本号和插件所支持的版本是否一致
// Description:必须的导出函数
//************************************
extern "C" __declspec(dllexport) cdecl int ODBG_Plugininit(int ollydbgversion, HWND hw, ulong *features)
{

if (ollydbgversion < PLUGIN_VERSION)
{
MessageBox(hw, "本插件不支持当前版本OD!", "MyFirstPlugin", MB_ICONERROR);
return -1;
}
g_hOllyDbg = hw;
return 0;
}




//======================================重要的导出函数=======================================================


//************************************
// Method:显示菜单项
// Description:显示对应的菜单选项
//************************************
extern "C" __declspec(dllexport) cdecl int ODBG_Pluginmenu(int origin, TCHAR data[4096], VOID *item)
{

if (origin == PM_MAIN)
{
strcpy(data, "0&顶部菜单子菜单一,1&顶部菜单子菜单二");
}
if (origin == PM_DISASM)
{
strcpy(data, "鼠标右键主菜单{0&鼠标右键子菜单一,1&鼠标右键子菜单二}");
}
return 1;
}


//************************************
// Method:菜单项被点击执行函数
// Description:所有的菜单项被点击都会执行到这个函数
//************************************
extern "C" __declspec(dllexport) cdecl void ODBG_Pluginaction(int origin, int action, VOID *item)
{
//如果是在主窗口点击
if (origin == PM_MAIN)
{
if (action == 0)
{
MessageBoxA(g_hOllyDbg, "顶部菜单子菜单一", "点击了顶部子菜单一", MB_ICONINFORMATION);
}
if (action == 1)
{
MessageBoxA(g_hOllyDbg, "顶部菜单子菜单二", "点击了顶部子菜单二", MB_ICONINFORMATION);
}
}
//如果是在反汇编窗口点击
if (origin == PM_DISASM)
{
if (action == 0)
{
MessageBoxA(g_hOllyDbg, "鼠标右键子菜单一", "点击了右键子菜单一", MB_ICONINFORMATION);
}
if (action == 1)
{
MessageBoxA(g_hOllyDbg, "鼠标右键子菜单二", "点击了右键子菜单二", MB_ICONINFORMATION);
}
}
}

VS设置

包含SDK文件

image-20210407092011085

设置多字节

image-20210407091835507

关闭SDL检查

或者也可以用安全版的函数

image-20210407093106134

添加参数

image-20210407092150132

至此就能编译成功

image-20210407092846380

输出路径

为了方便查看

image-20210407092647049

设置调试路径

把OD的绝对路径写入,这样就能够调试写的插件

image-20210407093541482

调试启动时OD也会跟着启动,

如下,右击插件子菜单一

image-20210407094216948