My dll service disappears after restarting the system











up vote
0
down vote

favorite
1












I wrote a dll service in c++ with API functions and working properly. I implemented a ServiceMain() function as dllexport in which call RegisterServiceCtrlHandlerW() function to handle the incoming signals (e.g. stop, pause, ...) of my service.



Every thing working good and I defined all the necessary functions to run the service :





  • ServiceMain() is defined and RegisterServiceCtrlHandlerW() calls within to register control handler.

  • Set service status to SERVICE_START_PENDING then to SERVICE_RUNNING to run the service.

  • I implemented a thread to do stuffs as service jobs and working properly.

  • And I can start and stop my service.


My service is a dll not exe so I'm using svchost.exe to host it and I did below steps to register in windows registry:



1. I create a new value in registry as a group to introduce my service to svchost.exe as following :



enter image description here



2. I create Parameters subkey And fill a value with my dll (service file) as following :



enter image description here



3. Also I defined a value (ServiceMain) due to introduce my ServiceMain function to svchost.exe as start point.



So far, my service working even in logged off user BUT when I restart my computer, after logon to windows my service disappeared from Windows Service Manager. Actually it is removed from SCM database.



By the way I installed my service with 3 methods. And I'm using svchost.exe as binarypath to install the service (because svchost.exe behave as host for my dll service). For example with sc.exe program I set binarypath to svchost.exe to run my service indirectly with -k groupname as parameters.



My problem is : When I restart my system then my service disappeared (is deleted) after logging in. Please help me to solve this problem.










share|improve this question




















  • 1




    Why don't you register the service using the API? Why hack at the registry?
    – David Heffernan
    Nov 19 at 13:37












  • @DavidHeffernan I hacked at the registry because its need to create some keys and values to introduce the service to svchost.exe
    – Mohammadreza Panahi
    Nov 19 at 13:44










  • Where is this documented as a supported thing to do? It doesn't seem to work. Perhaps it is a valid thing and you got something wrong. In which case that should be clear once we read the documentation. Or is this unsupported and you instead need to use the service API to add a new service.
    – David Heffernan
    Nov 19 at 13:56










  • @DavidHeffernan according this stackoverflow.com/questions/30554180/…
    – Mohammadreza Panahi
    Nov 19 at 13:58










  • Note that Svchost.exe is reserved for use by the operating system and should not be used by non-Windows services. Instead, developers should implement their own service hosting programs.
    – David Heffernan
    Nov 19 at 14:24















up vote
0
down vote

favorite
1












I wrote a dll service in c++ with API functions and working properly. I implemented a ServiceMain() function as dllexport in which call RegisterServiceCtrlHandlerW() function to handle the incoming signals (e.g. stop, pause, ...) of my service.



Every thing working good and I defined all the necessary functions to run the service :





  • ServiceMain() is defined and RegisterServiceCtrlHandlerW() calls within to register control handler.

  • Set service status to SERVICE_START_PENDING then to SERVICE_RUNNING to run the service.

  • I implemented a thread to do stuffs as service jobs and working properly.

  • And I can start and stop my service.


My service is a dll not exe so I'm using svchost.exe to host it and I did below steps to register in windows registry:



1. I create a new value in registry as a group to introduce my service to svchost.exe as following :



enter image description here



2. I create Parameters subkey And fill a value with my dll (service file) as following :



enter image description here



3. Also I defined a value (ServiceMain) due to introduce my ServiceMain function to svchost.exe as start point.



So far, my service working even in logged off user BUT when I restart my computer, after logon to windows my service disappeared from Windows Service Manager. Actually it is removed from SCM database.



By the way I installed my service with 3 methods. And I'm using svchost.exe as binarypath to install the service (because svchost.exe behave as host for my dll service). For example with sc.exe program I set binarypath to svchost.exe to run my service indirectly with -k groupname as parameters.



My problem is : When I restart my system then my service disappeared (is deleted) after logging in. Please help me to solve this problem.










share|improve this question




















  • 1




    Why don't you register the service using the API? Why hack at the registry?
    – David Heffernan
    Nov 19 at 13:37












  • @DavidHeffernan I hacked at the registry because its need to create some keys and values to introduce the service to svchost.exe
    – Mohammadreza Panahi
    Nov 19 at 13:44










  • Where is this documented as a supported thing to do? It doesn't seem to work. Perhaps it is a valid thing and you got something wrong. In which case that should be clear once we read the documentation. Or is this unsupported and you instead need to use the service API to add a new service.
    – David Heffernan
    Nov 19 at 13:56










  • @DavidHeffernan according this stackoverflow.com/questions/30554180/…
    – Mohammadreza Panahi
    Nov 19 at 13:58










  • Note that Svchost.exe is reserved for use by the operating system and should not be used by non-Windows services. Instead, developers should implement their own service hosting programs.
    – David Heffernan
    Nov 19 at 14:24













up vote
0
down vote

favorite
1









up vote
0
down vote

favorite
1






1





I wrote a dll service in c++ with API functions and working properly. I implemented a ServiceMain() function as dllexport in which call RegisterServiceCtrlHandlerW() function to handle the incoming signals (e.g. stop, pause, ...) of my service.



Every thing working good and I defined all the necessary functions to run the service :





  • ServiceMain() is defined and RegisterServiceCtrlHandlerW() calls within to register control handler.

  • Set service status to SERVICE_START_PENDING then to SERVICE_RUNNING to run the service.

  • I implemented a thread to do stuffs as service jobs and working properly.

  • And I can start and stop my service.


My service is a dll not exe so I'm using svchost.exe to host it and I did below steps to register in windows registry:



1. I create a new value in registry as a group to introduce my service to svchost.exe as following :



enter image description here



2. I create Parameters subkey And fill a value with my dll (service file) as following :



enter image description here



3. Also I defined a value (ServiceMain) due to introduce my ServiceMain function to svchost.exe as start point.



So far, my service working even in logged off user BUT when I restart my computer, after logon to windows my service disappeared from Windows Service Manager. Actually it is removed from SCM database.



By the way I installed my service with 3 methods. And I'm using svchost.exe as binarypath to install the service (because svchost.exe behave as host for my dll service). For example with sc.exe program I set binarypath to svchost.exe to run my service indirectly with -k groupname as parameters.



My problem is : When I restart my system then my service disappeared (is deleted) after logging in. Please help me to solve this problem.










share|improve this question















I wrote a dll service in c++ with API functions and working properly. I implemented a ServiceMain() function as dllexport in which call RegisterServiceCtrlHandlerW() function to handle the incoming signals (e.g. stop, pause, ...) of my service.



Every thing working good and I defined all the necessary functions to run the service :





  • ServiceMain() is defined and RegisterServiceCtrlHandlerW() calls within to register control handler.

  • Set service status to SERVICE_START_PENDING then to SERVICE_RUNNING to run the service.

  • I implemented a thread to do stuffs as service jobs and working properly.

  • And I can start and stop my service.


My service is a dll not exe so I'm using svchost.exe to host it and I did below steps to register in windows registry:



1. I create a new value in registry as a group to introduce my service to svchost.exe as following :



enter image description here



2. I create Parameters subkey And fill a value with my dll (service file) as following :



enter image description here



3. Also I defined a value (ServiceMain) due to introduce my ServiceMain function to svchost.exe as start point.



So far, my service working even in logged off user BUT when I restart my computer, after logon to windows my service disappeared from Windows Service Manager. Actually it is removed from SCM database.



By the way I installed my service with 3 methods. And I'm using svchost.exe as binarypath to install the service (because svchost.exe behave as host for my dll service). For example with sc.exe program I set binarypath to svchost.exe to run my service indirectly with -k groupname as parameters.



My problem is : When I restart my system then my service disappeared (is deleted) after logging in. Please help me to solve this problem.







c++ winapi windows-services






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 23 at 20:45









