Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi Inject my Dll from a Service (https://www.delphipraxis.net/168020-inject-my-dll-service.html)

randy_dom 30. Apr 2012 19:20

Inject my Dll from a Service
 
Hi ,i've these Functions declared in my Dll , i'm focusing on
StartHook and StopHook , if i use them in a standalone Application all goes well .
But the problem is when using them in a Service i don't get any result there's no Hook .

Delphi-Quellcode:
function HookProc(code: Integer; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall;
begin
  Result := CallNextHookEx(Code, code, wParam, lParam)
end;
procedure StartHook; stdcall;
begin
  HookHandle := SetWindowsHookEx(WH_GETMESSAGE, HookProc, hInstance, 0);
end;

procedure StopHook; stdcall;
begin
  UnhookWindowsHookEx(HookHandle);
end;
The issue is only with Vista and up .

sx2008 30. Apr 2012 20:21

AW: Inject my Dll from a Service
 
You should allow the service to interact with your desktop.
Starting with Vista services by default are not allowed to interact with the desktop or any window on the desktop.

http://lostechies.com/keithdahlby/20...t-localsystem/

randy_dom 30. Apr 2012 21:50

AW: Inject my Dll from a Service
 
Zitat:

Zitat von sx2008 (Beitrag 1164347)
You should allow the service to interact with your desktop.
Starting with Vista services by default are not allowed to interact with the desktop or any window on the desktop.

Thank you sx2008 , is there any Fixes or suggestions to this please ?

Zacherl 30. Apr 2012 23:38

AW: Inject my Dll from a Service
 
Interactive services are not longer allowed. If you only want to inject your dll, you should loop through all processes and use WriteProcessMemory() and CreateRemoteThread() to call LoadLibrary() in the remote context.

As an alternative way, you could use the AppInit_DLLs registry value.

randy_dom 30. Apr 2012 23:59

AW: Inject my Dll from a Service
 
thank you Zacherl , The problem is that i'm using PIP commutation between the service and another App, so the App will ask the service to HOOK/UNHOOK (a) target Process(s).

So please is there any fix to this or even another alternative .

thank you

Assarbad 1. Mai 2012 04:39

AW: Inject my Dll from a Service
 
Zitat:

Zitat von randy_dom (Beitrag 1164357)
thank you Zacherl , The problem is that i'm using PIP commutation between the service and another App, so the App will ask the service to HOOK/UNHOOK (a) target Process(s).

So please is there any fix to this or even another alternative .

Zacherl already gave you the only method that would work with active session 0 separation. Otherwise you'd always need some agent running in the same session (strictly speaking on the desktop) inside which the process to be hooked resides.


Alle Zeitangaben in WEZ +1. Es ist jetzt 14:49 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz