通过远程注入的dll中的函数为什么运行不起来???
dll文件如下(remoteinject.dll)
library remoteinject;
uses
SysUtils,
windows,
Classes;
{$R *.res}
procedure func;
begin
MessageBox(0,'test','test dll',0);
end;
begin
func;
end.
远程注入的程序如下:
procedure TForm1.Button2Click(Sender: TObject);
var
h,pid:longword;
tmp:longword;
DllName:pchar;
Mysize:longword;
Parameter:pointer;//放那个参数的指针(位置在目标进程内)
hwnd1: HWND;
begin
DLLName:='remoteinject.dll';
Mysize:=strlen(Dllname)+1;
hwnd1:=FindWindow('notepad', nil);
GetWindowThreadProcessId(hwnd1, @pid);
h:=OpenProcess(PROCESS_ALL_ACCESS, False, pid);
parameter:= VirtualAllocEx(h, nil, Mysize, MEM_COMMIT, PAGE_READWRITE);
WriteProcessMemory(h, Parameter, Pointer(DllName), MySize, tmp);
CreateRemoteThread(h,nil, 0, GetProcAddress(GetModuleHandle('KERNEL32.DLL'), 'LoadLibraryA'),
Parameter, 0 , tmp);
end;
我运行的过程是这样的:
先打开记事本,然后运行上面的程序,但是记事本没反应,dll中的函数没有运行,请教这是什么原因??