Werner Henze

10.1k72550




10.1k72550










asked Nov 19 at 12:28









Mohammadreza Panahi

2,52021432




2,52021432








  • 1




    Why don't you register the service using the API? Why hack at the registry?
    – David Heffernan
    Nov 19 at 13:37












  • @DavidHeffernan I hacked at the registry because its need to create some keys and values to introduce the service to svchost.exe
    – Mohammadreza Panahi
    Nov 19 at 13:44










  • Where is this documented as a supported thing to do? It doesn't seem to work. Perhaps it is a valid thing and you got something wrong. In which case that should be clear once we read the documentation. Or is this unsupported and you instead need to use the service API to add a new service.
    – David Heffernan
    Nov 19 at 13:56










  • @DavidHeffernan according this stackoverflow.com/questions/30554180/…
    – Mohammadreza Panahi
    Nov 19 at 13:58










  • Note that Svchost.exe is reserved for use by the operating system and should not be used by non-Windows services. Instead, developers should implement their own service hosting programs.
    – David Heffernan
    Nov 19 at 14:24














  • 1




    Why don't you register the service using the API? Why hack at the registry?
    – David Heffernan
    Nov 19 at 13:37












  • @DavidHeffernan I hacked at the registry because its need to create some keys and values to introduce the service to svchost.exe
    – Mohammadreza Panahi
    Nov 19 at 13:44










  • Where is this documented as a supported thing to do? It doesn't seem to work. Perhaps it is a valid thing and you got something wrong. In which case that should be clear once we read the documentation. Or is this unsupported and you instead need to use the service API to add a new service.
    – David Heffernan
    Nov 19 at 13:56










  • @DavidHeffernan according this stackoverflow.com/questions/30554180/…
    – Mohammadreza Panahi
    Nov 19 at 13:58










  • Note that Svchost.exe is reserved for use by the operating system and should not be used by non-Windows services. Instead, developers should implement their own service hosting programs.
    – David Heffernan
    Nov 19 at 14:24








1




1




Why don't you register the service using the API? Why hack at the registry?
– David Heffernan
Nov 19 at 13:37






Why don't you register the service using the API? Why hack at the registry?
– David Heffernan
Nov 19 at 13:37














@DavidHeffernan I hacked at the registry because its need to create some keys and values to introduce the service to svchost.exe
– Mohammadreza Panahi
Nov 19 at 13:44




@DavidHeffernan I hacked at the registry because its need to create some keys and values to introduce the service to svchost.exe
– Mohammadreza Panahi
Nov 19 at 13:44












Where is this documented as a supported thing to do? It doesn't seem to work. Perhaps it is a valid thing and you got something wrong. In which case that should be clear once we read the documentation. Or is this unsupported and you instead need to use the service API to add a new service.
– David Heffernan
Nov 19 at 13:56




Where is this documented as a supported thing to do? It doesn't seem to work. Perhaps it is a valid thing and you got something wrong. In which case that should be clear once we read the documentation. Or is this unsupported and you instead need to use the service API to add a new service.
– David Heffernan
Nov 19 at 13:56












@DavidHeffernan according this stackoverflow.com/questions/30554180/…
– Mohammadreza Panahi
Nov 19 at 13:58




@DavidHeffernan according this stackoverflow.com/questions/30554180/…
– Mohammadreza Panahi
Nov 19 at 13:58












Note that Svchost.exe is reserved for use by the operating system and should not be used by non-Windows services. Instead, developers should implement their own service hosting programs.
– David Heffernan
Nov 19 at 14:24




Note that Svchost.exe is reserved for use by the operating system and should not be used by non-Windows services. Instead, developers should implement their own service hosting programs.
– David Heffernan
Nov 19 at 14:24

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53374664%2fmy-dll-service-disappears-after-restarting-the-system%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53374664%2fmy-dll-service-disappears-after-restarting-the-system%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Ottavio Pratesi

Tricia Helfer

15 giugno