// 我想做LordPE Dump的Edit控件实时检测输入[包括键盘和剪切板](不是做击中按钮函数),帮我看看
library TEST;
uses
Windows,
SysUtils,
Messages,
Classes,
Plugin;
Type
TBuffer = array[1..256] of Char;
resourcestring
VERSION = '1.0';
AUTHOR = 'askformore';
PLUGIN_NAME = 'TEST';
ABOUT = 'TEST pluin v1.0'#13#10#13#10'This plugin for OllyDbg1.10'#13#10'Compiled with Delphi7'#13#10#13#10'By askformore'#13#10#13#10'Thanks to:'#13#10' TQN provide Delphi-SDK!';
{$R ActionOptionDlg.RES}
const
MYICO = 1000 ;
IDB_DONE = 1001 ;
IDB_CANCEL = 1002 ;
IDE_STARTBASE = 1003 ;
IDE_STARTEND = 1004 ;
IDE_CODEBASE = 1005 ;
IDR_MAINFRAME = 1006 ;
MYDLG= 'IDD_ACTION';
var
g_hwndOlly: HWND;
g_dllhmod: HMODULE;
SaveDLLProc: TDLLProc;
procedure IsFixInput( Wnd: hWnd);
var
msg: Tmsg;
Key: char;
begin
if Msg.message =WM_KeyDown then
begin
key := Char(low(msg.wParam));
if not ( Key in ['0'..'9', 'A'..'F', 'a'..'f', #8]) then
msg.wParam := 0;
end;
end;
function GetCheck(Src: TBuffer): TBuffer;
var
tmp : string;
i,Len : integer;
begin
tmp := '';
for i:=1 to Length(Src) do
begin
if Src[i]= '' then
break;
end;
if i=1 then
Len :=1
else
Len := i-1;
for i:=1 to Len do
begin
if Src[i] in ['0'..'9','A'..'F','a'..'F'] then
begin
tmp := tmp + Src[i];
end
else
begin
tmp := 'Invalid!';
break;
end;
end;
ZeroMemory(@Result,256);
for i:=1 to length(Tmp) do
begin
Result[i]:= tmp[i];
end;
end;
function DlgProc( Wnd: hWnd; Msg:Cardinal ;wParam: wParam; lParam: LongInt ):Boolean; stdcall;
var
STARTBASE,STARTEND,CodeBase: TBuffer;
hmainico: DWORD;
whoid : WORD;
begin
Case Msg of
WM_CLOSE:
begin
EndDialog(Wnd,0);
Result := True;
Exit;
end;
WM_INITDIALOG:
begin
SetDlgItemText(Wnd, IDE_CODEBASE, PChar( '00401000' ) );
hmainico:=LoadIcon(g_dllhmod, PChar(MYICO));
SendMessage(Wnd,WM_SETICON, ICON_SMALL, hmainico);
Result := True;
Exit;
end;
WM_COMMAND:
begin
whoid:=wParam;
Case whoid of
IDE_STARTBASE : IsFixInput(IDE_STARTBASE);
IDE_STARTEND : IsFixInput(IDE_STARTEND);
IDE_CODEBASE : IsFixInput(IDE_CODEBASE);
IDB_DONE:
begin
GetDlgItemText(Wnd, IDE_STARTBASE, @STARTBASE, 256 );
STARTBASE := GetCheck(STARTBASE);
SetDlgItemText(Wnd, IDE_STARTBASE , @STARTBASE);
GetDlgItemText(Wnd, IDE_STARTEND, @STARTEND, 256 );
STARTEND := GetCheck(STARTEND);
SetDlgItemText(Wnd, IDE_STARTEND, @STARTEND );
GetDlgItemText(Wnd, IDE_CODEBASE, @CodeBase, 256 );
CodeBase := GetCheck(CodeBase);
SetDlgItemText(Wnd, IDE_CODEBASE, @CodeBase );
Result := True ;
Exit;
end;
IDB_CANCEL:
begin
SendMessage(Wnd,WM_CLOSE, 0, 0);
Result := True ;
Exit;
{------------<Cancel被按下,退出>}
end;
end; // end case wm_cmd
end; // end wm_cmd
end; // end Case msg
Result := False;
end; // 窗口消息循环函数
function ODBG_Plugindata(name: PChar): Integer; cdecl;
begin
StrLCopy(name, PChar(PLUGIN_NAME), 32); // Name of plugin
Result := PLUGIN_VERSION;
end;
function ODBG_Plugininit(ollydbgversion: Integer; hWndOlly: HWND; features: PULONG): Integer; cdecl;
begin
if (ollydbgversion < PLUGIN_VERSION) then // 比较OD版本
begin
Result := -1;
Exit;
end;
g_hwndOlly := hWndOlly;
Addtolist(0, 0, 'TEST Plugin - Ver %s by %s', VERSION, AUTHOR);
Result := 0;
end;
function ODBG_Pluginmenu(origin: Integer; pData: PChar; pItem: Pointer): Integer; cdecl;
begin
case origin of
PM_MAIN:
begin
// 在主窗口的插件菜单
StrCopy(pData, '0 &Action, 1 &About...');
Result := 1;
end;
else
Result := 0; // Any other window
end;
end;
procedure ODBG_Pluginaction(origin: Integer; action: Integer; pItem: Pointer); cdecl;
begin
if (origin = PM_MAIN) then
begin
case action of
0: DialogBoxParam( g_dllhmod, PChar(MYDLG), g_hwndOlly, @DlgProc, 0 );
1: MessageBox( g_hwndOlly, PChar(ABOUT), PChar(PLUGIN_NAME), MB_ICONASTERISK );
end;
end;
end;
procedure DLLExit(dwReason: DWORD);
begin
if (dwReason = DLL_PROCESS_DETACH) then
begin
// 这里输出初始化代码失败
OutputDebugString('Plugin unloaded by DLL_PROCESS_DETACH');
end;
// 调用保存 入口过程
if Assigned(SaveDLLProc) then
SaveDLLProc(dwReason);
end;
exports
ODBG_Plugindata name '_ODBG_Plugindata',
ODBG_Plugininit name '_ODBG_Plugininit',
ODBG_Pluginmenu name '_ODBG_Pluginmenu',
ODBG_Pluginaction name '_ODBG_Pluginaction';
begin
// 这里初始化代码
g_dllhmod := GetModuleHandle( PChar( PLUGIN_NAME+'.dll' ) );
SaveDLLProc := @DLLProc;
DLLProc := @DLLExit;
end.