today I've had my first tries with madCodehook. I read the tutorial for hooking the WinExec API processwide. That works perfectly. Then i've tried to put the code into a dll to make it processwide. My Code looks as this :
dll:
Code: Select all
var WinExecHookNext : function (cmdLine : pchar; showcmd : dword) : dword ; stdcall;
function WinExecHookProc(cmdLine : pchar; showcmd : dword) : dword ; stdcall;
begin
if MessageBox(0, cmdLine, 'Execute?', MB_YESNO or MB_ICONQUESTION) = IDYES then
result := WinExecHookNext(cmdLine, showCmd)
else
result := ERROR_ACCESS_DENIED;
end;
begin
HookAPI('kernel32.dll','WinExec',@WinExecHookProc,@WinExecHookNext);
end.
Code: Select all
procedure TForm1.btninstallClick(Sender: TObject);
begin
InjectLibrary(ALL_SESSIONS or SYSTEM_PROCESSES, 'Project1.dll');
end;
procedure TForm1.btnuninstallClick(Sender: TObject);
begin
UninjectLibrary(ALL_SESSIONS or SYSTEM_PROCESSES, 'Project1.dll');
end;
procedure TForm1.btnnotepadClick(Sender: TObject);
begin
WinExec('notepad.exe', SW_SHOWNORMAL);
end;
Does anybody know why i get this?