Home > Back-end >  Add using Svchost start DLL services, cannot be started?
Add using Svchost start DLL services, cannot be started?

Time:05-14

Add a DLL using Svchost start netsvcs_0x0 Shared services, in the registry has been successfully added, but in the service interface is to start up, an error 126: can't find the specified module,


Bosses help look at what is going wrong???????
Or there is something wrong with the DLL file?
Dllmain. CPP:

Service. H:
 # pragma once 
# include "stdafx. H"


DWORD WINAPI ServiceHandler (DWORD dwControl, dwords dwEventType LPVOID lpEventData, LPVOID lpContext);

# ifdef __cplusplus
Extern "C"
{
# endif
__declspec (dllexport) VOID WINAPI ServiceMain (DWORD dwArgc, LPCTSTR * lpszArgv);

# ifdef __cplusplus
}
# endif

Service. The CPP:
//service. The CPP: defines the DLL export function of the application, 
//

# include "service. H"
# include "stdafx. H"



SERVICE_STATUS_HANDLE g_service_status_handle=NULL;



SERVICE_STATUS g_service_status=

{

SERVICE_WIN32_SHARE_PROCESS,

SERVICE_START_PENDING,

SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN | SERVICE_ACCEPT_PAUSE_CONTINUE

};



DWORD WINAPI ServiceHandler (DWORD dwControl, dwords dwEventType LPVOID lpEventData, LPVOID lpContext)

{


The switch (dwControl)

{

Case SERVICE_CONTROL_STOP:

Case SERVICE_CONTROL_SHUTDOWN:

G_service_status. DwCurrentState=SERVICE_STOPPED;

break;

Case SERVICE_CONTROL_PAUSE:

G_service_status. DwCurrentState=SERVICE_PAUSED;

break;

Case SERVICE_CONTROL_CONTINUE:

G_service_status. DwCurrentState=SERVICE_RUNNING;

break;

Case SERVICE_CONTROL_INTERROGATE:

break;

Default:

break;

};

SetServiceStatus (g_service_status_handle, & amp; G_service_status);

Return NO_ERROR.

}



Extern "C" __declspec (dllexport) VOID WINAPI ServiceMain (DWORD dwArgc, LPCTSTR * lpszArgv)

{

Svchost g_service_status_handle=RegisterServiceCtrlHandlerEx (TEXT (" Service "), ServiceHandler, NULL);

if (! G_service_status_handle)

{

return;

}



G_service_status. DwCurrentState=SERVICE_RUNNING;



SetServiceStatus (g_service_status_handle, & amp; G_service_status);



While (TRUE)

{

Sleep (1000);

OutputDebugString (TEXT (" Hello Topsec Svchost In "));

}



return;

};



CodePudding user response:

Baidu search "Session0 through"

CodePudding user response:

Set path % SystemRoot % directly to C: \ Windows give it a try
  • Related