We don't display ads so we rely on your Bitcoin donations to 1KWEk9QaiJb2NwP5YFmR24LyUBa4JyuKqZ
Post date: Oct 17, 2010 10:57:04 PM
{
Inject Library Demo
by Aphex
This program demonstrates how to inject a DLL into another process.
}
program InjLib;
uses
Windows,
afxCodeHook;
var
Process: dword;
StartInfo: TStartupInfo;
ProcInfo: TProcessInformation;
Path: array [0..MAX_PATH] of char;
begin
//create process to inject into
ZeroMemory(@StartInfo, SizeOf(TStartupInfo));
StartInfo.cb := SizeOf(TStartupInfo);
CreateProcess(nil, 'notepad.exe', nil, nil, False, 0, nil, nil, StartInfo, ProcInfo);
Sleep(100);
//inject the dll into the process
Process := ProcInfo.hProcess;
InjectLibrary(Process, 'test.dll');
Sleep(3000);
//kill the process
TerminateProcess(Process, 0);
end.
test.dll
library test;
uses
Windows;
procedure EntryPoint(Reason: dword); stdcall;
begin
if Reason = DLL_PROCESS_ATTACH then MessageBox(0, 'hi from notepad :)', 'afxCodeHook', 0);
end;
begin
DLLProc := @EntryPoint;
EntryPoint(DLL_PROCESS_ATTACH);
end.