callback in windows service
-
hi all i want to implement windows hooks in service.i had implemented the hooks at the standard application(as DLL) it works fine.but the problem is that it did not worked for the service. i mean callback function is not called when service executed. tell me what i do. any help is welcomed.
Tasleem Arif
-
hi all i want to implement windows hooks in service.i had implemented the hooks at the standard application(as DLL) it works fine.but the problem is that it did not worked for the service. i mean callback function is not called when service executed. tell me what i do. any help is welcomed.
Tasleem Arif
Nt services are running in a difrent window station and desktop called -
Service0x0-3e7$\default
. All our applications are underWinsta0\default
. So there may not be any applications running with an associated window object to invoke the hooked WindoProc. Try by changing the service type toSERVICE_INTERACTIVE_PROCESS
so that the service will run underWinsta0\default
desktop. cheers...Milton KB -
Nt services are running in a difrent window station and desktop called -
Service0x0-3e7$\default
. All our applications are underWinsta0\default
. So there may not be any applications running with an associated window object to invoke the hooked WindoProc. Try by changing the service type toSERVICE_INTERACTIVE_PROCESS
so that the service will run underWinsta0\default
desktop. cheers...Milton KBi think u did not understand my question. i had implemented hooks as dll and used in desktop application and it works fine.when i use the same dll from service then it did not work i mean setwidows hooks is called and the callback function in response to hook is not called. and my service is controlled by the SCM and present in services list in the controll panel->admntool->services. how to do that in i mean changing service type. -- modified at 6:05 Wednesday 16th August, 2006
Tasleem Arif
-
i think u did not understand my question. i had implemented hooks as dll and used in desktop application and it works fine.when i use the same dll from service then it did not work i mean setwidows hooks is called and the callback function in response to hook is not called. and my service is controlled by the SCM and present in services list in the controll panel->admntool->services. how to do that in i mean changing service type. -- modified at 6:05 Wednesday 16th August, 2006
Tasleem Arif
I had understood what exactly u meant. Ur windows hook is not working in a service app while it works fine in a desktop application. This is what I understood before and now as well. The answer is same as before. Hope you are aware of the fact that the Desktop window is the parent window of all other windows we create using
Createwindow()
API. Actually this desktop what we are seeing is just one among a number of other desktops which Windows OS keeps invisible(some of them are visible as well. eg: logon desktop). This is a mystery to most of us. Actually there is something called a window station and a window station can have n number of desktops in it. A window station is a secure kernel object that contains a clipboard, a private atom table, a set of desktops, and a set of windows. see the info http://www.pluralsight.com/wiki/default.aspx/Keith.GuideBook/WhatIsAWindowStation.html[^] All our applications (including your desktop application what you were talking about) are running under a desktop calledWinsta0\default
. But NT Services are running in a different window station and desktop calledService0x0-3e7$\default
. Your hook will not get invoked as there are no windows in the service desktop. So try by changing the service type toSERVICE_INTERACTIVE_PROCESS
so that the service will run under Winsta0\default desktop and you will start getting the notifications in the windows hook. cheers Milton KB -
I had understood what exactly u meant. Ur windows hook is not working in a service app while it works fine in a desktop application. This is what I understood before and now as well. The answer is same as before. Hope you are aware of the fact that the Desktop window is the parent window of all other windows we create using
Createwindow()
API. Actually this desktop what we are seeing is just one among a number of other desktops which Windows OS keeps invisible(some of them are visible as well. eg: logon desktop). This is a mystery to most of us. Actually there is something called a window station and a window station can have n number of desktops in it. A window station is a secure kernel object that contains a clipboard, a private atom table, a set of desktops, and a set of windows. see the info http://www.pluralsight.com/wiki/default.aspx/Keith.GuideBook/WhatIsAWindowStation.html[^] All our applications (including your desktop application what you were talking about) are running under a desktop calledWinsta0\default
. But NT Services are running in a different window station and desktop calledService0x0-3e7$\default
. Your hook will not get invoked as there are no windows in the service desktop. So try by changing the service type toSERVICE_INTERACTIVE_PROCESS
so that the service will run under Winsta0\default desktop and you will start getting the notifications in the windows hook. cheers Milton KBthanks for such a descriptive answer, how can i change the service type to SERVICE_INTERFACTIVE_PROCESS only change the create service paramter to this or had to call different api calls for that purpose. one thing Thank U very Much Again.:)
Tasleem Arif
-
thanks for such a descriptive answer, how can i change the service type to SERVICE_INTERFACTIVE_PROCESS only change the create service paramter to this or had to call different api calls for that purpose. one thing Thank U very Much Again.:)
Tasleem Arif
Yes u can use
SERVICE_INTERFACTIVE_PROCESS
in ur CreateService call. cheers..Milton KB -
Yes u can use
SERVICE_INTERFACTIVE_PROCESS
in ur CreateService call. cheers..Milton KBit did not work callback function is not called through this technique as well.i had found an article related to the interactive servies at the codeproject.com here is its link [it was showing the icon in the tray what i did is replace the code of showing icons with the method of calling/registering hook's dll. The func of dll that hook the windows.but it did not work 2.Now i had one method use the timer to check whether it will be called or not. i dont have any thing in mind what to do next.
Tasleem Arif