EasyHook works if ran Interactive but doesn't work when ran as a Service -


i'm trying create windows service hook target application.

i have code set can ran service or directly debugging. when run code directly (interactively) hook works expected. when run service there no exceptions, hook doesn't work.

here's how switch between running service or not:

static void main() {     var service = new autoservice();     if (environment.userinteractive)     {         task.factory.startnew(() =>         {             service.start(new string[] { });         });                          while (true)         {             system.threading.thread.sleep(2000);         }     }     else     {         servicebase.run(new servicebase[] { service });     } } 

here's hook:

public void addhook(string methodname, string procmethodname) {     _reminterface.log($"addhook(methodname =  {methodname}, procmethodname = {procmethodname}");     var nametouse = procmethodname ?? methodname;     var procaddr = localhook.getprocaddress(_targetdll, nametouse);     var msgdel = getdelegate(methodname);     var msghook = localhook.create(procaddr, msgdel, this);      _reminterface.log("hook created");      lhooks.add(msghook);     msghook.threadacl.setexclusiveacl(new int[] { 0 });      _reminterface.log("sendmessage hooked = " + msghook.isthreadintercepted(0)); } 

has else seen same issue?


Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -